text stringlengths 1 1.05M |
|---|
; A153466: a(n) = A027941(n) + A027941(n+6).
; 232,610,1600,4192,10978,28744,75256,197026,515824,1350448,3535522,9256120,24232840,63442402,166094368,434840704,1138427746,2980442536,7802899864,20428257058,53481871312,140017356880,366570199330,959693241112,2512509524008,6577835330914,17220996468736,45085154075296,118034465757154,309018243196168,809020263831352,2118042548297890,5545107381062320,14517279594889072,38006731403604898,99502914615925624,260502012444171976,682003122716590306,1785507355705598944,4674518944400206528
add $0,1
mov $1,5
mov $2,3
lpb $0
sub $0,1
add $2,$1
add $1,$2
lpe
sub $1,13
mul $1,18
add $1,232
mov $0,$1
|
; A072065: Define a "piece" to consist of 3 mutually touching pennies welded together to form a triangle; sequence gives side lengths of triangles that can be made from such pieces.
; 0,2,9,11,12,14,21,23,24,26,33,35,36,38,45,47,48,50,57,59,60,62,69,71,72,74,81,83,84,86,93,95,96,98,105,107,108,110,117,119,120,122,129,131,132,134,141,143,144,146,153,155,156,158,165,167,168,170,177,179,180,182,189,191,192,194,201,203,204,206,213,215,216,218,225,227,228,230,237,239,240,242,249,251,252,254,261,263,264,266,273,275,276,278,285,287,288,290,297,299
mov $4,$0
lpb $0
trn $0,3
mov $2,$0
trn $0,1
add $1,$0
trn $0,1
add $0,1
add $1,6
mov $3,1
add $3,$2
sub $1,$3
lpe
lpb $4
add $1,2
sub $4,1
lpe
mov $0,$1
|
; A054452: Partial sums of A027941(n-1) with a(-1) = 0.
; 0,0,1,5,17,50,138,370,979,2575,6755,17700,46356,121380,317797,832025,2178293,5702870,14930334,39088150,102334135,267914275,701408711,1836311880,4807526952,12586269000,32951280073,86267571245,225851433689,591286729850,1548008755890,4052739537850,10610209857691,27777890035255,72723460248107,190392490709100,498454011879228,1304969544928620,3416454622906669,8944394323791425,23416728348467645,61305790721611550,160500643816367046,420196140727489630,1100087778366101887,2880067194370816075
lpb $0
sub $0,1
add $3,$1
add $3,$2
add $1,$3
add $2,1
lpe
mov $0,$1
|
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/06/rect/Rect.asm
// Draws a rectangle at the top-left corner of the screen.
// The rectangle is 16 pixels wide and R0 pixels high.
@0
D=M
@INFINITE_LOOP
D;JLE
@counter
M=D
@SCREEN
D=A
@address
M=D
(LOOP)
@address
A=M
M=-1
@address
D=M
@32
D=D+A
@address
M=D
@counter
MD=M-1
@LOOP
D;JGT
(INFINITE_LOOP)
@INFINITE_LOOP
0;JMP
|
SECTION code_fp_math32
PUBLIC m32_fsconst_pzero
PUBLIC m32_fsconst_nzero
PUBLIC m32_fsconst_one
PUBLIC m32_fsconst_1_3
PUBLIC m32_fsconst_pi
PUBLIC m32_fsconst_pinf
PUBLIC m32_fsconst_ninf
PUBLIC m32_fsconst_pnan
PUBLIC m32_fsconst_nnan
.m32_fsconst_pzero
ld de,0
ld h,e
ld l,e
ret
.m32_fsconst_nzero
ld de,$8000
ld h,e
ld l,e
ret
.m32_fsconst_one
ld de,$3f80
ld hl,$0000
ret
.m32_fsconst_1_3
ld de,$3eaa
ld hl,$aaab
ret
.m32_fsconst_pi
ld de,$4049
ld hl,$0fdb
ret
.m32_fsconst_pinf
ld de,$7f80
ld hl,0
ret
.m32_fsconst_ninf
ld de,$ff80
ld hl,0
ret
.m32_fsconst_pnan
ld de,$7fff
ld h,e
ld l,e
ret
.m32_fsconst_nnan
ld de,$ffff
ld h,e
ld l,e
ret
|
INCLUDE "config_private.inc"
SECTION code_clib
SECTION code_math
PUBLIC l_small_muls_16_16x16
EXTERN l_small_mul_16_16x16, l_neg_de, l_neg_hl
l_small_muls_16_16x16:
; signed multiply of two 16-bit signed numbers
;
; error reported on overflow
;
; enter : de = 16-bit signed number
; hl = 16-bit signed number
;
; exit : success
;
; hl = signed product
; carry reset
;
; uses : af, bc, de, hl
; determine sign of result
ld a,d
xor h
push af
; make multiplicands positive
bit 7,d
call NZ,l_neg_de
bit 7,h
call NZ,l_neg_hl
; multiply & check for overflow
call l_small_mul_16_16x16
pop af
ret P
; correct sign of result
jp l_neg_hl
|
; A285950: Positions of 0's in A285949; complement of A285951.
; 1,3,4,5,7,8,10,12,13,14,16,18,19,21,22,23,25,26,28,30,31,33,34,35,37,39,40,41,43,44,46,48,49,50,52,54,55,57,58,59,61,63,64,65,67,68,70,72,73,75,76,77,79,80,82,84,85,86,88,90,91,93,94,95,97,98,100,102,103,105,106,107,109,111,112,113,115,116,118,120,121,123,124,125,127,128,130,132,133,134,136,138,139,141,142,143,145,147,148,149,151,152,154,156,157,158,160,162,163,165,166,167,169,170,172,174,175,177,178,179,181,183,184,185,187,188,190,192,193,194,196,198,199,201,202,203,205,207,208,209,211,212,214,216,217,219,220,221,223,224,226,228,229,230,232,234,235,237,238,239,241,243,244,245,247,248,250,252,253,254,256,258,259,261,262,263,265,266,268,270,271,273,274,275,277,279,280,281,283,284,286,288,289,291,292,293,295,296,298,300,301,302,304,306,307,309,310,311,313,314,316,318,319,321,322,323,325,327,328,329,331,332,334,336,337,338,340,342,343,345,346,347,349,351,352,353,355,356,358,360,361,363,364,365,367,368,370,372,373,374
mov $2,$0
add $2,1
mov $3,$0
lpb $2,1
mov $0,$3
sub $2,1
sub $0,$2
mul $0,2
mov $4,2
mov $5,1
mov $6,$0
lpb $0,1
sub $0,1
add $6,1
div $6,2
add $4,$6
lpe
mov $6,2
mov $7,$5
add $7,4
sub $7,$4
trn $7,2
sub $6,$7
gcd $6,$4
add $1,$6
lpe
|
10 ORG 100H
20 JP MAIN
30GPF EQU 0BFD0H
40WAITK EQU 0BFCDH
50RPTCHR EQU 0BFEEH
60MAIN: CALL CLS
70 LD HL, L0
80 LD B, 144
90 LD DE, 0000H
100 CALL GPF
110 LD HL, L1
120 LD B, 144
130 LD DE, 0100H
140 CALL GPF
150 LD HL, L2
160 LD B, 144
170 LD DE, 0200H
180 CALL GPF
190 LD HL, L3
200 LD B, 144
210 LD DE, 0300H
220 CALL GPF
230 LD HL, L4
240 LD B, 144
250 LD DE, 0400H
260 CALL GPF
270 LD HL, L5
280 LD B, 144
290 LD DE, 0500H
300 CALL GPF
310MAIN0: CALL WAITK
320 CP 0
330 JP Z, MAIN0
340 RET
350CLS: LD B, 144
360 LD DE, 0
370CLS0: LD A, 32
380 CALL RPTCHR
390 RET
400L0: DB 0FFH, 0FFH, 0FFH, 00FH, 00FH, 0FFH, 0FFH, 0FFH
410 DB 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0CFH, 00FH, 01FH
420 DB 07FH, 01FH, 00FH, 0CFH, 0FFH, 0FFH, 03FH, 00FH
430 DB 0CFH, 0CFH, 0CFH, 00FH, 01FH, 0FFH, 0FFH, 0FFH
440 DB 00FH, 00FH, 0FFH, 0FFH, 0FFH, 0FFH, 00FH, 00FH
450 DB 0EFH, 0CFH, 00FH, 01FH, 0FFH, 0FFH, 0FFH, 0FFH
460 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
470 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
480 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
490 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
500 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
510 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
520 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
530 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
540 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
550 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
560 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
570 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
580L1: DB 0FFH, 0FFH, 0FFH, 0B8H, 0F8H, 0FDH, 0DFH, 0FFH
590 DB 03FH, 0FFH, 0FFH, 0BFH, 0BFH, 0FFH, 0FFH, 0FCH
600 DB 0F8H, 078H, 03EH, 01FH, 01FH, 00FH, 01EH, 0FCH
610 DB 01CH, 019H, 019H, 03CH, 07EH, 0FFH, 0FFH, 0FFH
620 DB 0FCH, 01CH, 0ECH, 0EFH, 0EFH, 0EFH, 0ECH, 0FCH
630 DB 0FCH, 0FCH, 0FCH, 0EEH, 0FFH, 0FFH, 0FFH, 0FFH
640 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
650 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
660 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
670 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
680 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
690 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
700 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
710 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
720 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
730 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
740 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
750 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
760L2: DB 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH
770 DB 0F8H, 0FFH, 0FAH, 0FAH, 0FBH, 0F3H, 0FFH, 0FFH
780 DB 0FFH, 0F8H, 0E0H, 0C8H, 008H, 008H, 000H, 020H
790 DB 008H, 008H, 088H, 0E0H, 0F8H, 07FH, 03FH, 07FH
800 DB 0FFH, 0F8H, 0F7H, 0F5H, 0F7H, 0F7H, 0F7H, 0F7H
810 DB 0F7H, 0F7H, 0F7H, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH
820 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
830 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
840 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
850 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
860 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
870 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
880 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
890 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
900 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
910 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
920 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
930 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
940L3: DB 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0FFH, 0DFH, 0DFH
950 DB 0DFH, 0BFH, 0FFH, 0FFH, 0FFH, 0FFH, 07FH, 0FFH
960 DB 0FFH, 0FDH, 0F9H, 0F3H, 0E7H, 0CEH, 01CH, 09EH
970 DB 04EH, 0C6H, 0C3H, 0E1H, 0F8H, 0FCH, 0FEH, 0FFH
980 DB 0FFH, 0FFH, 0FFH, 02FH, 0EFH, 0EFH, 0EFH, 0EFH
990 DB 0EFH, 0EFH, 0EFH, 0AFH, 01FH, 0FFH, 0FFH, 0FFH
1000 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1010 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1020 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1030 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1040 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1050 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1060 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1070 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1080 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1090 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1100 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1110 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1120L4: DB 0FFH, 0FFH, 0FFH, 0FFH, 07FH, 0FFH, 03FH, 0F0H
1130 DB 07FH, 0F7H, 077H, 03FH, 0FFH, 0FEH, 03CH, 03FH
1140 DB 07FH, 0FFH, 03FH, 03FH, 03FH, 0FFH, 0FFH, 03FH
1150 DB 07FH, 0FEH, 0FDH, 03BH, 0F7H, 03FH, 0FFH, 03FH
1160 DB 03FH, 03FH, 0FFH, 038H, 0FFH, 0FFH, 03FH, 0BFH
1170 DB 0BFH, 0FFH, 037H, 0B5H, 037H, 0FFH, 0FFH, 0FFH
1180 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1190 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1200 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1210 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1220 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1230 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1240 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1250 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1260 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1270 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1280 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1290 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1300L5: DB 0FFH, 0FFH, 0FFH, 0FFH, 0FCH, 0E0H, 0F0H, 0E0H
1310 DB 0FEH, 0FFH, 0E0H, 0F0H, 0E3H, 0FFH, 0E0H, 0F0H
1320 DB 0E0H, 0FFH, 0E0H, 0F9H, 0E0H, 0FFH, 0E3H, 0F0H
1330 DB 0F0H, 0E7H, 0FFH, 0F0H, 0F0H, 0F0H, 0FFH, 0FFH
1340 DB 0F0H, 0FFH, 0FFH, 0F0H, 0F3H, 0FFH, 0F0H, 0F4H
1350 DB 0F7H, 0FFH, 0F2H, 0F4H, 0F0H, 0FFH, 0FFH, 0FFH
1360 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1370 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1380 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1390 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1400 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1410 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1420 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1430 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1440 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1450 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1460 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
1470 DB 000H, 000H, 000H, 000H, 000H, 000H, 000H, 000H
|
// -----------------------------------------------------------------------------------------
// <copyright file="logging.cpp" company="Microsoft">
// Copyright 2013 Microsoft 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.
// </copyright>
// -----------------------------------------------------------------------------------------
#include "stdafx.h"
#include "wascore/logging.h"
#ifdef _WIN32
#include <evntprov.h>
#include <evntrace.h>
#else
#include <boost/log/core.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/attributes.hpp>
#include <boost/log/sources/basic_logger.hpp>
#include <boost/log/sources/severity_logger.hpp>
#include <boost/log/sources/record_ostream.hpp>
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/text_ostream_backend.hpp>
#include <boost/log/attributes/scoped_attribute.hpp>
#include <boost/log/utility/setup/common_attributes.hpp>
#endif
namespace azure { namespace storage { namespace core {
#ifdef _WIN32
const std::wstring wconnector(L" : ");
// {EE5D17C5-1B3E-4792-B0F9-F8C5FC6AC22A}
static const GUID event_provider_guid = { 0xee5d17c5, 0x1b3e, 0x4792, { 0xb0, 0xf9, 0xf8, 0xc5, 0xfc, 0x6a, 0xc2, 0x2a } };
static REGHANDLE g_event_provider_handle;
UCHAR get_etw_log_level(client_log_level level)
{
switch (level)
{
case client_log_level::log_level_off:
throw std::invalid_argument("level");
case client_log_level::log_level_error:
return TRACE_LEVEL_ERROR;
case client_log_level::log_level_warning:
return TRACE_LEVEL_WARNING;
case client_log_level::log_level_informational:
return TRACE_LEVEL_INFORMATION;
}
return TRACE_LEVEL_VERBOSE;
}
logger::logger()
{
if (EventRegister(&event_provider_guid, NULL, NULL, &g_event_provider_handle) != ERROR_SUCCESS)
{
g_event_provider_handle = NULL;
}
}
logger::~logger()
{
if (g_event_provider_handle != NULL)
{
EventUnregister(g_event_provider_handle);
}
}
void logger::log(azure::storage::operation_context context, client_log_level level, const std::string& message) const
{
if (g_event_provider_handle != NULL)
{
log(context, level, utility::conversions::to_utf16string(message));
}
}
void logger::log(azure::storage::operation_context context, client_log_level level, const std::wstring& message) const
{
if (g_event_provider_handle != NULL)
{
utf16string utf16_message;
utf16string req_id_16 = utility::conversions::to_utf16string(context.client_request_id());
utf16_message.reserve(req_id_16.length() + wconnector.length() + message.length());
utf16_message.append(req_id_16);
utf16_message.append(wconnector);
utf16_message.append(message);
EventWriteString(g_event_provider_handle, get_etw_log_level(level), 0, utf16_message.c_str());
}
}
bool logger::should_log(azure::storage::operation_context context, client_log_level level) const
{
return (g_event_provider_handle != NULL) && (level <= context.log_level());
}
#else
const std::string connector(" : ");
logger::logger()
{
}
logger::~logger()
{
}
boost::log::trivial::severity_level get_boost_log_level(client_log_level level)
{
switch (level)
{
case client_log_level::log_level_error:
return boost::log::trivial::severity_level::error;
case client_log_level::log_level_warning:
return boost::log::trivial::warning;
case client_log_level::log_level_informational:
return boost::log::trivial::info;
case client_log_level::log_level_verbose:
return boost::log::trivial::trace;
}
throw std::invalid_argument("level");
}
void logger::log(azure::storage::operation_context context, client_log_level level, const std::string& message) const
{
std::string utf8_message;
utf8_message.reserve(context.client_request_id().length() + connector.length() + message.length());
utf8_message.append(context.client_request_id());
utf8_message.append(connector);
utf8_message.append(message);
BOOST_LOG_SEV(context.logger(), get_boost_log_level(level)) << utf8_message;
}
bool logger::should_log(azure::storage::operation_context context, client_log_level level) const
{
return (level != client_log_level::log_level_off) && (level <= context.log_level());
}
#endif // _WIN32
logger logger::m_instance;
}}} // namespace azure::storage::core
|
public sec_part
public print_string
; extrn _data:near
extrn quit:near
STK_SEG SEGMENT para stack 'STACK'
db 100 dup(0)
STK_SEG ENDS
DATA_SEG segment para common 'data'
ORG 1
_data label byte
new_line db 13, 10, '$'
DATA_SEG ends
CODE_SEG SEGMENT para public 'code'
ASSUME CS:CODE_SEG, SS:STK_SEG, DS:DATA_SEG
print_string proc near
mov dx, offset new_line
mov ah, 09
int 21h
mov dx, 0
int 21h
ret
print_string endp
_inc:
inc si
jmp __label
_upper:
add byte ptr [_data + si], 32
jmp _inc
_label:
cmp dl, 'A'
jb _inc
cmp dl, 'Z'
ja _inc
jmp _upper
jmp __label
sec_part:
mov ax, DATA_SEG
mov ds, ax
mov si, 0
__label:
mov dl, byte ptr [_data + si]
cmp dl, '$'
je print
test si, 1b
jne _label
jmp _inc
print:
call print_string
jmp quit
CODE_SEG ENDS
END sec_part |
/*
*If not stated otherwise in this file or this component's Licenses.txt file the
* following copyright and licenses apply:
*
* Copyright 2016 RDK Management
*
* 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 "CMHAL.h"
/***************************************************************************
*Function name : initialize
*Description : Initialize Function will be used for registering the wrapper method
* with the agent so that wrapper function will be used in the script
*
*****************************************************************************/
bool CMHAL::initialize(IN const char* szVersion)
{
return TEST_SUCCESS;
}
/***************************************************************************
*Function name : testmodulepre_requisites
*Description : testmodulepre_requisites will be used for setting the
* pre-requisites that are necessary for this component
*
*****************************************************************************/
std::string CMHAL::testmodulepre_requisites()
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_testmodulepre_requisites --->Entry \n");
DEBUG_PRINT(DEBUG_TRACE,"\n Initialising DB \n");
int DBInitStatus = ssp_CMHAL_Init("InitDB");
DEBUG_PRINT(DEBUG_TRACE,"\n Initialising DS \n");
int DSInitStatus = ssp_CMHAL_Init("InitDS");
DEBUG_PRINT(DEBUG_TRACE,"\n Initialising DB \n");
int USInitStatus = ssp_CMHAL_Init("InitUS");
if(DBInitStatus == 0 && DSInitStatus ==0 && USInitStatus==0)
{
DEBUG_PRINT(DEBUG_TRACE,"\n Initialised CMHAL ---> Exit\n");
return "SUCCESS";
}
else
{
DEBUG_PRINT(DEBUG_TRACE,"\n Failed to initialise CMHAL --->Exit \n");
return "FAILURE";
}
}
/***************************************************************************
*Function name : testmodulepost_requisites
*Description : testmodulepost_requisites will be used for resetting the
* pre-requisites that are set
*
*****************************************************************************/
bool CMHAL::testmodulepost_requisites()
{
DEBUG_PRINT(DEBUG_LOG,"DBG:CMHAL:testmodulepost_requisites() \n");
return 0;
}
/*******************************************************************************************
*
* Function Name : CMHAL_GetParamCharValue
* Description : This will get the char values
*
* @param [in] req - paramName : Holds the name of api
paramType : Holds NULL in the case of negative scenario and empty otherwise
* @param [out] response - filled with SUCCESS or FAILURE based on the return value
*
*******************************************************************************************/
void CMHAL::CMHAL_GetParamCharValue(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetParamCharValue --->Entry \n");
int returnValue = 0;
char paramName[100];
char Details[800] = {'\0'};
char value[700];
char paramType[10] = {'\0'};
/* Validate the input arguments */
if(&req["paramName"]==NULL)
{
response["result"]="FAILURE";
response["details"]="NULL parameter as input argument";
return;
}
strcpy(paramName,req["paramName"].asCString());
strcpy(paramType, req["paramType"].asCString());
//For negative scenario, "NULL" will be passed as the paramType argument
if(strcmp(paramType, "NULL"))
returnValue = ssp_CMHAL_GetParamCharValue(paramName,value);
else
returnValue = ssp_CMHAL_GetParamCharValue(paramName,NULL);
if(0 == returnValue)
{
sprintf(Details,"%s", value);
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to get the value";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetParamCharValue --->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetParamCharValue --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_GetParamUlongValue
* Description : This will get the Ulong values
* @param [in] req - paramName : Holds the name of api
paramType :Holds NULL in the case of negative scenario and empty otherwise
* @param [out] response - filled with SUCCESS or FAILURE based on the return value
*
*******************************************************************************************/
void CMHAL::CMHAL_GetParamUlongValue(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetParamUlongValue --->Entry \n");
int returnValue = 0;
char paramName[100];
char Details[64] = {'\0'};
unsigned long value = 0;
char paramType[10] = {'\0'};
/* Validate the input arguments */
if(&req["paramName"]==NULL)
{
response["result"]="FAILURE";
response["details"]="NULL parameter as input argument";
return;
}
strcpy(paramName,req["paramName"].asCString());
strcpy(paramType, req["paramType"].asCString());
//For negative scenario, "NULL" will be passed as the paramType argument
if(strcmp(paramType, "NULL"))
returnValue = ssp_CMHAL_GetParamUlongValue(paramName,&value);
else
returnValue = ssp_CMHAL_GetParamUlongValue(paramName,NULL);
if(0 == returnValue)
{
sprintf(Details,"%d", value);
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to get the value";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetParamUlongValue --->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetParamUlongValue --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_GetErrorCodeWords
* Description :This function will invoke the SSP HAL wrapper to get the ErrorCodeWords
*
* @param [in] req- : flag: To handle negative scenario
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_GetErrorCodeWords(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"Inside Function CMHAL_GetErrorCodeWords stub\n");
int isNegativeScenario = 0;
char details[800] = {'\0'};
char value[800] = {'\0'};
if(&req["flag"])
{
isNegativeScenario = req["flag"].asInt();
}
if(ssp_CMHAL_GetErrorCodeWords(value,isNegativeScenario) == 0)
{
sprintf(details, "Value returned successfully\n");
DEBUG_PRINT(DEBUG_TRACE, "Successfully retrieved the ErrorCodeWords status\n");
response["result"] = "SUCCESS";
response["details"] = details;
return;
}
else
{
response["result"] = "FAILURE";
response["details"] = "CMHAL_GetErrorCodeWords function has failed.Please check logs";
return;
}
}
/*******************************************************************************************
*
* Function Name : CMHAL_Init
* Description :This function will invoke the SSP HAL wrapper to init the CM
*
* @param [in] req- :ParamName : Name of the api
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_Init(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"Inside Function CMHAL_Init stub\n");
char details[64] = {'\0'};
char paramName[64] = {'\0'};
strcpy(paramName,req["paramName"].asCString());
if(ssp_CMHAL_Init(paramName) == 0)
{
sprintf(details, "CM has initiated successfully\n");
DEBUG_PRINT(DEBUG_TRACE, "Successfully initiated the CM \n");
response["result"] = "SUCCESS";
response["details"] = details;
return;
}
else
{
response["result"] = "FAILURE";
response["details"] = "CMHAL_Init function has failed.Please check logs";
return;
}
}
/*******************************************************************************************
*
* Function Name : CMHAL_GetDocsisEventLogItems
* Description :This function will invoke the SSP HAL wrapper to get the DocsisEventLogItems
*
* @param [in] req- :flag- to execute negative scenarios
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_GetDocsisEventLogItems(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"Inside Function CMHAL_GetDocsisEventLogItems stub\n");
int isNegativeScenario = 0;
char details[120] = {'\0'};
CMMGMT_CM_EventLogEntry_t entries[DOCSIS_EVENT_LOG_SIZE];
if(&req["flag"])
{
isNegativeScenario = req["flag"].asInt();
}
if(ssp_CMHAL_GetDocsisEventLogItems(entries, DOCSIS_EVENT_LOG_SIZE,isNegativeScenario) == 0)
{
sprintf(details, "Retrieved the event log items successfully");
DEBUG_PRINT(DEBUG_TRACE, "Successfully retrieved the event log items\n");
response["result"] = "SUCCESS";
response["details"] = details;
return;
}
else
{
response["result"] = "FAILURE";
response["details"] = "CMHAL_GetDocsisEventLogItems function has failed.Please check logs";
return;
}
}
/*******************************************************************************************
*
* Function Name : CMHAL_SetLEDFlashStatus
* Description :This function will invoke the SSP HAL wrapper to set the LEDFlashStatus
*
* @param [in] req- :LEDFlash - to enable LEDFlash status
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_SetLEDFlashStatus(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetLEDFlashStatus --->Entry \n");
int returnValue = 0;
unsigned char* LEDFlash;
char Details[64] = {'\0'};
LEDFlash=(unsigned char*)req["LEDFlash"].asCString();
returnValue = ssp_CMHAL_SetLEDFlashStatus(*LEDFlash);
if(0 == returnValue)
{
sprintf(Details,"CMHAL_SetLEDFlashStatus enabled successfully");
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to set enable status";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetLEDFlashStatus failed--->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetLEDFlashStatus --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_ClearDocsisEventLog
* Description :This function will invoke the SSP HAL wrapper to clear the docsis event logs
*
* @param [in] req- :
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_ClearDocsisEventLog(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"Inside Function CMHAL_ClearDocsisEventLog stub\n");
char details[120] = {'\0'};
int return_status = 0;
return_status=ssp_CMHAL_ClearDocsisEventLog();
if(return_status== 0)
{
sprintf(details, "Cleared the docsis log successfully\n");
response["result"] = "SUCCESS";
response["details"] = details;
return;
}
else
{
response["result"] = "FAILURE";
response["details"] = "CMHAL_ClearDocsisEventLog function has failed.Please check logs";
return;
}
}
/*******************************************************************************************
*
* Function Name : CMHAL_GetCPEList
* Description : This function will invoke the SSP HAL wrapper to get the CPE List
*
* @param [in] req- : flag- to execute negative scenarios
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
* @param [in] req- : lanMode - to know lan operational mode of device
********************************************************************************************/
void CMHAL::CMHAL_GetCPEList(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"Inside Function CMHAL_GetCPEList stub\n");
int isNegativeScenario = 0;
char details[120] = {'\0'};
unsigned long int InstanceNum =0;
char cpeList[120] = {'\0'};
char lanMode[60] = {'\0'};
strcpy(lanMode,req["lanMode"].asCString());
if(&req["flag"])
{
isNegativeScenario = req["flag"].asInt();
}
if(ssp_CMHAL_GetCPEList(&InstanceNum,cpeList,lanMode,isNegativeScenario) == 0)
{
sprintf(details, "%s InstNum :%d ", cpeList, InstanceNum);
DEBUG_PRINT(DEBUG_TRACE, "Successfully retrieved cpe list\n");
response["result"] = "SUCCESS";
response["details"] = details;
return;
}
else
{sprintf(details, "Failed to get the cpe List, InstNum :%d ",InstanceNum);
response["result"] = "FAILURE";
response["details"] = details;
return;
}
}
/*******************************************************************************************
*
* Function Name : CMHAL_SetMddIpModeOverride
* Description : This function will invoke the SSP HAL wrapper to set the MddIpModeOverride
*
* @param [in] req- : Value - To set the MddIpModeOverride
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_SetMddIpModeOverride(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetMddIpModeOverride --->Entry \n");
int returnValue = 0;
char Value[60];
char Details[64] = {'\0'};
strcpy(Value,req["value"].asCString());
returnValue = ssp_CMHAL_SetMddIpModeOverride(Value);
if(0 == returnValue)
{
sprintf(Details,"CMHAL_SetMddIpModeOverride:set function success");
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to set MddIpModeOverride";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetMddIpModeOverride failed--->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetMddIpModeOverride --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_SetStartFreq
* Description : This function will set the StartFreq
*
* @param [in] req- : Value - Value to set the StartFreq
* @param [out] response - filled with SUCCESS or FAILURE based on the return value
*
*******************************************************************************************/
void CMHAL::CMHAL_SetStartFreq(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetStartFreq --->Entry \n");
int returnValue = 0;
int Value = 0;
/* Validate the input arguments */
if(&req["Value"]==NULL)
{
response["result"]="FAILURE";
response["details"]="NULL parameter as input argument";
return;
}
Value = req["Value"].asInt();
returnValue = ssp_CMHAL_SetStartFreq(Value);
if(0 == returnValue)
{
response["result"]="SUCCESS";
response["details"]="Successfully set the StartFreq";
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to set the StartFreq";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetStartFreq --->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetStartFreq --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_SetUSChannelId
* Description : This function will set the USChannelId
*
* @param [in] req- : Value - Value to set the UDChannelId
* @param [out] response - filled with SUCCESS or FAILURE based on the return value
*
*******************************************************************************************/
void CMHAL::CMHAL_SetUSChannelId(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetUSChannelId --->Entry \n");
int returnValue = 0;
int Value = 0;
/* Validate the input arguments */
if(&req["Value"]==NULL)
{
response["result"]="FAILURE";
response["details"]="NULL parameter as input argument";
return;
}
Value = req["Value"].asInt();
returnValue = ssp_CMHAL_SetUSChannelId(Value);
if(0 == returnValue)
{
response["result"]="SUCCESS";
response["details"]="US Channel ID is set successfully";
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to set the US Channel ID";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetUSChannelId --->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetUSChannelId --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_SetHTTP_Download_Interface
* Description : This function will invoke the SSP HAL wrapper to set the HTTP_Download_Interface
*
* @param [in] req- : interface - The value of download interface
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_SetHTTP_Download_Interface(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetHTTP_Download_Interface --->Entry \n");
int returnValue = 0;
unsigned int interface =0;
char Details[64] = {'\0'};
interface =req["interface"].asInt();
returnValue = ssp_CMHAL_SetHTTP_Download_Interface(interface);
if(0 == returnValue)
{
sprintf(Details,"CMHAL_SetHTTP_Download_Interface set interface successfully");
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to set download interface";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetHTTP_Download_Interface failed--->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetHTTP_Download_Interface --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_HTTP_Download
* Description :This function will invoke the SSP HAL wrapper to Download
*
* @param [in] req- : None
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_HTTP_Download(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_HTTP_Download --->Entry \n");
int returnValue = 0;
char Details[64] = {'\0'};
returnValue = ssp_CMHAL_Download();
if(0 == returnValue)
{
sprintf(Details,"CMHAL_HTTP_Download: success");
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to download ";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_HTTP_Download failed--->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_HTTP_Download --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_Reboot_Now
* Description :This function will invoke the SSP HAL wrapper to Reboot
*
* @param [in] req- : None
* @param [out] response - filled with SUCCESS or FAILURE based on the output status of operation
*
********************************************************************************************/
void CMHAL::CMHAL_Reboot_Now(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_Reboot_Now --->Entry \n");
int returnValue = 0;
char Details[64] = {'\0'};
returnValue = ssp_CMHAL_Reboot_Now();
if(0 == returnValue)
{
sprintf(Details,"CMHAL_Reboot_Now: success");
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to reboot ";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_Reboot_Now failed--->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_Reboot_Now --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_GetHTTP_Download_Url
* Description : This will get the HTTP_Download_Url and filename
*
* @param [in] : httpURL : To save the URL
* : filename : To save the filename
* @param [out] response - filled with SUCCESS or FAILURE based on the return value
*
*******************************************************************************************/
void CMHAL::CMHAL_GetHTTP_Download_Url(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetHTTP_Download_Url --->Entry \n");
int returnValue = 0;
char httpURL[200]={'\0'};
char Details[800] = {'\0'};
char filename[200]= {'\0'};
char paramType[10] = {'\0'};
strcpy(paramType, req["paramType"].asCString());
if(strcmp(paramType, "NULL"))
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Positive Sceanrio\n");
returnValue = ssp_CMHAL_GetHTTP_Download_Url(httpURL,filename);
}
else
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Negative Scenario\n");
returnValue = ssp_CMHAL_GetHTTP_Download_Url(NULL,NULL);
}
if(0 == returnValue)
{
sprintf(Details,"url is %s, filename is %s",httpURL,filename);
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to get the value of URL and file";
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetHTTP_Download_Url --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_SetHTTP_Download_Url
* Description : This function will invoke the SSP HAL wrapper to set the HTTP_Download_Url
*
* @param [in] req- : httpURL : The URL of the site from which the file is to be downloaded
* filename : The name of the file to be downloaded
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_SetHTTP_Download_Url(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetHTTP_Download_Url --->Entry \n");
int returnValue = 0;
char httpURL[60] = {'\0'};
char filename[60] = {'\0'};
char Details[64] = {'\0'};
strcpy(httpURL,req["httpURL"].asCString());
strcpy(filename,req["filename"].asCString());
returnValue = ssp_CMHAL_SetHTTP_Download_Url(httpURL,filename);
if(0 == returnValue)
{
sprintf(Details,"CMHAL_SetHTTP_Download_Url:set function success");
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to set HTTP_Download_Url";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetHTTP_Download_Url failed--->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_SetHTTP_Download_Url --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_FWupdateAndFactoryReset
* Description : This function will invoke the SSP HAL wrapper to FWupdateAndFactoryReset
*
* @param [in] req- : URL - Image URL
: imageName - Name of the image
* @param [out] response - filled with SUCCESS or FAILURE based on the output staus of operation
*
********************************************************************************************/
void CMHAL::CMHAL_FWupdateAndFactoryReset(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_FWupdateAndFactoryReset --->Entry \n");
int returnValue = 0;
char Details[64] = {'\0'};
char url[1024] = {'\0'};
char imagename[1024] = {'\0'};
if((&req["URL"]==NULL) || (&req["imageName"]==NULL))
{
response["result"]="FAILURE";
response["details"]="NULL parameter as input argument";
return;
}
strcpy(url, req["URL"].asCString());
strcpy(imagename, req["imageName"].asCString());
returnValue = ssp_CMHAL_FWupdateAndFactoryReset(url,imagename);
if(0 == returnValue)
{
sprintf(Details,"CMHAL_FWupdateAndFactoryReset: success");
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to FWupdateAndFactoryReset ";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_FWupdateAndFactoryReset failed--->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_FWupdateAndFactoryReset --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_GetDsOfdmChanTable
* Description : This will get the values in DS OFDM channel table
*
* @param [in] req - paramName : Holds the name of api
* @param [out] response - filled with SUCCESS or FAILURE based on the return value
*
*******************************************************************************************/
void CMHAL::CMHAL_GetDsOfdmChanTable(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetDsOfdmChanTable --->Entry \n");
int returnValue = 0;
char paramName[100];
char Details[800] = {'\0'};
char value[700];
int NoOfEntries = 0;
char paramType[10] = {'\0'};
strcpy(paramType, req["paramType"].asCString());
/* Validate the input arguments */
if(&req["paramName"]==NULL)
{
response["result"]="FAILURE";
response["details"]="NULL parameter as input argument";
return;
}
strcpy(paramName,req["paramName"].asCString());
if (strcmp(paramType, "NULL"))
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Positive Sceanrio\n");
returnValue = ssp_CMHAL_GetDsOfdmChanTable(paramName,value,&NoOfEntries);
}
else
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Negative Scenario\n");
returnValue = ssp_CMHAL_GetDsOfdmChanTable(paramName,value,NULL);
}
if(0 == returnValue)
{
sprintf(Details,"No of Entries in table:%d; Value:%s", NoOfEntries,value);
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to get the value from docsis_GetDsOfdmChanTable()";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetDsOfdmChanTable --->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetDsOfdmChanTable --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_GetUsOfdmChanTable
* Description : This will get the values in US OFDM channel table
*
* @param [in] req - paramName : Holds the name of api
* @param [out] response - filled with SUCCESS or FAILURE based on the return value
*
*******************************************************************************************/
void CMHAL::CMHAL_GetUsOfdmChanTable(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetUsOfdmChanTable --->Entry \n");
int returnValue = 0;
char paramName[100];
char Details[800] = {'\0'};
char value[700];
int NoOfEntries = 0;
char paramType[10] = {'\0'};
strcpy(paramType, req["paramType"].asCString());
/* Validate the input arguments */
if(&req["paramName"]==NULL)
{
response["result"]="FAILURE";
response["details"]="NULL parameter as input argument";
return;
}
strcpy(paramName,req["paramName"].asCString());
if(strcmp(paramType, "NULL"))
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Positive Sceanrio\n");
returnValue = ssp_CMHAL_GetUsOfdmChanTable(paramName,value,&NoOfEntries);
}
else
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Negative Scenario\n");
returnValue = ssp_CMHAL_GetUsOfdmChanTable(paramName,value,NULL);
}
if(0 == returnValue)
{
sprintf(Details,"No of Entries in table:%d; Value:%s", NoOfEntries,value);
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to get the value from docsis_GetUsOfdmChanTable()";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetUsOfdmChanTable --->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetUsOfdmChanTable --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_GetStatusOfdmaUsTable
* Description : This will get the status of dmaUsTable
*
* @param [in] req - paramName : Holds the name of api
* @param [out] response - filled with SUCCESS or FAILURE based on the return value
*
*******************************************************************************************/
void CMHAL::CMHAL_GetStatusOfdmaUsTable(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetStatusOfdmaUsTable --->Entry \n");
int returnValue = 0;
char paramName[100];
char Details[800] = {'\0'};
char value[700];
int NoOfEntries = 0;
char paramType[10] = {'\0'};
strcpy(paramType, req["paramType"].asCString());
/* Validate the input arguments */
if(&req["paramName"]==NULL)
{
response["result"]="FAILURE";
response["details"]="NULL parameter as input argument";
return;
}
strcpy(paramName,req["paramName"].asCString());
if(strcmp(paramType, "NULL"))
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Positive Sceanrio\n");
returnValue = ssp_CMHAL_GetStatusOfdmaUsTable(paramName,value,&NoOfEntries);
}
else
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Negative Scenario\n");
returnValue = ssp_CMHAL_GetStatusOfdmaUsTable(paramName,value,NULL);
}
if(0 == returnValue)
{
sprintf(Details,"No of Entries in table:%d; Value:%s", NoOfEntries,value);
response["result"]="SUCCESS";
response["details"]=Details;
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to get the value from docsis_GetStatusOfdmaUsTable()";
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetDsOfdmChanTable --->Exit\n");
return;
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_GetStatusOfdmaUsTable --->Exit\n");
return;
}
/*******************************************************************************************
*
* Function Name : CMHAL_IsEnergyDetected
* Description : This will get the Energy Detected status from HAL
* @param [in] req - none
* @param [out] response - filled with SUCCESS or FAILURE based on the return value
*
*******************************************************************************************/
void CMHAL::CMHAL_IsEnergyDetected(IN const Json::Value& req, OUT Json::Value& response)
{
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_IsEnergyDetected --->Entry \n");
int returnValue = 0;
char* energyDetected = 0;
char Details[800] = {'\0'};
char paramType[10] = {'\0'};
strcpy(paramType, req["paramType"].asCString());
if(strcmp(paramType, "NULL"))
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Positive Sceanrio\n");
returnValue = ssp_CMHAL_IsEnergyDetected(energyDetected);
}
else
{
DEBUG_PRINT(DEBUG_TRACE,"\n Executing Negative Sceanrio\n");
returnValue = ssp_CMHAL_IsEnergyDetected(NULL);
}
if(0 == returnValue)
{
if(energyDetected != NULL)
{
sprintf(Details,"CMHAL_IsEnergyDetected:%d", energyDetected);
response["result"]="SUCCESS";
response["details"]=Details;
}
}
else
{
response["result"]="FAILURE";
response["details"]="Failed to get the value from docsis_IsEnergyDetected()";
}
DEBUG_PRINT(DEBUG_TRACE,"\n CMHAL_IsEnergyDetected --->Exit\n");
return;
}
/**************************************************************************
* Function Name : CreateObject
* Description : This function will be used to create a new object for the
* class "CMHAL".
*
+ **************************************************************************/
extern "C" CMHAL* CreateObject(TcpSocketServer &ptrtcpServer)
{
return new CMHAL(ptrtcpServer);
}
/**************************************************************************
* Function Name : cleanup
* Description : This function will be used to clean the log details.
*
**************************************************************************/
bool CMHAL::cleanup(IN const char* szVersion)
{
DEBUG_PRINT(DEBUG_LOG,"CMHAL shutting down\n");
return TEST_SUCCESS;
}
/**************************************************************************
* Function Name : DestroyObject
* Description : This function will be used to destroy the object
*
**************************************************************************/
extern "C" void DestroyObject(CMHAL *stubobj)
{
DEBUG_PRINT(DEBUG_LOG,"Destroying CMHAL object\n");
delete stubobj;
}
|
; FILL ZX SPECTRUM SCREEN GOING THROUGH EACH VISUAL LINE
;
; SCREEN ADDRESS
;
; H = 0 1 0 Y7 Y6 Y2 Y1 Y0
; L = Y5 Y4 Y3 X4 X3 X2 X1 X0
ORG 50000
LD HL,$4000 ; SCREEN START
LOOP: ; LD A,255
LD (HL),A
INC HL
CALL W_DELAY
LD A,H
CP $58
JR NZ, LOOP
; need to return to lower screen
LD A,1 ; lower screen
CALL 5633 ; open channel
CALL $15DE ; WAIT-KEY1
RET
W_DELAY:
PUSH BC
LD B,255
WAIT: DJNZ WAIT
LD B,255
WAIT2: DJNZ WAIT2
POP BC
RET
END 50000
|
; A002506: Denominators of coefficients of expansion of Bessel function J_2(x).
; 8,96,3072,184320,17694720,2477260800,475634073600,119859786547200,38355131695104000,15188632151261184000,7290543432605368320000,4170190843450270679040000,2802368246798581896314880000,2185847232502893879125606400000,1958519120322592915696543334400000,1997689502729044774010474201088000000,2301338307143859579660066279653376000000,2973329092829866576920805633312161792000000,4281593893675007870765960111969512980480000000,6833423854305312561742472338703342716846080000000
mov $2,1
lpb $0
sub $0,1
add $3,8
add $1,$3
add $1,4
mul $2,$1
lpe
mov $0,$2
mul $0,8
|
Map_489CC: dc.w word_489E8-Map_489CC
dc.w word_489F6-Map_489CC
dc.w word_48A04-Map_489CC
dc.w word_48A12-Map_489CC
dc.w word_48A12-Map_489CC
dc.w word_48A2C-Map_489CC
dc.w word_48A34-Map_489CC
dc.w word_48A3C-Map_489CC
dc.w word_48A4A-Map_489CC
dc.w word_48A5E-Map_489CC
dc.w word_48A6C-Map_489CC
dc.w word_48A7A-Map_489CC
dc.w word_48A88-Map_489CC
dc.w word_48A9C-Map_489CC
word_489E8: dc.w 2
dc.b $E8, 2, 0, $18, $FF, $FC
dc.b 0, 2, $10, $18, $FF, $FC
word_489F6: dc.w 2
dc.b $E8, 6, 0, $1B, $FF, $F8
dc.b 0, 6, $10, $1B, $FF, $F8
word_48A04: dc.w 2
dc.b $E8, $E, 0, $21, $FF, $F0
dc.b 0, $E, $10, $21, $FF, $F0
word_48A12: dc.w 4
dc.b $E8, $A, 0, $2D, $FF, $EC
dc.b $E8, 6, 0, $36, 0, 4
dc.b 0, $A, $10, $2D, $FF, $EC
dc.b 0, 6, $10, $36, 0, 4
word_48A2C: dc.w 1
dc.b $FC, 0, 0, $3C, $FF, $FC
word_48A34: dc.w 1
dc.b $F8, 5, 0, $3D, $FF, $F8
word_48A3C: dc.w 2
dc.b $E8, 6, 0, $50, $FF, $FC
dc.b 0, 6, 0, $56, $FF, $F4
word_48A4A: dc.w 3
dc.b $EC, 9, 0, $5C, $FF, $FC
dc.b $FC, 8, 0, $62, $FF, $F4
dc.b 4, 9, 0, $65, $FF, $EC
word_48A5E: dc.w 2
dc.b $F4, 9, 0, $6B, 0, 0
dc.b $FC, 9, 0, $71, $FF, $E8
word_48A6C: dc.w 2
dc.b $FC, 8, 0, $77, $FF, $E8
dc.b $FC, 8, 8, $77, 0, 0
word_48A7A: dc.w 2
dc.b $F4, 9, $10, $71, $FF, $E8
dc.b $FC, 9, $10, $6B, 0, 0
word_48A88: dc.w 3
dc.b $EC, 9, $10, $65, $FF, $EC
dc.b $FC, 8, $10, $62, $FF, $F4
dc.b 4, 9, $10, $5C, $FF, $FC
word_48A9C: dc.w 2
dc.b $E8, 6, $10, $56, $FF, $F4
dc.b 0, 6, $10, $50, $FF, $FC
|
*PROCESS DUPALIAS
*
* Compiled by DCC Version 2.25.07 Mar 6 2021 08:51:07
* on Fri Apr 30 15:36:12 2021
*
WXTRN @@ZARCH#
*
*
*
* Code Section
*
@CODE ALIAS X'7CD9C4D2C1C6D2C16DE2E4C2E2C3D9C9D7E3C9D6D5'
@CODE CSECT
@CODE AMODE ANY
@CODE RMODE ANY
@DATA ALIAS X'7C998492818692816DA2A482A283998997A3899695'
rd_kafka_topic_partition_list_sum ALIAS X'99846D92818692816DA3969789836*
D978199A389A38996956D9389A2A36DA2A494'
EXTRN rd_kafka_topic_partition_list_sum
rd_kafka_topic_partition_list_has_duplicates ALIAS X'99846D92818692816D*
A3969789836D978199A389A38996956D9389A2A36D8881A26D84A497*
93898381A385A2'
EXTRN rd_kafka_topic_partition_list_has_duplicates
rd_kafka_op_destroy ALIAS X'99846D92818692816D96976D8485A2A39996A8'
EXTRN rd_kafka_op_destroy
rd_kafka_op_new0 ALIAS X'99846D92818692816D96976D9585A6F0'
EXTRN rd_kafka_op_new0
rd_regex_destroy ALIAS X'99846D99858785A76D8485A2A39996A8'
EXTRN rd_regex_destroy
rd_regex_comp ALIAS X'99846D99858785A76D83969497'
EXTRN rd_regex_comp
rd_kafka_op_req ALIAS X'99846D92818692816D96976D998598'
EXTRN rd_kafka_op_req
rd_kafka_op_req2 ALIAS X'99846D92818692816D96976D998598F2'
EXTRN rd_kafka_op_req2
rd_kafka_op_err_destroy ALIAS X'99846D92818692816D96976D8599996D8485A2A*
39996A8'
EXTRN rd_kafka_op_err_destroy
rd_kafka_op_error_destroy ALIAS X'99846D92818692816D96976D85999996996D8*
485A2A39996A8'
EXTRN rd_kafka_op_error_destroy
rd_kafka_cgrp_assignment_is_lost ALIAS X'99846D92818692816D838799976D81*
A2A2898795948595A36D89A26D9396A2A3'
EXTRN rd_kafka_cgrp_assignment_is_lost
rd_kafka_error_code ALIAS X'99846D92818692816D85999996996D83968485'
EXTRN rd_kafka_error_code
rd_kafka_error_destroy ALIAS X'99846D92818692816D85999996996D8485A2A399*
96A8'
EXTRN rd_kafka_error_destroy
rd_kafka_error_new ALIAS X'99846D92818692816D85999996996D9585A6'
EXTRN rd_kafka_error_new
rd_kafka_topic_partition_list_new ALIAS X'99846D92818692816DA3969789836*
D978199A389A38996956D9389A2A36D9585A6'
EXTRN rd_kafka_topic_partition_list_new
rd_kafka_topic_partition_list_destroy ALIAS X'99846D92818692816DA396978*
9836D978199A389A38996956D9389A2A36D8485A2A39996A8'
EXTRN rd_kafka_topic_partition_list_destroy
rd_kafka_topic_partition_list_copy ALIAS X'99846D92818692816DA396978983*
6D978199A389A38996956D9389A2A36D839697A8'
EXTRN rd_kafka_topic_partition_list_copy
rd_kafka_toppars_pause_resume ALIAS X'99846D92818692816DA39697978199A26*
D9781A4A2856D9985A2A49485'
EXTRN rd_kafka_toppars_pause_resume
*
*
*
* ....... start of rd_kafka_unsubscribe
rd_kafka_unsubscribe ALIAS X'99846D92818692816DA495A2A482A28399898285'
@LNAME602 DS 0H
DC X'00000014'
DC C'rd_kafka_unsubscribe'
DC X'00'
rd_kafka_unsubscribe DCCPRLG CINDEX=602,BASER=12,FRAME=192,ENTRY=YES,AR*
CH=ZARCH,LNAMEADDR=@LNAME602
* ******* End of Prologue
* *
* *** rd_kafka_cgrp_t *rkcg;
* ***
* *** if (!(rkcg = ((rk)->rk_cgrp)))
LG 15,0(0,1) ; rk
LG 15,520(0,15) ; offset of rk_cgrp in rd_kafka_s
LTGR 1,15
BNZ @L630
* *** return RD_KAFKA_RESP_ERR__UNKNOWN_GROUP;
LGHI 15,-179 ; -179
B @ret_lab_602
DS 0D
@FRAMESIZE_602 DC F'192'
@lit_602_1 DC AD(rd_kafka_op_req2)
@lit_602_2 DC AD(rd_kafka_op_err_destroy)
@L630 DS 0H
* ***
* *** return rd_kafka_op_err_destroy(rd_kafka_op_req2(rkcg->\
* rkcg_ops,
* *** RD_KAF\
* KA_OP_SUBSCRIBE));
LG 15,80(0,15)
STG 15,176(0,13)
MVGHI 184(13),21
LA 1,176(0,13)
LG 15,@lit_602_1 ; rd_kafka_op_req2
@@gen_label1 DS 0H
BALR 14,15
@@gen_label2 DS 0H
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_602_2 ; rd_kafka_op_err_destroy
@@gen_label3 DS 0H
BALR 14,15
@@gen_label4 DS 0H
LGFR 15,15
* *** }
@ret_lab_602 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_unsubscribe"
* (FUNCTION #602)
*
@AUTO#rd_kafka_unsubscribe DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of _invalid_topic_cb
@LNAME1917 DS 0H
DC X'00000011'
DC C'_invalid_topic_cb'
DC X'00'
_invalid_topic_cb DCCPRLG CINDEX=1917,BASER=12,FRAME=200,ENTRY=NO,ARCH=*
ZARCH,LNAMEADDR=@LNAME1917
* ******* End of Prologue
* *
LG 15,0(0,1) ; rktpar
* *** rd_regex_t *re;
* *** char errstr[1];
* ***
* *** if (!*rktpar->topic)
LG 1,0(0,15) ; rktpar
CLI 0(1),0
BNE @L631
* *** return 1;
LGHI 15,1 ; 1
B @ret_lab_1917
DS 0D
@FRAMESIZE_1917 DC F'200'
@lit_1917_6 DC AD(rd_regex_comp)
@lit_1917_8 DC AD(rd_regex_destroy)
@L631 DS 0H
* ***
* *** if (*rktpar->topic != '^')
LG 1,0(0,15) ; rktpar
CLI 0(1),95
BE @L632
* *** return 0;
LGHI 15,0 ; 0
B @ret_lab_1917
@L632 DS 0H
* ***
* *** if (!(re = rd_regex_comp(rktpar->topic, errstr, sizeof\
* (errstr))))
LG 15,0(0,15)
STG 15,176(0,13)
LA 15,168(0,13)
STG 15,184(0,13)
MVGHI 192(13),1
LA 1,176(0,13)
LG 15,@lit_1917_6 ; rd_regex_comp
@@gen_label7 DS 0H
BALR 14,15
@@gen_label8 DS 0H
LTGR 1,15
BNZ @L633
* *** return 1;
LGHI 15,1 ; 1
B @ret_lab_1917
@L633 DS 0H
* ***
* *** rd_regex_destroy(re);
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_1917_8 ; rd_regex_destroy
@@gen_label10 DS 0H
BALR 14,15
@@gen_label11 DS 0H
* ***
* *** return 0;
LGHI 15,0 ; 0
* *** }
@ret_lab_1917 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "_invalid_topic_cb"
* (FUNCTION #1917)
*
@AUTO#_invalid_topic_cb DSECT
DS XL168
_invalid_topic_cb#errstr#0 DS 1XL1 ; errstr
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_subscribe
rd_kafka_subscribe ALIAS X'99846D92818692816DA2A482A28399898285'
@LNAME601 DS 0H
DC X'00000012'
DC C'rd_kafka_subscribe'
DC X'00'
rd_kafka_subscribe DCCPRLG CINDEX=601,BASER=12,FRAME=200,ENTRY=YES,ARCH*
=ZARCH,LNAMEADDR=@LNAME601
* ******* End of Prologue
* *
LG 2,8(0,1) ; topics
* ***
* *** rd_kafka_op_t *rko;
* *** rd_kafka_cgrp_t *rkcg;
* *** rd_kafka_topic_partition_list_t *topics_cpy;
* ***
* *** if (!(rkcg = ((rk)->rk_cgrp)))
LG 15,0(0,1) ; rk
LG 3,520(0,15) ; offset of rk_cgrp in rd_kafka_s
LTGR 15,3
BNZ @L634
* *** return RD_KAFKA_RESP_ERR__UNKNOWN_GROUP;
LGHI 15,-179 ; -179
B @ret_lab_601
DS 0D
@FRAMESIZE_601 DC F'200'
@lit_601_13 DC AD(rd_kafka_topic_partition_list_sum)
@lit_601_12 DC AD(_invalid_topic_cb)
@lit_601_15 DC AD(rd_kafka_topic_partition_list_copy)
@lit_601_16 DC AD(rd_kafka_topic_partition_list_has_duplicates)
@lit_601_17 DC AD(rd_kafka_topic_partition_list_destroy)
@lit_601_19 DC AD(rd_kafka_op_new0)
@lit_601_20 DC AD(rd_kafka_op_req)
@lit_601_21 DC AD(rd_kafka_op_err_destroy)
@L634 DS 0H
* ***
* ***
* *** if (topics->cnt == 0 ||
CHSI 0(2),0
BE @L636
* *** rd_kafka_topic_partition_list_sum(topics,
* *** _invalid_topic_c\
* b, ((void *)0)) > 0)
STG 2,176(0,13)
LG 15,@lit_601_12 ; _invalid_topic_cb
STG 15,184(0,13)
XC 192(8,13),192(13)
LA 1,176(0,13)
LG 15,@lit_601_13 ; rd_kafka_topic_partition_list_sum
@@gen_label14 DS 0H
BALR 14,15
@@gen_label15 DS 0H
CLGFI 15,X'00000000'
BNH @L635
@L636 DS 0H
* *** return RD_KAFKA_RESP_ERR__INVALID_ARG;
LGHI 15,-186 ; -186
B @ret_lab_601
@L635 DS 0H
* ***
* *** topics_cpy = rd_kafka_topic_partition_list_copy(topics\
* );
STG 2,176(0,13)
LA 1,176(0,13)
LG 15,@lit_601_15 ; rd_kafka_topic_partition_list_copy
@@gen_label17 DS 0H
BALR 14,15
@@gen_label18 DS 0H
LGR 2,15
* *** if (rd_kafka_topic_partition_list_has_duplicates(topic\
* s_cpy,
* *** 1)) {
STG 2,176(0,13)
MVGHI 184(13),1
LA 1,176(0,13)
LG 15,@lit_601_16 ; rd_kafka_topic_partition_list_has_dupli*
cates
@@gen_label19 DS 0H
BALR 14,15
@@gen_label20 DS 0H
NILF 15,X'000000FF'
LTR 15,15
BZ @L637
* *** rd_kafka_topic_partition_list_destroy(topics_c\
* py);
STG 2,176(0,13)
LA 1,176(0,13)
LG 15,@lit_601_17 ; rd_kafka_topic_partition_list_destroy
@@gen_label22 DS 0H
BALR 14,15
@@gen_label23 DS 0H
* *** return RD_KAFKA_RESP_ERR__INVALID_ARG;
LGHI 15,-186 ; -186
B @ret_lab_601
* *** }
@L637 DS 0H
* ***
* *** rko = rd_kafka_op_new0(((void *)0), RD_KAFKA_OP_SUBSCR\
* IBE);
XC 176(8,13),176(13)
MVGHI 184(13),21
LA 1,176(0,13)
LG 15,@lit_601_19 ; rd_kafka_op_new0
@@gen_label24 DS 0H
BALR 14,15
@@gen_label25 DS 0H
* *** rko->rko_u.subscribe.topics = topics_cpy;
STG 2,112(0,15) ; offset of rko_u in rd_kafka_op_s
* ***
* *** return rd_kafka_op_err_destroy(
* *** rd_kafka_op_req(rkcg->rkcg_ops, rko, -1));
LG 1,80(0,3)
STG 1,176(0,13)
STG 15,184(0,13)
MVGHI 192(13),-1
LA 1,176(0,13)
LG 15,@lit_601_20 ; rd_kafka_op_req
@@gen_label26 DS 0H
BALR 14,15
@@gen_label27 DS 0H
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_601_21 ; rd_kafka_op_err_destroy
@@gen_label28 DS 0H
BALR 14,15
@@gen_label29 DS 0H
LGFR 15,15
* *** }
@ret_lab_601 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_subscribe"
* (FUNCTION #601)
*
@AUTO#rd_kafka_subscribe DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_assign0
rd_kafka_assign0 ALIAS X'99846D92818692816D81A2A2898795F0'
@LNAME1918 DS 0H
DC X'00000010'
DC C'rd_kafka_assign0'
DC X'00'
rd_kafka_assign0 DCCPRLG CINDEX=1918,BASER=12,FRAME=200,ENTRY=YES,ARCH=*
ZARCH,LNAMEADDR=@LNAME1918
LGR 4,1 ; ptr to parm area
* ******* End of Prologue
* *
* *** rd_kafka_op_t *rko;
* *** rd_kafka_cgrp_t *rkcg;
* ***
* *** if (!(rkcg = ((rk)->rk_cgrp)))
LG 15,0(0,4) ; rk
LG 3,520(0,15) ; offset of rk_cgrp in rd_kafka_s
LTGR 15,3
BNZ @L638
* *** return rd_kafka_error_new(RD_KAFKA_RESP_ERR__U\
* NKNOWN_GROUP,
* *** "Requires a consumer\
* with group.id "
MVGHI 176(13),-179
* *** "configured");
LG 15,@lit_1918_23
STG 15,184(0,13)
LA 1,176(0,13)
LG 15,@lit_1918_24 ; rd_kafka_error_new
@@gen_label31 DS 0H
BALR 14,15
@@gen_label32 DS 0H
B @ret_lab_1918
DS 0D
@FRAMESIZE_1918 DC F'200'
@lit_1918_24 DC AD(rd_kafka_error_new)
@lit_1918_23 DC AD(@strings@)
@lit_1918_25 DC AD(rd_kafka_op_new0)
@lit_1918_26 DC AD(rd_kafka_topic_partition_list_copy)
@lit_1918_27 DC AD(rd_kafka_op_req)
@lit_1918_28 DC AD(rd_kafka_op_error_destroy)
@L638 DS 0H
* ***
* *** rko = rd_kafka_op_new0(((void *)0), RD_KAFKA_OP_ASSIGN\
* );
XC 176(8,13),176(13)
MVGHI 184(13),22
LA 1,176(0,13)
LG 15,@lit_1918_25 ; rd_kafka_op_new0
@@gen_label33 DS 0H
BALR 14,15
@@gen_label34 DS 0H
LGR 2,15
* ***
* *** rko->rko_u.assign.method = assign_method;
L 1,12(0,4) ; assign_method
ST 1,120(0,2) ; offset of method in 0000061
* ***
* *** if (partitions)
LG 15,16(0,4) ; partitions
LTGR 1,15
BZ @L639
* *** rko->rko_u.assign.partitions =
* *** rd_kafka_topic_partition_list_copy(par\
* titions);
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_1918_26 ; rd_kafka_topic_partition_list_copy
@@gen_label36 DS 0H
BALR 14,15
@@gen_label37 DS 0H
STG 15,112(0,2)
@L639 DS 0H
* ***
* *** return rd_kafka_op_error_destroy(
* *** rd_kafka_op_req(rkcg->rkcg_ops, rko, -1));
LG 15,80(0,3)
STG 15,176(0,13)
STG 2,184(0,13)
MVGHI 192(13),-1
LA 1,176(0,13)
LG 15,@lit_1918_27 ; rd_kafka_op_req
@@gen_label38 DS 0H
BALR 14,15
@@gen_label39 DS 0H
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_1918_28 ; rd_kafka_op_error_destroy
@@gen_label40 DS 0H
BALR 14,15
@@gen_label41 DS 0H
* *** }
@ret_lab_1918 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_assign0"
* (FUNCTION #1918)
*
@AUTO#rd_kafka_assign0 DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_assign
rd_kafka_assign ALIAS X'99846D92818692816D81A2A2898795'
@LNAME609 DS 0H
DC X'0000000F'
DC C'rd_kafka_assign'
DC X'00'
rd_kafka_assign DCCPRLG CINDEX=609,BASER=12,FRAME=200,ENTRY=YES,ARCH=ZA*
RCH,LNAMEADDR=@LNAME609
* ******* End of Prologue
* *
* *** rd_kafka_error_t *error;
* *** rd_kafka_resp_err_t err;
* ***
* *** error = rd_kafka_assign0(rk, RD_KAFKA_ASSIGN_METHOD_AS\
* SIGN,
* *** partitions);
LG 15,0(0,1) ; rk
STG 15,176(0,13)
XC 184(8,13),184(13)
LG 15,8(0,1) ; partitions
STG 15,192(0,13)
LA 1,176(0,13)
LG 15,@lit_609_30 ; rd_kafka_assign0
@@gen_label42 DS 0H
BALR 14,15
@@gen_label43 DS 0H
LGR 3,15
* ***
* *** if (!error)
LTGR 15,3
BNZ @L640
* *** err = RD_KAFKA_RESP_ERR_NO_ERROR;
LHI 2,0 ; 0
B @L641
DS 0D
@FRAMESIZE_609 DC F'200'
@lit_609_30 DC AD(rd_kafka_assign0)
@lit_609_32 DC AD(rd_kafka_error_code)
@lit_609_33 DC AD(rd_kafka_error_destroy)
* *** else {
@L640 DS 0H
* *** err = rd_kafka_error_code(error);
STG 3,176(0,13)
LA 1,176(0,13)
LG 15,@lit_609_32 ; rd_kafka_error_code
@@gen_label45 DS 0H
BALR 14,15
@@gen_label46 DS 0H
LR 2,15 ; err
* *** rd_kafka_error_destroy(error);
STG 3,176(0,13)
LA 1,176(0,13)
LG 15,@lit_609_33 ; rd_kafka_error_destroy
@@gen_label47 DS 0H
BALR 14,15
@@gen_label48 DS 0H
* *** }
@L641 DS 0H
* ***
* *** return err;
LGFR 15,2
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_assign"
* (FUNCTION #609)
*
@AUTO#rd_kafka_assign DSECT
DS XL168
rd_kafka_assign#err#0 DS 1F ; err
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_incremental_assign
rd_kafka_incremental_assign ALIAS X'99846D92818692816D8995839985948595A*
381936D81A2A2898795'
@LNAME606 DS 0H
DC X'0000001B'
DC C'rd_kafka_incremental_assign'
DC X'00'
rd_kafka_incremental_assign DCCPRLG CINDEX=606,BASER=12,FRAME=192,ENTRY*
=YES,ARCH=ZARCH,LNAMEADDR=@LNAME606
* ******* End of Prologue
* *
* *** if (!partitions)
LG 15,8(0,1) ; partitions
LTGR 2,15
BNZ @L642
* *** return rd_kafka_error_new(RD_KAFKA_RESP_ERR__I\
* NVALID_ARG,
* *** "partitions must not\
* be NULL");
MVGHI 168(13),-186
LG 15,@lit_606_35
LA 15,46(0,15)
STG 15,176(0,13)
LA 1,168(0,13)
LG 15,@lit_606_36 ; rd_kafka_error_new
@@gen_label50 DS 0H
BALR 14,15
@@gen_label51 DS 0H
B @ret_lab_606
DS 0D
@FRAMESIZE_606 DC F'192'
@lit_606_36 DC AD(rd_kafka_error_new)
@lit_606_35 DC AD(@strings@)
@lit_606_37 DC AD(rd_kafka_assign0)
@L642 DS 0H
* ***
* *** return rd_kafka_assign0(rk, RD_KAFKA_ASSIGN_METHOD_INC\
* R_ASSIGN,
* *** partitions);
LG 1,0(0,1) ; rk
STG 1,168(0,13)
MVGHI 176(13),1
STG 15,184(0,13)
LA 1,168(0,13)
LG 15,@lit_606_37 ; rd_kafka_assign0
@@gen_label52 DS 0H
BALR 14,15
@@gen_label53 DS 0H
* *** }
@ret_lab_606 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_incremental_assign"
* (FUNCTION #606)
*
@AUTO#rd_kafka_incremental_assign DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_incremental_unassign
rd_kafka_incremental_unassign ALIAS X'99846D92818692816D899583998594859*
5A381936DA49581A2A2898795'
@LNAME607 DS 0H
DC X'0000001D'
DC C'rd_kafka_incremental_unassign'
DC X'00'
rd_kafka_incremental_unassign DCCPRLG CINDEX=607,BASER=12,FRAME=192,ENT*
RY=YES,ARCH=ZARCH,LNAMEADDR=@LNAME607
* ******* End of Prologue
* *
* *** if (!partitions)
LG 15,8(0,1) ; partitions
LTGR 2,15
BNZ @L643
* *** return rd_kafka_error_new(RD_KAFKA_RESP_ERR__I\
* NVALID_ARG,
* *** "partitions must not\
* be NULL");
MVGHI 168(13),-186
LG 15,@lit_607_39
LA 15,46(0,15)
STG 15,176(0,13)
LA 1,168(0,13)
LG 15,@lit_607_40 ; rd_kafka_error_new
@@gen_label55 DS 0H
BALR 14,15
@@gen_label56 DS 0H
B @ret_lab_607
DS 0D
@FRAMESIZE_607 DC F'192'
@lit_607_40 DC AD(rd_kafka_error_new)
@lit_607_39 DC AD(@strings@)
@lit_607_41 DC AD(rd_kafka_assign0)
@L643 DS 0H
* ***
* *** return rd_kafka_assign0(rk, RD_KAFKA_ASSIGN_METHOD_INC\
* R_UNASSIGN,
* *** partitions);
LG 1,0(0,1) ; rk
STG 1,168(0,13)
MVGHI 176(13),2
STG 15,184(0,13)
LA 1,168(0,13)
LG 15,@lit_607_41 ; rd_kafka_assign0
@@gen_label57 DS 0H
BALR 14,15
@@gen_label58 DS 0H
* *** }
@ret_lab_607 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_incremental_unassign"
* (FUNCTION #607)
*
@AUTO#rd_kafka_incremental_unassign DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_assignment_lost
rd_kafka_assignment_lost ALIAS X'99846D92818692816D81A2A2898795948595A3*
6D9396A2A3'
@LNAME611 DS 0H
DC X'00000018'
DC C'rd_kafka_assignment_lost'
DC X'00'
rd_kafka_assignment_lost DCCPRLG CINDEX=611,BASER=12,FRAME=184,ENTRY=YE*
S,ARCH=ZARCH,LNAMEADDR=@LNAME611
* ******* End of Prologue
* *
* *** rd_kafka_cgrp_t *rkcg;
* ***
* *** if (!(rkcg = ((rk)->rk_cgrp)))
LG 15,0(0,1) ; rk
LG 15,520(0,15) ; offset of rk_cgrp in rd_kafka_s
LTGR 1,15
BNZ @L644
* *** return 0;
LGHI 15,0 ; 0
B @ret_lab_611
DS 0D
@FRAMESIZE_611 DC F'184'
@lit_611_44 DC AD(rd_kafka_cgrp_assignment_is_lost)
@L644 DS 0H
* ***
* *** return rd_kafka_cgrp_assignment_is_lost(rkcg) == 1;
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_611_44 ; rd_kafka_cgrp_assignment_is_lost
@@gen_label60 DS 0H
BALR 14,15
@@gen_label61 DS 0H
NILF 15,X'000000FF'
XILF 15,X'00000001'
LPR 15,15
AHI 15,-1
SRL 15,31(0)
LGFR 15,15
* *** }
@ret_lab_611 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_assignment_lost"
* (FUNCTION #611)
*
@AUTO#rd_kafka_assignment_lost DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_rebalance_protocol
rd_kafka_rebalance_protocol ALIAS X'99846D92818692816D99858281938195838*
56D979996A396839693'
@LNAME608 DS 0H
DC X'0000001B'
DC C'rd_kafka_rebalance_protocol'
DC X'00'
rd_kafka_rebalance_protocol DCCPRLG CINDEX=608,BASER=12,FRAME=192,ENTRY*
=YES,ARCH=ZARCH,LNAMEADDR=@LNAME608
* ******* End of Prologue
* *
* *** rd_kafka_op_t *rko;
* *** rd_kafka_cgrp_t *rkcg;
* *** const char *result;
* ***
* *** if (!(rkcg = ((rk)->rk_cgrp)))
LG 15,0(0,1) ; rk
LG 15,520(0,15) ; offset of rk_cgrp in rd_kafka_s
LTGR 1,15
BNZ @L645
* *** return ((void *)0);
LGHI 15,0 ; 0
B @ret_lab_608
DS 0D
@FRAMESIZE_608 DC F'192'
@lit_608_47 DC AD(rd_kafka_op_req2)
@lit_608_49 DC AD(rd_kafka_op_destroy)
@L645 DS 0H
* ***
* *** rko = rd_kafka_op_req2(rkcg->rkcg_ops,
* *** RD_KAFKA_OP_GET_REBALANCE_PROTO\
* COL);
LG 15,80(0,15)
STG 15,176(0,13)
MVGHI 184(13),48
LA 1,176(0,13)
LG 15,@lit_608_47 ; rd_kafka_op_req2
@@gen_label63 DS 0H
BALR 14,15
@@gen_label64 DS 0H
* ***
* *** if (!rko)
LTGR 1,15
BNZ @L646
* *** return ((void *)0);
LGHI 15,0 ; 0
B @ret_lab_608
* *** else if (rko->rko_err) {
@L646 DS 0H
LT 1,32(0,15) ; offset of rko_err in rd_kafka_op_s
BZ @L647
* *** rd_kafka_op_destroy(rko);
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_608_49 ; rd_kafka_op_destroy
@@gen_label67 DS 0H
BALR 14,15
@@gen_label68 DS 0H
* *** return ((void *)0);
LGHI 15,0 ; 0
B @ret_lab_608
* *** }
* ***
* *** result = rko->rko_u.rebalance_protocol.str;
@L647 DS 0H
LG 2,112(0,15) ; offset of rko_u in rd_kafka_op_s
* ***
* *** rd_kafka_op_destroy(rko);
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_608_49 ; rd_kafka_op_destroy
@@gen_label69 DS 0H
BALR 14,15
@@gen_label70 DS 0H
* ***
* *** return result;
LGR 15,2
* *** }
@ret_lab_608 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_rebalance_protocol"
* (FUNCTION #608)
*
@AUTO#rd_kafka_rebalance_protocol DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_assignment
rd_kafka_assignment ALIAS X'99846D92818692816D81A2A2898795948595A3'
@LNAME610 DS 0H
DC X'00000013'
DC C'rd_kafka_assignment'
DC X'00'
rd_kafka_assignment DCCPRLG CINDEX=610,BASER=12,FRAME=192,ENTRY=YES,ARC*
H=ZARCH,LNAMEADDR=@LNAME610
* ******* End of Prologue
* *
LG 2,8(0,1) ; partitions
* *** rd_kafka_op_t *rko;
* *** rd_kafka_resp_err_t err;
* *** rd_kafka_cgrp_t *rkcg;
* ***
* *** if (!(rkcg = ((rk)->rk_cgrp)))
LG 15,0(0,1) ; rk
LG 15,520(0,15) ; offset of rk_cgrp in rd_kafka_s
LTGR 1,15
BNZ @L649
* *** return RD_KAFKA_RESP_ERR__UNKNOWN_GROUP;
LGHI 15,-179 ; -179
B @ret_lab_610
DS 0D
@FRAMESIZE_610 DC F'192'
@lit_610_54 DC AD(rd_kafka_op_req2)
@lit_610_57 DC AD(rd_kafka_op_destroy)
@lit_610_58 DC AD(rd_kafka_topic_partition_list_new)
@L649 DS 0H
* ***
* *** rko = rd_kafka_op_req2(rkcg->rkcg_ops, RD_KAFKA_OP_GET\
* _ASSIGNMENT);
LG 15,80(0,15)
STG 15,176(0,13)
MVGHI 184(13),24
LA 1,176(0,13)
LG 15,@lit_610_54 ; rd_kafka_op_req2
@@gen_label72 DS 0H
BALR 14,15
@@gen_label73 DS 0H
* *** if (!rko)
LTGR 1,15
BNZ @L650
* *** return RD_KAFKA_RESP_ERR__TIMED_OUT;
LGHI 15,-185 ; -185
B @ret_lab_610
@L650 DS 0H
* ***
* *** err = rko->rko_err;
L 3,32(0,15) ; offset of rko_err in rd_kafka_op_s
* ***
* *** *partitions = rko->rko_u.assign.partitions;
LG 1,112(0,15) ; offset of rko_u in rd_kafka_op_s
STG 1,0(0,2) ; partitions
* *** rko->rko_u.assign.partitions = ((void *)0);
LGHI 1,0 ; 0
STG 1,112(0,15) ; offset of rko_u in rd_kafka_op_s
* *** rd_kafka_op_destroy(rko);
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_610_57 ; rd_kafka_op_destroy
@@gen_label75 DS 0H
BALR 14,15
@@gen_label76 DS 0H
* ***
* *** if (!*partitions && !err) {
LTG 15,0(0,2) ; partitions
BNZ @L651
LTR 3,3
BNZ @L651
* ***
* *** *partitions = rd_kafka_topic_partition_list_ne\
* w(0);
XC 176(8,13),176(13)
LA 1,176(0,13)
LG 15,@lit_610_58 ; rd_kafka_topic_partition_list_new
@@gen_label79 DS 0H
BALR 14,15
@@gen_label80 DS 0H
STG 15,0(0,2)
* *** }
@L651 DS 0H
* ***
* *** return err;
LGFR 15,3
* *** }
@ret_lab_610 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_assignment"
* (FUNCTION #610)
*
@AUTO#rd_kafka_assignment DSECT
DS XL168
rd_kafka_assignment#err#0 DS 1F ; err
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_subscription
rd_kafka_subscription ALIAS X'99846D92818692816DA2A482A283998997A389969*
5'
@LNAME603 DS 0H
DC X'00000015'
DC C'rd_kafka_subscription'
DC X'00'
rd_kafka_subscription DCCPRLG CINDEX=603,BASER=12,FRAME=192,ENTRY=YES,A*
RCH=ZARCH,LNAMEADDR=@LNAME603
* ******* End of Prologue
* *
LG 2,8(0,1) ; topics
* *** rd_kafka_op_t *rko;
* *** rd_kafka_resp_err_t err;
* *** rd_kafka_cgrp_t *rkcg;
* ***
* *** if (!(rkcg = ((rk)->rk_cgrp)))
LG 15,0(0,1) ; rk
LG 15,520(0,15) ; offset of rk_cgrp in rd_kafka_s
LTGR 1,15
BNZ @L652
* *** return RD_KAFKA_RESP_ERR__UNKNOWN_GROUP;
LGHI 15,-179 ; -179
B @ret_lab_603
DS 0D
@FRAMESIZE_603 DC F'192'
@lit_603_61 DC AD(rd_kafka_op_req2)
@lit_603_64 DC AD(rd_kafka_op_destroy)
@lit_603_65 DC AD(rd_kafka_topic_partition_list_new)
@L652 DS 0H
* ***
* *** rko = rd_kafka_op_req2(rkcg->rkcg_ops, RD_KAFKA_OP_GET\
* _SUBSCRIPTION);
LG 15,80(0,15)
STG 15,176(0,13)
MVGHI 184(13),23
LA 1,176(0,13)
LG 15,@lit_603_61 ; rd_kafka_op_req2
@@gen_label82 DS 0H
BALR 14,15
@@gen_label83 DS 0H
* *** if (!rko)
LTGR 1,15
BNZ @L653
* *** return RD_KAFKA_RESP_ERR__TIMED_OUT;
LGHI 15,-185 ; -185
B @ret_lab_603
@L653 DS 0H
* ***
* *** err = rko->rko_err;
L 3,32(0,15) ; offset of rko_err in rd_kafka_op_s
* ***
* *** *topics = rko->rko_u.subscribe.topics;
LG 1,112(0,15) ; offset of rko_u in rd_kafka_op_s
STG 1,0(0,2) ; topics
* *** rko->rko_u.subscribe.topics = ((void *)0);
LGHI 1,0 ; 0
STG 1,112(0,15) ; offset of rko_u in rd_kafka_op_s
* *** rd_kafka_op_destroy(rko);
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_603_64 ; rd_kafka_op_destroy
@@gen_label85 DS 0H
BALR 14,15
@@gen_label86 DS 0H
* ***
* *** if (!*topics && !err) {
LTG 15,0(0,2) ; topics
BNZ @L654
LTR 3,3
BNZ @L654
* ***
* *** *topics = rd_kafka_topic_partition_list_new(0)\
* ;
XC 176(8,13),176(13)
LA 1,176(0,13)
LG 15,@lit_603_65 ; rd_kafka_topic_partition_list_new
@@gen_label89 DS 0H
BALR 14,15
@@gen_label90 DS 0H
STG 15,0(0,2)
* *** }
@L654 DS 0H
* ***
* *** return err;
LGFR 15,3
* *** }
@ret_lab_603 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_subscription"
* (FUNCTION #603)
*
@AUTO#rd_kafka_subscription DSECT
DS XL168
rd_kafka_subscription#err#0 DS 1F ; err
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_pause_partitions
rd_kafka_pause_partitions ALIAS X'99846D92818692816D9781A4A2856D978199A*
389A3899695A2'
@LNAME570 DS 0H
DC X'00000019'
DC C'rd_kafka_pause_partitions'
DC X'00'
rd_kafka_pause_partitions DCCPRLG CINDEX=570,BASER=12,FRAME=208,ENTRY=Y*
ES,ARCH=ZARCH,LNAMEADDR=@LNAME570
* ******* End of Prologue
* *
* *** return rd_kafka_toppars_pause_resume(rk,
* *** 1,
* *** RD_SYNC,
* *** 0x10,
* *** partitions);
LG 15,0(0,1) ; rk
STG 15,168(0,13)
MVGHI 176(13),1
XC 184(8,13),184(13)
MVGHI 192(13),16
LG 15,8(0,1) ; partitions
STG 15,200(0,13)
LA 1,168(0,13)
LG 15,@lit_570_67 ; rd_kafka_toppars_pause_resume
@@gen_label91 DS 0H
BALR 14,15
@@gen_label92 DS 0H
LGFR 15,15
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_570 DC F'208'
@lit_570_67 DC AD(rd_kafka_toppars_pause_resume)
DROP 12
*
* DSECT for automatic variables in "rd_kafka_pause_partitions"
* (FUNCTION #570)
*
@AUTO#rd_kafka_pause_partitions DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_resume_partitions
rd_kafka_resume_partitions ALIAS X'99846D92818692816D9985A2A494856D9781*
99A389A3899695A2'
@LNAME571 DS 0H
DC X'0000001A'
DC C'rd_kafka_resume_partitions'
DC X'00'
rd_kafka_resume_partitions DCCPRLG CINDEX=571,BASER=12,FRAME=208,ENTRY=*
YES,ARCH=ZARCH,LNAMEADDR=@LNAME571
* ******* End of Prologue
* *
* *** return rd_kafka_toppars_pause_resume(rk,
* *** 0,
* *** RD_SYNC,
* *** 0x10,
* *** partitions);
LG 15,0(0,1) ; rk
STG 15,168(0,13)
XC 176(16,13),176(13)
MVGHI 192(13),16
LG 15,8(0,1) ; partitions
STG 15,200(0,13)
LA 1,168(0,13)
LG 15,@lit_571_69 ; rd_kafka_toppars_pause_resume
@@gen_label93 DS 0H
BALR 14,15
@@gen_label94 DS 0H
LGFR 15,15
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_571 DC F'208'
@lit_571_69 DC AD(rd_kafka_toppars_pause_resume)
DROP 12
*
* DSECT for automatic variables in "rd_kafka_resume_partitions"
* (FUNCTION #571)
*
@AUTO#rd_kafka_resume_partitions DSECT
DS XL168
*
@CODE CSECT
@@STATIC ALIAS X'7C998492818692816DA2A482A283998997A389969550'
@@STATIC DXD 219D
*
* Non-Re-Entrant Data Section
*
@DATA CSECT
@DATA RMODE ANY
@DATA AMODE ANY
@@T48F DC X'99846D838193939683' rd.calloc
DC 1X'00'
@@T493 DC X'99846D948193939683' rd.malloc
DC 1X'00'
@@T498 DC X'99846D99858193939683' rd.realloc
DC 2X'00'
@@T49E DC X'99846DA2A39984A497' rd.strdup
DC 1X'00'
@@T4A3 DC X'99846DA2A3999584A497' rd.strndup
DC 2X'00'
@@T4AB DC X'99846D9985868395A36DA2A482F0' rd.refcnt.sub0
DC 4X'00'
@@T65A DC 4X'00'
DC X'0000001A000000000000002200000000' ................
DC X'00000024' ....
@@T67D DC X'99846D92818692816D94A287986D8485' rd.kafka.msgq.de
DC X'98' q
DC 1X'00'
@@T704 DC X'99846D92818692816D986D8485A2A399' rd.kafka.q.destr
DC X'96A8F0' oy0
DC 1X'00'
@@T785 DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8485A2A39996A8F0' e.destroy0
DC 2X'00'
@@T78D DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8485936DA296A4998385' e.del.source
DC 2X'00'
@@T794 DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8485936DA296A49983856D9985A3' e.del.source.ret
DC X'A49995' urn
DC 1X'00'
@@T79C DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856DA3998987878599' e.trigger
DC 1X'00'
@@T7A0 DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8485A2A39996A8' e.destroy
DC 1X'00'
@@T7A5 DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8489A281829385' e.disable
DC 1X'00'
@@T7C5 DC X'99846DA394978182A4866D8193939683' rd.tmpabuf.alloc
DC X'F0' 0
DC 1X'00'
@@T7F9 DC X'99846D92818692816D82A4866DA49784' rd.kafka.buf.upd
DC X'81A385' ate
DC 1X'00'
@@T81A DC X'99846D92818692816D82A4866D868995' rd.kafka.buf.fin
DC X'819389A9856D81999981A88395A3' alize.arraycnt
DC 2X'00'
@@T857 DC X'99846D92818692816D82A4866D839983' rd.kafka.buf.crc
DC X'6D899589A3' .init
DC 1X'00'
@@TA27 DC X'99846D92818692816D83A499996D94A2' rd.kafka.curr.ms
DC X'87A26DA2A482' gs.sub
DC 1X'00'
@strings@ DS 0H
DC X'D98598A4899985A2408140839695A2A4' Requires.a.consu
DC X'94859940A689A38840879996A4974B89' mer.with.group.i
DC X'8440839695868987A499858400009781' d.configured..pa
DC X'99A389A3899695A24094A4A2A3409596' rtitions.must.no
DC X'A340828540D5E4D3D300D7999684A483' t.be.NULL.Produc
DC X'8500C685A3838800D68686A285A30000' e.Fetch.Offset..
DC X'D485A3818481A3810000D38581848599' Metadata..Leader
DC X'C19584C9A2990000E2A39697D9859793' AndIsr..StopRepl
DC X'89838100E4978481A385D485A3818481' ica.UpdateMetada
DC X'A3810000C39695A3999693938584E288' ta..ControlledSh
DC X'A4A38496A6950000D68686A285A3C396' utdown..OffsetCo
DC X'949489A30000D68686A285A3C685A383' mmit..OffsetFetc
DC X'8800C6899584C396969984899581A396' h.FindCoordinato
DC X'9900D1968995C79996A49700C8858199' r.JoinGroup.Hear
DC X'A3828581A300D38581A585C79996A497' tbeat.LeaveGroup
DC X'0000E2A89583C79996A49700C485A283' ..SyncGroup.Desc
DC X'99898285C79996A497A20000D389A2A3' ribeGroups..List
DC X'C79996A497A20000E281A293C8819584' Groups..SaslHand
DC X'A28881928500C19789E58599A2899695' shake.ApiVersion
DC X'0000C3998581A385E396978983A20000' ..CreateTopics..
DC X'C4859385A385E396978983A20000C485' DeleteTopics..De
DC X'9385A385D98583969984A200C99589A3' leteRecords.Init
DC X'D7999684A4838599C9840000D68686A2' ProducerId..Offs
DC X'85A3C69699D38581848599C597968388' etForLeaderEpoch
DC X'0000C18484D78199A389A3899695A2E3' ..AddPartitionsT
DC X'96E3A7950000C18484D68686A285A3A2' oTxn..AddOffsets
DC X'E396E3A79500C59584E3A7950000E699' ToTxn.EndTxn..Wr
DC X'89A385E3A795D48199928599A200E3A7' iteTxnMarkers.Tx
DC X'95D68686A285A3C396949489A300C485' nOffsetCommit.De
DC X'A28399898285C18393A20000C3998581' scribeAcls..Crea
DC X'A385C18393A20000C4859385A385C183' teAcls..DeleteAc
DC X'93A20000C485A28399898285C3969586' ls..DescribeConf
DC X'8987A200C193A38599C39695868987A2' igs.AlterConfigs
DC X'0000C193A38599D9859793898381D396' ..AlterReplicaLo
DC X'87C48999A200C485A28399898285D396' gDirs.DescribeLo
DC X'87C48999A200E281A293C1A4A3888595' gDirs.SaslAuthen
DC X'A3898381A3850000C3998581A385D781' ticate..CreatePa
DC X'99A389A3899695A20000C3998581A385' rtitions..Create
DC X'C48593858781A3899695E39692859500' DelegationToken.
DC X'D9859585A6C48593858781A3899695E3' RenewDelegationT
DC X'969285950000C5A797899985C4859385' oken..ExpireDele
DC X'8781A3899695E39692859500C485A283' gationToken.Desc
DC X'99898285C48593858781A3899695E396' ribeDelegationTo
DC X'92859500C4859385A385C79996A497A2' ken.DeleteGroups
DC X'0000C5938583A3D38581848599A2D985' ..ElectLeadersRe
DC X'98A485A2A300C995839985948595A381' quest.Incrementa
DC X'93C193A38599C39695868987A2D98598' lAlterConfigsReq
DC X'A485A2A30000C193A38599D78199A389' uest..AlterParti
DC X'A3899695D98581A2A2898795948595A3' tionReassignment
DC X'A2D98598A485A2A30000D389A2A3D781' sRequest..ListPa
DC X'99A389A3899695D98581A2A289879594' rtitionReassignm
DC X'8595A3A2D98598A485A2A300D68686A2' entsRequest.Offs
DC X'85A3C4859385A385D98598A485A2A300' etDeleteRequest.
DC X'C485A28399898285C393898595A3D8A4' DescribeClientQu
DC X'96A381A2D98598A485A2A300C193A385' otasRequest.Alte
DC X'99C393898595A3D8A496A381A2D98598' rClientQuotasReq
DC X'A485A2A30000C485A28399898285E4A2' uest..DescribeUs
DC X'8599E283998194C39985848595A38981' erScramCredentia
DC X'93A2D98598A485A2A300C193A38599E4' lsRequest.AlterU
DC X'A28599E283998194C39985848595A389' serScramCredenti
DC X'8193A2D98598A485A2A30000E596A385' alsRequest..Vote
DC X'D98598A485A2A300C285878995D8A496' Request.BeginQuo
DC X'99A494C597968388D98598A485A2A300' rumEpochRequest.
DC X'C59584D8A49699A494C597968388D985' EndQuorumEpochRe
DC X'98A485A2A300C485A28399898285D8A4' quest.DescribeQu
DC X'9699A494D98598A485A2A300C193A385' orumRequest.Alte
DC X'99C9A299D98598A485A2A300E4978481' rIsrRequest.Upda
DC X'A385C68581A3A49985A2D98598A485A2' teFeaturesReques
DC X'A300C595A58593969785D98598A485A2' t.EnvelopeReques
DC X'A30095969585000087A989970000A295' t.none..gzip..sn
DC X'819797A8000093A9F400A9A2A3840000' appy..lz4.zstd..
DC X'899588859989A300839695868987A499' inherit.configur
DC X'8584000093858199958584008995A385' ed..learned.inte
DC X'9995819300009396878983819300C995' rnal..logical.In
DC X'89A30000E3859994899581A38500C681' it..Terminate.Fa
DC X'A38193C5999996990000D98598A485A2' talError..Reques
DC X'A3D7C9C40000E68189A3E3998195A297' tPID..WaitTransp
DC X'9699A300E68189A3D7C9C400C1A2A289' ort.WaitPID.Assi
DC X'879585840000C499818995D985A285A3' gned..DrainReset
DC X'0000C499818995C2A4949700D9858184' ..DrainBump.Read
DC X'A8D596A3C18392858400D9858184A800' yNotAcked.Ready.
DC X'C995E3998195A28183A389969500C285' InTransaction.Be
DC X'878995C396949489A300C396949489A3' ginCommit.Commit
DC X'A3899587E3998195A28183A389969500' tingTransaction.
DC X'C396949489A3D596A3C1839285840000' CommitNotAcked..
DC X'C1829699A3899587E3998195A28183A3' AbortingTransact
DC X'89969500C1829699A38584D596A3C183' ion.AbortedNotAc
DC X'92858400C1829699A381829385C59999' ked.AbortableErr
DC X'96990000' or..
*
*
* Re-entrant Data Initialization Section
*
@@INIT@ ALIAS C'rdkafka_subscription:'
@@INIT@ CSECT
@@INIT@ AMODE ANY
@@INIT@ RMODE ANY
DC XL1'5'
DC AL3(0)
DC AL4(288)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000001'
DC X'00000000'
DC X'000000FF'
DC X'0102039C09867F978D8E0B0C0D0E0F10' .....f.p........
DC X'1112139D8508871819928F1C1D1E1F80' ....e.g..k......
DC X'818283840A171B88898A8B8C05060790' abcd...hi.......
DC X'9116939495960498999A9B14159E1A20' j.lmno.qr.......
DC X'A0E2E4E0E1E3E5E7F1A22E3C282B7C26' .SU..TVX1s......
DC X'E9EAEBE8EDEEEFECDF21242A293B5E2D' Z..Y............
DC X'2FC2C4C0C1C3C5C7D1A62C255F3E3FF8' .BD.ACEGJw.....8
DC X'C9CACBC8CDCECFCC603A2340273D22D8' I..H...........Q
DC X'616263646566676869ABBBF0FDFEB1B0' ...........0....
DC X'6A6B6C6D6E6F707172AABAE6B8C6A4B5' ...........W.Fu.
DC X'7E737475767778797AA1BFD05BDEAEAC' ................
DC X'A3A5B7A9A7B6BCBDBEDDA8AF5DB4D77B' tv.zx.....y...P.
DC X'414243444546474849ADF4F6F2F3F57D' ..........46235.
DC X'4A4B4C4D4E4F505152B9FBFCF9FAFF5C' ............9...
DC X'F7535455565758595AB2D4D6D2D3D530' 7.........MOKLN.
DC X'313233343536373839B3DBDCD9DA9F40' ............R...
*
DC XL1'5'
DC AL3(0)
DC AL4(480)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000101'
DC X'00000000'
DC X'000000A0'
DC X'010203372D2E2F1605150B0C0D0E0F10' ................
DC X'1112133C3D322618193F271C1D1E1F40' ................
DC X'5A7F7B5B6C507D4D5D5C4E6B604B61F0' ...............0
DC X'F1F2F3F4F5F6F7F8F97A5E4C7E6E6F7C' 123456789.......
DC X'C1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7' ABCDEFGHIJKLMNOP
DC X'D8D9E2E3E4E5E6E7E8E9ADE0BD5F6D79' QRSTUVWXYZ......
DC X'81828384858687888991929394959697' abcdefghijklmnop
DC X'9899A2A3A4A5A6A7A8A9C04FD0A10720' qrstuvwxyz......
DC X'2122232425061728292A2B2C090A1B30' ................
DC X'311A333435360838393A3B04143EFF80' ................
*
DC XL1'5'
DC AL3(0)
DC AL4(520)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000001C0'
DC X'00000000'
DC X'00000001'
DC X'8A40404040404040' ........
*
DC XL1'5'
DC AL3(0)
DC AL4(560)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000001E0'
DC X'00000000'
DC X'00000001'
DC X'8B40404040404040' ........
*
DC XL1'D'
DC AL3(0)
DC AL4(600)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000220'
DC ADL8(@DATA)
DC X'00000000'
DC X'000001F0'
*
DC XL1'D'
DC AL3(0)
DC AL4(640)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000228'
DC ADL8(@DATA)
DC X'00000000'
DC X'000001F8'
*
DC XL1'D'
DC AL3(0)
DC AL4(680)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000230'
DC ADL8(@DATA)
DC X'00000000'
DC X'000001FE'
*
DC XL1'D'
DC AL3(0)
DC AL4(720)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000238'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000206'
*
DC XL1'D'
DC AL3(0)
DC AL4(760)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000240'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000210'
*
DC XL1'D'
DC AL3(0)
DC AL4(800)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000248'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000021E'
*
DC XL1'D'
DC AL3(0)
DC AL4(840)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000250'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000022A'
*
DC XL1'D'
DC AL3(0)
DC AL4(880)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000258'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000023A'
*
DC XL1'D'
DC AL3(0)
DC AL4(920)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000260'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000024E'
*
DC XL1'D'
DC AL3(0)
DC AL4(960)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000268'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000025C'
*
DC XL1'D'
DC AL3(0)
DC AL4(1000)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000270'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000268'
*
DC XL1'D'
DC AL3(0)
DC AL4(1040)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000278'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000278'
*
DC XL1'D'
DC AL3(0)
DC AL4(1080)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000280'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000282'
*
DC XL1'D'
DC AL3(0)
DC AL4(1120)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000288'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000028C'
*
DC XL1'D'
DC AL3(0)
DC AL4(1160)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000290'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000298'
*
DC XL1'D'
DC AL3(0)
DC AL4(1200)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000298'
DC ADL8(@DATA)
DC X'00000000'
DC X'000002A2'
*
DC XL1'D'
DC AL3(0)
DC AL4(1240)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002A0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000002B2'
*
DC XL1'D'
DC AL3(0)
DC AL4(1280)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002A8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000002BE'
*
DC XL1'D'
DC AL3(0)
DC AL4(1320)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002B0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000002CC'
*
DC XL1'D'
DC AL3(0)
DC AL4(1360)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002B8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000002D8'
*
DC XL1'D'
DC AL3(0)
DC AL4(1400)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002C0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000002E6'
*
DC XL1'D'
DC AL3(0)
DC AL4(1440)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002C8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000002F4'
*
DC XL1'D'
DC AL3(0)
DC AL4(1480)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002D0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000302'
*
DC XL1'D'
DC AL3(0)
DC AL4(1520)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002D8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000312'
*
DC XL1'D'
DC AL3(0)
DC AL4(1560)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002E0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000328'
*
DC XL1'D'
DC AL3(0)
DC AL4(1600)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002E8'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000033C'
*
DC XL1'D'
DC AL3(0)
DC AL4(1640)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002F0'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000034C'
*
DC XL1'D'
DC AL3(0)
DC AL4(1680)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002F8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000354'
*
DC XL1'D'
DC AL3(0)
DC AL4(1720)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000300'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000364'
*
DC XL1'D'
DC AL3(0)
DC AL4(1760)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000308'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000374'
*
DC XL1'D'
DC AL3(0)
DC AL4(1800)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000310'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000382'
*
DC XL1'D'
DC AL3(0)
DC AL4(1840)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000318'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000038E'
*
DC XL1'D'
DC AL3(0)
DC AL4(1880)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000320'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000039A'
*
DC XL1'D'
DC AL3(0)
DC AL4(1920)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000328'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003AA'
*
DC XL1'D'
DC AL3(0)
DC AL4(1960)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000330'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003B8'
*
DC XL1'D'
DC AL3(0)
DC AL4(2000)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000338'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003CC'
*
DC XL1'D'
DC AL3(0)
DC AL4(2040)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000340'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003DC'
*
DC XL1'D'
DC AL3(0)
DC AL4(2080)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000348'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003EE'
*
DC XL1'D'
DC AL3(0)
DC AL4(2120)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000350'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000400'
*
DC XL1'D'
DC AL3(0)
DC AL4(2160)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000358'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000416'
*
DC XL1'D'
DC AL3(0)
DC AL4(2200)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000360'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000042C'
*
DC XL1'D'
DC AL3(0)
DC AL4(2240)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000368'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000442'
*
DC XL1'D'
DC AL3(0)
DC AL4(2280)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000370'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000045A'
*
DC XL1'D'
DC AL3(0)
DC AL4(2320)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000378'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000468'
*
DC XL1'D'
DC AL3(0)
DC AL4(2360)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000380'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000047C'
*
DC XL1'D'
DC AL3(0)
DC AL4(2400)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000388'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000049C'
*
DC XL1'D'
DC AL3(0)
DC AL4(2440)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000390'
DC ADL8(@DATA)
DC X'00000000'
DC X'000004C0'
*
DC XL1'D'
DC AL3(0)
DC AL4(2480)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000398'
DC ADL8(@DATA)
DC X'00000000'
DC X'000004E2'
*
DC XL1'D'
DC AL3(0)
DC AL4(2520)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003A0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000004F6'
*
DC XL1'D'
DC AL3(0)
DC AL4(2560)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003A8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000512'
*
DC XL1'D'
DC AL3(0)
DC AL4(2600)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003B0'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000052C'
*
DC XL1'D'
DC AL3(0)
DC AL4(2640)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003B8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000550'
*
DC XL1'D'
DC AL3(0)
DC AL4(2680)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003C0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000572'
*
DC XL1'D'
DC AL3(0)
DC AL4(2720)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003C8'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000057E'
*
DC XL1'D'
DC AL3(0)
DC AL4(2760)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003D0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000596'
*
DC XL1'D'
DC AL3(0)
DC AL4(2800)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003D8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000005AC'
*
DC XL1'D'
DC AL3(0)
DC AL4(2840)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003E0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000005C2'
*
DC XL1'D'
DC AL3(0)
DC AL4(2880)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003E8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000005D2'
*
DC XL1'D'
DC AL3(0)
DC AL4(2920)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003F0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000005E8'
*
DC XL1'D'
DC AL3(0)
DC AL4(2960)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004C0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000005F8'
*
DC XL1'D'
DC AL3(0)
DC AL4(3000)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004C8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000005FE'
*
DC XL1'D'
DC AL3(0)
DC AL4(3040)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004D0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000604'
*
DC XL1'D'
DC AL3(0)
DC AL4(3080)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004D8'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000060C'
*
DC XL1'D'
DC AL3(0)
DC AL4(3120)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004E0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000610'
*
DC XL1'D'
DC AL3(0)
DC AL4(3160)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004E8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000616'
*
DC XL1'D'
DC AL3(0)
DC AL4(3200)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000510'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000061E'
*
DC XL1'D'
DC AL3(0)
DC AL4(3240)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000518'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000062A'
*
DC XL1'D'
DC AL3(0)
DC AL4(3280)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000520'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000632'
*
DC XL1'D'
DC AL3(0)
DC AL4(3320)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000528'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000063C'
*
DC XL1'D'
DC AL3(0)
DC AL4(3360)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000630'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000644'
*
DC XL1'D'
DC AL3(0)
DC AL4(3400)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000638'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000064A'
*
DC XL1'D'
DC AL3(0)
DC AL4(3440)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000640'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000654'
*
DC XL1'D'
DC AL3(0)
DC AL4(3480)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000648'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000660'
*
DC XL1'D'
DC AL3(0)
DC AL4(3520)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000650'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000066C'
*
DC XL1'D'
DC AL3(0)
DC AL4(3560)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000658'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000067A'
*
DC XL1'D'
DC AL3(0)
DC AL4(3600)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000660'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000682'
*
DC XL1'D'
DC AL3(0)
DC AL4(3640)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000668'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000068C'
*
DC XL1'D'
DC AL3(0)
DC AL4(3680)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000670'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000698'
*
DC XL1'D'
DC AL3(0)
DC AL4(3720)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000678'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000644'
*
DC XL1'D'
DC AL3(0)
DC AL4(3760)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000680'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000067A'
*
DC XL1'D'
DC AL3(0)
DC AL4(3800)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000688'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006A2'
*
DC XL1'D'
DC AL3(0)
DC AL4(3840)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000690'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006B0'
*
DC XL1'D'
DC AL3(0)
DC AL4(3880)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000698'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006B6'
*
DC XL1'D'
DC AL3(0)
DC AL4(3920)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006A0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006C4'
*
DC XL1'D'
DC AL3(0)
DC AL4(3960)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006A8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006D0'
*
DC XL1'D'
DC AL3(0)
DC AL4(4000)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006B0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006E6'
*
DC XL1'D'
DC AL3(0)
DC AL4(4040)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006B8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006F6'
*
DC XL1'D'
DC AL3(0)
DC AL4(4080)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006C0'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000070A'
*
DC XL1'D'
DC AL3(0)
DC AL4(4120)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006C8'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000071A'
*
DC XL1'D'
DC AL3(0)
DC AL4(0)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006D0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000654'
*
END
|
;
;/*
; * FreeRTOS V202104.00
; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
; *
; * Permission is hereby granted, free of charge, to any person obtaining a copy of
; * this software and associated documentation files (the "Software"), to deal in
; * the Software without restriction, including without limitation the rights to
; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
; * the Software, and to permit persons to whom the Software is furnished to do so,
; * subject to the following conditions:
; *
; * The above copyright notice and this permission notice shall be included in all
; * copies or substantial portions of the Software.
; *
; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
; *
; * http://www.FreeRTOS.org
; * http://aws.amazon.com/freertos
; *
; * 1 tab == 4 spaces!
; */
; * The definition of the "register test" tasks, as described at the top of
; * main.c
.include data_model.h
.if $DEFINED( __LARGE_DATA_MODEL__ )
.define "cmp.a", cmp_x
.define "incx.w", inc_x
.else
.define "cmp.w", cmp_x
.define "inc.w", inc_x
.endif
.global usRegTest1LoopCounter
.global usRegTest2LoopCounter
.global vPortYield
.def vRegTest1Implementation
.def vRegTest2Implementation
.text
.align 2
vRegTest1Implementation: .asmfunc
; Fill each general purpose register with a known value.
mov_x #0x4444, r4
mov_x #0x5555, r5
mov_x #0x6666, r6
mov_x #0x7777, r7
mov_x #0x8888, r8
mov_x #0x9999, r9
mov_x #0xaaaa, r10
mov_x #0xbbbb, r11
mov_x #0xcccc, r12
mov_x #0xdddd, r13
mov_x #0xeeee, r14
mov_x #0xffff, r15
prvRegTest1Loop:
; Test each general purpose register to check that it still contains the
; expected known value, jumping to vRegTest1Error if any register contains
; an unexpected value.
cmp_x #0x4444, r4
jne vRegTest1Error
cmp_x #0x5555, r5
jne vRegTest1Error
cmp_x #0x6666, r6
jne vRegTest1Error
cmp_x #0x7777, r7
jne vRegTest1Error
cmp_x #0x8888, r8
jne vRegTest1Error
cmp_x #0x9999, r9
jne vRegTest1Error
cmp_x #0xaaaa, r10
jne vRegTest1Error
cmp_x #0xbbbb, r11
jne vRegTest1Error
cmp_x #0xcccc, r12
jne vRegTest1Error
cmp_x #0xdddd, r13
jne vRegTest1Error
cmp_x #0xeeee, r14
jne vRegTest1Error
cmp_x #0xffff, r15
jne vRegTest1Error
; This task is still running without jumping to vRegTest1Error, so increment
; the loop counter so the check task knows the task is running error free.
inc_x &usRegTest1LoopCounter
; Loop again, performing the same tests.
jmp prvRegTest1Loop
nop
vRegTest1Error:
jmp vRegTest1Error
nop
.endasmfunc
; -----------------------------------------------------------
; See the comments in vRegTest1Implementation. This task is the same, it just uses
; different values in its registers.
.align 2
vRegTest2Implementation: .asmfunc
mov_x #0x4441, r4
mov_x #0x5551, r5
mov_x #0x6661, r6
mov_x #0x7771, r7
mov_x #0x8881, r8
mov_x #0x9991, r9
mov_x #0xaaa1, r10
mov_x #0xbbb1, r11
mov_x #0xccc1, r12
mov_x #0xddd1, r13
mov_x #0xeee1, r14
mov_x #0xfff1, r15
prvRegTest2Loop:
cmp_x #0x4441, r4
jne vRegTest2Error
cmp_x #0x5551, r5
jne vRegTest2Error
cmp_x #0x6661, r6
jne vRegTest2Error
cmp_x #0x7771, r7
jne vRegTest2Error
cmp_x #0x8881, r8
jne vRegTest2Error
cmp_x #0x9991, r9
jne vRegTest2Error
cmp_x #0xaaa1, r10
jne vRegTest2Error
cmp_x #0xbbb1, r11
jne vRegTest2Error
cmp_x #0xccc1, r12
jne vRegTest2Error
cmp_x #0xddd1, r13
jne vRegTest2Error
cmp_x #0xeee1, r14
jne vRegTest2Error
cmp_x #0xfff1, r15
jne vRegTest2Error
; Also perform a manual yield, just to increase the scope of the test.
call_x #vPortYield
inc_x &usRegTest2LoopCounter
jmp prvRegTest2Loop
nop
vRegTest2Error:
jmp vRegTest2Error
nop
.endasmfunc
; /*-----------------------------------------------------------
.end
|
// Copyright 2018 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 "chromeos/services/ime/public/cpp/rulebased/def/si.h"
#include "base/cxx17_backports.h"
namespace si {
const char* kId = "si";
bool kIs102 = false;
const char* kNormal[] = {
u8"\u0dca\u200d\u0dbb", // BackQuote
u8"1", // Digit1
u8"2", // Digit2
u8"3", // Digit3
u8"4", // Digit4
u8"5", // Digit5
u8"6", // Digit6
u8"7", // Digit7
u8"8", // Digit8
u8"9", // Digit9
u8"0", // Digit0
u8"-", // Minus
u8"=", // Equal
u8"\u0dd4", // KeyQ
u8"\u0d85", // KeyW
u8"\u0dd0", // KeyE
u8"\u0dbb", // KeyR
u8"\u0d91", // KeyT
u8"\u0dc4", // KeyY
u8"\u0db8", // KeyU
u8"\u0dc3", // KeyI
u8"\u0daf", // KeyO
u8"\u0da0", // KeyP
u8"\u0da4", // BracketLeft
u8";", // BracketRight
u8"\u200d\u0dca", // Backslash
u8"\u0dca", // KeyA
u8"\u0dd2", // KeyS
u8"\u0dcf", // KeyD
u8"\u0dd9", // KeyF
u8"\u0da7", // KeyG
u8"\u0dba", // KeyH
u8"\u0dc0", // KeyJ
u8"\u0db1", // KeyK
u8"\u0d9a", // KeyL
u8"\u0dad", // Semicolon
u8".", // Quote
u8"'", // KeyZ
u8"\u0d82", // KeyX
u8"\u0da2", // KeyC
u8"\u0da9", // KeyV
u8"\u0d89", // KeyB
u8"\u0db6", // KeyN
u8"\u0db4", // KeyM
u8"\u0dbd", // Comma
u8"\u0d9c", // Period
u8"?", // Slash
u8"\u0020", // Space
};
const char* kShift[] = {
u8"\u0dbb\u0dca\u200d", // BackQuote
u8"!", // Digit1
u8"@", // Digit2
u8"#", // Digit3
u8"$", // Digit4
u8"%", // Digit5
u8"^", // Digit6
u8"&", // Digit7
u8"*", // Digit8
u8"(", // Digit9
u8")", // Digit0
u8"_", // Minus
u8"+", // Equal
u8"\u0dd6", // KeyQ
u8"\u0d8b", // KeyW
u8"\u0dd1", // KeyE
u8"\u0d8d", // KeyR
u8"\u0d94", // KeyT
u8"\u0dc1", // KeyY
u8"\u0db9", // KeyU
u8"\u0dc2", // KeyI
u8"\u0db0", // KeyO
u8"\u0da1", // KeyP
u8"\u0da5", // BracketLeft
u8":", // BracketRight
u8"\u0dca\u200d", // Backslash
u8"\u0ddf", // KeyA
u8"\u0dd3", // KeyS
u8"\u0dd8", // KeyD
u8"\u0dc6", // KeyF
u8"\u0da8", // KeyG
u8"\u0dca\u200d\u0dba", // KeyH
u8"", // KeyJ
u8"\u0dab", // KeyK
u8"\u0d9b", // KeyL
u8"\u0dae", // Semicolon
u8",", // Quote
u8"\"", // KeyZ
u8"\u0d9e", // KeyX
u8"\u0da3", // KeyC
u8"\u0daa", // KeyV
u8"\u0d8a", // KeyB
u8"\u0db7", // KeyN
u8"\u0db5", // KeyM
u8"\u0dc5", // Comma
u8"\u0d9d", // Period
u8"/", // Slash
u8"\u0020", // Space
};
const char* kAltGr[] = {
u8"", // BackQuote
u8"", // Digit1
u8"", // Digit2
u8"", // Digit3
u8"", // Digit4
u8"", // Digit5
u8"", // Digit6
u8"", // Digit7
u8"", // Digit8
u8"", // Digit9
u8"", // Digit0
u8"", // Minus
u8"", // Equal
u8"", // KeyQ
u8"", // KeyW
u8"", // KeyE
u8"", // KeyR
u8"", // KeyT
u8"", // KeyY
u8"", // KeyU
u8"", // KeyI
u8"\u0db3", // KeyO
u8"", // KeyP
u8"", // BracketLeft
u8"", // BracketRight
u8"", // Backslash
u8"\u0df3", // KeyA
u8"", // KeyS
u8"", // KeyD
u8"", // KeyF
u8"", // KeyG
u8"", // KeyH
u8"", // KeyJ
u8"", // KeyK
u8"", // KeyL
u8"", // Semicolon
u8"\u0df4", // Quote
u8"\u0d80", // KeyZ
u8"\u0d83", // KeyX
u8"\u0da6", // KeyC
u8"\u0dac", // KeyV
u8"", // KeyB
u8"", // KeyN
u8"", // KeyM
u8"\u0d8f", // Comma
u8"\u0d9f", // Period
u8"", // Slash
u8"\u0020", // Space
};
const char* kCapslock[] = {
u8"\u0dbb\u0dca\u200d", // BackQuote
u8"!", // Digit1
u8"@", // Digit2
u8"#", // Digit3
u8"$", // Digit4
u8"%", // Digit5
u8"^", // Digit6
u8"&", // Digit7
u8"*", // Digit8
u8"(", // Digit9
u8")", // Digit0
u8"_", // Minus
u8"+", // Equal
u8"\u0dd6", // KeyQ
u8"\u0d8b", // KeyW
u8"\u0dd1", // KeyE
u8"\u0d8d", // KeyR
u8"\u0d94", // KeyT
u8"\u0dc1", // KeyY
u8"\u0db9", // KeyU
u8"\u0dc2", // KeyI
u8"\u0db0", // KeyO
u8"\u0da1", // KeyP
u8"\u0da5", // BracketLeft
u8":", // BracketRight
u8"\u0dca\u200d", // Backslash
u8"\u0ddf", // KeyA
u8"\u0dd3", // KeyS
u8"\u0dd8", // KeyD
u8"\u0dc6", // KeyF
u8"\u0da8", // KeyG
u8"\u0dca\u200d\u0dba", // KeyH
u8"", // KeyJ
u8"\u0dab", // KeyK
u8"\u0d9b", // KeyL
u8"\u0dae", // Semicolon
u8",", // Quote
u8"\"", // KeyZ
u8"\u0d9e", // KeyX
u8"\u0da3", // KeyC
u8"\u0daa", // KeyV
u8"\u0d8a", // KeyB
u8"\u0db7", // KeyN
u8"\u0db5", // KeyM
u8"\u0dc5", // Comma
u8"\u0d9d", // Period
u8"/", // Slash
u8"\u0020", // Space
};
const char* kShiftAltGr[] = {
u8"", // BackQuote
u8"", // Digit1
u8"", // Digit2
u8"", // Digit3
u8"", // Digit4
u8"", // Digit5
u8"", // Digit6
u8"", // Digit7
u8"", // Digit8
u8"", // Digit9
u8"", // Digit0
u8"", // Minus
u8"", // Equal
u8"", // KeyQ
u8"", // KeyW
u8"", // KeyE
u8"", // KeyR
u8"", // KeyT
u8"", // KeyY
u8"", // KeyU
u8"", // KeyI
u8"\u0db3", // KeyO
u8"", // KeyP
u8"", // BracketLeft
u8"", // BracketRight
u8"", // Backslash
u8"\u0df3", // KeyA
u8"", // KeyS
u8"", // KeyD
u8"", // KeyF
u8"", // KeyG
u8"", // KeyH
u8"", // KeyJ
u8"", // KeyK
u8"", // KeyL
u8"", // Semicolon
u8"\u0df4", // Quote
u8"\u0d80", // KeyZ
u8"\u0d83", // KeyX
u8"\u0da6", // KeyC
u8"\u0dac", // KeyV
u8"", // KeyB
u8"", // KeyN
u8"", // KeyM
u8"\u0d8f", // Comma
u8"\u0d9f", // Period
u8"", // Slash
u8"\u0020", // Space
};
const char* kAltgrCapslock[] = {
u8"", // BackQuote
u8"", // Digit1
u8"", // Digit2
u8"", // Digit3
u8"", // Digit4
u8"", // Digit5
u8"", // Digit6
u8"", // Digit7
u8"", // Digit8
u8"", // Digit9
u8"", // Digit0
u8"", // Minus
u8"", // Equal
u8"", // KeyQ
u8"", // KeyW
u8"", // KeyE
u8"", // KeyR
u8"", // KeyT
u8"", // KeyY
u8"", // KeyU
u8"", // KeyI
u8"\u0db3", // KeyO
u8"", // KeyP
u8"", // BracketLeft
u8"", // BracketRight
u8"", // Backslash
u8"\u0df3", // KeyA
u8"", // KeyS
u8"", // KeyD
u8"", // KeyF
u8"", // KeyG
u8"", // KeyH
u8"", // KeyJ
u8"", // KeyK
u8"", // KeyL
u8"", // Semicolon
u8"\u0df4", // Quote
u8"\u0d80", // KeyZ
u8"\u0d83", // KeyX
u8"\u0da6", // KeyC
u8"\u0dac", // KeyV
u8"", // KeyB
u8"", // KeyN
u8"", // KeyM
u8"\u0d8f", // Comma
u8"\u0d9f", // Period
u8"", // Slash
u8"\u0020", // Space
};
const char* kShiftCapslock[] = {
u8"\u0dca\u200d\u0dbb", // BackQuote
u8"1", // Digit1
u8"2", // Digit2
u8"3", // Digit3
u8"4", // Digit4
u8"5", // Digit5
u8"6", // Digit6
u8"7", // Digit7
u8"8", // Digit8
u8"9", // Digit9
u8"0", // Digit0
u8"-", // Minus
u8"=", // Equal
u8"\u0dd4", // KeyQ
u8"\u0d85", // KeyW
u8"\u0dd0", // KeyE
u8"\u0dbb", // KeyR
u8"\u0d91", // KeyT
u8"\u0dc4", // KeyY
u8"\u0db8", // KeyU
u8"\u0dc3", // KeyI
u8"\u0daf", // KeyO
u8"\u0da0", // KeyP
u8"\u0da4", // BracketLeft
u8";", // BracketRight
u8"\u200d\u0dca", // Backslash
u8"\u0dca", // KeyA
u8"\u0dd2", // KeyS
u8"\u0dcf", // KeyD
u8"\u0dd9", // KeyF
u8"\u0da7", // KeyG
u8"\u0dba", // KeyH
u8"\u0dc0", // KeyJ
u8"\u0db1", // KeyK
u8"\u0d9a", // KeyL
u8"\u0dad", // Semicolon
u8".", // Quote
u8"'", // KeyZ
u8"\u0d82", // KeyX
u8"\u0da2", // KeyC
u8"\u0da9", // KeyV
u8"\u0d89", // KeyB
u8"\u0db6", // KeyN
u8"\u0db4", // KeyM
u8"\u0dbd", // Comma
u8"\u0d9c", // Period
u8"?", // Slash
u8"\u0020", // Space
};
const char* kShiftAltGrCapslock[] = {
u8"", // BackQuote
u8"", // Digit1
u8"", // Digit2
u8"", // Digit3
u8"", // Digit4
u8"", // Digit5
u8"", // Digit6
u8"", // Digit7
u8"", // Digit8
u8"", // Digit9
u8"", // Digit0
u8"", // Minus
u8"", // Equal
u8"", // KeyQ
u8"", // KeyW
u8"", // KeyE
u8"", // KeyR
u8"", // KeyT
u8"", // KeyY
u8"", // KeyU
u8"", // KeyI
u8"\u0db3", // KeyO
u8"", // KeyP
u8"", // BracketLeft
u8"", // BracketRight
u8"", // Backslash
u8"\u0df3", // KeyA
u8"", // KeyS
u8"", // KeyD
u8"", // KeyF
u8"", // KeyG
u8"", // KeyH
u8"", // KeyJ
u8"", // KeyK
u8"", // KeyL
u8"", // Semicolon
u8"\u0df4", // Quote
u8"\u0d80", // KeyZ
u8"\u0d83", // KeyX
u8"\u0da6", // KeyC
u8"\u0dac", // KeyV
u8"", // KeyB
u8"", // KeyN
u8"", // KeyM
u8"\u0d8f", // Comma
u8"\u0d9f", // Period
u8"", // Slash
u8"\u0020", // Space
};
const char** kKeyMap[8] = {
kNormal, kShift, kAltGr, kShiftAltGr,
kCapslock, kShiftCapslock, kAltgrCapslock, kShiftAltGrCapslock};
const char* kTransforms[] = {u8"\u0d85\u0dcf",
u8"\u0d86",
u8"\u0d85\u0dd0",
u8"\u0d87",
u8"\u0d85\u0dd1",
u8"\u0d88",
u8"\u0d8b\u0ddf",
u8"\u0d8c",
u8"\u0d8d\u0dd8",
u8"\u0d8e",
u8"\u0d91\u0dca",
u8"\u0d92",
u8"\u0dd9\u0d91",
u8"\u0d93",
u8"\u0d94\u0dca",
u8"\u0d95",
u8"\u0d94\u0ddf",
u8"\u0d96",
u8"([\u0d9a-\u0dc6])\u0dd8\u0dd8",
u8"\\1\u0df2",
u8"\u0dd9([\u0d9a-\u0dc6])",
u8"\\1\u0dd9",
u8"([\u0d9a-\u0dc6])\u0dd9\u001d\u0dca",
u8"\\1\u0dda",
u8"\u0dd9\u0dd9([\u0d9a-\u0dc6])",
u8"\\1\u0ddb",
u8"([\u0d9a-\u0dc6])\u0dd9\u001d\u0dcf",
u8"\\1\u0ddc",
u8"([\u0d9a-\u0dc6])\u0ddc\u001d\u0dca",
u8"\\1\u0ddd",
u8"([\u0d9a-\u0dc6])\u0dd9\u001d\u0ddf",
u8"\\1\u0dde",
u8"([\u0d9a-\u0dc6])(\u0dd9)\u001d((\u0dca\u200d["
u8"\u0dba\u0dbb])|(\u0dbb\u0dca\u200d))",
u8"\\1\\3\\2",
u8"([\u0d9a-\u0dc6](\u0dca\u200d[\u0dba\u0dbb])|("
u8"\u0dbb\u0dca\u200d))\u0dd9\u001d\u0dca",
u8"\\1\u0dda",
u8"([\u0d9a-\u0dc6](\u0dca\u200d[\u0dba\u0dbb])|("
u8"\u0dbb\u0dca\u200d))\u0dd9\u001d\u0dcf",
u8"\\1\u0ddc",
u8"([\u0d9a-\u0dc6](\u0dca\u200d[\u0dba\u0dbb])|("
u8"\u0dbb\u0dca\u200d))\u0ddc\u001d\u0dca",
u8"\\1\u0ddd"};
const unsigned int kTransformsLen = base::size(kTransforms);
const char* kHistoryPrune = nullptr;
} // namespace si
|
; A160538: a(n) = 4*(n^4-n^3).
; 0,32,216,768,2000,4320,8232,14336,23328,36000,53240,76032,105456,142688,189000,245760,314432,396576,493848,608000,740880,894432,1070696,1271808,1500000,1757600,2047032,2370816,2731568,3132000
mov $1,$0
add $0,1
pow $0,3
mul $1,$0
div $1,2
mul $1,8
|
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <vector>
// Compare iterators from different containers with <.
// UNSUPPORTED: libcxx-no-debug-mode, c++03, windows
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
#include <vector>
#include "check_assertion.h"
#include "min_allocator.h"
int main(int, char**) {
{
typedef int T;
typedef std::vector<T> C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators");
}
{
typedef int T;
typedef std::vector<T, min_allocator<T> > C;
C c1;
C c2;
TEST_LIBCPP_ASSERT_FAILURE(c1.begin() < c2.begin(), "Attempted to compare incomparable iterators");
}
return 0;
}
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/imageburner/burn_controller.h"
#include "base/bind.h"
#include "base/file_path.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/cros/burn_library.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/imageburner/burn_manager.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "grit/generated_resources.h"
#include "googleurl/src/gurl.h"
namespace chromeos {
namespace imageburner {
namespace {
// Name for hwid in machine statistics.
const char kHwidStatistic[] = "hardware_class";
const char kImageZipFileName[] = "chromeos_image.bin.zip";
// 3.9GB. It is less than 4GB because true device size ussually varies a little.
const uint64 kMinDeviceSize = static_cast<uint64>(3.9 * 1000 * 1000 * 1000);
// Returns true when |disk| is a device on which we can burn recovery image.
bool IsBurnableDevice(const disks::DiskMountManager::Disk& disk) {
return disk.is_parent() && !disk.on_boot_device() &&
(disk.device_type() == DEVICE_TYPE_USB ||
disk.device_type() == DEVICE_TYPE_SD);
}
class BurnControllerImpl
: public BurnController,
public disks::DiskMountManager::Observer,
public BurnLibrary::Observer,
public NetworkLibrary::NetworkManagerObserver,
public StateMachine::Observer,
public BurnManager::Delegate,
public BurnManager::Observer {
public:
explicit BurnControllerImpl(BurnController::Delegate* delegate)
: burn_manager_(NULL),
state_machine_(NULL),
observing_burn_lib_(false),
working_(false),
delegate_(delegate) {
disks::DiskMountManager::GetInstance()->AddObserver(this);
CrosLibrary::Get()->GetNetworkLibrary()->AddNetworkManagerObserver(this);
burn_manager_ = BurnManager::GetInstance();
burn_manager_->AddObserver(this);
state_machine_ = burn_manager_->state_machine();
state_machine_->AddObserver(this);
}
virtual ~BurnControllerImpl() {
CrosLibrary::Get()->GetBurnLibrary()->RemoveObserver(this);
if (state_machine_)
state_machine_->RemoveObserver(this);
burn_manager_->RemoveObserver(this);
CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this);
disks::DiskMountManager::GetInstance()->RemoveObserver(this);
}
// disks::DiskMountManager::Observer interface.
virtual void DiskChanged(disks::DiskMountManagerEventType event,
const disks::DiskMountManager::Disk* disk)
OVERRIDE {
if (!IsBurnableDevice(*disk))
return;
if (event == disks::MOUNT_DISK_ADDED) {
delegate_->OnDeviceAdded(*disk);
} else if (event == disks::MOUNT_DISK_REMOVED) {
delegate_->OnDeviceRemoved(*disk);
if (burn_manager_->target_device_path().value() == disk->device_path())
ProcessError(IDS_IMAGEBURN_DEVICE_NOT_FOUND_ERROR);
}
}
virtual void DeviceChanged(disks::DiskMountManagerEventType event,
const std::string& device_path) OVERRIDE {
}
virtual void MountCompleted(
disks::DiskMountManager::MountEvent event_type,
MountError error_code,
const disks::DiskMountManager::MountPointInfo& mount_info)
OVERRIDE {
}
// BurnLibrary::Observer interface.
virtual void BurnProgressUpdated(BurnLibrary* object,
BurnEvent evt,
const ImageBurnStatus& status) OVERRIDE {
switch (evt) {
case(BURN_SUCCESS):
FinalizeBurn();
break;
case(BURN_FAIL):
ProcessError(IDS_IMAGEBURN_BURN_ERROR);
break;
case(BURN_UPDATE):
delegate_->OnProgress(BURNING, status.amount_burnt, status.total_size);
break;
case(UNZIP_STARTED):
delegate_->OnProgress(UNZIPPING, 0, 0);
break;
case(UNZIP_FAIL):
ProcessError(IDS_IMAGEBURN_EXTRACTING_ERROR);
break;
case(UNZIP_COMPLETE):
// We ignore this.
break;
default:
NOTREACHED();
break;
}
}
// NetworkLibrary::NetworkManagerObserver interface.
virtual void OnNetworkManagerChanged(NetworkLibrary* obj) OVERRIDE {
if (state_machine_->state() == StateMachine::INITIAL && CheckNetwork())
delegate_->OnNetworkDetected();
if (state_machine_->state() == StateMachine::DOWNLOADING &&
!CheckNetwork())
ProcessError(IDS_IMAGEBURN_NETWORK_ERROR);
}
// BurnManager::Observer override.
virtual void OnDownloadUpdated(
int64 received_bytes,
int64 total_bytes,
const base::TimeDelta& time_remaining) OVERRIDE {
if (state_machine_->state() == StateMachine::DOWNLOADING) {
delegate_->OnProgressWithRemainingTime(DOWNLOADING,
received_bytes,
total_bytes,
time_remaining);
}
}
// BurnManager::Observer override.
virtual void OnDownloadCancelled() OVERRIDE {
DownloadCompleted(false);
}
// BurnManager::Observer override.
virtual void OnDownloadCompleted() OVERRIDE {
DownloadCompleted(true);
}
// StateMachine::Observer interface.
virtual void OnBurnStateChanged(StateMachine::State state) OVERRIDE {
if (state == StateMachine::CANCELLED) {
ProcessError(IDS_IMAGEBURN_USER_ERROR);
} else if (state != StateMachine::INITIAL && !working_) {
// User has started burn process, so let's start observing.
StartBurnImage(FilePath(), FilePath());
}
}
virtual void OnError(int error_message_id) OVERRIDE {
delegate_->OnFail(error_message_id);
working_ = false;
}
// Part of BurnManager::Delegate interface.
virtual void OnImageDirCreated(bool success) OVERRIDE {
if (success) {
zip_image_file_path_ =
burn_manager_->GetImageDir().Append(kImageZipFileName);
burn_manager_->FetchConfigFile(this);
} else {
DownloadCompleted(success);
}
}
// Part of BurnManager::Delegate interface.
virtual void OnConfigFileFetched(const ConfigFile& config_file, bool success)
OVERRIDE {
if (!success || !ExtractInfoFromConfigFile(config_file)) {
DownloadCompleted(false);
return;
}
if (state_machine_->download_finished()) {
BurnImage();
return;
}
if (!state_machine_->download_started()) {
burn_manager_->FetchImage(image_download_url_, zip_image_file_path_);
state_machine_->OnDownloadStarted();
}
}
// BurnController override.
virtual void Init() OVERRIDE {
if (state_machine_->state() == StateMachine::BURNING) {
// There is nothing else left to do but observe burn progress.
BurnImage();
} else if (state_machine_->state() != StateMachine::INITIAL) {
// User has started burn process, so let's start observing.
StartBurnImage(FilePath(), FilePath());
}
}
// BurnController override.
virtual std::vector<disks::DiskMountManager::Disk> GetBurnableDevices()
OVERRIDE {
const disks::DiskMountManager::DiskMap& disks =
disks::DiskMountManager::GetInstance()->disks();
std::vector<disks::DiskMountManager::Disk> result;
for (disks::DiskMountManager::DiskMap::const_iterator iter = disks.begin();
iter != disks.end();
++iter) {
const disks::DiskMountManager::Disk& disk = *iter->second;
if (IsBurnableDevice(disk))
result.push_back(disk);
}
return result;
}
// BurnController override.
virtual void CancelBurnImage() OVERRIDE {
state_machine_->OnCancelation();
}
// BurnController override.
// May be called with empty values if there is a handler that has started
// burning, and thus set the target paths.
virtual void StartBurnImage(const FilePath& target_device_path,
const FilePath& target_file_path) OVERRIDE {
if (!target_device_path.empty() && !target_file_path.empty() &&
state_machine_->new_burn_posible()) {
if (!CheckNetwork()) {
delegate_->OnNoNetwork();
return;
}
burn_manager_->set_target_device_path(target_device_path);
burn_manager_->set_target_file_path(target_file_path);
uint64 device_size = GetDeviceSize(
burn_manager_->target_device_path().value());
if (device_size < kMinDeviceSize) {
delegate_->OnDeviceTooSmall(device_size);
return;
}
}
if (working_)
return;
working_ = true;
// Send progress signal now so ui doesn't hang in intial state until we get
// config file
delegate_->OnProgress(DOWNLOADING, 0, 0);
if (burn_manager_->GetImageDir().empty()) {
burn_manager_->CreateImageDir(this);
} else {
OnImageDirCreated(true);
}
}
private:
void DownloadCompleted(bool success) {
if (success) {
state_machine_->OnDownloadFinished();
BurnImage();
} else {
ProcessError(IDS_IMAGEBURN_DOWNLOAD_ERROR);
}
}
void BurnImage() {
if (!observing_burn_lib_) {
CrosLibrary::Get()->GetBurnLibrary()->AddObserver(this);
observing_burn_lib_ = true;
}
if (state_machine_->state() == StateMachine::BURNING)
return;
state_machine_->OnBurnStarted();
CrosLibrary::Get()->GetBurnLibrary()->DoBurn(
zip_image_file_path_,
image_file_name_, burn_manager_->target_file_path(),
burn_manager_->target_device_path());
}
void FinalizeBurn() {
state_machine_->OnSuccess();
burn_manager_->ResetTargetPaths();
CrosLibrary::Get()->GetBurnLibrary()->RemoveObserver(this);
observing_burn_lib_ = false;
delegate_->OnSuccess();
working_ = false;
}
// Error is ussually detected by all existing Burn handlers, but only first
// one that calls ProcessError should actually process it.
void ProcessError(int message_id) {
// If we are in intial state, error has already been dispached.
if (state_machine_->state() == StateMachine::INITIAL) {
// We don't need burn library since we are not the ones doing the cleanup.
if (observing_burn_lib_) {
CrosLibrary::Get()->GetBurnLibrary()->RemoveObserver(this);
observing_burn_lib_ = false;
}
return;
}
// Remember burner state, since it will be reset after OnError call.
StateMachine::State state = state_machine_->state();
// Dispach error. All hadlers' OnError event will be called before returning
// from this. This includes us, too.
state_machine_->OnError(message_id);
// Do cleanup.
if (state == StateMachine::DOWNLOADING) {
burn_manager_->CancelImageFetch();
} else if (state == StateMachine::BURNING) {
DCHECK(observing_burn_lib_);
// Burn library doesn't send cancelled signal upon CancelBurnImage
// invokation.
CrosLibrary::Get()->GetBurnLibrary()->CancelBurnImage();
CrosLibrary::Get()->GetBurnLibrary()->RemoveObserver(this);
observing_burn_lib_ = false;
}
burn_manager_->ResetTargetPaths();
}
bool ExtractInfoFromConfigFile(const ConfigFile& config_file) {
std::string hwid;
if (!system::StatisticsProvider::GetInstance()->
GetMachineStatistic(kHwidStatistic, &hwid))
return false;
image_file_name_ = config_file.GetProperty(kFileName, hwid);
if (image_file_name_.empty())
return false;
image_download_url_ = GURL(config_file.GetProperty(kUrl, hwid));
if (image_download_url_.is_empty()) {
image_file_name_.clear();
return false;
}
return true;
}
int64 GetDeviceSize(const std::string& device_path) {
disks::DiskMountManager* disk_mount_manager =
disks::DiskMountManager::GetInstance();
const disks::DiskMountManager::DiskMap& disks = disk_mount_manager->disks();
return disks.find(device_path)->second->total_size_in_bytes();
}
bool CheckNetwork() {
return CrosLibrary::Get()->GetNetworkLibrary()->Connected();
}
FilePath zip_image_file_path_;
GURL image_download_url_;
std::string image_file_name_;
BurnManager* burn_manager_;
StateMachine* state_machine_;
bool observing_burn_lib_;
bool working_;
BurnController::Delegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(BurnControllerImpl);
};
} // namespace
// static
BurnController* BurnController::CreateBurnController(
content::WebContents* web_contents,
Delegate* delegate) {
return new BurnControllerImpl(delegate);
}
} // namespace imageburner
} // namespace chromeos
|
leh $end_probe_loop
cle
lc g3, 0x40000000
lc g4, 0x80000000
lc g0, 0
probe_loop:
add g5, g0, g4
ld4 g1, g5, 0
gts g2, g0, g3
jnzi g2, $end_probe_loop
addi g0, g0, 0x1000
j $probe_loop
end_probe_loop:
cle
mov g4, g0
halt
|
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/tf2xla/kernels/gather_op.h"
#include "tensorflow/compiler/tf2xla/kernels/gather_op_helpers.h"
#include "tensorflow/compiler/tf2xla/shape_util.h"
#include "tensorflow/compiler/tf2xla/type_util.h"
#include "tensorflow/compiler/tf2xla/xla_context.h"
#include "tensorflow/compiler/tf2xla/xla_helpers.h"
#include "tensorflow/compiler/tf2xla/xla_op_kernel.h"
#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#include "tensorflow/core/framework/kernel_def_builder.h"
#include "tensorflow/core/framework/op_kernel.h"
namespace tensorflow {
xla::ComputationDataHandle XlaComputeGatherDynamicSlice(
XlaOpKernelContext* context, const xla::ComputationDataHandle& input,
const TensorShape& input_shape, const xla::ComputationDataHandle& indices,
const TensorShape& indices_shape, int64 axis, DataType dtype,
DataType index_type, xla::ComputationBuilder* builder) {
// Although the indices Tensor is flattened into rank 1 during the lookup,
// and each scalar entry is used as an index into the first dimension of the
// input, the output is returned with shape:
// input.shape[:axis] + indices.shape + input.shape[axis+1:]
const int num_indices = indices_shape.num_elements();
TensorShape input_shape_pre_axis(input_shape);
input_shape_pre_axis.RemoveDimRange(axis, input_shape.dims());
TensorShape input_shape_post_axis(input_shape);
input_shape_post_axis.RemoveDimRange(0, axis + 1);
// Each slice of the input tensor has shape:
// [<input_shape_pre_axis>, 1, <input shape_post_axis>]
TensorShape slice_shape(input_shape);
slice_shape.set_dim(axis, 1);
TensorShape loop_out_shape;
loop_out_shape.AppendShape(input_shape_pre_axis);
loop_out_shape.AddDim(num_indices);
loop_out_shape.AppendShape(input_shape_post_axis);
TensorShape loop_out_slice_shape;
loop_out_slice_shape.AppendShape(input_shape_pre_axis);
loop_out_slice_shape.AddDim(1);
loop_out_slice_shape.AppendShape(input_shape_post_axis);
TensorShape out_shape;
out_shape.AppendShape(input_shape_pre_axis);
out_shape.AppendShape(indices_shape);
out_shape.AppendShape(input_shape_post_axis);
// Degenerate case: empty indices.
if (num_indices == 0) {
return builder->Broadcast(XlaHelpers::Zero(builder, dtype),
out_shape.dim_sizes());
}
// Specify the shape of the loop-carried Tensor tuple.
xla::PrimitiveType ptype;
TF_CHECK_OK(DataTypeToPrimitiveType(dtype, &ptype));
xla::PrimitiveType idxtype;
TF_CHECK_OK(DataTypeToPrimitiveType(index_type, &idxtype));
std::vector<xla::Shape> tuple_shapes(
{// The iteration counter i is a scalar, incremented each iteration.
xla::ShapeUtil::MakeShape(idxtype, {}),
// The input array has shape input_shape. Loop invariant.
xla::ShapeUtil::MakeShape(ptype, input_shape.dim_sizes()),
// The gather indices are reshaped to rank 1. Loop invariant.
xla::ShapeUtil::MakeShape(idxtype, {num_indices}),
// The output array, which is updated on each loop iteration.
xla::ShapeUtil::MakeShape(ptype, loop_out_shape.dim_sizes())});
xla::Shape tuple_shape = xla::ShapeUtil::MakeTupleShape(tuple_shapes);
// Construct the initial values of the loop-carried Tensors.
auto init_i = XlaHelpers::Zero(builder, index_type);
auto init_out = builder->Broadcast(XlaHelpers::Zero(builder, dtype),
loop_out_shape.dim_sizes());
// Flatten the indices into 1-D for ease of iteration.
auto indices_1d = builder->Reshape(indices, {num_indices});
auto init = builder->Tuple({init_i, input, indices_1d, init_out});
// Construct the while loop condition (i < num_indices)
xla::ComputationBuilder condb(context->builder()->client(),
"GatherWhileCond");
condb.Lt(condb.GetTupleElement(
condb.Parameter(0, tuple_shape, "GatherWhileTuple"), 0),
XlaHelpers::IntegerLiteral(&condb, index_type, num_indices));
auto cond_status = condb.Build();
auto cond = cond_status.ConsumeValueOrDie();
// Construct the while loop body's function. The implementation of gather is:
// for i in range(num_indices):
// index = dynamic-slice(indices, i)
// xi = dynamic-slice(input, index)
// output = dynamic-update-slice(output, xi, i)
xla::ComputationBuilder bodyb(context->builder()->client(),
"GatherWhileBody");
{
// The four loop carried values.
auto loop_tuple = bodyb.Parameter(0, tuple_shape, "GatherWhileTuple");
auto i = bodyb.GetTupleElement(loop_tuple, 0);
auto input = bodyb.GetTupleElement(loop_tuple, 1);
auto indices = bodyb.GetTupleElement(loop_tuple, 2);
auto output = bodyb.GetTupleElement(loop_tuple, 3);
// Slice from the input array.
auto index = bodyb.DynamicSlice(indices, bodyb.Reshape(i, {1}), {1});
auto start_indices = bodyb.Pad(
bodyb.Reshape(index, {1}), XlaHelpers::Zero(&bodyb, index_type),
xla::MakeEdgePaddingConfig(
{{input_shape_pre_axis.dims(), input_shape_post_axis.dims()}}));
auto slice_i = bodyb.Reshape(
bodyb.DynamicSlice(input, start_indices, slice_shape.dim_sizes()),
loop_out_slice_shape.dim_sizes());
// Construct the index into the output Tensor 0, ..., <index>, 0, ...
std::vector<xla::ComputationDataHandle> out_index_vals(
loop_out_shape.dims(),
bodyb.Reshape(XlaHelpers::Zero(&bodyb, index_type), {1}));
out_index_vals[input_shape_pre_axis.dims()] = bodyb.Reshape(i, {1});
auto out_index = bodyb.ConcatInDim(out_index_vals, 0);
// Update the output Tensor
auto updated_output = bodyb.DynamicUpdateSlice(output, slice_i, out_index);
bodyb.Tuple({bodyb.Add(i, XlaHelpers::One(&bodyb, index_type)), input,
indices, updated_output});
}
auto body_status = bodyb.Build();
auto body = body_status.ConsumeValueOrDie();
// Construct the While loop, extract and reshape the output.
auto gather_while = builder->While(cond, body, init);
auto gather_output = builder->GetTupleElement(gather_while, 3);
return builder->Reshape(gather_output, out_shape.dim_sizes());
}
GatherOpDynamicSlice::GatherOpDynamicSlice(OpKernelConstruction* context)
: XlaOpKernel(context) {}
void GatherOpDynamicSlice::Compile(XlaOpKernelContext* context) {
xla::ComputationBuilder* builder = context->builder();
auto input = context->Input(0);
auto input_shape = context->InputShape(0);
auto indices = context->Input(1);
auto indices_shape = context->InputShape(1);
int64 axis = 0;
if (context->num_inputs() == 3) {
const TensorShape axis_shape = context->InputShape(2);
OP_REQUIRES(context, TensorShapeUtils::IsScalar(axis_shape),
errors::InvalidArgument("axis must be scalar"));
DataType axis_type = input_type(2);
OP_REQUIRES(context, axis_type == DT_INT32 || axis_type == DT_INT64,
errors::InvalidArgument("axis must be int32 or int64"));
OP_REQUIRES_OK(context, context->ConstantInputAsIntScalar(2, &axis));
const auto params_dims = input_shape.dims();
if (axis < 0) {
axis += params_dims;
}
OP_REQUIRES(
context, 0 <= axis && axis < params_dims,
errors::InvalidArgument("Expected axis in the range [", -params_dims,
", ", params_dims, "), but got ", axis));
}
DataType index_type = input_type(1);
OP_REQUIRES(context, index_type == DT_INT32 || index_type == DT_INT64,
errors::InvalidArgument("indices must be int32 or int64"));
xla::ComputationDataHandle gather = XlaComputeGatherDynamicSlice(
context, input, input_shape, indices, indices_shape, axis, input_type(0),
index_type, builder);
context->SetOutput(0, gather);
}
REGISTER_XLA_OP(Name("Gather"), GatherOpDynamicSlice);
REGISTER_XLA_OP(Name("GatherV2").CompileTimeConstInput("axis"),
GatherOpDynamicSlice);
} // namespace tensorflow
|
; ---
; Copyright (c) 2016 Johan Sköld
; License: https://opensource.org/licenses/ISC
; ---
.code
get_xmm_register PROC FRAME
.endprolog
; First argument (rcx) = register to get
cmp rcx, 6
je get_6
cmp rcx, 7
je get_7
cmp rcx, 8
je get_8
cmp rcx, 9
je get_9
cmp rcx, 10
je get_10
cmp rcx, 11
je get_11
cmp rcx, 12
je get_12
cmp rcx, 13
je get_13
cmp rcx, 14
je get_14
jmp get_15
get_6:
movdqa xmm0, xmm6
ret
get_7:
movdqa xmm0, xmm7
ret
get_8:
movdqa xmm0, xmm8
ret
get_9:
movdqa xmm0, xmm9
ret
get_10:
movdqa xmm0, xmm10
ret
get_11:
movdqa xmm0, xmm11
ret
get_12:
movdqa xmm0, xmm12
ret
get_13:
movdqa xmm0, xmm13
ret
get_14:
movdqa xmm0, xmm14
ret
get_15:
movdqa xmm0, xmm15
ret
get_xmm_register ENDP
END
|
DEVICE ZXSPECTRUM48
org $8000
jp start ; jump over data to code (extended immediate)
string:
db "Hello_world!"
colors:
db $47
db $78
db $79
db $7A
db $7B
db $7C
db $7D
db $7E
db $70
db $38
db $07
db $D6
STRING_LENGTH = 12
ROM_CLS = $0DAF ; ROM address for "Clear Screen" routine
COLOR_ATTR = $5800 ; start of color attribute memory
ENTER = $0D ; Character code for Enter key
BLACK_WHITE = $47 ; black paper, white ink
WHITE_BLACK = $78 ; white paper, black ink
WHITE_BLUE = $79 ; white paper, blue ink
WHITE_RED = $7A ; white paper, red ink
WHITE_MAGENTA = $7B ; white paper, magenta ink
WHITE_GREEN = $7C ; white paper, green ink
WHITE_CYAN = $7D ; white paper, cyan ink
WHITE_YELLOW = $7E ; white paper, yellow ink
WHITE_WHITE = $7F ; white paper, white ink
start:
im 1 ; Set interrupt mode to 1 (interrupt mode)
call ROM_CLS ; Call clear screen routine from ROM (extended immediate)
ld hl,string ; HL = address of string (register,extended immediate)
ld b,STRING_LENGTH ; B = length of string (register,immediate)
ld de,colors
ld ix,COLOR_ATTR ; IX = address of string (register,extended immediate)
loop:
ld a,(hl) ; A = byte at address in HL (register,register indirect)
rst $10 ; print character code in A (modified page zero)
inc hl ; increment HL to address of next character (register)
dec b ; decrement B (register)
ld a, (de) ; load color to A (register)
ld (ix),a ; load A to current color attribute memory address
inc ix
inc de ; increment color attribute memory address
jr nz,loop ; if B not zero, jump back to top of loop (condition,relative)
ld a,ENTER ; A = Enter character code (register,immediate)
rst $10 ; print Enter for new line (modified page zero)
ret
; Deployment: Snapshot
SAVESNA "colors.sna", start
|
db 0 ; species ID placeholder
db 70, 90, 110, 95, 60, 75
; hp atk def spd sat sdf
db POISON, DARK ; type
db 45 ; catch rate
db 175 ; base exp
db NO_ITEM, POISON_BARB ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/drapion/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_SLOW ; growth rate
dn EGG_BUG, EGG_WATER_3 ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, ROAR, TOXIC, ROCK_SMASH, HIDDEN_POWER, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, IRON_TAIL, EARTHQUAKE, RETURN, DIG, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, REST, ATTRACT, THIEF, FURY_CUTTER, NIGHTMARE, CUT, STRENGTH, FLASH
; end
|
; A183623: Number of (n+1)X(n+1) 0..2 arrays with every 2X2 subblock summing to 4
; Submitted by Christian Krause
; 19,87,355,1383,5299,20247,77635,299463,1162579,4540407
add $0,2
mov $2,4
pow $2,$0
seq $0,101052 ; Number of preferential arrangements of n labeled elements when only k<=3 ranks are allowed.
mul $0,2
add $0,$2
sub $0,3
|
; A052460: 3-magic series constant.
; 1,50,675,4624,21125,73926,214375,540800,1225449,2550250,4952651,9082800,15873325,26622974,43095375,67634176,103295825,154001250,224707699,321602000,452316501,626168950,854427575,1150602624,1530765625,2013897626,2622267675,3381842800,4322730749,5479656750,6892475551,8606720000,10674187425,13153565074,16111095875,19621285776,23767653925,28643526950,34352878599,41011216000,48746513801,57700197450,68028176875,79901931824,93509650125,109057420126,126770478575,146894515200,169697035249,195468781250,224525215251,257208062800,293886919925,334960924374,380860492375,432049122176,489025265625,552324269050,622520384699,700228854000,786108063901,880861777550,985241440575,1100048564224,1226137186625,1364416413426,1515853039075,1681474250000,1862370410949,2059697935750,2274682243751,2508620803200,2762886262825,3038929672874,3338283796875,3662566515376,4013484322925,4392835919550,4802515897999,5244518528000,5720941638801,6233990601250,6785982410675,7379349871824,8016645887125,8700547849526,9433862141175,10219528739200,11060625929849,11960375132250,12922145833051,13949460633200,15046000408125,16215609582574,17462301521375,18790264037376,20203865017825,21707658170450,23306388890499,25005000250000,26808639110501,28722662360550,30752643279175,32904378026624,35183892263625,37597447900426,40151549976875,42852953674800,45708671463949,48725980382750,51912429455151,55275847244800,58824349547825,62566347225474,66510554177875,70665995460176,75042015542325,79648286713750,84494817634199,89591962032000,94950427551001,100581284747450,106495976238075,112706326000624,119224548828125,126063259938126,133235484738175,140754668748800,148634687685249,156889857699250,165534945782051,174585180330000,184056261873925,193964373973574,204326194278375,215158905755776,226480208088425,238308329241450,250662037201099,263560651886000,277024057232301,291072713453950,305727669479375,321010575565824,336943696092625,353549922534626,370852786617075,388876473653200,407645836065749,427186407093750,447524414685751,468686795580800,490701209578425,513596053998874,537400478334875,562144399096176,587858514848125,614574321445550,642324127463199,671141069824000,701059129626401,732113148172050,764338843195075,797772825294224,832452614569125,868416657461926,905704343805575,944356024080000,984413026877449,1025917676578250,1068913311238251,1113444300689200,1159556064853325,1207295092273374,1256708958859375,1307846346853376,1360757064013425,1415492063018050,1472103461092499,1530644559858000,1591169865405301,1653735108593750,1718397265577175,1785214578557824,1854246576769625,1925554097692026,1999199308495675,2075245727721200,2153758247192349,2234803154164750,2318448153711551,2404762391347200,2493816475890625,2585682502569074,2680434076363875,2778146335599376,2878895975776325,2982761273650950,3089822111560999,3200160002000000,3313858112441001,3431001290411050,3551676088817675,3675970791528624,3803975439206125,3935781855396926,4071483672879375,4211176360268800,4354957248882449,4502925559865250,4655182431577651,4811830947246800,4972976162882325,5138725135457974,5309186951360375,5484472755106176,5664695778328825,5849971369036250,6040417021140699,6236152404262000,6437299393805501,6643982101315950,6856326905108575,7074462481178624,7298519834390625,7528632329948626,7764935725148675,8007568201414800,8256670396619749,8512385437691750,8774858973508551,9044239208080000
mov $1,$0
add $1,1
pow $1,3
mov $3,$0
mov $0,1
add $3,1
add $1,$3
mul $3,$1
mul $1,$3
lpb $0,1
sub $0,1
mov $4,$1
mul $4,2
mov $2,$4
lpe
add $0,$2
mul $0,6
mov $1,$0
sub $1,48
div $1,48
add $1,1
|
clc
lda {c1},y
adc #1
sta {c1},x
bne !+
lda {c1}+1,y
adc #0
sta {c1}+1,x
!: |
db 0 ; species ID placeholder
db 45, 60, 30, 65, 80, 50
; hp atk def spd sat sdf
db DARK, FIRE ; type
db 120 ; catch rate
db 114 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 20 ; step cycles to hatch
INCBIN "gfx/pokemon/houndour/front.dimensions"
db GROWTH_SLOW ; growth rate
dn EGG_GROUND, EGG_GROUND ; egg groups
db 35 ; happiness
; tm/hm learnset
tmhm ROAR, TOXIC, HIDDEN_POWER, SUNNY_DAY, TAUNT, PROTECT, FRUSTRATION, SOLARBEAM, IRON_TAIL, RETURN, SHADOW_BALL, DOUBLE_TEAM, FLAMETHROWER, SLUDGE_BOMB, FIRE_BLAST, TORMENT, FACADE, SECRET_POWER, REST, ATTRACT, THIEF, SNATCH, OVERHEAT, ENDURE, WILL_O_WISP, EMBARGO, PAYBACK, CAPTIVATE, DARK_PULSE, SLEEP_TALK, NATURAL_GIFT, DREAM_EATER, SWAGGER, SUBSTITUTE, ROCK_SMASH, HEAT_WAVE, MUD_SLAP, SNORE, SPITE, SUCKER_PUNCH, SWIFT, UPROAR
; end
|
//
// Copyright © 2017 OsmaniHernandez. All rights reserved.
//
#include "../include/Decoder.h"
#include "../include/Format.h"
#include "../include/SimpleFormatFactory.h"
Decoder::Decoder(const unsigned int *instruct, const int instructSize) : instruction(instruct), INSTRUCT(instructSize)
{ this->factory = new FormatFactory; }
void Decoder::decode()
{
for(int i = 0; i < INSTRUCT; ++i, ++this->instruction)
{
this->instrucFormat = this->factory->returnFormat(*this->instruction);
instrucFormat->decodeAndPrint();
delete instrucFormat;
}
}
Decoder::~Decoder() { delete this->factory; }
|
// seed 2
lbi r0, 128 // icount 0
slbi r0, 0 // icount 1
lbi r1, 128 // icount 2
slbi r1, 0 // icount 3
lbi r2, 128 // icount 4
slbi r2, 0 // icount 5
lbi r3, 128 // icount 6
slbi r3, 0 // icount 7
lbi r4, 128 // icount 8
slbi r4, 0 // icount 9
lbi r5, 128 // icount 10
slbi r5, 0 // icount 11
lbi r6, 128 // icount 12
slbi r6, 0 // icount 13
lbi r7, 128 // icount 14
nop // to align meminst icount 15
slbi r7, 0 // icount 16
nop // to align meminst icount 17
ld r6, r1, 6 // icount 18
nop // to align meminst icount 19
st r4, r0, -8 // icount 20
nop // to align meminst icount 21
stu r2, r1, -16 // icount 22
nop // to align meminst icount 23
st r2, r0, -4 // icount 24
nop // to align meminst icount 25
st r3, r0, 6 // icount 26
nop // to align meminst icount 27
ld r2, r0, -14 // icount 28
nop // to align meminst icount 29
ld r4, r1, -6 // icount 30
nop // to align meminst icount 31
st r4, r1, -4 // icount 32
nop // to align meminst icount 33
stu r4, r0, -16 // icount 34
nop // to align meminst icount 35
ld r5, r1, -12 // icount 36
nop // to align meminst icount 37
ld r3, r0, -10 // icount 38
nop // to align meminst icount 39
ld r2, r0, -2 // icount 40
nop // to align meminst icount 41
ld r2, r1, -16 // icount 42
nop // to align meminst icount 43
ld r4, r1, -16 // icount 44
nop // to align meminst icount 45
ld r4, r0, 2 // icount 46
nop // to align meminst icount 47
st r3, r0, 6 // icount 48
nop // to align meminst icount 49
st r6, r0, 14 // icount 50
nop // to align meminst icount 51
ld r3, r0, -2 // icount 52
nop // to align meminst icount 53
ld r6, r0, 0 // icount 54
nop // to align meminst icount 55
st r5, r1, 6 // icount 56
nop // to align meminst icount 57
st r6, r1, 4 // icount 58
nop // to align meminst icount 59
stu r2, r1, -4 // icount 60
nop // to align meminst icount 61
st r3, r1, -16 // icount 62
nop // to align meminst icount 63
stu r4, r1, -2 // icount 64
nop // to align meminst icount 65
st r3, r1, -4 // icount 66
nop // to align meminst icount 67
st r3, r1, 10 // icount 68
nop // to align meminst icount 69
stu r2, r1, -4 // icount 70
nop // to align meminst icount 71
stu r2, r1, 4 // icount 72
nop // to align meminst icount 73
ld r2, r0, 4 // icount 74
nop // to align meminst icount 75
stu r6, r1, -16 // icount 76
nop // to align meminst icount 77
st r5, r1, -16 // icount 78
stu r3, r0, 10 // icount 79
rol r7, r6, r5 // icount 80
nop // to align meminst icount 81
ld r6, r0, -16 // icount 82
nop // to align meminst icount 83
ld r6, r0, -12 // icount 84
nop // to align meminst icount 85
stu r5, r1, 12 // icount 86
nop // to align meminst icount 87
ld r3, r1, 6 // icount 88
nop // to align meminst icount 89
st r6, r0, 12 // icount 90
nop // to align meminst icount 91
ld r6, r1, 4 // icount 92
nop // to align meminst icount 93
ld r3, r0, 10 // icount 94
nop // to align meminst icount 95
st r3, r1, -6 // icount 96
nop // to align meminst icount 97
st r5, r1, 10 // icount 98
nop // to align meminst icount 99
st r2, r1, 14 // icount 100
nop // to align meminst icount 101
stu r5, r0, 6 // icount 102
nop // to align meminst icount 103
stu r6, r0, 0 // icount 104
nop // to align meminst icount 105
stu r5, r1, -12 // icount 106
nop // to align meminst icount 107
st r3, r0, 10 // icount 108
nop // to align meminst icount 109
stu r4, r1, 4 // icount 110
st r6, r1, -10 // icount 111
lbi r3, 0 // icount 112
lbi r5, 0 // icount 113
nop // to align branch icount 114
bltz r2, 28 // icount 115
sll r7, r2, r2 // icount 116
sco r6, r1, r7 // icount 117
add r6, r5, r6 // icount 118
andni r3, r4, 5 // icount 119
lbi r7, 6 // icount 120
sco r5, r4, r5 // icount 121
seq r2, r6, r2 // icount 122
sco r4, r0, r1 // icount 123
xor r2, r5, r4 // icount 124
slt r4, r2, r3 // icount 125
andni r4, r4, 1 // icount 126
stu r5, r4, 10 // icount 127
rori r7, r5, 11 // icount 128
sub r2, r6, r3 // icount 129
andni r5, r5, 1 // icount 130
ld r4, r5, 0 // icount 131
subi r5, r2, 11 // icount 132
srli r7, r3, 3 // icount 133
lbi r4, 15 // icount 134
seq r6, r2, r6 // icount 135
rori r7, r3, 9 // icount 136
slli r7, r3, 4 // icount 137
subi r4, r6, 9 // icount 138
sub r7, r4, r3 // icount 139
rori r6, r5, 12 // icount 140
xor r2, r6, r7 // icount 141
sle r7, r2, r5 // icount 142
slt r4, r7, r2 // icount 143
sll r2, r2, r2 // icount 144
nop // to align meminst icount 145
sll r4, r6, r0 // icount 146
nop // to align meminst icount 147
ld r3, r1, 14 // icount 148
nop // to align meminst icount 149
ld r3, r1, 0 // icount 150
nop // to align meminst icount 151
st r2, r1, -6 // icount 152
nop // to align meminst icount 153
ld r2, r1, -6 // icount 154
nop // to align meminst icount 155
st r5, r0, -16 // icount 156
stu r6, r0, -14 // icount 157
lbi r3, 0 // icount 158
lbi r3, 0 // icount 159
nop // to align branch icount 160
beqz r0, 24 // icount 161
rol r4, r5, r0 // icount 162
subi r3, r3, 10 // icount 163
sle r4, r2, r2 // icount 164
seq r3, r2, r1 // icount 165
slli r5, r3, 8 // icount 166
sle r3, r6, r4 // icount 167
seq r7, r1, r3 // icount 168
roli r4, r1, 10 // icount 169
andni r3, r3, 1 // icount 170
stu r4, r3, 8 // icount 171
rori r7, r5, 14 // icount 172
nop // to align meminst icount 173
andni r1, r1, 1 // icount 174
stu r4, r1, 12 // icount 175
srl r3, r0, r6 // icount 176
xori r6, r4, 0 // icount 177
lbi r3, 1 // icount 178
sub r3, r5, r3 // icount 179
lbi r3, 0 // icount 180
nop // to align meminst icount 181
andni r0, r0, 1 // icount 182
stu r3, r0, 10 // icount 183
lbi r4, 1 // icount 184
seq r2, r6, r3 // icount 185
sll r7, r4, r1 // icount 186
rori r4, r3, 11 // icount 187
addi r7, r6, 3 // icount 188
andni r3, r6, 7 // icount 189
sle r3, r2, r5 // icount 190
stu r2, r1, -6 // icount 191
andni r6, r6, 1 // icount 192
nop // to align meminst icount 193
stu r4, r6, 12 // icount 194
nop // to align meminst icount 195
ld r4, r1, -12 // icount 196
nop // to align meminst icount 197
ld r4, r1, 10 // icount 198
nop // to align meminst icount 199
stu r6, r1, 8 // icount 200
nop // to align meminst icount 201
stu r3, r1, 0 // icount 202
nop // to align meminst icount 203
st r4, r0, -2 // icount 204
nop // to align meminst icount 205
ld r5, r1, 2 // icount 206
nop // to align meminst icount 207
st r2, r1, 6 // icount 208
nop // to align meminst icount 209
ld r5, r1, 10 // icount 210
st r5, r0, 8 // icount 211
addi r1, r1, -14 // change base addr // icount 212
lbi r7, 0 // icount 213
lbi r7, 0 // icount 214
bnez r1, 24 // icount 215
andni r3, r6, 9 // icount 216
nop // to align meminst icount 217
andni r2, r2, 1 // icount 218
ld r5, r2, 6 // icount 219
lbi r4, 11 // icount 220
andn r3, r3, r2 // icount 221
slt r4, r0, r3 // icount 222
rol r6, r4, r6 // icount 223
sle r4, r1, r6 // icount 224
nop // to align meminst icount 225
andni r5, r5, 1 // icount 226
ld r4, r5, 6 // icount 227
sll r3, r4, r6 // icount 228
rol r7, r5, r6 // icount 229
rol r5, r0, r4 // icount 230
addi r3, r1, 3 // icount 231
sll r3, r5, r2 // icount 232
roli r5, r3, 2 // icount 233
slli r7, r0, 15 // icount 234
slt r3, r0, r1 // icount 235
sco r3, r2, r2 // icount 236
ror r4, r6, r1 // icount 237
ror r5, r4, r6 // icount 238
sub r7, r0, r2 // icount 239
sle r5, r1, r0 // icount 240
srl r7, r3, r6 // icount 241
sco r6, r0, r6 // icount 242
nop // to align meminst icount 243
lbi r2, 0 // icount 244
nop // to align meminst icount 245
ld r5, r0, -2 // icount 246
nop // to align meminst icount 247
ld r6, r1, 4 // icount 248
ld r5, r0, 10 // icount 249
lbi r7, 0 // icount 250
lbi r2, 0 // icount 251
nop // to align branch icount 252
beqz r3, 16 // icount 253
roli r5, r5, 9 // icount 254
roli r6, r1, 13 // icount 255
sle r7, r5, r5 // icount 256
sub r3, r2, r1 // icount 257
andn r6, r3, r5 // icount 258
rori r7, r6, 2 // icount 259
roli r7, r7, 5 // icount 260
sle r7, r5, r6 // icount 261
srli r4, r3, 15 // icount 262
seq r3, r7, r0 // icount 263
andni r2, r2, 1 // icount 264
stu r4, r2, 10 // icount 265
seq r6, r7, r6 // icount 266
roli r7, r0, 14 // icount 267
subi r3, r4, 9 // icount 268
sco r3, r3, r7 // icount 269
sle r3, r2, r1 // icount 270
stu r5, r0, 0 // icount 271
lbi r4, 0 // icount 272
lbi r2, 0 // icount 273
nop // to align branch icount 274
bgez r4, 4 // icount 275
ror r2, r5, r1 // icount 276
sco r3, r5, r4 // icount 277
andni r5, r7, 3 // icount 278
nop // to align meminst icount 279
srl r3, r2, r6 // icount 280
nop // to align meminst icount 281
st r3, r1, -12 // icount 282
nop // to align meminst icount 283
ld r6, r0, 4 // icount 284
nop // to align meminst icount 285
st r2, r0, 10 // icount 286
nop // to align meminst icount 287
st r6, r0, 4 // icount 288
nop // to align meminst icount 289
ld r6, r0, -10 // icount 290
nop // to align meminst icount 291
ld r2, r1, -4 // icount 292
nop // to align meminst icount 293
st r6, r0, -6 // icount 294
nop // to align meminst icount 295
st r2, r1, 14 // icount 296
nop // to align meminst icount 297
st r2, r0, 10 // icount 298
nop // to align meminst icount 299
ld r6, r0, -8 // icount 300
nop // to align meminst icount 301
stu r2, r1, -12 // icount 302
nop // to align meminst icount 303
ld r4, r0, 12 // icount 304
nop // to align meminst icount 305
stu r2, r0, -10 // icount 306
nop // to align meminst icount 307
ld r5, r0, -2 // icount 308
nop // to align meminst icount 309
stu r3, r0, 12 // icount 310
nop // to align meminst icount 311
stu r2, r0, -2 // icount 312
nop // to align meminst icount 313
ld r3, r0, 0 // icount 314
nop // to align meminst icount 315
ld r3, r1, -6 // icount 316
nop // to align meminst icount 317
stu r4, r0, 8 // icount 318
nop // to align meminst icount 319
stu r5, r1, -8 // icount 320
nop // to align meminst icount 321
ld r2, r0, 6 // icount 322
nop // to align meminst icount 323
ld r5, r0, 2 // icount 324
nop // to align meminst icount 325
stu r5, r0, 0 // icount 326
nop // to align meminst icount 327
ld r6, r1, 4 // icount 328
nop // to align meminst icount 329
ld r5, r1, 8 // icount 330
nop // to align meminst icount 331
ld r6, r0, 8 // icount 332
nop // to align meminst icount 333
ld r4, r1, 14 // icount 334
nop // to align meminst icount 335
ld r5, r1, -14 // icount 336
nop // to align meminst icount 337
st r6, r0, 0 // icount 338
nop // to align meminst icount 339
st r6, r0, 6 // icount 340
stu r3, r0, 12 // icount 341
andni r1, r1, 1 // icount 342
nop // to align meminst icount 343
stu r4, r1, 10 // icount 344
nop // to align meminst icount 345
st r6, r0, 8 // icount 346
nop // to align meminst icount 347
ld r6, r1, 2 // icount 348
nop // to align meminst icount 349
ld r6, r1, -10 // icount 350
ld r2, r0, 14 // icount 351
addi r0, r0, -4 // change base addr // icount 352
nop // to align meminst icount 353
addi r0, r0, 2 // change base addr // icount 354
nop // to align meminst icount 355
stu r4, r0, -16 // icount 356
nop // to align meminst icount 357
ld r4, r0, 10 // icount 358
nop // to align meminst icount 359
ld r2, r1, -10 // icount 360
nop // to align meminst icount 361
st r3, r0, 8 // icount 362
nop // to align meminst icount 363
stu r3, r0, 10 // icount 364
nop // to align meminst icount 365
st r6, r0, 6 // icount 366
nop // to align meminst icount 367
ld r3, r0, -12 // icount 368
nop // to align meminst icount 369
st r3, r1, 0 // icount 370
nop // to align meminst icount 371
ld r4, r0, 12 // icount 372
nop // to align meminst icount 373
st r4, r1, -8 // icount 374
nop // to align meminst icount 375
ld r2, r0, 8 // icount 376
nop // to align meminst icount 377
ld r6, r1, -14 // icount 378
nop // to align meminst icount 379
stu r5, r1, 4 // icount 380
nop // to align meminst icount 381
stu r2, r1, -14 // icount 382
nop // to align meminst icount 383
st r6, r0, 4 // icount 384
st r5, r1, 6 // icount 385
add r4, r4, r2 // icount 386
nop // to align meminst icount 387
ld r3, r0, -2 // icount 388
nop // to align meminst icount 389
ld r4, r0, -6 // icount 390
nop // to align meminst icount 391
st r2, r0, 14 // icount 392
nop // to align meminst icount 393
st r2, r0, 2 // icount 394
nop // to align meminst icount 395
stu r6, r0, -2 // icount 396
nop // to align meminst icount 397
ld r6, r1, -10 // icount 398
nop // to align meminst icount 399
ld r2, r1, 4 // icount 400
nop // to align meminst icount 401
ld r4, r1, 4 // icount 402
nop // to align meminst icount 403
ld r6, r0, 14 // icount 404
nop // to align meminst icount 405
st r4, r0, -10 // icount 406
nop // to align meminst icount 407
ld r4, r0, -2 // icount 408
nop // to align meminst icount 409
ld r6, r1, -16 // icount 410
nop // to align meminst icount 411
st r4, r0, -8 // icount 412
nop // to align meminst icount 413
stu r3, r1, -12 // icount 414
nop // to align meminst icount 415
ld r6, r0, -2 // icount 416
nop // to align meminst icount 417
ld r2, r1, 10 // icount 418
nop // to align meminst icount 419
ld r6, r0, 14 // icount 420
nop // to align meminst icount 421
st r6, r0, 6 // icount 422
nop // to align meminst icount 423
st r2, r0, -10 // icount 424
nop // to align meminst icount 425
st r6, r1, -8 // icount 426
nop // to align meminst icount 427
ld r2, r0, 14 // icount 428
ld r4, r1, -2 // icount 429
addi r7, r5, 13 // icount 430
nop // to align meminst icount 431
andn r2, r6, r1 // icount 432
nop // to align meminst icount 433
stu r2, r1, -2 // icount 434
nop // to align meminst icount 435
st r6, r1, -8 // icount 436
nop // to align meminst icount 437
ld r4, r0, -16 // icount 438
nop // to align meminst icount 439
st r4, r0, -16 // icount 440
nop // to align meminst icount 441
st r3, r1, -8 // icount 442
nop // to align meminst icount 443
stu r2, r1, -8 // icount 444
ld r3, r1, -2 // icount 445
xori r7, r6, 4 // icount 446
nop // to align meminst icount 447
ld r2, r1, 2 // icount 448
nop // to align meminst icount 449
st r6, r1, -10 // icount 450
nop // to align meminst icount 451
ld r3, r0, 2 // icount 452
nop // to align meminst icount 453
st r5, r1, 2 // icount 454
nop // to align meminst icount 455
ld r6, r1, -16 // icount 456
nop // to align meminst icount 457
stu r4, r0, 4 // icount 458
nop // to align meminst icount 459
stu r6, r0, -12 // icount 460
nop // to align meminst icount 461
stu r6, r1, -6 // icount 462
nop // to align meminst icount 463
ld r3, r0, -12 // icount 464
nop // to align meminst icount 465
ld r6, r1, -6 // icount 466
nop // to align meminst icount 467
ld r2, r1, 6 // icount 468
nop // to align meminst icount 469
stu r6, r1, 14 // icount 470
ld r6, r1, -16 // icount 471
andn r7, r1, r4 // icount 472
nop // to align meminst icount 473
stu r2, r1, -4 // icount 474
nop // to align meminst icount 475
ld r6, r0, -12 // icount 476
nop // to align meminst icount 477
ld r6, r1, 14 // icount 478
nop // to align meminst icount 479
ld r3, r1, 14 // icount 480
nop // to align meminst icount 481
st r4, r0, 14 // icount 482
nop // to align meminst icount 483
ld r5, r1, 12 // icount 484
nop // to align meminst icount 485
stu r3, r1, 6 // icount 486
nop // to align meminst icount 487
st r6, r0, -10 // icount 488
nop // to align meminst icount 489
ld r4, r1, 14 // icount 490
nop // to align meminst icount 491
ld r2, r1, -12 // icount 492
nop // to align meminst icount 493
ld r4, r0, -6 // icount 494
nop // to align meminst icount 495
ld r4, r1, 4 // icount 496
nop // to align meminst icount 497
ld r5, r1, 8 // icount 498
nop // to align meminst icount 499
st r4, r1, 12 // icount 500
stu r5, r0, 12 // icount 501
addi r1, r1, -4 // change base addr // icount 502
nop // to align meminst icount 503
ld r3, r0, -2 // icount 504
nop // to align meminst icount 505
st r3, r1, 12 // icount 506
nop // to align meminst icount 507
ld r4, r0, 0 // icount 508
nop // to align meminst icount 509
stu r4, r1, -12 // icount 510
nop // to align meminst icount 511
ld r4, r0, -14 // icount 512
nop // to align meminst icount 513
stu r4, r0, -6 // icount 514
nop // to align meminst icount 515
ld r2, r1, 10 // icount 516
nop // to align meminst icount 517
ld r5, r0, -8 // icount 518
nop // to align meminst icount 519
stu r6, r0, 14 // icount 520
nop // to align meminst icount 521
ld r4, r0, 8 // icount 522
nop // to align meminst icount 523
ld r2, r0, -16 // icount 524
nop // to align meminst icount 525
stu r6, r0, -6 // icount 526
nop // to align meminst icount 527
st r5, r1, -14 // icount 528
nop // to align meminst icount 529
ld r4, r0, 6 // icount 530
nop // to align meminst icount 531
stu r5, r1, 6 // icount 532
nop // to align meminst icount 533
ld r3, r0, 2 // icount 534
nop // to align meminst icount 535
ld r2, r1, -2 // icount 536
nop // to align meminst icount 537
st r5, r1, 0 // icount 538
nop // to align meminst icount 539
stu r3, r0, 10 // icount 540
nop // to align meminst icount 541
stu r4, r1, -8 // icount 542
nop // to align meminst icount 543
stu r4, r0, -6 // icount 544
nop // to align meminst icount 545
ld r3, r1, 0 // icount 546
nop // to align meminst icount 547
st r6, r0, -8 // icount 548
nop // to align meminst icount 549
stu r2, r1, 6 // icount 550
nop // to align meminst icount 551
st r3, r1, -8 // icount 552
nop // to align meminst icount 553
ld r5, r0, -4 // icount 554
nop // to align meminst icount 555
stu r6, r1, -12 // icount 556
nop // to align meminst icount 557
ld r3, r1, -16 // icount 558
nop // to align meminst icount 559
ld r4, r0, 2 // icount 560
nop // to align meminst icount 561
ld r4, r1, -8 // icount 562
nop // to align meminst icount 563
st r6, r0, 6 // icount 564
nop // to align meminst icount 565
st r3, r1, 14 // icount 566
nop // to align meminst icount 567
ld r5, r0, -14 // icount 568
nop // to align meminst icount 569
st r5, r1, 6 // icount 570
nop // to align meminst icount 571
ld r3, r0, 14 // icount 572
nop // to align meminst icount 573
st r6, r1, 8 // icount 574
nop // to align meminst icount 575
ld r2, r1, 6 // icount 576
nop // to align meminst icount 577
ld r5, r0, -8 // icount 578
nop // to align meminst icount 579
ld r4, r1, -2 // icount 580
nop // to align meminst icount 581
stu r4, r1, 10 // icount 582
nop // to align meminst icount 583
st r4, r0, 8 // icount 584
nop // to align meminst icount 585
st r3, r0, 2 // icount 586
nop // to align meminst icount 587
stu r4, r0, 8 // icount 588
nop // to align meminst icount 589
st r2, r1, 10 // icount 590
nop // to align meminst icount 591
st r4, r1, 4 // icount 592
nop // to align meminst icount 593
stu r6, r0, -14 // icount 594
nop // to align meminst icount 595
stu r3, r0, 4 // icount 596
nop // to align meminst icount 597
stu r6, r1, 0 // icount 598
nop // to align meminst icount 599
ld r3, r0, -6 // icount 600
nop // to align meminst icount 601
ld r6, r1, -16 // icount 602
nop // to align meminst icount 603
ld r6, r0, 4 // icount 604
nop // to align meminst icount 605
st r4, r0, -2 // icount 606
nop // to align meminst icount 607
ld r6, r1, 0 // icount 608
nop // to align meminst icount 609
stu r5, r1, -10 // icount 610
nop // to align meminst icount 611
st r6, r1, 8 // icount 612
nop // to align meminst icount 613
stu r6, r0, 10 // icount 614
nop // to align meminst icount 615
stu r2, r1, 8 // icount 616
nop // to align meminst icount 617
ld r5, r0, -14 // icount 618
nop // to align meminst icount 619
ld r3, r0, 2 // icount 620
nop // to align meminst icount 621
st r5, r1, 10 // icount 622
nop // to align meminst icount 623
ld r6, r0, -16 // icount 624
nop // to align meminst icount 625
stu r5, r1, 8 // icount 626
nop // to align meminst icount 627
ld r5, r0, -10 // icount 628
nop // to align meminst icount 629
stu r3, r1, 0 // icount 630
nop // to align meminst icount 631
stu r5, r0, -2 // icount 632
nop // to align meminst icount 633
ld r2, r1, -12 // icount 634
nop // to align meminst icount 635
ld r5, r1, -14 // icount 636
nop // to align meminst icount 637
stu r3, r1, -12 // icount 638
nop // to align meminst icount 639
ld r3, r0, -16 // icount 640
nop // to align meminst icount 641
stu r6, r1, -16 // icount 642
nop // to align meminst icount 643
ld r4, r1, -12 // icount 644
nop // to align meminst icount 645
ld r6, r0, 6 // icount 646
nop // to align meminst icount 647
st r5, r0, -14 // icount 648
nop // to align meminst icount 649
stu r3, r1, -16 // icount 650
nop // to align meminst icount 651
stu r5, r1, -8 // icount 652
nop // to align meminst icount 653
ld r4, r1, -16 // icount 654
nop // to align meminst icount 655
ld r3, r1, -8 // icount 656
nop // to align meminst icount 657
ld r5, r0, -2 // icount 658
nop // to align meminst icount 659
stu r4, r0, 14 // icount 660
nop // to align meminst icount 661
stu r5, r0, -4 // icount 662
nop // to align meminst icount 663
st r5, r0, 2 // icount 664
nop // to align meminst icount 665
st r3, r0, 10 // icount 666
nop // to align meminst icount 667
ld r5, r0, 8 // icount 668
nop // to align meminst icount 669
st r3, r0, 8 // icount 670
nop // to align meminst icount 671
ld r6, r1, -4 // icount 672
nop // to align meminst icount 673
st r2, r1, -4 // icount 674
nop // to align meminst icount 675
stu r4, r1, -6 // icount 676
nop // to align meminst icount 677
ld r5, r1, -6 // icount 678
nop // to align meminst icount 679
st r3, r1, 6 // icount 680
nop // to align meminst icount 681
stu r3, r0, -14 // icount 682
nop // to align meminst icount 683
ld r5, r0, 12 // icount 684
nop // to align meminst icount 685
ld r2, r0, 12 // icount 686
nop // to align meminst icount 687
ld r6, r0, -2 // icount 688
nop // to align meminst icount 689
ld r2, r1, -16 // icount 690
nop // to align meminst icount 691
ld r2, r0, 12 // icount 692
ld r5, r1, -4 // icount 693
srli r4, r4, 4 // icount 694
nop // to align meminst icount 695
ld r3, r0, -8 // icount 696
nop // to align meminst icount 697
ld r5, r1, 4 // icount 698
nop // to align meminst icount 699
ld r5, r1, -6 // icount 700
nop // to align meminst icount 701
ld r2, r0, 12 // icount 702
nop // to align meminst icount 703
stu r5, r0, -2 // icount 704
nop // to align meminst icount 705
st r4, r0, -16 // icount 706
nop // to align meminst icount 707
ld r4, r0, 6 // icount 708
nop // to align meminst icount 709
ld r2, r0, -6 // icount 710
nop // to align meminst icount 711
stu r3, r1, -8 // icount 712
nop // to align meminst icount 713
stu r3, r0, 12 // icount 714
nop // to align meminst icount 715
ld r5, r1, 0 // icount 716
nop // to align meminst icount 717
ld r3, r0, -6 // icount 718
nop // to align meminst icount 719
stu r4, r0, -8 // icount 720
nop // to align meminst icount 721
stu r6, r1, 8 // icount 722
nop // to align meminst icount 723
st r5, r1, -12 // icount 724
nop // to align meminst icount 725
st r2, r0, -12 // icount 726
nop // to align meminst icount 727
ld r6, r0, 12 // icount 728
nop // to align meminst icount 729
st r3, r1, -2 // icount 730
nop // to align meminst icount 731
st r4, r0, 6 // icount 732
nop // to align meminst icount 733
ld r5, r1, -8 // icount 734
nop // to align meminst icount 735
ld r5, r1, -8 // icount 736
nop // to align meminst icount 737
stu r2, r1, -2 // icount 738
ld r3, r1, 6 // icount 739
andni r7, r7, 1 // icount 740
nop // to align meminst icount 741
st r7, r7, 2 // icount 742
nop // to align meminst icount 743
ld r3, r1, 6 // icount 744
nop // to align meminst icount 745
ld r2, r0, -2 // icount 746
nop // to align meminst icount 747
stu r3, r0, -10 // icount 748
nop // to align meminst icount 749
st r3, r0, 2 // icount 750
nop // to align meminst icount 751
ld r2, r1, -16 // icount 752
nop // to align meminst icount 753
ld r4, r1, 2 // icount 754
nop // to align meminst icount 755
stu r4, r1, -4 // icount 756
nop // to align meminst icount 757
ld r5, r1, -16 // icount 758
nop // to align meminst icount 759
ld r3, r1, -12 // icount 760
nop // to align meminst icount 761
ld r6, r0, 2 // icount 762
nop // to align meminst icount 763
ld r6, r0, 4 // icount 764
nop // to align meminst icount 765
stu r5, r0, 6 // icount 766
nop // to align meminst icount 767
ld r3, r0, 14 // icount 768
nop // to align meminst icount 769
st r5, r0, -10 // icount 770
nop // to align meminst icount 771
st r5, r0, -8 // icount 772
nop // to align meminst icount 773
ld r6, r1, 4 // icount 774
nop // to align meminst icount 775
ld r5, r1, -6 // icount 776
nop // to align meminst icount 777
ld r3, r0, -6 // icount 778
nop // to align meminst icount 779
ld r4, r0, 2 // icount 780
nop // to align meminst icount 781
ld r6, r0, 0 // icount 782
nop // to align meminst icount 783
ld r2, r1, 8 // icount 784
nop // to align meminst icount 785
ld r2, r1, -2 // icount 786
nop // to align meminst icount 787
stu r5, r1, -16 // icount 788
nop // to align meminst icount 789
st r5, r1, 6 // icount 790
nop // to align meminst icount 791
ld r4, r0, 2 // icount 792
nop // to align meminst icount 793
ld r3, r1, -8 // icount 794
nop // to align meminst icount 795
stu r3, r0, 14 // icount 796
nop // to align meminst icount 797
st r5, r0, 10 // icount 798
nop // to align meminst icount 799
st r5, r1, 6 // icount 800
nop // to align meminst icount 801
ld r3, r0, -4 // icount 802
nop // to align meminst icount 803
st r3, r1, 10 // icount 804
nop // to align meminst icount 805
st r3, r1, 0 // icount 806
nop // to align meminst icount 807
stu r3, r0, 0 // icount 808
nop // to align meminst icount 809
ld r2, r0, -8 // icount 810
nop // to align meminst icount 811
ld r6, r1, -10 // icount 812
nop // to align meminst icount 813
ld r4, r0, -8 // icount 814
nop // to align meminst icount 815
ld r5, r1, 10 // icount 816
nop // to align meminst icount 817
ld r2, r1, -12 // icount 818
nop // to align meminst icount 819
ld r6, r1, 0 // icount 820
nop // to align meminst icount 821
stu r5, r1, 8 // icount 822
nop // to align meminst icount 823
st r2, r0, -2 // icount 824
nop // to align meminst icount 825
ld r4, r1, -12 // icount 826
nop // to align meminst icount 827
st r5, r0, -12 // icount 828
nop // to align meminst icount 829
ld r4, r1, 8 // icount 830
nop // to align meminst icount 831
stu r2, r0, -10 // icount 832
nop // to align meminst icount 833
st r4, r1, -16 // icount 834
nop // to align meminst icount 835
ld r2, r1, 0 // icount 836
nop // to align meminst icount 837
st r6, r0, 14 // icount 838
nop // to align meminst icount 839
ld r5, r0, 4 // icount 840
nop // to align meminst icount 841
stu r3, r1, 2 // icount 842
nop // to align meminst icount 843
stu r6, r1, -12 // icount 844
nop // to align meminst icount 845
stu r3, r0, 6 // icount 846
nop // to align meminst icount 847
ld r3, r1, 12 // icount 848
nop // to align meminst icount 849
ld r6, r1, 14 // icount 850
st r5, r1, 10 // icount 851
lbi r2, 0 // icount 852
lbi r7, 0 // icount 853
nop // to align branch icount 854
beqz r6, 20 // icount 855
sco r4, r6, r2 // icount 856
slli r7, r6, 15 // icount 857
andni r4, r4, 1 // icount 858
ld r2, r4, 10 // icount 859
andn r2, r6, r5 // icount 860
lbi r3, 4 // icount 861
sco r7, r3, r5 // icount 862
slbi r5, 10 // icount 863
sle r5, r2, r2 // icount 864
addi r5, r4, 12 // icount 865
andni r1, r1, 1 // icount 866
ld r7, r1, 8 // icount 867
xor r3, r2, r4 // icount 868
sco r3, r5, r7 // icount 869
add r3, r7, r5 // icount 870
subi r4, r6, 3 // icount 871
lbi r2, 11 // icount 872
rori r5, r2, 5 // icount 873
srli r5, r2, 12 // icount 874
srli r4, r3, 15 // icount 875
andni r7, r4, 2 // icount 876
nop // to align meminst icount 877
andn r3, r5, r5 // icount 878
nop // to align meminst icount 879
st r5, r1, 8 // icount 880
nop // to align meminst icount 881
ld r3, r0, 10 // icount 882
nop // to align meminst icount 883
ld r6, r1, 2 // icount 884
ld r4, r1, 12 // icount 885
addi r1, r1, 2 // change base addr // icount 886
nop // to align meminst icount 887
st r4, r1, 10 // icount 888
nop // to align meminst icount 889
ld r4, r0, -8 // icount 890
nop // to align meminst icount 891
st r4, r1, -14 // icount 892
nop // to align meminst icount 893
ld r6, r1, -2 // icount 894
nop // to align meminst icount 895
st r4, r1, -2 // icount 896
nop // to align meminst icount 897
stu r2, r0, -2 // icount 898
nop // to align meminst icount 899
ld r5, r1, -6 // icount 900
nop // to align meminst icount 901
stu r3, r0, -12 // icount 902
nop // to align meminst icount 903
stu r4, r1, -10 // icount 904
nop // to align meminst icount 905
ld r2, r1, 0 // icount 906
nop // to align meminst icount 907
stu r6, r1, -14 // icount 908
nop // to align meminst icount 909
st r5, r1, 10 // icount 910
nop // to align meminst icount 911
st r5, r1, 8 // icount 912
nop // to align meminst icount 913
ld r2, r1, 12 // icount 914
nop // to align meminst icount 915
st r2, r1, 6 // icount 916
nop // to align meminst icount 917
ld r2, r0, -8 // icount 918
nop // to align meminst icount 919
stu r3, r0, 12 // icount 920
nop // to align meminst icount 921
ld r5, r0, 2 // icount 922
nop // to align meminst icount 923
st r2, r1, -4 // icount 924
nop // to align meminst icount 925
ld r5, r1, -2 // icount 926
nop // to align meminst icount 927
stu r5, r1, -2 // icount 928
nop // to align meminst icount 929
ld r3, r1, 8 // icount 930
nop // to align meminst icount 931
ld r3, r1, 10 // icount 932
nop // to align meminst icount 933
stu r5, r0, -16 // icount 934
nop // to align meminst icount 935
stu r4, r0, -8 // icount 936
nop // to align meminst icount 937
st r5, r0, 0 // icount 938
nop // to align meminst icount 939
st r4, r0, 10 // icount 940
nop // to align meminst icount 941
ld r3, r1, 0 // icount 942
nop // to align meminst icount 943
stu r4, r1, -16 // icount 944
nop // to align meminst icount 945
ld r3, r0, -6 // icount 946
nop // to align meminst icount 947
st r3, r0, -16 // icount 948
nop // to align meminst icount 949
ld r4, r1, -10 // icount 950
nop // to align meminst icount 951
ld r6, r0, 12 // icount 952
nop // to align meminst icount 953
ld r2, r0, -14 // icount 954
nop // to align meminst icount 955
st r3, r0, 6 // icount 956
nop // to align meminst icount 957
ld r3, r1, 0 // icount 958
nop // to align meminst icount 959
ld r2, r0, 10 // icount 960
nop // to align meminst icount 961
st r5, r1, -6 // icount 962
nop // to align meminst icount 963
ld r3, r1, 0 // icount 964
nop // to align meminst icount 965
stu r6, r0, -12 // icount 966
nop // to align meminst icount 967
ld r5, r1, -14 // icount 968
nop // to align meminst icount 969
ld r4, r1, -12 // icount 970
nop // to align meminst icount 971
st r2, r1, 14 // icount 972
nop // to align meminst icount 973
ld r4, r0, -4 // icount 974
nop // to align meminst icount 975
st r6, r0, 4 // icount 976
nop // to align meminst icount 977
ld r4, r1, -8 // icount 978
nop // to align meminst icount 979
st r3, r0, 12 // icount 980
nop // to align meminst icount 981
ld r5, r0, 2 // icount 982
nop // to align meminst icount 983
st r4, r0, 14 // icount 984
nop // to align meminst icount 985
ld r3, r0, 0 // icount 986
nop // to align meminst icount 987
stu r2, r0, -2 // icount 988
nop // to align meminst icount 989
ld r2, r0, -6 // icount 990
nop // to align meminst icount 991
ld r3, r0, 12 // icount 992
nop // to align meminst icount 993
ld r2, r0, 8 // icount 994
nop // to align meminst icount 995
ld r4, r1, -2 // icount 996
nop // to align meminst icount 997
ld r4, r0, -4 // icount 998
nop // to align meminst icount 999
stu r5, r1, 6 // icount 1000
nop // to align meminst icount 1001
stu r5, r0, -6 // icount 1002
nop // to align meminst icount 1003
ld r2, r1, 12 // icount 1004
nop // to align meminst icount 1005
stu r3, r1, 8 // icount 1006
nop // to align meminst icount 1007
ld r2, r1, 0 // icount 1008
nop // to align meminst icount 1009
stu r3, r0, 12 // icount 1010
nop // to align meminst icount 1011
stu r2, r1, 4 // icount 1012
nop // to align meminst icount 1013
ld r3, r0, 10 // icount 1014
nop // to align meminst icount 1015
ld r6, r0, 14 // icount 1016
nop // to align meminst icount 1017
stu r4, r0, 12 // icount 1018
nop // to align meminst icount 1019
stu r6, r0, 14 // icount 1020
nop // to align meminst icount 1021
ld r6, r0, 10 // icount 1022
nop // to align meminst icount 1023
st r4, r1, -8 // icount 1024
nop // to align meminst icount 1025
stu r3, r1, 2 // icount 1026
nop // to align meminst icount 1027
stu r6, r0, 6 // icount 1028
nop // to align meminst icount 1029
ld r3, r1, -16 // icount 1030
nop // to align meminst icount 1031
ld r6, r0, -6 // icount 1032
nop // to align meminst icount 1033
ld r6, r0, 8 // icount 1034
nop // to align meminst icount 1035
ld r3, r1, 12 // icount 1036
nop // to align meminst icount 1037
ld r3, r1, 10 // icount 1038
nop // to align meminst icount 1039
stu r6, r1, 6 // icount 1040
nop // to align meminst icount 1041
ld r2, r0, 6 // icount 1042
nop // to align meminst icount 1043
ld r2, r1, 2 // icount 1044
nop // to align meminst icount 1045
st r6, r0, 4 // icount 1046
nop // to align meminst icount 1047
st r3, r0, 6 // icount 1048
nop // to align meminst icount 1049
ld r3, r0, 10 // icount 1050
nop // to align meminst icount 1051
stu r4, r1, 12 // icount 1052
nop // to align meminst icount 1053
st r3, r1, 2 // icount 1054
nop // to align meminst icount 1055
st r3, r0, -16 // icount 1056
nop // to align meminst icount 1057
ld r4, r0, -2 // icount 1058
nop // to align meminst icount 1059
ld r6, r0, -8 // icount 1060
nop // to align meminst icount 1061
ld r4, r0, -14 // icount 1062
nop // to align meminst icount 1063
ld r2, r0, 10 // icount 1064
nop // to align meminst icount 1065
stu r3, r1, 8 // icount 1066
nop // to align meminst icount 1067
ld r2, r0, -12 // icount 1068
nop // to align meminst icount 1069
st r5, r1, 6 // icount 1070
nop // to align meminst icount 1071
ld r4, r0, 8 // icount 1072
ld r3, r0, 12 // icount 1073
rori r7, r5, 3 // icount 1074
nop // to align meminst icount 1075
ld r3, r1, -10 // icount 1076
nop // to align meminst icount 1077
ld r2, r0, 10 // icount 1078
nop // to align meminst icount 1079
stu r6, r1, -14 // icount 1080
nop // to align meminst icount 1081
stu r3, r0, 10 // icount 1082
nop // to align meminst icount 1083
st r4, r0, -10 // icount 1084
nop // to align meminst icount 1085
stu r6, r0, 12 // icount 1086
nop // to align meminst icount 1087
st r2, r1, 2 // icount 1088
nop // to align meminst icount 1089
st r6, r1, -6 // icount 1090
nop // to align meminst icount 1091
st r6, r1, -4 // icount 1092
nop // to align meminst icount 1093
ld r6, r0, 14 // icount 1094
nop // to align meminst icount 1095
stu r2, r1, -6 // icount 1096
nop // to align meminst icount 1097
st r5, r0, -12 // icount 1098
st r6, r0, 12 // icount 1099
lbi r2, 0 // icount 1100
lbi r7, 0 // icount 1101
nop // to align branch icount 1102
bgez r5, 20 // icount 1103
slt r2, r3, r3 // icount 1104
slt r5, r3, r5 // icount 1105
rori r5, r6, 6 // icount 1106
ror r3, r3, r6 // icount 1107
lbi r7, 8 // icount 1108
sle r4, r7, r1 // icount 1109
xor r3, r1, r5 // icount 1110
subi r5, r4, 13 // icount 1111
roli r4, r5, 8 // icount 1112
subi r4, r2, 14 // icount 1113
srl r4, r2, r2 // icount 1114
andn r6, r5, r7 // icount 1115
slt r3, r3, r1 // icount 1116
slli r2, r5, 12 // icount 1117
rori r4, r2, 10 // icount 1118
sub r2, r2, r0 // icount 1119
seq r3, r4, r2 // icount 1120
sle r4, r5, r6 // icount 1121
sub r6, r5, r4 // icount 1122
rol r7, r1, r0 // icount 1123
addi r0, r0, 2 // change base addr // icount 1124
nop // to align meminst icount 1125
ld r3, r1, 10 // icount 1126
nop // to align meminst icount 1127
ld r6, r0, 0 // icount 1128
nop // to align meminst icount 1129
stu r3, r0, -2 // icount 1130
stu r4, r0, -2 // icount 1131
rol r3, r2, r7 // icount 1132
nop // to align meminst icount 1133
ld r4, r0, 6 // icount 1134
st r6, r0, -12 // icount 1135
lbi r5, 0 // icount 1136
lbi r5, 0 // icount 1137
nop // to align branch icount 1138
beqz r5, 24 // icount 1139
andni r6, r6, 1 // icount 1140
st r3, r6, 10 // icount 1141
slt r7, r4, r0 // icount 1142
sub r5, r6, r2 // icount 1143
sub r2, r5, r0 // icount 1144
rol r5, r0, r4 // icount 1145
srli r2, r1, 15 // icount 1146
seq r4, r7, r4 // icount 1147
andni r2, r2, 1 // icount 1148
stu r7, r2, 4 // icount 1149
slli r3, r4, 9 // icount 1150
srl r4, r7, r6 // icount 1151
andni r5, r5, 1 // icount 1152
st r6, r5, 4 // icount 1153
addi r4, r0, 15 // icount 1154
rol r4, r7, r2 // icount 1155
andni r5, r5, 1 // icount 1156
stu r2, r5, 10 // icount 1157
add r4, r6, r4 // icount 1158
slli r5, r0, 13 // icount 1159
andni r7, r7, 1 // icount 1160
ld r5, r7, 12 // icount 1161
sco r6, r2, r1 // icount 1162
sle r2, r6, r1 // icount 1163
slt r4, r6, r6 // icount 1164
srli r5, r7, 1 // icount 1165
seq r2, r4, r0 // icount 1166
roli r7, r3, 8 // icount 1167
seq r5, r3, r4 // icount 1168
nop // to align meminst icount 1169
ld r3, r1, 14 // icount 1170
nop // to align meminst icount 1171
st r5, r0, 4 // icount 1172
nop // to align meminst icount 1173
st r2, r0, -2 // icount 1174
nop // to align meminst icount 1175
ld r6, r0, 12 // icount 1176
nop // to align meminst icount 1177
ld r2, r0, -16 // icount 1178
nop // to align meminst icount 1179
st r3, r0, -16 // icount 1180
nop // to align meminst icount 1181
st r6, r1, 0 // icount 1182
nop // to align meminst icount 1183
ld r3, r1, -4 // icount 1184
nop // to align meminst icount 1185
ld r6, r0, 8 // icount 1186
nop // to align meminst icount 1187
st r2, r1, -10 // icount 1188
nop // to align meminst icount 1189
ld r4, r0, -2 // icount 1190
nop // to align meminst icount 1191
stu r6, r0, 10 // icount 1192
nop // to align meminst icount 1193
stu r4, r1, -2 // icount 1194
nop // to align meminst icount 1195
st r5, r0, -4 // icount 1196
nop // to align meminst icount 1197
stu r4, r1, -14 // icount 1198
nop // to align meminst icount 1199
st r4, r1, 6 // icount 1200
nop // to align meminst icount 1201
stu r2, r1, 4 // icount 1202
nop // to align meminst icount 1203
stu r4, r0, -8 // icount 1204
nop // to align meminst icount 1205
st r2, r1, -10 // icount 1206
nop // to align meminst icount 1207
ld r2, r0, 8 // icount 1208
nop // to align meminst icount 1209
stu r3, r0, 0 // icount 1210
nop // to align meminst icount 1211
ld r2, r1, -10 // icount 1212
nop // to align meminst icount 1213
ld r6, r1, 0 // icount 1214
nop // to align meminst icount 1215
st r6, r0, -12 // icount 1216
nop // to align meminst icount 1217
ld r5, r1, -6 // icount 1218
nop // to align meminst icount 1219
ld r4, r1, -6 // icount 1220
nop // to align meminst icount 1221
ld r5, r1, -8 // icount 1222
nop // to align meminst icount 1223
st r4, r1, -16 // icount 1224
nop // to align meminst icount 1225
st r5, r1, 0 // icount 1226
nop // to align meminst icount 1227
st r6, r0, -6 // icount 1228
nop // to align meminst icount 1229
stu r6, r0, 6 // icount 1230
nop // to align meminst icount 1231
st r6, r0, -10 // icount 1232
nop // to align meminst icount 1233
stu r4, r1, 2 // icount 1234
nop // to align meminst icount 1235
ld r2, r1, 8 // icount 1236
nop // to align meminst icount 1237
st r4, r1, -12 // icount 1238
nop // to align meminst icount 1239
ld r5, r1, -14 // icount 1240
nop // to align meminst icount 1241
ld r4, r0, 12 // icount 1242
nop // to align meminst icount 1243
stu r4, r1, -10 // icount 1244
nop // to align meminst icount 1245
stu r6, r0, -14 // icount 1246
nop // to align meminst icount 1247
ld r3, r0, -10 // icount 1248
nop // to align meminst icount 1249
stu r4, r1, -10 // icount 1250
nop // to align meminst icount 1251
ld r6, r0, 8 // icount 1252
nop // to align meminst icount 1253
ld r4, r1, -8 // icount 1254
nop // to align meminst icount 1255
st r2, r1, -16 // icount 1256
nop // to align meminst icount 1257
st r3, r1, -10 // icount 1258
nop // to align meminst icount 1259
st r6, r0, 4 // icount 1260
nop // to align meminst icount 1261
ld r2, r1, -8 // icount 1262
nop // to align meminst icount 1263
ld r6, r1, -8 // icount 1264
nop // to align meminst icount 1265
ld r4, r1, 12 // icount 1266
nop // to align meminst icount 1267
st r6, r1, 14 // icount 1268
nop // to align meminst icount 1269
ld r6, r0, 14 // icount 1270
nop // to align meminst icount 1271
st r5, r1, 0 // icount 1272
nop // to align meminst icount 1273
ld r2, r0, -14 // icount 1274
nop // to align meminst icount 1275
stu r4, r0, -6 // icount 1276
nop // to align meminst icount 1277
ld r4, r0, 14 // icount 1278
nop // to align meminst icount 1279
stu r2, r1, -12 // icount 1280
nop // to align meminst icount 1281
ld r6, r1, 10 // icount 1282
nop // to align meminst icount 1283
ld r3, r0, 12 // icount 1284
nop // to align meminst icount 1285
ld r4, r0, 2 // icount 1286
nop // to align meminst icount 1287
st r3, r1, -16 // icount 1288
nop // to align meminst icount 1289
stu r6, r1, -14 // icount 1290
nop // to align meminst icount 1291
ld r5, r1, 4 // icount 1292
nop // to align meminst icount 1293
st r2, r0, -4 // icount 1294
nop // to align meminst icount 1295
st r4, r1, 10 // icount 1296
nop // to align meminst icount 1297
ld r6, r1, -8 // icount 1298
nop // to align meminst icount 1299
ld r6, r1, -2 // icount 1300
nop // to align meminst icount 1301
ld r5, r1, 2 // icount 1302
nop // to align meminst icount 1303
ld r5, r1, -8 // icount 1304
nop // to align meminst icount 1305
ld r2, r0, 6 // icount 1306
nop // to align meminst icount 1307
ld r4, r0, 14 // icount 1308
nop // to align meminst icount 1309
ld r4, r0, 4 // icount 1310
nop // to align meminst icount 1311
ld r3, r0, 14 // icount 1312
nop // to align meminst icount 1313
ld r6, r0, -2 // icount 1314
nop // to align meminst icount 1315
ld r2, r1, -10 // icount 1316
nop // to align meminst icount 1317
ld r3, r0, 2 // icount 1318
nop // to align meminst icount 1319
stu r5, r1, 0 // icount 1320
nop // to align meminst icount 1321
st r4, r1, 6 // icount 1322
nop // to align meminst icount 1323
ld r3, r1, -4 // icount 1324
nop // to align meminst icount 1325
st r4, r0, -10 // icount 1326
nop // to align meminst icount 1327
st r2, r1, -10 // icount 1328
nop // to align meminst icount 1329
st r6, r1, -12 // icount 1330
nop // to align meminst icount 1331
stu r2, r0, 14 // icount 1332
st r5, r0, 14 // icount 1333
lbi r4, 0 // icount 1334
lbi r6, 0 // icount 1335
nop // to align branch icount 1336
bnez r6, 8 // icount 1337
add r4, r1, r3 // icount 1338
srli r4, r7, 7 // icount 1339
sub r4, r1, r4 // icount 1340
xori r3, r2, 6 // icount 1341
andn r5, r5, r3 // icount 1342
rori r6, r5, 1 // icount 1343
rol r5, r6, r3 // icount 1344
nop // to align meminst icount 1345
rol r4, r5, r7 // icount 1346
nop // to align meminst icount 1347
st r5, r1, 10 // icount 1348
stu r2, r0, -8 // icount 1349
lbi r7, 0 // icount 1350
lbi r2, 0 // icount 1351
nop // to align branch icount 1352
bnez r1, 28 // icount 1353
add r4, r6, r3 // icount 1354
nop // to align meminst icount 1355
andni r7, r7, 1 // icount 1356
stu r7, r7, 0 // icount 1357
xori r6, r3, 6 // icount 1358
slbi r6, 9 // icount 1359
addi r4, r2, 8 // icount 1360
subi r2, r4, 9 // icount 1361
sco r5, r1, r4 // icount 1362
xori r5, r2, 9 // icount 1363
sll r6, r0, r3 // icount 1364
add r6, r0, r3 // icount 1365
roli r6, r0, 4 // icount 1366
subi r7, r7, 11 // icount 1367
sle r6, r6, r5 // icount 1368
nop // to align meminst icount 1369
andni r7, r7, 1 // icount 1370
stu r5, r7, 14 // icount 1371
andn r3, r6, r5 // icount 1372
add r5, r3, r7 // icount 1373
rori r7, r1, 14 // icount 1374
roli r6, r4, 9 // icount 1375
ror r7, r7, r7 // icount 1376
sle r4, r4, r1 // icount 1377
xor r2, r3, r0 // icount 1378
sll r6, r3, r7 // icount 1379
subi r7, r4, 1 // icount 1380
sub r5, r6, r0 // icount 1381
slt r2, r2, r3 // icount 1382
addi r2, r7, 2 // icount 1383
xor r3, r3, r0 // icount 1384
nop // to align meminst icount 1385
sco r5, r1, r1 // icount 1386
nop // to align meminst icount 1387
ld r4, r1, -6 // icount 1388
nop // to align meminst icount 1389
ld r6, r1, 10 // icount 1390
nop // to align meminst icount 1391
ld r4, r1, -14 // icount 1392
nop // to align meminst icount 1393
st r3, r1, 6 // icount 1394
nop // to align meminst icount 1395
stu r3, r0, -4 // icount 1396
nop // to align meminst icount 1397
st r5, r0, 14 // icount 1398
nop // to align meminst icount 1399
stu r2, r0, 10 // icount 1400
nop // to align meminst icount 1401
ld r2, r1, 6 // icount 1402
nop // to align meminst icount 1403
ld r4, r1, -8 // icount 1404
nop // to align meminst icount 1405
ld r5, r0, 10 // icount 1406
nop // to align meminst icount 1407
ld r6, r0, -2 // icount 1408
nop // to align meminst icount 1409
stu r4, r0, 4 // icount 1410
nop // to align meminst icount 1411
stu r3, r0, -6 // icount 1412
nop // to align meminst icount 1413
ld r5, r1, 2 // icount 1414
nop // to align meminst icount 1415
stu r2, r1, -12 // icount 1416
nop // to align meminst icount 1417
stu r3, r1, -12 // icount 1418
nop // to align meminst icount 1419
stu r4, r0, 10 // icount 1420
nop // to align meminst icount 1421
stu r5, r0, -8 // icount 1422
nop // to align meminst icount 1423
stu r6, r1, 12 // icount 1424
nop // to align meminst icount 1425
stu r6, r0, 10 // icount 1426
nop // to align meminst icount 1427
stu r6, r0, 6 // icount 1428
nop // to align meminst icount 1429
ld r5, r0, -8 // icount 1430
nop // to align meminst icount 1431
stu r6, r1, -6 // icount 1432
nop // to align meminst icount 1433
stu r4, r0, 10 // icount 1434
nop // to align meminst icount 1435
ld r3, r1, 12 // icount 1436
nop // to align meminst icount 1437
stu r6, r0, 14 // icount 1438
nop // to align meminst icount 1439
ld r5, r0, -16 // icount 1440
nop // to align meminst icount 1441
st r2, r1, -6 // icount 1442
nop // to align meminst icount 1443
stu r2, r1, 12 // icount 1444
nop // to align meminst icount 1445
ld r6, r1, -4 // icount 1446
nop // to align meminst icount 1447
ld r6, r0, -12 // icount 1448
nop // to align meminst icount 1449
st r3, r1, 0 // icount 1450
nop // to align meminst icount 1451
stu r3, r0, 10 // icount 1452
nop // to align meminst icount 1453
ld r2, r1, 0 // icount 1454
nop // to align meminst icount 1455
ld r4, r1, -14 // icount 1456
nop // to align meminst icount 1457
ld r6, r1, -6 // icount 1458
nop // to align meminst icount 1459
ld r2, r1, 4 // icount 1460
nop // to align meminst icount 1461
ld r2, r0, -8 // icount 1462
nop // to align meminst icount 1463
ld r5, r1, -12 // icount 1464
nop // to align meminst icount 1465
ld r5, r0, 10 // icount 1466
nop // to align meminst icount 1467
ld r3, r0, 0 // icount 1468
nop // to align meminst icount 1469
stu r2, r1, -14 // icount 1470
nop // to align meminst icount 1471
stu r6, r0, 12 // icount 1472
nop // to align meminst icount 1473
stu r4, r0, -2 // icount 1474
nop // to align meminst icount 1475
ld r2, r0, 4 // icount 1476
nop // to align meminst icount 1477
ld r2, r0, 4 // icount 1478
nop // to align meminst icount 1479
stu r5, r0, 0 // icount 1480
nop // to align meminst icount 1481
ld r3, r1, -2 // icount 1482
nop // to align meminst icount 1483
stu r2, r1, 2 // icount 1484
nop // to align meminst icount 1485
stu r4, r0, 14 // icount 1486
nop // to align meminst icount 1487
stu r6, r0, 8 // icount 1488
st r6, r1, 12 // icount 1489
lbi r2, 0 // icount 1490
lbi r6, 0 // icount 1491
nop // to align branch icount 1492
bltz r4, 28 // icount 1493
andni r2, r2, 1 // icount 1494
st r6, r2, 8 // icount 1495
xori r4, r6, 13 // icount 1496
subi r7, r1, 6 // icount 1497
slt r3, r0, r5 // icount 1498
andn r2, r1, r5 // icount 1499
slt r6, r6, r4 // icount 1500
srli r2, r0, 12 // icount 1501
andni r4, r7, 12 // icount 1502
slt r4, r4, r4 // icount 1503
ror r2, r1, r1 // icount 1504
slt r6, r2, r6 // icount 1505
lbi r3, 15 // icount 1506
xor r7, r0, r3 // icount 1507
andni r6, r6, 1 // icount 1508
ld r7, r6, 12 // icount 1509
rori r6, r0, 9 // icount 1510
rori r2, r7, 8 // icount 1511
sll r5, r7, r7 // icount 1512
ror r2, r7, r3 // icount 1513
andni r3, r3, 1 // icount 1514
stu r4, r3, 10 // icount 1515
subi r6, r0, 13 // icount 1516
slt r2, r0, r1 // icount 1517
andni r0, r0, 1 // icount 1518
ld r3, r0, 14 // icount 1519
andni r2, r5, 5 // icount 1520
srl r7, r5, r2 // icount 1521
xor r2, r0, r6 // icount 1522
slli r2, r0, 5 // icount 1523
sco r3, r2, r2 // icount 1524
nop // to align meminst icount 1525
rol r4, r3, r1 // icount 1526
nop // to align meminst icount 1527
stu r5, r1, 0 // icount 1528
nop // to align meminst icount 1529
ld r6, r0, 8 // icount 1530
nop // to align meminst icount 1531
ld r2, r1, -12 // icount 1532
nop // to align meminst icount 1533
stu r2, r1, 14 // icount 1534
nop // to align meminst icount 1535
st r2, r1, 10 // icount 1536
nop // to align meminst icount 1537
stu r2, r1, 0 // icount 1538
nop // to align meminst icount 1539
ld r6, r0, 4 // icount 1540
nop // to align meminst icount 1541
stu r4, r0, -6 // icount 1542
nop // to align meminst icount 1543
ld r2, r0, -10 // icount 1544
nop // to align meminst icount 1545
stu r3, r0, 12 // icount 1546
nop // to align meminst icount 1547
st r3, r0, -16 // icount 1548
nop // to align meminst icount 1549
ld r4, r1, -8 // icount 1550
nop // to align meminst icount 1551
stu r4, r0, -2 // icount 1552
st r3, r0, -14 // icount 1553
sub r7, r6, r3 // icount 1554
nop // to align meminst icount 1555
st r5, r1, -10 // icount 1556
nop // to align meminst icount 1557
st r5, r1, -10 // icount 1558
nop // to align meminst icount 1559
ld r2, r0, -14 // icount 1560
nop // to align meminst icount 1561
st r4, r1, 2 // icount 1562
nop // to align meminst icount 1563
ld r5, r0, -4 // icount 1564
nop // to align meminst icount 1565
ld r4, r1, -2 // icount 1566
nop // to align meminst icount 1567
stu r4, r1, -10 // icount 1568
nop // to align meminst icount 1569
st r6, r1, 0 // icount 1570
nop // to align meminst icount 1571
ld r3, r1, -10 // icount 1572
nop // to align meminst icount 1573
st r5, r0, 14 // icount 1574
nop // to align meminst icount 1575
ld r4, r0, 6 // icount 1576
nop // to align meminst icount 1577
ld r2, r0, -14 // icount 1578
nop // to align meminst icount 1579
st r3, r0, 2 // icount 1580
nop // to align meminst icount 1581
ld r4, r0, 4 // icount 1582
nop // to align meminst icount 1583
ld r2, r1, 4 // icount 1584
nop // to align meminst icount 1585
st r5, r0, 2 // icount 1586
nop // to align meminst icount 1587
ld r4, r1, -16 // icount 1588
nop // to align meminst icount 1589
st r4, r0, 10 // icount 1590
nop // to align meminst icount 1591
ld r2, r0, -6 // icount 1592
nop // to align meminst icount 1593
stu r2, r1, -6 // icount 1594
nop // to align meminst icount 1595
ld r4, r1, -6 // icount 1596
nop // to align meminst icount 1597
ld r6, r0, 6 // icount 1598
nop // to align meminst icount 1599
ld r6, r0, 4 // icount 1600
nop // to align meminst icount 1601
st r6, r1, -2 // icount 1602
nop // to align meminst icount 1603
stu r2, r1, -2 // icount 1604
nop // to align meminst icount 1605
stu r2, r0, 10 // icount 1606
nop // to align meminst icount 1607
st r3, r0, -14 // icount 1608
st r4, r1, 10 // icount 1609
addi r1, r1, -12 // change base addr // icount 1610
nop // to align meminst icount 1611
stu r2, r1, -16 // icount 1612
nop // to align meminst icount 1613
stu r6, r1, 0 // icount 1614
nop // to align meminst icount 1615
ld r5, r1, 6 // icount 1616
nop // to align meminst icount 1617
stu r4, r1, -4 // icount 1618
nop // to align meminst icount 1619
ld r3, r0, 4 // icount 1620
nop // to align meminst icount 1621
ld r5, r1, 8 // icount 1622
nop // to align meminst icount 1623
ld r6, r1, 12 // icount 1624
nop // to align meminst icount 1625
ld r4, r0, 2 // icount 1626
nop // to align meminst icount 1627
ld r3, r1, 14 // icount 1628
nop // to align meminst icount 1629
stu r2, r1, -8 // icount 1630
nop // to align meminst icount 1631
ld r3, r1, -10 // icount 1632
nop // to align meminst icount 1633
stu r6, r0, 2 // icount 1634
nop // to align meminst icount 1635
st r3, r1, -10 // icount 1636
nop // to align meminst icount 1637
st r5, r1, 8 // icount 1638
nop // to align meminst icount 1639
ld r2, r0, 14 // icount 1640
nop // to align meminst icount 1641
stu r6, r1, 12 // icount 1642
nop // to align meminst icount 1643
ld r5, r0, -8 // icount 1644
nop // to align meminst icount 1645
stu r4, r1, -12 // icount 1646
nop // to align meminst icount 1647
ld r2, r0, -4 // icount 1648
nop // to align meminst icount 1649
ld r4, r0, -6 // icount 1650
nop // to align meminst icount 1651
stu r2, r1, -6 // icount 1652
nop // to align meminst icount 1653
ld r6, r1, 0 // icount 1654
nop // to align meminst icount 1655
ld r6, r1, -14 // icount 1656
nop // to align meminst icount 1657
stu r6, r1, -2 // icount 1658
nop // to align meminst icount 1659
stu r4, r1, -10 // icount 1660
nop // to align meminst icount 1661
ld r4, r0, 12 // icount 1662
nop // to align meminst icount 1663
ld r5, r1, 8 // icount 1664
nop // to align meminst icount 1665
ld r4, r0, 12 // icount 1666
nop // to align meminst icount 1667
stu r3, r0, 0 // icount 1668
nop // to align meminst icount 1669
stu r4, r1, 10 // icount 1670
nop // to align meminst icount 1671
ld r2, r0, -14 // icount 1672
nop // to align meminst icount 1673
stu r2, r0, -12 // icount 1674
nop // to align meminst icount 1675
st r5, r0, -14 // icount 1676
nop // to align meminst icount 1677
stu r4, r1, -6 // icount 1678
nop // to align meminst icount 1679
ld r2, r1, -12 // icount 1680
nop // to align meminst icount 1681
st r3, r1, -6 // icount 1682
nop // to align meminst icount 1683
stu r4, r0, 0 // icount 1684
nop // to align meminst icount 1685
ld r4, r0, -4 // icount 1686
nop // to align meminst icount 1687
ld r4, r1, 14 // icount 1688
nop // to align meminst icount 1689
ld r6, r1, 10 // icount 1690
nop // to align meminst icount 1691
stu r4, r0, 2 // icount 1692
nop // to align meminst icount 1693
ld r2, r0, 8 // icount 1694
nop // to align meminst icount 1695
st r2, r1, 10 // icount 1696
nop // to align meminst icount 1697
ld r6, r0, -6 // icount 1698
nop // to align meminst icount 1699
ld r6, r1, -12 // icount 1700
nop // to align meminst icount 1701
ld r5, r1, -8 // icount 1702
nop // to align meminst icount 1703
ld r3, r1, 10 // icount 1704
ld r5, r1, -8 // icount 1705
lbi r4, 0 // icount 1706
lbi r4, 0 // icount 1707
nop // to align branch icount 1708
beqz r1, 20 // icount 1709
andni r3, r3, 1 // icount 1710
stu r7, r3, 14 // icount 1711
rol r6, r3, r2 // icount 1712
slbi r4, 7 // icount 1713
ror r3, r0, r4 // icount 1714
slt r5, r4, r4 // icount 1715
add r3, r7, r4 // icount 1716
srl r7, r6, r7 // icount 1717
sco r5, r7, r3 // icount 1718
add r6, r3, r7 // icount 1719
xori r6, r0, 5 // icount 1720
rori r4, r4, 7 // icount 1721
subi r5, r7, 5 // icount 1722
slbi r3, 14 // icount 1723
sub r4, r7, r0 // icount 1724
ror r6, r7, r4 // icount 1725
rol r6, r7, r5 // icount 1726
subi r7, r4, 5 // icount 1727
andni r7, r4, 13 // icount 1728
xori r4, r0, 13 // icount 1729
addi r6, r4, 11 // icount 1730
nop // to align meminst icount 1731
ld r4, r0, 0 // icount 1732
nop // to align meminst icount 1733
ld r3, r1, -16 // icount 1734
nop // to align meminst icount 1735
ld r6, r1, -10 // icount 1736
nop // to align meminst icount 1737
stu r2, r0, -14 // icount 1738
nop // to align meminst icount 1739
stu r6, r1, -12 // icount 1740
nop // to align meminst icount 1741
stu r4, r1, -2 // icount 1742
nop // to align meminst icount 1743
ld r4, r0, 8 // icount 1744
nop // to align meminst icount 1745
ld r5, r0, 6 // icount 1746
nop // to align meminst icount 1747
st r4, r0, -12 // icount 1748
nop // to align meminst icount 1749
st r5, r0, -2 // icount 1750
nop // to align meminst icount 1751
stu r4, r0, 8 // icount 1752
nop // to align meminst icount 1753
ld r2, r0, 6 // icount 1754
nop // to align meminst icount 1755
ld r3, r0, 12 // icount 1756
nop // to align meminst icount 1757
stu r5, r1, 12 // icount 1758
nop // to align meminst icount 1759
st r5, r1, 6 // icount 1760
nop // to align meminst icount 1761
stu r2, r1, 4 // icount 1762
nop // to align meminst icount 1763
ld r6, r1, -8 // icount 1764
nop // to align meminst icount 1765
stu r2, r1, -10 // icount 1766
nop // to align meminst icount 1767
ld r6, r0, -2 // icount 1768
nop // to align meminst icount 1769
ld r5, r0, 8 // icount 1770
nop // to align meminst icount 1771
stu r6, r1, 4 // icount 1772
nop // to align meminst icount 1773
ld r3, r0, 2 // icount 1774
nop // to align meminst icount 1775
st r5, r0, 12 // icount 1776
nop // to align meminst icount 1777
ld r4, r0, -16 // icount 1778
nop // to align meminst icount 1779
ld r3, r1, 0 // icount 1780
nop // to align meminst icount 1781
ld r5, r0, 2 // icount 1782
nop // to align meminst icount 1783
st r2, r0, 2 // icount 1784
nop // to align meminst icount 1785
ld r4, r1, -2 // icount 1786
nop // to align meminst icount 1787
stu r6, r0, -8 // icount 1788
nop // to align meminst icount 1789
stu r5, r0, -8 // icount 1790
nop // to align meminst icount 1791
st r6, r1, 6 // icount 1792
nop // to align meminst icount 1793
ld r3, r0, 10 // icount 1794
nop // to align meminst icount 1795
ld r4, r0, 12 // icount 1796
nop // to align meminst icount 1797
stu r2, r1, 12 // icount 1798
nop // to align meminst icount 1799
stu r3, r0, -10 // icount 1800
st r2, r0, -14 // icount 1801
srl r4, r6, r0 // icount 1802
nop // to align meminst icount 1803
st r3, r1, 4 // icount 1804
nop // to align meminst icount 1805
stu r4, r1, 12 // icount 1806
nop // to align meminst icount 1807
ld r5, r0, 0 // icount 1808
nop // to align meminst icount 1809
ld r2, r1, 12 // icount 1810
nop // to align meminst icount 1811
stu r4, r1, -10 // icount 1812
nop // to align meminst icount 1813
ld r3, r0, 4 // icount 1814
nop // to align meminst icount 1815
st r3, r0, -6 // icount 1816
nop // to align meminst icount 1817
ld r3, r1, -2 // icount 1818
nop // to align meminst icount 1819
ld r3, r0, -10 // icount 1820
nop // to align meminst icount 1821
ld r2, r0, -6 // icount 1822
nop // to align meminst icount 1823
st r2, r1, 0 // icount 1824
nop // to align meminst icount 1825
stu r2, r1, -6 // icount 1826
nop // to align meminst icount 1827
st r4, r0, 8 // icount 1828
nop // to align meminst icount 1829
st r6, r0, -4 // icount 1830
ld r6, r0, -4 // icount 1831
slli r5, r1, 8 // icount 1832
nop // to align meminst icount 1833
ld r3, r1, -10 // icount 1834
nop // to align meminst icount 1835
ld r6, r1, -4 // icount 1836
nop // to align meminst icount 1837
stu r5, r0, 14 // icount 1838
nop // to align meminst icount 1839
st r3, r1, -4 // icount 1840
nop // to align meminst icount 1841
ld r6, r1, -12 // icount 1842
nop // to align meminst icount 1843
ld r5, r0, -6 // icount 1844
nop // to align meminst icount 1845
st r5, r1, -6 // icount 1846
nop // to align meminst icount 1847
ld r6, r1, 8 // icount 1848
nop // to align meminst icount 1849
ld r2, r1, -8 // icount 1850
nop // to align meminst icount 1851
ld r3, r1, 2 // icount 1852
nop // to align meminst icount 1853
ld r5, r0, -12 // icount 1854
nop // to align meminst icount 1855
ld r4, r1, -16 // icount 1856
nop // to align meminst icount 1857
ld r6, r0, -16 // icount 1858
nop // to align meminst icount 1859
stu r6, r1, 14 // icount 1860
nop // to align meminst icount 1861
ld r4, r1, -14 // icount 1862
nop // to align meminst icount 1863
st r4, r0, -16 // icount 1864
nop // to align meminst icount 1865
ld r2, r1, -2 // icount 1866
nop // to align meminst icount 1867
ld r3, r0, 0 // icount 1868
nop // to align meminst icount 1869
ld r3, r0, 12 // icount 1870
nop // to align meminst icount 1871
stu r3, r0, -4 // icount 1872
nop // to align meminst icount 1873
stu r4, r1, -16 // icount 1874
st r2, r1, 4 // icount 1875
slbi r2, 5 // icount 1876
nop // to align meminst icount 1877
st r4, r1, 0 // icount 1878
stu r3, r0, 12 // icount 1879
srl r6, r3, r0 // icount 1880
lbi r2, 0 // icount 1881
lbi r2, 0 // icount 1882
beqz r3, 32 // icount 1883
ror r4, r2, r5 // icount 1884
xori r5, r2, 10 // icount 1885
sll r7, r5, r1 // icount 1886
add r4, r7, r7 // icount 1887
seq r7, r4, r4 // icount 1888
nop // to align meminst icount 1889
andni r7, r7, 1 // icount 1890
ld r4, r7, 6 // icount 1891
sub r3, r7, r1 // icount 1892
rori r4, r5, 8 // icount 1893
andn r7, r6, r3 // icount 1894
nop // to align meminst icount 1895
andni r7, r7, 1 // icount 1896
stu r5, r7, 2 // icount 1897
lbi r5, 12 // icount 1898
lbi r4, 2 // icount 1899
add r3, r7, r6 // icount 1900
srl r6, r1, r3 // icount 1901
andni r7, r7, 1 // icount 1902
ld r4, r7, 10 // icount 1903
andni r6, r6, 1 // icount 1904
st r5, r6, 14 // icount 1905
sco r6, r5, r4 // icount 1906
roli r4, r1, 1 // icount 1907
sle r2, r4, r6 // icount 1908
sco r2, r5, r4 // icount 1909
ror r7, r2, r3 // icount 1910
srli r6, r0, 8 // icount 1911
sco r7, r3, r5 // icount 1912
rol r5, r6, r0 // icount 1913
andn r3, r4, r3 // icount 1914
nop // to align meminst icount 1915
andni r6, r6, 1 // icount 1916
ld r4, r6, 12 // icount 1917
ror r6, r3, r3 // icount 1918
andn r2, r3, r0 // icount 1919
lbi r3, 1 // icount 1920
lbi r3, 9 // icount 1921
seq r6, r7, r5 // icount 1922
nop // to align meminst icount 1923
sll r7, r0, r4 // icount 1924
nop // to align meminst icount 1925
st r2, r0, 6 // icount 1926
nop // to align meminst icount 1927
stu r4, r1, -4 // icount 1928
nop // to align meminst icount 1929
st r6, r1, 8 // icount 1930
nop // to align meminst icount 1931
st r2, r0, -14 // icount 1932
nop // to align meminst icount 1933
ld r2, r1, 8 // icount 1934
nop // to align meminst icount 1935
st r2, r0, -4 // icount 1936
nop // to align meminst icount 1937
st r6, r0, -4 // icount 1938
nop // to align meminst icount 1939
ld r3, r1, -4 // icount 1940
nop // to align meminst icount 1941
ld r2, r0, 2 // icount 1942
st r5, r0, -14 // icount 1943
srli r7, r1, 6 // icount 1944
nop // to align meminst icount 1945
ld r2, r0, -12 // icount 1946
nop // to align meminst icount 1947
stu r2, r0, 12 // icount 1948
nop // to align meminst icount 1949
ld r4, r1, 12 // icount 1950
nop // to align meminst icount 1951
stu r3, r0, -8 // icount 1952
nop // to align meminst icount 1953
ld r5, r1, -6 // icount 1954
st r2, r1, -10 // icount 1955
sle r4, r4, r6 // icount 1956
nop // to align meminst icount 1957
ld r6, r1, -10 // icount 1958
nop // to align meminst icount 1959
ld r4, r0, -14 // icount 1960
ld r2, r1, 10 // icount 1961
slbi r6, 11 // icount 1962
nop // to align meminst icount 1963
stu r2, r0, 4 // icount 1964
nop // to align meminst icount 1965
stu r6, r1, 8 // icount 1966
nop // to align meminst icount 1967
ld r5, r1, 6 // icount 1968
nop // to align meminst icount 1969
st r2, r0, 2 // icount 1970
nop // to align meminst icount 1971
st r2, r1, -2 // icount 1972
nop // to align meminst icount 1973
ld r5, r0, 12 // icount 1974
nop // to align meminst icount 1975
ld r2, r0, -2 // icount 1976
nop // to align meminst icount 1977
stu r2, r0, 12 // icount 1978
nop // to align meminst icount 1979
ld r6, r0, 8 // icount 1980
nop // to align meminst icount 1981
ld r6, r0, -2 // icount 1982
nop // to align meminst icount 1983
st r4, r0, -16 // icount 1984
nop // to align meminst icount 1985
ld r2, r1, -6 // icount 1986
nop // to align meminst icount 1987
ld r3, r1, 0 // icount 1988
nop // to align meminst icount 1989
ld r6, r0, -14 // icount 1990
nop // to align meminst icount 1991
ld r5, r1, 14 // icount 1992
nop // to align meminst icount 1993
ld r6, r1, -8 // icount 1994
nop // to align meminst icount 1995
stu r6, r0, 12 // icount 1996
nop // to align meminst icount 1997
st r3, r1, -4 // icount 1998
nop // to align meminst icount 1999
st r3, r0, -10 // icount 2000
nop // to align meminst icount 2001
ld r3, r1, -14 // icount 2002
nop // to align meminst icount 2003
st r4, r1, 10 // icount 2004
nop // to align meminst icount 2005
ld r6, r0, 12 // icount 2006
ld r6, r0, 12 // icount 2007
andn r7, r3, r1 // icount 2008
nop // to align meminst icount 2009
stu r4, r1, -16 // icount 2010
nop // to align meminst icount 2011
ld r4, r0, 2 // icount 2012
nop // to align meminst icount 2013
ld r3, r1, -14 // icount 2014
nop // to align meminst icount 2015
ld r5, r0, -14 // icount 2016
nop // to align meminst icount 2017
ld r2, r0, -16 // icount 2018
nop // to align meminst icount 2019
ld r5, r0, 10 // icount 2020
nop // to align meminst icount 2021
stu r2, r1, 6 // icount 2022
nop // to align meminst icount 2023
stu r5, r0, 6 // icount 2024
nop // to align meminst icount 2025
ld r5, r1, -14 // icount 2026
nop // to align meminst icount 2027
stu r4, r0, -8 // icount 2028
nop // to align meminst icount 2029
ld r5, r1, 4 // icount 2030
nop // to align meminst icount 2031
st r3, r1, -14 // icount 2032
nop // to align meminst icount 2033
stu r4, r0, -2 // icount 2034
nop // to align meminst icount 2035
stu r2, r1, 0 // icount 2036
nop // to align meminst icount 2037
ld r4, r1, 14 // icount 2038
nop // to align meminst icount 2039
ld r6, r1, -16 // icount 2040
nop // to align meminst icount 2041
st r2, r0, 14 // icount 2042
nop // to align meminst icount 2043
ld r2, r0, 4 // icount 2044
nop // to align meminst icount 2045
st r2, r0, -2 // icount 2046
nop // to align meminst icount 2047
st r5, r1, 0 // icount 2048
nop // to align meminst icount 2049
stu r2, r1, 12 // icount 2050
nop // to align meminst icount 2051
ld r6, r0, -10 // icount 2052
nop // to align meminst icount 2053
ld r4, r1, 2 // icount 2054
nop // to align meminst icount 2055
st r5, r1, 2 // icount 2056
nop // to align meminst icount 2057
stu r3, r0, -10 // icount 2058
nop // to align meminst icount 2059
stu r5, r1, -8 // icount 2060
nop // to align meminst icount 2061
st r2, r0, -16 // icount 2062
nop // to align meminst icount 2063
stu r5, r0, 12 // icount 2064
nop // to align meminst icount 2065
st r4, r0, 8 // icount 2066
nop // to align meminst icount 2067
ld r4, r1, 6 // icount 2068
nop // to align meminst icount 2069
st r3, r1, 4 // icount 2070
nop // to align meminst icount 2071
ld r3, r1, -16 // icount 2072
nop // to align meminst icount 2073
ld r2, r0, 2 // icount 2074
nop // to align meminst icount 2075
ld r4, r0, 2 // icount 2076
nop // to align meminst icount 2077
stu r5, r0, 12 // icount 2078
nop // to align meminst icount 2079
ld r3, r0, 12 // icount 2080
nop // to align meminst icount 2081
st r2, r0, 10 // icount 2082
nop // to align meminst icount 2083
st r4, r1, 4 // icount 2084
nop // to align meminst icount 2085
st r4, r0, -14 // icount 2086
st r4, r0, -14 // icount 2087
rol r6, r2, r2 // icount 2088
nop // to align meminst icount 2089
st r5, r1, -12 // icount 2090
nop // to align meminst icount 2091
ld r6, r1, 10 // icount 2092
nop // to align meminst icount 2093
st r4, r1, 6 // icount 2094
nop // to align meminst icount 2095
ld r2, r1, 8 // icount 2096
nop // to align meminst icount 2097
st r5, r1, -10 // icount 2098
nop // to align meminst icount 2099
ld r6, r0, 14 // icount 2100
nop // to align meminst icount 2101
st r6, r0, 6 // icount 2102
nop // to align meminst icount 2103
ld r5, r0, -14 // icount 2104
nop // to align meminst icount 2105
ld r2, r1, 8 // icount 2106
nop // to align meminst icount 2107
ld r6, r1, -16 // icount 2108
nop // to align meminst icount 2109
ld r3, r1, 2 // icount 2110
nop // to align meminst icount 2111
stu r5, r0, 2 // icount 2112
nop // to align meminst icount 2113
ld r4, r1, 8 // icount 2114
nop // to align meminst icount 2115
stu r6, r1, 8 // icount 2116
nop // to align meminst icount 2117
stu r5, r1, 12 // icount 2118
nop // to align meminst icount 2119
stu r2, r1, 8 // icount 2120
nop // to align meminst icount 2121
st r6, r1, -6 // icount 2122
nop // to align meminst icount 2123
ld r4, r1, 14 // icount 2124
nop // to align meminst icount 2125
stu r5, r0, 10 // icount 2126
nop // to align meminst icount 2127
ld r3, r0, 4 // icount 2128
nop // to align meminst icount 2129
ld r5, r0, 0 // icount 2130
nop // to align meminst icount 2131
st r3, r0, 14 // icount 2132
ld r2, r1, 0 // icount 2133
lbi r6, 0 // icount 2134
lbi r3, 0 // icount 2135
nop // to align branch icount 2136
bnez r1, 8 // icount 2137
xori r3, r5, 3 // icount 2138
xor r2, r2, r4 // icount 2139
ror r2, r6, r7 // icount 2140
slbi r4, 8 // icount 2141
slli r6, r5, 2 // icount 2142
addi r4, r2, 6 // icount 2143
slli r3, r2, 10 // icount 2144
nop // to align meminst icount 2145
ror r3, r5, r7 // icount 2146
nop // to align meminst icount 2147
st r5, r0, -12 // icount 2148
nop // to align meminst icount 2149
st r4, r0, 6 // icount 2150
nop // to align meminst icount 2151
ld r3, r0, -2 // icount 2152
nop // to align meminst icount 2153
st r2, r1, -12 // icount 2154
nop // to align meminst icount 2155
ld r4, r0, -2 // icount 2156
nop // to align meminst icount 2157
st r4, r0, -8 // icount 2158
nop // to align meminst icount 2159
ld r2, r0, 14 // icount 2160
nop // to align meminst icount 2161
ld r3, r1, -12 // icount 2162
nop // to align meminst icount 2163
stu r6, r1, 10 // icount 2164
nop // to align meminst icount 2165
ld r3, r1, 14 // icount 2166
nop // to align meminst icount 2167
ld r4, r1, -14 // icount 2168
nop // to align meminst icount 2169
ld r4, r0, -10 // icount 2170
nop // to align meminst icount 2171
stu r5, r1, 12 // icount 2172
nop // to align meminst icount 2173
ld r4, r0, -16 // icount 2174
nop // to align meminst icount 2175
stu r6, r1, -8 // icount 2176
nop // to align meminst icount 2177
stu r2, r0, 12 // icount 2178
nop // to align meminst icount 2179
ld r6, r1, -2 // icount 2180
nop // to align meminst icount 2181
ld r6, r1, 12 // icount 2182
nop // to align meminst icount 2183
ld r6, r0, -14 // icount 2184
nop // to align meminst icount 2185
stu r4, r0, 0 // icount 2186
nop // to align meminst icount 2187
ld r2, r0, 12 // icount 2188
nop // to align meminst icount 2189
ld r5, r1, -10 // icount 2190
nop // to align meminst icount 2191
ld r2, r1, 14 // icount 2192
nop // to align meminst icount 2193
ld r6, r1, -10 // icount 2194
nop // to align meminst icount 2195
ld r5, r1, -10 // icount 2196
nop // to align meminst icount 2197
st r4, r0, 0 // icount 2198
nop // to align meminst icount 2199
ld r6, r1, -2 // icount 2200
nop // to align meminst icount 2201
stu r2, r0, 4 // icount 2202
nop // to align meminst icount 2203
ld r5, r0, -6 // icount 2204
nop // to align meminst icount 2205
ld r5, r0, 4 // icount 2206
nop // to align meminst icount 2207
stu r2, r1, 10 // icount 2208
nop // to align meminst icount 2209
ld r5, r1, -10 // icount 2210
nop // to align meminst icount 2211
st r5, r0, 12 // icount 2212
nop // to align meminst icount 2213
st r4, r1, 0 // icount 2214
nop // to align meminst icount 2215
ld r6, r0, -12 // icount 2216
nop // to align meminst icount 2217
ld r2, r0, 14 // icount 2218
nop // to align meminst icount 2219
stu r6, r1, 0 // icount 2220
nop // to align meminst icount 2221
ld r5, r0, -14 // icount 2222
st r4, r0, -8 // icount 2223
lbi r7, 0 // icount 2224
lbi r2, 0 // icount 2225
nop // to align branch icount 2226
bnez r0, 28 // icount 2227
sll r6, r0, r3 // icount 2228
subi r5, r0, 11 // icount 2229
andni r7, r7, 1 // icount 2230
stu r7, r7, 6 // icount 2231
slt r6, r3, r4 // icount 2232
xor r4, r6, r3 // icount 2233
slt r6, r3, r5 // icount 2234
andni r5, r1, 10 // icount 2235
srl r5, r6, r4 // icount 2236
ror r6, r6, r6 // icount 2237
andni r5, r2, 14 // icount 2238
andn r2, r0, r6 // icount 2239
srli r7, r0, 14 // icount 2240
addi r4, r7, 4 // icount 2241
srl r2, r0, r7 // icount 2242
andn r4, r6, r2 // icount 2243
sle r6, r6, r3 // icount 2244
andn r7, r1, r6 // icount 2245
seq r5, r5, r3 // icount 2246
andn r5, r6, r5 // icount 2247
andn r2, r4, r3 // icount 2248
srli r6, r2, 13 // icount 2249
sll r6, r4, r7 // icount 2250
andn r6, r1, r4 // icount 2251
slli r4, r6, 14 // icount 2252
sle r5, r0, r0 // icount 2253
andni r7, r7, 1 // icount 2254
stu r2, r7, 2 // icount 2255
xori r5, r4, 2 // icount 2256
slli r3, r0, 1 // icount 2257
lbi r2, 0 // icount 2258
lbi r5, 0 // icount 2259
nop // to align branch icount 2260
bgez r0, 16 // icount 2261
lbi r7, 3 // icount 2262
slli r4, r5, 7 // icount 2263
subi r7, r0, 9 // icount 2264
sub r5, r2, r0 // icount 2265
slbi r7, 2 // icount 2266
addi r7, r0, 11 // icount 2267
andni r0, r0, 1 // icount 2268
stu r7, r0, 4 // icount 2269
srli r6, r5, 2 // icount 2270
srli r4, r0, 10 // icount 2271
lbi r3, 8 // icount 2272
andn r6, r0, r1 // icount 2273
sll r7, r0, r6 // icount 2274
andni r6, r5, 15 // icount 2275
seq r5, r0, r2 // icount 2276
rol r2, r3, r5 // icount 2277
add r6, r6, r3 // icount 2278
nop // to align meminst icount 2279
st r6, r0, 2 // icount 2280
nop // to align meminst icount 2281
ld r6, r0, 12 // icount 2282
nop // to align meminst icount 2283
stu r4, r1, -12 // icount 2284
nop // to align meminst icount 2285
ld r5, r1, -12 // icount 2286
nop // to align meminst icount 2287
ld r4, r1, 4 // icount 2288
nop // to align meminst icount 2289
ld r5, r0, 4 // icount 2290
nop // to align meminst icount 2291
ld r6, r0, 10 // icount 2292
nop // to align meminst icount 2293
st r2, r0, -8 // icount 2294
nop // to align meminst icount 2295
ld r2, r0, 14 // icount 2296
nop // to align meminst icount 2297
ld r3, r0, 2 // icount 2298
nop // to align meminst icount 2299
ld r5, r1, 6 // icount 2300
nop // to align meminst icount 2301
stu r5, r0, 8 // icount 2302
nop // to align meminst icount 2303
ld r3, r1, 6 // icount 2304
nop // to align meminst icount 2305
ld r4, r0, -10 // icount 2306
nop // to align meminst icount 2307
ld r2, r1, -16 // icount 2308
nop // to align meminst icount 2309
ld r6, r1, 4 // icount 2310
nop // to align meminst icount 2311
ld r6, r0, 8 // icount 2312
nop // to align meminst icount 2313
ld r6, r1, 2 // icount 2314
nop // to align meminst icount 2315
stu r2, r1, -16 // icount 2316
nop // to align meminst icount 2317
stu r2, r1, 4 // icount 2318
stu r4, r1, -14 // icount 2319
lbi r5, 0 // icount 2320
lbi r6, 0 // icount 2321
nop // to align branch icount 2322
bltz r3, 8 // icount 2323
rol r2, r2, r5 // icount 2324
sle r6, r5, r5 // icount 2325
sco r4, r2, r0 // icount 2326
sub r2, r1, r2 // icount 2327
slt r7, r1, r1 // icount 2328
nop // to align meminst icount 2329
andni r6, r6, 1 // icount 2330
ld r4, r6, 12 // icount 2331
sle r6, r4, r0 // icount 2332
nop // to align meminst icount 2333
srl r7, r4, r1 // icount 2334
nop // to align meminst icount 2335
ld r2, r0, -12 // icount 2336
nop // to align meminst icount 2337
ld r3, r1, -14 // icount 2338
nop // to align meminst icount 2339
ld r6, r1, -8 // icount 2340
nop // to align meminst icount 2341
ld r3, r1, 2 // icount 2342
nop // to align meminst icount 2343
ld r6, r0, 6 // icount 2344
nop // to align meminst icount 2345
ld r2, r1, 0 // icount 2346
nop // to align meminst icount 2347
ld r6, r0, 12 // icount 2348
nop // to align meminst icount 2349
st r4, r0, -16 // icount 2350
stu r5, r0, 2 // icount 2351
addi r1, r1, -14 // change base addr // icount 2352
nop // to align meminst icount 2353
st r6, r1, 0 // icount 2354
nop // to align meminst icount 2355
ld r5, r1, 8 // icount 2356
nop // to align meminst icount 2357
st r3, r0, -16 // icount 2358
nop // to align meminst icount 2359
ld r4, r1, 10 // icount 2360
nop // to align meminst icount 2361
st r3, r1, 12 // icount 2362
nop // to align meminst icount 2363
ld r3, r0, -16 // icount 2364
nop // to align meminst icount 2365
ld r5, r1, 10 // icount 2366
nop // to align meminst icount 2367
stu r5, r0, 4 // icount 2368
nop // to align meminst icount 2369
ld r6, r0, 0 // icount 2370
nop // to align meminst icount 2371
st r6, r1, -16 // icount 2372
nop // to align meminst icount 2373
ld r6, r0, 0 // icount 2374
nop // to align meminst icount 2375
ld r4, r1, 10 // icount 2376
nop // to align meminst icount 2377
ld r4, r1, -8 // icount 2378
nop // to align meminst icount 2379
ld r5, r1, -6 // icount 2380
nop // to align meminst icount 2381
stu r5, r1, -4 // icount 2382
nop // to align meminst icount 2383
stu r2, r1, -8 // icount 2384
nop // to align meminst icount 2385
ld r2, r0, -4 // icount 2386
nop // to align meminst icount 2387
st r3, r0, -14 // icount 2388
nop // to align meminst icount 2389
ld r3, r1, 0 // icount 2390
nop // to align meminst icount 2391
ld r5, r0, -8 // icount 2392
nop // to align meminst icount 2393
stu r5, r1, -10 // icount 2394
nop // to align meminst icount 2395
ld r6, r0, -6 // icount 2396
nop // to align meminst icount 2397
ld r3, r0, 8 // icount 2398
nop // to align meminst icount 2399
stu r6, r1, 12 // icount 2400
nop // to align meminst icount 2401
st r2, r1, 0 // icount 2402
nop // to align meminst icount 2403
ld r5, r0, 0 // icount 2404
nop // to align meminst icount 2405
ld r6, r1, -12 // icount 2406
nop // to align meminst icount 2407
st r5, r1, 10 // icount 2408
nop // to align meminst icount 2409
ld r2, r0, -14 // icount 2410
nop // to align meminst icount 2411
ld r4, r0, 2 // icount 2412
nop // to align meminst icount 2413
stu r2, r1, -6 // icount 2414
nop // to align meminst icount 2415
st r6, r0, -2 // icount 2416
nop // to align meminst icount 2417
ld r6, r0, -16 // icount 2418
st r3, r0, 8 // icount 2419
halt // icount 2420
|
/*
* Copyright (c) 2019-2020, Andrew Kaster <andrewdkaster@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/StringBuilder.h>
#include <LibELF/DynamicLoader.h>
#include <LibELF/Validation.h>
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#define DYNAMIC_LOAD_DEBUG
//#define DYNAMIC_LOAD_VERBOSE
#ifdef DYNAMIC_LOAD_VERBOSE
# define VERBOSE(fmt, ...) dbgprintf(fmt, ##__VA_ARGS__)
#else
# define VERBOSE(fmt, ...) \
do { \
} while (0)
#endif
#ifndef __serenity__
static void* mmap_with_name(void* addr, size_t length, int prot, int flags, int fd, off_t offset, const char*)
{
return mmap(addr, length, prot, flags, fd, offset);
}
#endif
namespace ELF {
static bool s_always_bind_now = false;
NonnullRefPtr<DynamicLoader> DynamicLoader::construct(const char* filename, int fd, size_t size)
{
return adopt(*new DynamicLoader(filename, fd, size));
}
DynamicLoader::DynamicLoader(const char* filename, int fd, size_t size)
: m_filename(filename)
, m_file_size(size)
, m_image_fd(fd)
{
if (m_file_size < sizeof(Elf32_Ehdr)) {
m_valid = false;
return;
}
String file_mmap_name = String::format("ELF_DYN: %s", m_filename.characters());
m_file_mapping = mmap_with_name(nullptr, m_file_size, PROT_READ, MAP_PRIVATE, m_image_fd, 0, file_mmap_name.characters());
if (MAP_FAILED == m_file_mapping) {
m_valid = false;
return;
}
auto* elf_header = (Elf32_Ehdr*)m_file_mapping;
if (!validate_elf_header(*elf_header, m_file_size) ||
!validate_program_headers(*elf_header, m_file_size, (u8*)m_file_mapping, m_file_size, m_program_interpreter)) {
m_valid = false;
}
}
DynamicLoader::~DynamicLoader()
{
if (MAP_FAILED != m_file_mapping)
munmap(m_file_mapping, m_file_size);
}
void* DynamicLoader::symbol_for_name(const char* name)
{
auto symbol = m_dynamic_object->hash_section().lookup_symbol(name);
if (symbol.is_undefined())
return nullptr;
return m_dynamic_object->base_address().offset(symbol.value()).as_ptr();
}
bool DynamicLoader::load_from_image(unsigned flags)
{
Image elf_image((u8*)m_file_mapping, m_file_size);
m_valid = elf_image.is_valid() && elf_image.is_dynamic();
if (!m_valid) {
return false;
}
#ifdef DYNAMIC_LOAD_VERBOSE
m_image->dump();
#endif
load_program_headers(elf_image);
// Don't need this private mapping anymore
munmap(m_file_mapping, m_file_size);
m_file_mapping = MAP_FAILED;
m_dynamic_object = AK::make<DynamicObject>(m_text_segment_load_address, m_dynamic_section_address);
return load_stage_2(flags);
}
bool DynamicLoader::load_stage_2(unsigned flags)
{
ASSERT(flags & RTLD_GLOBAL);
ASSERT(flags & RTLD_LAZY);
#ifdef DYNAMIC_LOAD_DEBUG
m_dynamic_object->dump();
#endif
if (m_dynamic_object->has_text_relocations()) {
dbg() << "Someone linked non -fPIC code into " << m_filename << " :(";
ASSERT(m_text_segment_load_address.get() != 0);
if (0 > mprotect(m_text_segment_load_address.as_ptr(), m_text_segment_size, PROT_READ | PROT_WRITE)) {
perror("mprotect .text: PROT_READ | PROT_WRITE"); // FIXME: dlerror?
return false;
}
}
do_relocations();
setup_plt_trampoline();
// Clean up our setting of .text to PROT_READ | PROT_WRITE
if (m_dynamic_object->has_text_relocations()) {
if (0 > mprotect(m_text_segment_load_address.as_ptr(), m_text_segment_size, PROT_READ | PROT_EXEC)) {
perror("mprotect .text: PROT_READ | PROT_EXEC"); // FIXME: dlerror?
return false;
}
}
call_object_init_functions();
#ifdef DYNAMIC_LOAD_DEBUG
dbgprintf("Loaded %s\n", m_filename.characters());
#endif
return true;
}
void DynamicLoader::load_program_headers(const Image& elf_image)
{
Vector<ProgramHeaderRegion> program_headers;
ProgramHeaderRegion* text_region_ptr = nullptr;
ProgramHeaderRegion* data_region_ptr = nullptr;
ProgramHeaderRegion* tls_region_ptr = nullptr;
VirtualAddress dynamic_region_desired_vaddr;
elf_image.for_each_program_header([&](const Image::ProgramHeader& program_header) {
ProgramHeaderRegion new_region;
new_region.set_program_header(program_header.raw_header());
program_headers.append(move(new_region));
auto& region = program_headers.last();
if (region.is_tls_template())
tls_region_ptr = ®ion;
else if (region.is_load()) {
if (region.is_executable())
text_region_ptr = ®ion;
else
data_region_ptr = ®ion;
} else if (region.is_dynamic()) {
dynamic_region_desired_vaddr = region.desired_load_address();
}
});
ASSERT(text_region_ptr && data_region_ptr);
// Process regions in order: .text, .data, .tls
auto* region = text_region_ptr;
void* text_segment_begin = mmap_with_name(nullptr, region->required_load_size(), region->mmap_prot(), MAP_PRIVATE, m_image_fd, region->offset(), String::format(".text: %s", m_filename.characters()).characters());
if (MAP_FAILED == text_segment_begin) {
ASSERT_NOT_REACHED();
}
m_text_segment_size = region->required_load_size();
m_text_segment_load_address = VirtualAddress { (FlatPtr)text_segment_begin };
m_dynamic_section_address = dynamic_region_desired_vaddr.offset(m_text_segment_load_address.get());
region = data_region_ptr;
void* data_segment_begin = mmap_with_name((u8*)text_segment_begin + m_text_segment_size, region->required_load_size(), region->mmap_prot(), MAP_ANONYMOUS | MAP_PRIVATE, 0, 0, String::format(".data: %s", m_filename.characters()).characters());
if (MAP_FAILED == data_segment_begin) {
ASSERT_NOT_REACHED();
}
VirtualAddress data_segment_actual_addr = region->desired_load_address().offset((FlatPtr)text_segment_begin);
memcpy(data_segment_actual_addr.as_ptr(), (u8*)m_file_mapping + region->offset(), region->size_in_image());
// FIXME: Do some kind of 'allocate TLS section' or some such from a per-application pool
if (tls_region_ptr) {
region = tls_region_ptr;
// FIXME: This can't be right either. TLS needs some real work i'd say :)
m_tls_segment_address = tls_region_ptr->desired_load_address();
VirtualAddress tls_segment_actual_addr = region->desired_load_address().offset((FlatPtr)text_segment_begin);
memcpy(tls_segment_actual_addr.as_ptr(), (u8*)m_file_mapping + region->offset(), region->size_in_image());
}
}
void DynamicLoader::do_relocations()
{
FlatPtr load_base_address = m_dynamic_object->base_address().get();
// FIXME: We should really bail on undefined symbols here.
auto main_relocation_section = m_dynamic_object->relocation_section();
main_relocation_section.for_each_relocation([&](const DynamicObject::Relocation& relocation) {
VERBOSE("====== RELOCATION %d: offset 0x%08X, type %d, symidx %08X\n", relocation.offset_in_section() / main_relocation_section.entry_size(), relocation.offset(), relocation.type(), relocation.symbol_index());
u32* patch_ptr = (u32*)(load_base_address + relocation.offset());
switch (relocation.type()) {
case R_386_NONE:
// Apparently most loaders will just skip these?
// Seems if the 'link editor' generates one something is funky with your code
VERBOSE("None relocation. No symbol, no nothin.\n");
break;
case R_386_32: {
auto symbol = relocation.symbol();
VERBOSE("Absolute relocation: name: '%s', value: %p\n", symbol.name(), symbol.value());
u32 symbol_address = symbol.value() + load_base_address;
*patch_ptr += symbol_address;
VERBOSE(" Symbol address: %p\n", *patch_ptr);
break;
}
case R_386_PC32: {
auto symbol = relocation.symbol();
VERBOSE("PC-relative relocation: '%s', value: %p\n", symbol.name(), symbol.value());
u32 relative_offset = (symbol.value() - relocation.offset());
*patch_ptr += relative_offset;
VERBOSE(" Symbol address: %p\n", *patch_ptr);
break;
}
case R_386_GLOB_DAT: {
auto symbol = relocation.symbol();
VERBOSE("Global data relocation: '%s', value: %p\n", symbol.name(), symbol.value());
u32 symbol_location = load_base_address + symbol.value();
*patch_ptr = symbol_location;
VERBOSE(" Symbol address: %p\n", *patch_ptr);
break;
}
case R_386_RELATIVE: {
// FIXME: According to the spec, R_386_relative ones must be done first.
// We could explicitly do them first using m_number_of_relocatoins from DT_RELCOUNT
// However, our compiler is nice enough to put them at the front of the relocations for us :)
VERBOSE("Load address relocation at offset %X\n", relocation.offset());
VERBOSE(" patch ptr == %p, adding load base address (%p) to it and storing %p\n", *patch_ptr, load_base_address, *patch_ptr + load_base_address);
*patch_ptr += load_base_address; // + addend for RelA (addend for Rel is stored at addr)
break;
}
case R_386_TLS_TPOFF: {
VERBOSE("Relocation type: R_386_TLS_TPOFF at offset %X\n", relocation.offset());
// FIXME: this can't be right? I have no idea what "negative offset into TLS storage" means...
// FIXME: Check m_has_static_tls and do something different for dynamic TLS
*patch_ptr = relocation.offset() - (FlatPtr)m_tls_segment_address.as_ptr() - *patch_ptr;
break;
}
default:
// Raise the alarm! Someone needs to implement this relocation type
dbgprintf("Found a new exciting relocation type %d\n", relocation.type());
printf("DynamicLoader: Found unknown relocation type %d\n", relocation.type());
ASSERT_NOT_REACHED();
break;
}
return IterationDecision::Continue;
});
// Handle PLT Global offset table relocations.
m_dynamic_object->plt_relocation_section().for_each_relocation([&](const DynamicObject::Relocation& relocation) {
// FIXME: Or BIND_NOW flag passed in?
if (m_dynamic_object->must_bind_now() || s_always_bind_now) {
// Eagerly BIND_NOW the PLT entries, doing all the symbol looking goodness
// The patch method returns the address for the LAZY fixup path, but we don't need it here
(void)patch_plt_entry(relocation.offset_in_section());
} else {
// LAZY-ily bind the PLT slots by just adding the base address to the offsets stored there
// This avoids doing symbol lookup, which might be expensive
ASSERT(relocation.type() == R_386_JMP_SLOT);
u8* relocation_address = relocation.address().as_ptr();
*(u32*)relocation_address += load_base_address;
}
return IterationDecision::Continue;
});
#ifdef DYNAMIC_LOAD_DEBUG
dbgprintf("Done relocating!\n");
#endif
}
// Defined in <arch>/plt_trampoline.S
extern "C" void _plt_trampoline(void) __attribute__((visibility("hidden")));
void DynamicLoader::setup_plt_trampoline()
{
VirtualAddress got_address = m_dynamic_object->plt_got_base_address();
FlatPtr* got_ptr = (FlatPtr*)got_address.as_ptr();
got_ptr[1] = (FlatPtr)this;
got_ptr[2] = (FlatPtr)&_plt_trampoline;
#ifdef DYNAMIC_LOAD_DEBUG
dbgprintf("Set GOT PLT entries at %p: [0] = %p [1] = %p, [2] = %p\n", got_ptr, (void*)got_ptr[0], (void*)got_ptr[1], (void*)got_ptr[2]);
#endif
}
// Called from our ASM routine _plt_trampoline.
// Tell the compiler that it might be called from other places:
extern "C" Elf32_Addr _fixup_plt_entry(DynamicLoader* object, u32 relocation_offset);
extern "C" Elf32_Addr _fixup_plt_entry(DynamicLoader* object, u32 relocation_offset)
{
return object->patch_plt_entry(relocation_offset);
}
// offset is in PLT relocation table
Elf32_Addr DynamicLoader::patch_plt_entry(u32 relocation_offset)
{
auto relocation = m_dynamic_object->plt_relocation_section().relocation_at_offset(relocation_offset);
ASSERT(relocation.type() == R_386_JMP_SLOT);
auto sym = relocation.symbol();
u8* relocation_address = relocation.address().as_ptr();
u32 symbol_location = sym.address().get();
VERBOSE("DynamicLoader: Jump slot relocation: putting %s (%p) into PLT at %p\n", sym.name(), symbol_location, relocation_address);
*(u32*)relocation_address = symbol_location;
return symbol_location;
}
void DynamicLoader::call_object_init_functions()
{
typedef void (*InitFunc)();
auto init_function = (InitFunc)(m_dynamic_object->init_section().address().as_ptr());
#ifdef DYNAMIC_LOAD_DEBUG
dbgprintf("Calling DT_INIT at %p\n", init_function);
#endif
(init_function)();
auto init_array_section = m_dynamic_object->init_array_section();
InitFunc* init_begin = (InitFunc*)(init_array_section.address().as_ptr());
InitFunc* init_end = init_begin + init_array_section.entry_count();
while (init_begin != init_end) {
// Android sources claim that these can be -1, to be ignored.
// 0 definitely shows up. Apparently 0/-1 are valid? Confusing.
if (!*init_begin || ((FlatPtr)*init_begin == (FlatPtr)-1))
continue;
#ifdef DYNAMIC_LOAD_DEBUG
dbgprintf("Calling DT_INITARRAY entry at %p\n", *init_begin);
#endif
(*init_begin)();
++init_begin;
}
}
u32 DynamicLoader::ProgramHeaderRegion::mmap_prot() const
{
int prot = 0;
prot |= is_executable() ? PROT_EXEC : 0;
prot |= is_readable() ? PROT_READ : 0;
prot |= is_writable() ? PROT_WRITE : 0;
return prot;
}
} // end namespace ELF
|
; A042200: Numerators of continued fraction convergents to sqrt(626).
; Submitted by Jamie Morken(s4.)
; 25,1251,62575,3130001,156562625,7831261251,391719625175,19593812520001,980082345625225,49023711093781251,2452165637034687775,122657305562828170001,6135317443778443187825,306888529494484987561251,15350561792168027821250375,767834978137895876050080001,38407099468686961830325250425,1921122808412485987392312601251,96094547520092986331445955312975,4806648498813061802559690078250001,240428519488173183114315949867813025,12026232622907472217518357183468901251,601552059664861784059032175123312875575
add $0,1
mov $2,1
lpb $0
sub $0,1
mul $2,-1
add $3,1
mov $1,$3
mul $1,26
sub $1,$3
mul $1,2
add $2,$1
add $3,$2
lpe
mov $0,$2
div $0,2
add $0,1
|
; A180304: Sum of consecutive equal values of floor(sqrt(A000040(n))).
; Submitted by Jamie Morken(w2)
; 2,4,6,12,10,24,21,32,27,50,44,60,65,56,90,112,85,108,114,140,147,154,138,216,200,182,216,252,232,240,310,288,330,306,350,324,333,456,429,480,451,378,516,484,585,460,611,720,490,550,765,832,636,702,605,672,969,754,944,960,793,1054,945,896,1040,990,1005,1156,897,1470,1065,1080,1241,1258,1350,1672,1078,1404,1817,1040,1620,1558,1660,1428,1360,1806,1914,1584,1602,1800,1820,1748,2139,1974,1995,2016,2134,2254,2079,2300
add $0,1
mov $2,$0
seq $0,14085 ; Number of primes between n^2 and (n+1)^2.
mul $2,2
mul $0,$2
div $0,2
|
# Program zamieniajacy dowolny plik na plik zrodlowy w jezyku C,
# reprezentujacy ten plik jako wektor bajtow zapisanych w postaci
# szesnastkowej. Plik wyjsciowy powinien byc rozsadnie sformatowany
# (16 bajtow w wierszu, co 16 wierszy komentarz z licznikiem bajtow,
# na koncu komentarz z calkowita liczba bajtow).
.data
fout: .asciiz "output.txt"
iferr: .asciiz "Nie udalo sie otworzyc pliku wejsciowego!"
oferr: .asciiz "Nie udalo sie otworzyc pliku wyjsciowego!"
intro: .ascii "unsigned char vector[] = {\n\n" # sizeof = 28
outro: .ascii "\n}; // " # sizeof = 7
linebeg:.ascii "\t" # sizeof = 1
lineend:.ascii "\n" # sizeof = 1
commbeg:.ascii "\t// " # sizeof = 4
commend:.ascii " bytes\n\n" # sizeof = 7
buf: .space 16
byte: .ascii "0xXX, " # 2($) -> druga cyfra, 3($) -> pierwsza cyfra, sizeof = 6
digits: .ascii "0123456789ABCDEF"
itos: .space 10
.text
.globl main
main:
bltu $a0, 1, quick_exit
li $v0, 13
lw $a0, ($a1)
li $a1, 0
li $a2, 0
syscall
bltz $v0, input_file_error
move $s0, $v0
li $v0, 13
la $a0, fout
li $a1, 1
li $a2, 0
syscall
bltz $v0, output_file_error
move $s1, $v0
li $v0, 15
move $a0, $s1
la $a1, intro
li $a2, 28
syscall
# $s2 zawiera licznik bajtow
# $s3 zawiera licznik linii
# $s4 zawiera bufor na akutalnie wypisywany bajt
li $s2, 0
li $s3, 0
la $s4, byte
process_file:
li $v0, 14
move $a0, $s0
la $a1, buf
li $a2, 16
syscall
move $t0, $v0
beqz $t0, print_outro
bne $s3, 16, no_comment
li $s3, 0
li $v0, 15
move $a0, $s1
la $a1, commbeg
li $a2, 4
syscall
move $a0, $s2
jal int_to_string
move $t1, $v0
li $v0, 15
move $a0, $s1
la $a1, itos
move $a2, $t1
syscall
li $v0, 15
move $a0, $s1
la $a1, commend
li $a2, 8
syscall
no_comment:
addu $s2, $s2, $t0
addiu $s3, $s3, 1
li $v0, 15
move $a0, $s1
la $a1, linebeg
li $a2, 1
syscall
la $t1, buf
move $t2, $t1
addu $t2, $t2, $t0
process_byte:
lbu $t3, ($t1)
and $t5, $t3, 0x0F
sra $t3, $t3, 4
subu $t5, $t5, $t3
la $t4, digits
addu $t4, $t4, $t3
lbu $t3, ($t4)
sb $t3, 2($s4)
addu $t4, $t4, $t5
lbu $t3, ($t4)
sb $t3, 3($s4)
li $v0, 15
move $a0, $s1
la $a1, byte
li $a2, 6
syscall
addiu $t1, $t1, 1
bltu $t1, $t2, process_byte
li $v0, 15
move $a0, $s1
la $a1, lineend
li $a2, 1
syscall
b process_file
print_outro:
li $v0, 15
move $a0, $s1
la $a1, outro
li $a2, 7
syscall
move $a0, $s2
jal int_to_string
move $t0, $v0
li $v0, 15
move $a0, $s1
la $a1, itos
move $a2, $t0
syscall
b exit
input_file_error:
li $v0, 4
la $a0, iferr
syscall
b quick_exit
output_file_error:
li $v0, 4
la $a0, oferr
syscall
b quick_exit
exit:
move $a0, $s0
li $v0, 16
syscall
move $a0, $s1
li $v0, 16
syscall
quick_exit:
li $v0, 10
syscall
int_to_string:
la $t9, itos
push_digits:
li $t6, 10
divu $a0, $t6
mfhi $t8
mflo $a0
addiu $t8, $t8, '0'
sb $t8, ($t9)
addiu $t9, $t9, 1
bnez $a0, push_digits
la $t8, itos
subu $v0, $t9, $t8
subiu $t9, $t9, 1
reverse:
lbu $t7, ($t9)
lbu $t6, ($t8)
sb $t6, ($t9)
sb $t7, ($t8)
addiu $t8, $t8, 1
subiu $t9, $t9, 1
bltu $t8, $t9, reverse
jr $ra
|
; A207450: Number of n X 5 0..1 arrays avoiding 0 0 0 and 0 0 1 horizontally and 0 0 1 and 1 0 1 vertically.
; 16,256,1008,2560,5200,9216,14896,22528,32400,44800,60016,78336,100048,125440,154800,188416,226576,269568,317680,371200,430416,495616,567088,645120,730000,822016,921456,1028608,1143760,1267200,1399216,1540096,1690128,1849600,2018800,2198016,2387536,2587648,2798640,3020800,3254416,3499776,3757168,4026880,4309200,4604416,4912816,5234688,5570320,5920000,6284016,6662656,7056208,7464960,7889200,8329216,8785296,9257728,9746800,10252800,10776016,11316736,11875248,12451840,13046800,13660416,14292976,14944768,15616080,16307200,17018416,17750016,18502288,19275520,20070000,20886016,21723856,22583808,23466160,24371200,25299216,26250496,27225328,28224000,29246800,30294016,31365936,32462848,33585040,34732800,35906416,37106176,38332368,39585280,40865200,42172416,43507216,44869888,46260720,47680000,49128016,50605056,52111408,53647360,55213200,56809216,58435696,60092928,61781200,63500800,65252016,67035136,68850448,70698240,72578800,74492416,76439376,78419968,80434480,82483200,84566416,86684416,88837488,91025920,93250000,95510016,97806256,100139008,102508560,104915200,107359216,109840896,112360528,114918400,117514800,120150016,122824336,125538048,128291440,131084800,133918416,136792576,139707568,142663680,145661200,148700416,151781616,154905088,158071120,161280000,164532016,167827456,171166608,174549760,177977200,181449216,184966096,188528128,192135600,195788800,199488016,203233536,207025648,210864640,214750800,218684416,222665776,226695168,230772880,234899200,239074416,243298816,247572688,251896320,256270000,260694016,265168656,269694208,274270960,278899200,283579216,288311296,293095728,297932800,302822800,307766016,312762736,317813248,322917840,328076800,333290416,338558976,343882768,349262080,354697200,360188416,365736016,371340288,377001520,382720000,388496016,394329856,400221808,406172160,412181200,418249216,424376496,430563328,436810000,443116800
add $0,1
mul $0,3
mov $2,$0
sub $0,2
pow $2,2
mul $0,$2
mov $1,$0
div $1,9
mul $1,16
|
; A013780: a(n) = 4^(4*n + 1).
; 4,1024,262144,67108864,17179869184,4398046511104,1125899906842624,288230376151711744,73786976294838206464,18889465931478580854784,4835703278458516698824704,1237940039285380274899124224,316912650057057350374175801344,81129638414606681695789005144064,20769187434139310514121985316880384,5316911983139663491615228241121378304,1361129467683753853853498429727072845824,348449143727040986586495598010130648530944,89202980794122492566142873090593446023921664,22835963083295358096932575511191922182123945984
mov $1,256
pow $1,$0
mul $1,4
mov $0,$1
|
; A169309: Number of reduced words of length n in Coxeter group on 8 generators S_i with relations (S_i)^2 = (S_i S_j)^30 = I.
; 1,8,56,392,2744,19208,134456,941192,6588344,46118408,322828856,2259801992,15818613944,110730297608,775112083256,5425784582792,37980492079544,265863444556808,1861044111897656,13027308783283592
mov $1,7
pow $1,$0
add $1,2
mul $1,8
div $1,7
sub $1,2
mov $0,$1
|
; A143731: Characteristic function of numbers n with at least two distinct prime factors.
; 0,0,0,0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,1,1,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1,0,1,1,0,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,0,1,0,0,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,1,1
cal $0,293810 ; The truncated kernel function of n: the product of distinct primes dividing n, but excluding the largest prime divisor of n.
lpb $0
div $0,8
add $0,2
lpe
sub $0,1
mov $1,$0
|
; A057570: Numbers of the form n*(7n+-1)/2.
; 0,3,4,13,15,30,33,54,58,85,90,123,129,168,175,220,228,279,288,345,355,418,429,498,510,585,598,679,693,780,795,888,904,1003,1020,1125,1143,1254,1273,1390,1410,1533,1554,1683,1705,1840,1863,2004,2028,2175,2200,2353,2379,2538,2565,2730,2758,2929,2958,3135,3165,3348,3379,3568,3600,3795,3828,4029,4063,4270,4305,4518,4554,4773,4810,5035,5073,5304,5343,5580,5620,5863,5904,6153,6195,6450,6493,6754,6798,7065,7110,7383,7429,7708,7755,8040,8088,8379,8428,8725,8775,9078,9129,9438,9490,9805,9858,10179,10233,10560,10615,10948,11004,11343,11400,11745,11803,12154,12213,12570,12630,12993,13054,13423,13485,13860,13923,14304,14368,14755,14820,15213,15279,15678,15745,16150,16218,16629,16698,17115,17185,17608,17679,18108,18180,18615,18688,19129,19203,19650,19725,20178,20254,20713,20790,21255,21333,21804,21883,22360,22440,22923,23004,23493,23575,24070,24153,24654,24738,25245,25330,25843,25929,26448,26535,27060,27148,27679,27768,28305,28395,28938,29029,29578,29670,30225,30318,30879,30973,31540,31635,32208,32304,32883,32980,33565,33663,34254,34353,34950,35050,35653,35754,36363,36465,37080,37183,37804,37908,38535,38640,39273,39379,40018,40125,40770,40878,41529,41638,42295,42405,43068,43179,43848,43960,44635,44748,45429,45543,46230,46345,47038,47154,47853,47970,48675,48793,49504,49623,50340,50460,51183,51304,52033,52155,52890,53013,53754,53878,54625
mov $2,$0
add $2,2
lpb $0,1
trn $0,2
add $1,$2
add $2,3
lpe
|
; A014126: Number of partitions of 2*n into at most 4 parts.
; 1,2,5,9,15,23,34,47,64,84,108,136,169,206,249,297,351,411,478,551,632,720,816,920,1033,1154,1285,1425,1575,1735,1906,2087,2280,2484,2700,2928,3169,3422,3689,3969,4263,4571,4894,5231,5584,5952,6336,6736,7153,7586,8037,8505,8991,9495,10018,10559,11120,11700,12300,12920,13561,14222,14905,15609,16335,17083,17854,18647,19464,20304,21168,22056,22969,23906,24869,25857,26871,27911,28978,30071,31192,32340,33516,34720,35953,37214,38505,39825,41175,42555,43966,45407,46880,48384,49920,51488,53089,54722
add $0,1
lpb $0
mov $2,$0
sub $0,3
seq $2,982 ; a(n) = ceiling(n^2/2).
add $1,$2
lpe
add $1,$0
mov $0,$1
|
; A132477: Row sums of triangle A132476.
; 1,4,12,24,48,96,192,384,768,1536,3072,6144,12288,24576,49152,98304,196608,393216,786432,1572864,3145728,6291456,12582912,25165824,50331648,100663296,201326592,402653184,805306368,1610612736,3221225472,6442450944,12884901888
mov $1,3
mov $2,2
trn $2,$0
sub $1,$2
lpb $0
sub $0,1
mul $1,2
lpe
|
#include "Debugger/ConsoleHelper.h"
#include <string>
namespace MarCmd
{
namespace Console
{
TextFormat::TextFormat(TextFormatCode tfc)
{
subsequence.append(std::to_string((int)tfc));
}
TextFormat::TextFormat(uint8_t r, uint8_t g, uint8_t b, TextFormatGround ground)
{
subsequence.append(std::to_string((int)ground));
subsequence.append(";2;");
subsequence.append(std::to_string((int)r));
subsequence.append(";");
subsequence.append(std::to_string((int)g));
subsequence.append(";");
subsequence.append(std::to_string((int)b));
}
TextFormat TextFormat::ColorFG(uint8_t r, uint8_t g, uint8_t b)
{
return TextFormat(r, g, b, TFG::Foreground);
}
TextFormat TextFormat::ColorBG(uint8_t r, uint8_t g, uint8_t b)
{
return TextFormat(r, g, b, TFG::Background);
}
std::ostream& operator<<(std::ostream& oStream, CursorVisibility curVis)
{
switch (curVis)
{
case CurVis::EnableBlink:
return oStream << "\033[?12h";
case CurVis::DisableBlink:
return oStream << "\033[?12l";
case CurVis::Show:
return oStream << "\033[?25h";
case CurVis::Hide:
return oStream << "\033[?25l";
}
return oStream;
}
std::ostream& operator<<(std::ostream& oStream, const CursorPos& cp)
{
return oStream << "\033[" << (1 + cp.x) << ";" << (1 + cp.y) << "H";
}
std::ostream& operator<<(std::ostream& oStream, TextFormat tf)
{
return oStream << "\033[" << tf.subsequence << "m";
}
}
} |
.386
.model flat, stdcall
includelib msvcrt.lib
extern exit: proc
extern malloc: proc
extern memset: proc
includelib canvas.lib
extern BeginDrawing: proc
public start
.data
cnt_aux DD 0
cnt DD 0
vector_simboluri DB 1, 1, 1, 1, 1, 1, 1, 1, 1 ;;un vector de 9 elemente care initial e gol pentru a alterna simbolurile
window_title DB "Tic Tac Toe", 0
area_width EQU 630
area_height EQU 630
area DD 0
counter DD 0 ; numara evenimentele de tip timer
arg1 EQU 8
arg2 EQU 12
arg3 EQU 16
arg4 EQU 20
x DD 0
y DD 0
symbol_width EQU 10
symbol_height EQU 20
include digits.inc
include letters.inc
dim_width EQU 41
dim_height EQU 41
include ZEROdraw.inc
include Xdraw.inc
;vector_simboluri DB 1, 1, 1, 1, 1, 1, 1, 1, 1 ;;un vector de 9 elemente care initial e gol pentru a alterna simbolurile
;cnt DD 0 ;; porneste de la 0 si merge pana la 8 si cu ajutorul lui verific paritatea ca sa stiu daca trebuie sa pun X sau 0
.code
; procedura make_text afiseaza o litera sau o cifra la coordonatele date
; arg1 - simbolul de afisat (litera sau cifra)
; arg2 - pointer la vectorul de pixeli
; arg3 - pos_x
; arg4 - pos_y
make_text proc
push ebp
mov ebp, esp
pusha
mov eax, [ebp + arg1] ; citim simbolul de afisat
cmp eax, 'A'
jl make_digit
cmp eax, 'Z'
jg make_digit
sub eax, 'A'
lea esi, letters
jmp draw_text
make_digit:
cmp eax, '0'
jl make_space
cmp eax, '9'
jg make_space
sub eax, '0'
lea esi, digits
jmp draw_text
make_space:
mov eax, 26 ; de la 0 pana la 25 sunt litere, 26 e space
lea esi, letters
draw_text:
mov ebx, symbol_width
mul ebx
mov ebx, symbol_height
mul ebx
add esi, eax
mov ecx, symbol_height
bucla_simbol_linii:
mov edi, [ebp+arg2] ; pointer la matricea de pixeli
mov eax, [ebp+arg4] ; pointer la coord y
add eax, symbol_height
sub eax, ecx
mov ebx, area_width
mul ebx
add eax, [ebp+arg3] ; pointer la coord x
shl eax, 2 ; inmultim cu 4, avem un DWORD per pixel
add edi, eax
push ecx
mov ecx, symbol_width
bucla_simbol_coloane:
cmp byte ptr [esi], 0
je simbol_pixel_alb
mov dword ptr [edi], 0
jmp simbol_pixel_next
simbol_pixel_alb:
mov dword ptr [edi], 0FFFFFFh
simbol_pixel_next:
inc esi
add edi, 4
loop bucla_simbol_coloane
pop ecx
loop bucla_simbol_linii
popa
mov esp, ebp
pop ebp
ret
make_text endp
; un macro ca sa apelam mai usor desenarea simbolului
make_text_macro macro symbol, drawArea, x, y
push y
push x
push drawArea
push symbol
call make_text
add esp, 16
endm
make_X proc
push ebp
mov ebp, esp
pusha
mov eax, [ebp + arg1] ; citim simbolul de afisat
cmp eax, 'X'
je etichetaX
etichetaZERO:
lea esi, ZEROdraw
jmp draw_text_pers
etichetaX:
lea esi, Xdraw
draw_text_pers:
mov ecx, dim_height
bucla_simbol_linii_:
mov edi, [ebp+arg2] ; pointer la matricea de pixeli
mov eax, [ebp+arg4] ; pointer la coord y
add eax, dim_height
sub eax, ecx
mov ebx, area_width
mul ebx
add eax, [ebp+arg3] ; pointer la coord x
shl eax, 2 ; inmultim cu 4, avem un DWORD per pixel
add edi, eax
push ecx
mov ecx, dim_width
bucla_simbol_coloane_:
cmp byte ptr [esi], 0
je simbol_pixel_alb_
mov dword ptr [edi], 0
jmp simbol_pixel_next_
simbol_pixel_alb_:
mov dword ptr [edi], 0FFFFFFh
simbol_pixel_next_:
inc esi
add edi, 4
loop bucla_simbol_coloane_
pop ecx
loop bucla_simbol_linii_
popa
mov esp, ebp
pop ebp
ret
make_X endp
make_X_macro macro symbol, drawArea, x, y
push y
push x
push drawArea
push symbol
call make_X
add esp, 16
endm
vertical_draw macro x, y
local bucla
pusha ;punem registrele pe stiva ca sa nu pierdem informatiile
mov edi, area
mov esi, area_width
shl esi, 2
mov eax, y
mov ebx, area_width
mul ebx ;suntem la linia care trebuie, mai avem nevoie sa adunam x
add eax, x
shl eax, 2
mov ecx, 300 ;lungimea liniei
bucla:
mov ebx, eax
add ebx, edi
mov dword ptr[ebx], 8000000
add eax, esi ;ajungem un nivel mai jos
loop bucla
popa
endm
horizontal_draw macro x, y
local bucla
pusha
mov eax, y
mov esi, area_width
mov edi, area
shl esi, 2
mov ebx, area_width
mul ebx
add eax, x ;;am ajuns la punctul de unde vrem sa desenam
shl eax, 2
mov ecx, 360
bucla:
mov ebx, eax
add ebx, edi
mov dword ptr[ebx], 25000
add eax, 4 ;;ajungem la punctul urmator unde vrem sa desenam
;; adunam 4 pentru ca noi avem double word
loop bucla
popa
endm
square macro
vertical_draw 130, 120
vertical_draw 250, 120
vertical_draw 370, 120
vertical_draw 490, 120
horizontal_draw 130, 120
horizontal_draw 130, 220
horizontal_draw 130, 320
horizontal_draw 130, 420
endm
verif_parity proc
push ebp
mov ebp, esp
mov eax, cnt
mov edx, 0
mov ebx, 2
div ebx
;;eax avem restul impartirii contorului la 2
mov eax, edx
mov esp, ebp
pop ebp
ret
verif_parity endp
algorithm proc
;aici se scrie codul
mov eax, 0
mov bl, [vector_simboluri + 4]
;;comparari pentru a doua linie orizontala
cmp bl, [vector_simboluri + 5]
je casuta_4_5
jmp gata0
casuta_4_5:
cmp bl, [vector_simboluri + 3]
je casuta_4_3
jmp gata0
casuta_4_3:
mov al, bl
jmp gata
;;comparari pentru a doua linie verticala
gata0:
cmp bl, [vector_simboluri + 7]
je casuta_4_7
jmp gata1
casuta_4_7:
cmp bl, [vector_simboluri + 1]
je casuta_7_1
jmp gata1
casuta_7_1:
mov al, bl
jmp gata
gata1:
;;comparari pentru diagonala principala
cmp bl, [vector_simboluri]
je casuta_4_0
jmp gata2
casuta_4_0:
cmp bl, [vector_simboluri + 8]
je casuta_4_8
jmp gata2
casuta_4_8:
mov al, bl
jmp gata
gata2:
;;comparari pentru diagonala secundara
cmp bl, [vector_simboluri + 2]
je casuta_4_2
jmp gata3
casuta_4_2:
cmp bl, [vector_simboluri + 6]
je casuta_4_6
jmp gata3
casuta_4_6:
mov al, bl
jmp gata
gata3:
;;comparari pentru prima linie verticala
mov bl, [vector_simboluri + 3]
cmp bl, [vector_simboluri]
je casuta_3_0
jmp gata4
casuta_3_0:
cmp bl, [vector_simboluri + 6]
je casuta_3_6
jmp gata4
casuta_3_6:
mov al, bl
jmp gata
gata4:
;;comparari pentru ultima linie verticala
mov bl, [vector_simboluri + 5]
cmp bl, [vector_simboluri + 2]
je casuta_5_2
jmp gata5
casuta_5_2:
cmp bl, [vector_simboluri + 8]
je casuta_5_8
jmp gata5
casuta_5_8:
mov al, bl
jmp gata
gata5:
;;comparari pentru prima linie orizontala
mov bl, [vector_simboluri + 1]
cmp bl, [vector_simboluri]
je casuta_1_0
jmp gata6
casuta_1_0:
cmp bl, [vector_simboluri + 2]
je casuta_1_2
jmp gata6
casuta_1_2:
mov al, bl
jmp gata
gata6:
;;comparari pentru ultima linie orizontala
mov bl, [vector_simboluri + 7]
cmp bl, [vector_simboluri + 6]
je casuta_6_7
jmp gata
casuta_6_7:
cmp bl, [vector_simboluri + 8]
je casuta_7_8
jmp gata
casuta_7_8:
mov al, bl
gata:
ret
algorithm endp
algorithm_2 proc
mov bl, [vector_simboluri + 8]
cmp bl, [vector_simboluri + 5]
je casuta_8_5
jmp linie_verticala
casuta_8_5:
cmp bl, [vector_simboluri + 2]
je casuta_8_2
jmp linie_verticala
casuta_8_2:
mov al, bl
linie_verticala:
cmp bl, [vector_simboluri + 7]
je casuta_8_7
jmp final_drum
casuta_8_7:
cmp bl, [vector_simboluri + 6]
je casuta_8_6
jmp final_drum
casuta_8_6:
mov al, bl
final_drum:
ret
algorithm_2 endp
simbol_alternativ proc
push ebp
mov ebp, esp
pusha
cmp cnt, 9
je gata
mov edx, [ebp + 12]
mov ebx, [ebp + 8]
;;punem contorul pe stiva pentru a-i verifica paritatea
; REZOLVA ASTA-> IDEEA E CA AICI SE STRICA EDX SAU EBX CAND SE APELEAZA FUNCTIA PENTRU CA LA IMPARTIRE STRICAM EDX
push ebx
push edx
;push cnt
call verif_parity
pop edx
pop ebx
cmp eax, 1
je punemZERO
make_X_macro "X", area, edx, ebx
jmp sfarsit
punemZERO:
make_X_macro "0", area, edx, ebx
sfarsit:
inc cnt
;cmp cnt, 8
;jg gata
jmp gata
;sari:
; make_text_macro 'T', area, 50, 50
; make_text_macro 'I', area, 60, 50
; make_text_macro 'E', area, 70, 50
gata:
popa
mov esp, ebp
pop ebp
ret 8
simbol_alternativ endp
display_TIE macro
make_text_macro 'T', area, 50, 50
make_text_macro 'I', area, 60, 50
make_text_macro 'E', area, 70, 50
endm
simbol_alternativ_macro macro x, y
push x
push y
call simbol_alternativ
endm
fix_in_centre proc
push ebp
mov ebp, esp
pusha
mov edx, [ebp + arg2] ;x
mov ebx, [ebp + arg3] ;y
mov x, edx
mov y, ebx
;;verificari cadrane Verificam mai intai daca suntem pe prima linie si de acolo verificam in ce careu de pe prima linie ne aflam
;; Apoi trecem la a treia linie ca sa mai scutim din cazuri
;; In cele din urma, ramanem cu a doua linie, excluzandu-le pe celelalte doua ne scutim de niste calcule in plus
;; Pentru careu, verificam mai intai daca e in primul careu, apoi in ultimul, ramanand cu cel din mijloc
cmp y, 220
jl linie_1 ;;verificam daca am dat click pe linia intai
cmp y, 320
jg linie_3 ;;verificam daca am dat click pe linia a treia
;;a ramas doar linia a 2-a neevaluata
cmp x, 250
jl ocup_apatra_casuta
cmp x, 370
jg ocup_asasea_casuta
cmp [vector_simboluri + 4], 1
jne gata
simbol_alternativ_macro 290, 250 ;;a 5 a casuta
call verif_parity
cmp eax, 0 ;;inseamna ca am pus 0 si marcam acest lucru in vectorul nostru
je impar_casuta5
mov [vector_simboluri + 4], 'X'
jmp gata
impar_casuta5:
mov [vector_simboluri + 4], '0'
jmp gata
linie_1:
cmp x, 250
jl ocup_prima_casuta
cmp x, 370
jg ocup_atreia_casuta
cmp [vector_simboluri + 1], 1
jne gata
simbol_alternativ_macro 290, 150 ;; a doua casuta
call verif_parity
cmp eax, 0 ;;inseamna ca am pus 0 si marcam acest lucru in vectorul nostru
je impar_casuta2
mov [vector_simboluri + 1], 'X' ;;punem invers pentru ca aici prima data creste cnt si apoi imparte la 2
jmp gata
impar_casuta2:
mov [vector_simboluri + 1], '0'
jmp gata
ocup_prima_casuta:
cmp [vector_simboluri], 1
jne gata
simbol_alternativ_macro 170, 150
call verif_parity
cmp eax, 0 ;;inseamna ca am pus 0 si marcam acest lucru in vectorul nostru
je impar_casuta1
mov [vector_simboluri], 'X'
jmp gata
impar_casuta1:
mov [vector_simboluri], '0'
jmp gata
ocup_atreia_casuta:
cmp [vector_simboluri + 2], 1
jne gata
simbol_alternativ_macro 413, 150
call verif_parity
cmp eax, 0 ;;inseamna ca am pus 0 si marcam acest lucru in vectorul nostru
je impar_casuta3
mov [vector_simboluri + 2], 'X'
jmp gata
impar_casuta3:
mov [vector_simboluri + 2], '0'
jmp gata
linie_3:
cmp x, 250
jl ocup_asaptea_casuta
cmp x, 370
jg ocup_anoua_casuta
cmp [vector_simboluri + 7], 1
jne gata
simbol_alternativ_macro 290, 350 ;a opta casuta
call verif_parity
cmp eax, 0 ;;inseamna ca am pus 0 si marcam acest lucru in vectorul nostru
je impar_casuta8
mov [vector_simboluri + 7], 'X'
jmp gata
impar_casuta8:
mov [vector_simboluri + 7], '0'
jmp gata
ocup_asaptea_casuta:
cmp [vector_simboluri + 6], 1
jne gata
simbol_alternativ_macro 170, 350
call verif_parity
cmp eax, 0 ;;inseamna ca am pus 0 si marcam acest lucru in vectorul nostru
je impar_casuta7
mov [vector_simboluri + 6], 'X'
jmp gata
impar_casuta7:
mov [vector_simboluri + 6], '0'
jmp gata
ocup_anoua_casuta:
cmp [vector_simboluri + 8], 1
jne gata
simbol_alternativ_macro 413, 350
call verif_parity
cmp eax, 0 ;;inseamna ca am pus 0 si marcam acest lucru in vectorul nostru
je impar_casuta9
mov [vector_simboluri + 8], 'X'
jmp gata
impar_casuta9:
mov [vector_simboluri + 8], '0'
jmp gata
ocup_apatra_casuta:
cmp [vector_simboluri + 3], 1
jne gata
simbol_alternativ_macro 170, 250
call verif_parity
cmp eax, 0 ;;inseamna ca am pus 0 si marcam acest lucru in vectorul nostru
je impar_casuta4
mov [vector_simboluri + 3], 'X'
jmp gata
impar_casuta4:
mov [vector_simboluri + 3], '0'
jmp gata
ocup_asasea_casuta:
cmp [vector_simboluri + 5], 1
jne gata
simbol_alternativ_macro 413, 250
call verif_parity
cmp eax, 0 ;;inseamna ca am pus 0 si marcam acest lucru in vectorul nostru
je impar_casuta6
mov [vector_simboluri + 5], 'X'
jmp gata
impar_casuta6:
mov [vector_simboluri + 5], '0'
jmp gata
miscare_nepermisa:
gata:
popa
mov esp, ebp
pop ebp
ret 8
fix_in_centre endp
draw proc
push ebp
mov ebp, esp
pusha
mov eax, [ebp+arg1]
cmp eax, 1
jz evt_click
cmp eax, 2
jz evt_timer ; nu s-a efectuat click pe nimic
;mai jos e codul care intializeaza fereastra cu pixeli albi
mov eax, area_width
mov ebx, area_height
mul ebx
shl eax, 2
push eax
push 255
push area
call memset
add esp, 12
square ; macro care deseneaza tabla de joc
jmp final_draw
evt_click:
cmp cnt_aux, -1
je final_draw
pusha
mov edx, [ebp + arg2] ;x
mov ebx, [ebp + arg3] ;y
mov x, edx
mov y, ebx
cmp y, 120 ;verificam daca e in partea de sus a tablei
jl registre
cmp y, 420 ;verificam daca e in partea de jos
jg registre
cmp x, 490 ;verificam daca e in partea dreapta
jg registre
cmp x, 130 ;verificam daca e in partea stanga
jl registre
;;punem coordonatele x si y pe stiva
push edx
push ebx
call fix_in_centre
call algorithm
cmp eax, 'X'
je Xwins
cmp eax, '0'
je ZEROwins
call algorithm_2
cmp eax, 'X'
je Xwins
cmp eax, '0'
je ZEROwins
cmp cnt, 9
je TIE
jmp sari
Xwins:
make_X_macro "X", area, 200, 50
make_text_macro "A", area, 260, 55
make_text_macro " ", area, 270, 55
make_text_macro "C", area, 280, 55
make_text_macro "A", area, 290, 55
make_text_macro "S", area, 300, 55
make_text_macro "T", area, 310, 55
make_text_macro "I", area, 320, 55
make_text_macro "G", area, 330, 55
make_text_macro "A", area, 340, 55
make_text_macro "T", area, 350, 55
mov cnt_aux, -1
jmp sari
ZEROwins:
make_X_macro "0", area, 200, 50
make_text_macro "A", area, 260, 55
make_text_macro " ", area, 270, 55
make_text_macro "C", area, 280, 55
make_text_macro "A", area, 290, 55
make_text_macro "S", area, 300, 55
make_text_macro "T", area, 310, 55
make_text_macro "I", area, 320, 55
make_text_macro "G", area, 330, 55
make_text_macro "A", area, 340, 55
make_text_macro "T", area, 350, 55
mov cnt_aux, -1
jmp sari
TIE:
make_text_macro "T", area, 260, 55
make_text_macro " ", area, 270, 55
make_text_macro "I", area, 280, 55
make_text_macro " ", area, 290, 55
make_text_macro "E", area, 300, 55
mov cnt_aux, -1
sari:
popa
jmp final
registre:
popa
jmp final_draw
final:
;bucla:
JMP final_draw
evt_timer:
afisare_litere:
;scriem un mesaj
make_text_macro 'T', area, 10, 10
make_text_macro 'I', area, 20, 10
make_text_macro 'C', area, 30, 10
make_text_macro '-', area, 40, 10
make_text_macro 'T', area, 50, 10
make_text_macro 'A', area, 60, 10
make_text_macro 'C', area, 70, 10
make_text_macro '-', area, 80, 10
make_text_macro 'T', area, 90, 10
make_text_macro 'O', area, 100, 10
make_text_macro 'E', area, 110, 10
final_draw:
popa
mov esp, ebp
pop ebp
ret
draw endp
start:
;alocam memorie pentru zona de desenat
mov eax, area_width
mov ebx, area_height
mul ebx
shl eax, 2
push eax
call malloc
add esp, 4
mov area, eax
;apelam functia de desenare a ferestrei
; typedef void (*DrawFunc)(int evt, int x, int y);
; void __cdecl BeginDrawing(const char *title, int width, int height, unsigned int *area, DrawFunc draw);
push offset draw
push area
push area_height
push area_width
push offset window_title
call BeginDrawing
add esp, 20
;terminarea programului
push 0
call exit
end start |
; A203478: a(n) = v(n+1)/v(n), where v=A203477.
; Submitted by Jamie Morken(s1)
; 3,30,1080,146880,77552640,161309491200,1331771159347200,43809944057885491200,5753472333233985788313600,3019422280481195741706977280000,6335279362770913356551778761441280000
add $0,1
mov $2,1
mov $3,2
mov $4,1
lpb $0
sub $0,1
add $3,$2
mul $4,$3
mul $4,$2
mul $2,2
lpe
mov $0,$4
|
;
; ASM Huffman unpacking code
;
ideal ; TASM Ideal mode
p386 ; protected mode 386 code
model os2 flat, syscall ; os/2 flat model, system calling
nosmart
dataseg
StackSave DD ?
DestEnd DD ?
Result DD ?
BitTable DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
DB 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h, 01h, 02h, 04h, 08h, 10h, 20h, 40h, 80h
IndexTable DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
DD 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1
struc Tree
Left DW ?
Right DW ?
Children DW ?
Value DB ?
Discard DB ?
ends
codeseg ; Start the code segment
public syscall HuffmanUnpackAsm
proc HuffmanUnpackAsm syscall
ARG @@Packed:PTR DWORD, @@SourceEnd:PTR DWORD, @@Sample:PTR DWORD, @@DestEnd:PTR DWORD, @@Tree:PTR DWORD, @@StartBit:BYTE
; Save volatile registers
pushad
push ebp
; Save esp and store MEnd
mov [StackSave],esp ; Stash esp in the dgroup
mov ESI, [@@Packed]
mov EDI, [@@Sample]
mov EAX, [@@DestEnd]
mov [DestEnd], EAX
mov EAX, [@@SourceEnd]
xor EDX, EDX
mov DL, [@@StartBit]
mov EBP, [@@Tree]
mov ESP, EAX
xor EBX, EBX
@@TopOfUnpack:
mov AH, [ESI]
add ESI, [IndexTable+EDX*4]
and AH, [BitTable+EDX]
jz @@NoSign
mov AH, 0FFh
@@NoSign:
inc DL
xor ECX, ECX
@@TopOfTree:
mov AL, [ESI]
add ESI, [IndexTable+EDX*4]
and AL, [BitTable+EDX]
jnz @@RightBranch
;;Take the left branch
mov CX, [EBP+ECX*8+0]
inc DL
cmp [WORD EBP+ECX*8+4], 0
jne @@TopOfTree
jmp @@BottomOfTree
@@RightBranch:
mov CX, [EBP+ECX*8+2]
inc DL
cmp [WORD EBP+ECX*8+4], 0
jne @@TopOfTree
@@BottomOfTree:
mov AL, [EBP+ECX*8+6]
xor AL, AH
add BL, AL
mov [EDI], BL
inc EDI
cmp ESI, ESP
jae @@NoMoreData
cmp EDI, [DestEnd]
jb @@TopOfUnpack
@@NoMoreData:
cmp EDI, [DestEnd]
jae @@NoEndFill
mov ECX, [DestEnd]
sub ECX, EDI
cmp ECX, 16
ja @@NoEndFill
mov AL, [EDI-1]
@@TopOfEndFill:
mov [EDI], AL
inc EDI
dec ECX
jnz @@TopOfEndFill
@@NoEndFill:
mov [Result], 0
cmp ESI, ESP
jb @@OKEnd
ja @@BadEnd
and DL, 7
jz @@OKEnd
@@BadEnd:
cmp EDI, [DestEnd]
jae @@OKEnd
mov [Result], 1
@@OKEnd:
; Restore the stack
mov esp,[StackSave]
; Restore the flags
pop ebp
popad
mov EAX, [Result]
cld
ret
endp
end
|
copyright zengfr site:http://github.com/zengfr/romhack
00042A move.l D1, (A0)+
00042C dbra D0, $42a
004D94 move.l D1, (A1)+
004D96 dbra D0, $4d94
03207E move.b ($3354,A5), D0
032082 btst #$2, D6 [123p+ E0]
03208A cmp.b ($34d4,A5), D0
03208E bcs $3209a [123p+ E0]
032096 move.b ($34d4,A5), D0
03209A btst #$3, D6 [123p+ E0]
0320A2 cmp.b ($3654,A5), D0
0320A6 bcs $320b2 [123p+ E0]
0320AE move.b ($3654,A5), D0
0320B2 cmpi.b #$3, D0 [123p+ E0]
03242E move.l ($3358,A5), ($3354,A5)
032434 move.l ($34d8,A5), ($34d4,A5) [123p+ E0, 123p+ E2]
03243A move.l ($3658,A5), ($3654,A5) [123p+ E0, 123p+ E2]
032440 move.b ($4fb,A5), ($4f3,A5) [123p+ E0, 123p+ E2]
0AAACA move.l (A0), D2
0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAACE move.w D0, ($2,A0)
0AAAD2 cmp.l (A0), D0
0AAAD4 bne $aaafc
0AAAD8 move.l D2, (A0)+
0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAE6 move.l (A0), D2
0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
0AAAF4 move.l D2, (A0)+
0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1]
copyright zengfr site:http://github.com/zengfr/romhack
|
<%
from pwnlib.shellcraft.amd64.linux import syscall
%>
<%page args="fd, file, owner, group, flag"/>
<%docstring>
Invokes the syscall fchownat. See 'man 2 fchownat' for more information.
Arguments:
fd(int): fd
file(char): file
owner(uid_t): owner
group(gid_t): group
flag(int): flag
</%docstring>
${syscall('SYS_fchownat', fd, file, owner, group, flag)}
|
;
; Dict Xiong is learning asm
.386
.model flat, stdcall
.stack 4096
ExitProcess proto, dwExitCode:dword
includelib msvcrt.lib
printf proto c : ptr sbyte, : vararg
.data
source BYTE 'This is the source string', 0
target BYTE SIZEOF source DUP('#')
.code
main proc
mov ecx, lengthof source
sub ecx, type source
mov target[ecx], 0
mov edi, 0
L1:
mov eax, ecx
sub eax, 1
mov al, source[eax]
mov target[edi], al
add edi, type target
loop L1
invoke printf, offset target
invoke ExitProcess,0
main endp
end main |
// Assembler: KickAssembler 4.4
// cannot be compiled standalone
// All made by myself
scrclr:
ldx #0
lda #' '
!l:
sta $0400,x
sta $0500,x
sta $0600,x
sta $06e8,x
inx
bne !l-
rts
|
; A050484: Partial sums of A051946.
; Submitted by Jamie Morken(s4)
; 1,12,68,264,810,2112,4884,10296,20163,37180,65208,109616,177684,279072,426360,635664,927333,1326732,1865116,2580600,3519230,4736160,6296940,8278920,10772775,13884156,17735472,22467808,28242984,35245760,43686192,53802144,65861961,80167308,97056180,116906088,140137426,167217024,198661892,235043160,276990219,325195068,380416872,443486736,515312700,596884960,689281320,793672880,911329965,1043628300,1192055436,1358217432,1543845798,1750804704,1981098460,2236879272,2520455279,2834298876,3181055328
mov $2,$0
mul $0,5
add $0,7
add $2,5
mov $1,$2
bin $1,5
mul $0,$1
add $2,1
mul $2,$0
mov $0,$2
div $0,42
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1991 -- All Rights Reserved
PROJECT: PC GEOS
MODULE: Impex/Main
FILE: mainThread.asm
AUTHOR: jimmy lefkowitz
DESCRIPTION:
Code involving thread management. The thread management is
straight forward, but the clean up is a bit involved. An
overview of the lift of a thread is as follows:
* An ImportExportClass object (a subclass, really)
asks to spawn a thread.
* The thread is created, and an entry in the
thread list maintained by the Impex library is
created and initialized.
* An IMPORT or EXPORT message is sent out, and the
import/export process ensues.
* Now, either the app finishes & and sends a MSG_DETACH
to itself
- or -
The application exits, and a DETACH is sent out before
import/export process is complete. An ObjIncDetach is
called on the owning object, to prevent it from leaving
before the thread has exited.
* On receipt of MSG_META_ACK by the ImportExportClass
object, the ImpexThreadInfo block is destroyed, the
entry for the now-dead thread is removed from the
thread list, and a MSG_META_ACK will be sent on to
the superclass of the ImportExport object iff the
application is detaching.
The code managing the thread lists is contained in this file.
The code managing the detaches of the ImportExportClass is
contained in UI/uiImportExport.asm
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 7/15/91 Initial version.
don 6/ 3/92 Code & documentation changes
$Id: mainThread.asm,v 1.1 97/04/04 23:29:41 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ProcessCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SpawnThread
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Spawn an ImpexThreadProcessClass thread for either
export or import
CALLED BY: ImportControlImport, ExportControlExport
PASS: AX = Message to send to newly spawned thread
BX = ImpexThreadInfo block handle (locked)
DS = Object block owned by application
RETURN: Nothing
DESTROYED: AX, BX, CX, DX, DI, SI, BP, DS, ES
PSEUDOCODE/STRATEGY:
This routine uses MSG_PROCESS_CREATE_EVENT_THREAD which
is call with an MF_CALL, thereby guaranteeing that the
new thread will have been attached to its own event queue
and be ready to receive messages
all routines sent to a spawned thread will be handled by
methods defined under ImpexThreadProcessClass
once the thread is created, I insert an entry into the
ImpexThreadList, this entry is how the Impex library
can keep track of any threads that it spawns. Each entry
contains the thread handle, the owning App's handle and
an ImpexThreadInfo block handle, this ImpexThreadInfo block
contains all information the thread needs to do its job.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jimmy 8/12/91 Initial version
jenny 1/92 Cleaned up
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SpawnThread proc far
; Ignore input, if requested
;
push ax, bx ; save message, ITI block handle
mov cx, ds:[LMBH_handle] ; block owned by app => CX
call MemDerefDS ; ImpexthreadInfo => DS
call InputIgnore
call MemUnlock ; unlock the Info first
; Create an event thread by sending a message to the
; application's thread.
;
mov bx, cx
call MemOwner ; application's process => BX
call GeodeGetDGroupDS ; core block => DS
mov ax, segment ProcessClass
mov es, ax
mov di, offset ProcessClass
mov ax, MSG_PROCESS_CREATE_EVENT_THREAD
mov cx, segment ImpexThreadProcessClass
mov dx, offset ImpexThreadProcessClass
mov bp, IMPEX_THREAD_STACK_SIZE
call ObjCallClassNoLock ; handle of new thread => AX
pop dx, cx ; message => DX
; ImpexThreadInfo => CX
jc errorSpawning ; report error in spawning
; Note that we've created a new thread
;
call ImpexThreadCreated ; store data away
; Now send off our initial message
;
mov_tr bx, ax ; thread handle => BX
mov_tr ax, dx ; initial message => AX
clr di ; MessageFlags => DI
GOTO ObjMessage ; go for it!
; We could not spawn the thread, so tell the user and abort
errorSpawning:
mov bx, cx ; ImpexThreadInfo => BX
call ImpexThreadInfoPLock
mov ax, IE_COULD_NOT_SPAWN_THREAD
call DisplayErrorAndBlock
call CleanUpImpexThreadInfo
call ImpexThreadInfoUnlockV
GOTO MemFree ; free the ThreadInfo
SpawnThread endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ImpexThreadCreated
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Note that an import/export thread has been created
CALLED BY: GLOBAL
PASS: AX = Impex thread handle
BX = Application process handle
CX = ImpexThreadInfo
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ImpexThreadCreated proc near
uses ds
.enter
; Some set-up work
;
call ThreadListPLock ; lock & own the thread list
; Add another entry, and initialize it
;
call ThreadListAddEntry ; thread list => DS:SI
mov ds:[si].TLE_appProcess, bx
mov ds:[si].TLE_threadInfo, cx
mov ds:[si].TLE_threadHandle, ax
; Clean up
;
call ThreadListUnlockV ; unlock & release thread list
.leave
ret
ImpexThreadCreated endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ImpexThreadDeleted
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Note that an Impex thread list has been deleted
CALLED BY: GLOBAL
PASS: BX = Impex thread handle
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ImpexThreadDeleted proc near
uses di, si, ds
.enter
; Some set-up work
;
call ThreadListPLock ; lock & own the thread list
; Find the thread, and delete it
;
mov di, offset EnumByThreadHandle
call ThreadListEnum ; search for entry by thread
jc done
call ThreadListDeleteEntry ; remove the entry
done:
call ThreadListUnlockV ; unlock & release thread list
.leave
ret
ImpexThreadDeleted endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ImpexThreadListAppExiting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Tell all import/export threads run by an application that
they need to exit
CALLED BY: ImportExportDetach
PASS: *DS:SI = ImportExportClass object
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
This routine goes through the thread list and for each
active thread owned by the App that is detaching, sends
a MSG_META_DETACH to it telling it to clean up and exit.
If the thread is already exiting, another DETACH is
*not* sent out, but the detach count for the
ImportExport object *is* incremented.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ImpexThreadListAppExiting proc near
uses ax, bx, cx, dx, di, bp, ds
.enter
; Some set-up work
;
mov dx, ds:[LMBH_handle]
mov bp, si ; Import/Export obj => ^lDX:BP
mov bx, dx
call MemOwner ; application thread => BX
call ThreadListPLock ; lock & own the thread list
; Find all threads, and start the detaching
;
mov di, offset EnumAppExiting
call ThreadListEnum ; enumerate though all entries
; Clean up
;
call ThreadListUnlockV ; unlock & release thread list
mov bx, dx
call MemDerefDS
mov si, bp ; Import/Export obj => *DS:SI
.leave
ret
ImpexThreadListAppExiting endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*** Lower-level routines
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ThreadListPLock
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Lock the ThreadList block down, creating one if it didn't
exist before
CALLED BY: INTERNAL
PASS: Nothing
RETURN: DS = ThreadList segment
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ThreadListPLock proc near
uses ax, bx
.enter
; Get the handle, and see if we need to do anything
;
NOFXIP < segmov ds, dgroup, ax >
FXIP < mov bx, handle dgroup >
FXIP < call MemDerefDS ; ds = dgroup >
mov bx, ds:[threadList]
EC < tst bx ; ensure handle exists >
EC < ERROR_Z IMPEX_THREAD_LIST_HANDLE_MUST_EXIST_TO_UNLOCK >
call MemPLock
mov ds, ax
.leave
ret
ThreadListPLock endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ThreadListUnlockV
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Unlock the ThreadList block
CALLED BY: INTERNAL
PASS: DS:0 = ThreadList segment
RETURN: Nothing
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ThreadListUnlockV proc near
uses bx
.enter
mov bx, ds:[TLH_handle] ; thread list handle => BX
EC < tst bx ; ensure handle exists >
EC < ERROR_Z IMPEX_THREAD_LIST_HANDLE_MUST_EXIST_TO_UNLOCK >
call MemUnlockV
.leave
ret
ThreadListUnlockV endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ThreadListAddEntry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Add an entry to the thread list
CALLED BY: INTERNAL
PASS: DS = ThreadList segment
RETURN: DS:SI = ThreadListEntry to use
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ThreadListAddEntry proc near
uses bx, di
.enter
; See if we have an entry available. If not, create one
;
clr bx
mov di, offset EnumByThreadHandle
call ThreadListEnum ; empty ThreadListEntry => DS:SI
jc appendEntry ; none, found, so append to end
done:
.leave
ret
; Append a ThreadListEntry to the end of the list
appendEntry:
push ax, cx
mov ax, ds:[TLH_size]
mov si, ax ; new ThreadListEntry => DS:SI
add ax, size ThreadListEntry
mov ds:[TLH_size], ax
mov bx, ds:[TLH_handle] ; ThreadList handle => BX
mov ch, mask HAF_NO_ERR ; can't deal with errors
call MemReAlloc ; reallocate block
mov ds, ax
pop ax, cx
jmp done ; we're done
ThreadListAddEntry endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ThreadListDeleteEntry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Delete a ThreadListEntry
CALLED BY: INTERNAL
PASS: DS:SI = ThreadListEntry
RETURN: Nothing
DESTROYED: DI
PSEUDO CODE/STRATEGY:
Mark the entry as unused, rather than coalescing the block,
as the block will only grow as large as the largest number
of import/exports that occur simultaneously
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ThreadListDeleteEntry proc near
clr di
mov ds:[si].TLE_appProcess, di
mov ds:[si].TLE_threadHandle, di
mov ds:[si].TLE_threadInfo, di
ret
ThreadListDeleteEntry endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*** Enumeration-related routines
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ThreadListEnum
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Enumerate all of the entries in a ThreadList
CALLED BY: INTERNAL
PASS: DS = ThreadList segment
DI = Callback routine to call (near)
Pass: DS:SI = ThreadListEntry
AX, BX, CX, DX, BP = Data
Returns: Carry = Set to stop enumeration
AX, BX, CX, DX, BP = Data
Destroys: Nothing
RETURN: AX, BX, CX, DX, BP = Data returned by callback
DS:SI = ThreadListEntry
Carry = Clear
- or -
Carry = Set (no entries accepted)
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
May not delete or add entries inside of callback routines
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ThreadListEnum proc near
.enter
; Loop through the list of entries
;
mov si, size ThreadListHeader
jmp midLoop
loopAgain:
call di
jc done ; if carry = set, accept
add si, size ThreadListHeader
midLoop:
cmp si, ds:[TLH_size]
jl loopAgain
clc
done:
cmc ; invert that carry!
.leave
ret
ThreadListEnum endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
EnumByThreadHandle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Callback routine for ThreadListEnum, searching for a
thread handle
CALLED BY: INTERNAL
PASS: DS:SI = ThreadListEntry
BX = Thread handle we're searching for
RETURN: Carry = Set if found
DESTROYED: Nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
EnumByThreadHandle proc near
if FULL_EXECUTE_IN_PLACE
;
; Make sure the fptr passed in is valid
;
EC < push bx >
EC < mov bx, ds >
EC < call ECAssertValidFarPointerXIP >
EC < pop bx >
endif
cmp ds:[si].TLE_threadHandle, bx
stc
jz done
clc
done:
ret
EnumByThreadHandle endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
EnumAppExiting
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: An application is exiting, so we need to tell all of
threads run by the application to exit
CALLED BY: ThreadListEnum
PASS: DS:SI = ThreadListEntry
BX = Application thread handle
DX:BP = Object that is detaching
RETURN: Carry = Clear (continue enumeration)
DESTROYED: AX, CX
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
EnumAppExiting proc near
uses bx, bp, ds, si
.enter
; See if we have the right thread
;
cmp bx, ds:[si].TLE_appProcess
jne exit
mov ax, ds:[si].TLE_threadHandle
mov bx, ds:[si].TLE_threadInfo
call ImpexThreadInfoPLock ; ImpexThreadInfo => DS:0
or ds:[ITI_state], mask ITS_APP_DETACHING
test ds:[ITI_state], mask ITS_THREAD_DETACHING
jnz incDetachCount ; don't sent two DETACH's
; Tell the thread that it better exit soon
;
mov cx, bx ; ImpexThreadInfo handle => CX
mov_tr bx, ax ; thread handle => BX
mov ax, MSG_META_DETACH
mov di, mask MF_FORCE_QUEUE or mask MF_INSERT_AT_FRONT
call ObjMessage
; Increment the detach count on the ImportExport object
incDetachCount:
push ds ; save ImpexThreadInfo
mov bx, dx
call MemDerefDS
mov si, bp ; ImpexObject => *DS:SI
call ObjIncDetach ; increment detach count
pop ds ; retreive ImpexThreadInfo
call ImpexThreadInfoUnlockV ; unlock & release Info block
exit:
.leave
ret
EnumAppExiting endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*** ImpexProcessThread methods
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ITPDetach
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Free all data structures as we're being destroyed
CALLED BY: GLOBAL (MSG_META_DETACH)
PASS: DS = ImpexThreadProcess segment
ES = ImpexThreadProcessClass segment
CX = ImpexThreadInfo handle
DX:BP = Caller's OD
RETURN: Nothing
DESTROYED: BX, DI
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 5/31/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ITPDetach method dynamic ImpexThreadProcessClass, MSG_META_DETACH
; Clean up the ImpexThreadInfo resources
;
push ds
call GetCurrentThreadHandle ; thread handle => BX
call ImpexThreadDeleted ; remove from the thread list
mov bx, cx
call ImpexThreadInfoPLock
call CleanUpImpexThreadInfo
mov cl, ds:[ITI_state] ; ImpexThreadState => CL
call ImpexThreadInfoUnlockV
call MemFree ; free the ImpexThreadInfo block
pop ds
; Pass message onto superclass
;
mov ax, MSG_META_DETACH
mov di, offset ImpexThreadProcessClass
GOTO ObjCallSuperNoLock
ITPDetach endm
ProcessCode ends
|
// Pair vs Subarray
// pair can be non-contiguous while subarray is contiguous
#include<bits/stdc++.h>
using namespace std;
bool Subarray(int a[],int n,int sum){
unordered_set<int>s;
int pre_sum = 0;
for(int i = 0; i <n; i++){
pre_sum += a[i];
if(pre_sum == sum) return true;
if(s.find(pre_sum - sum) != s.end()) return true;
s.insert(a[i]);
}
}
int main(){
int a[] = {1,2,3,4};
int sum = 6;
int n =sizeof(a)/sizeof(a[0]);
cout << Subarray(a,n,sum) << endl;
} |
dnl Intel Pentium-II mpn_lshift -- mpn left shift.
dnl Copyright 2001 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
dnl The P55 code runs well on P-II/III, but could stand some minor tweaks
dnl at some stage probably.
include(`../config.m4')
MULFUNC_PROLOGUE(mpn_lshift)
include_mpn(`x86/pentium/mmx/lshift.asm')
|
#include "Utilities/StorageFactory/interface/StorageMaker.h"
#include "Utilities/StorageFactory/interface/StorageMakerFactory.h"
#include "Utilities/StorageFactory/interface/StorageFactory.h"
#include "Utilities/StorageFactory/interface/RemoteFile.h"
class GsiFTPStorageMaker : public StorageMaker {
public:
std::unique_ptr<Storage> open(const std::string &proto,
const std::string &path,
int mode,
const AuxSettings &) const override {
std::string temp;
const StorageFactory *f = StorageFactory::get();
int localfd = RemoteFile::local(f->tempDir(), temp);
std::string lurl = "file://" + temp;
std::string newurl((proto == "sfn" ? "gsiftp" : proto) + ":" + path);
const char *ftpopts[] = {"globus-url-copy", newurl.c_str(), lurl.c_str(), nullptr};
return RemoteFile::get(localfd, temp, (char **)ftpopts, mode);
}
};
DEFINE_EDM_PLUGIN(StorageMakerFactory, GsiFTPStorageMaker, "gsiftp");
DEFINE_EDM_PLUGIN(StorageMakerFactory, GsiFTPStorageMaker, "sfn");
|
; A037458: a(1)=1; for n > 1, a(n) = n - a(n-floor(sqrt(n))).
; 1,1,2,3,3,3,4,5,6,6,6,6,7,8,9,10,10,10,10,10,11,12,13,14,15,15,15,15,15,15,16,17,18,19,20,21,21,21,21,21,21,21,22,23,24,25,26,27,28,28,28,28,28,28,28,28,29,30,31,32,33,34,35,36,36,36,36,36,36,36,36,36,37,38
add $0,2
mov $2,1
lpb $0
trn $0,$2
add $0,$2
add $1,1
sub $0,$1
add $2,$1
lpe
add $1,$0
sub $1,1
mov $0,$1
|
Map_361CB8: dc.w Frame_361CC8-Map_361CB8 ; ...
dc.w Frame_361CDC-Map_361CB8
dc.w Frame_361CF0-Map_361CB8
dc.w Frame_361D04-Map_361CB8
dc.w Frame_361D0C-Map_361CB8
dc.w Frame_361D14-Map_361CB8
dc.w Frame_361D1C-Map_361CB8
dc.w Frame_361D24-Map_361CB8
Frame_361CC8: dc.w 3
dc.b $E8, 7, 0, 0,$FF,$F0
dc.b $E8, 7, 0, 0, 0, 0
dc.b 8, 4, 0,$17,$FF,$F8
Frame_361CDC: dc.w 3
dc.b $F0, $A, 0, 8,$FF,$E8
dc.b $F0, $A, 8, 8, 0, 0
dc.b 8, 4, 0,$17,$FF,$F8
Frame_361CF0: dc.w 3
dc.b $F8, 9, 0,$11,$FF,$E8
dc.b $F8, 9, 8,$11, 0, 0
dc.b 8, 4, 0,$17,$FF,$F8
Frame_361D04: dc.w 1
dc.b $FC, 4, 0,$19,$FF,$F8
Frame_361D0C: dc.w 1
dc.b $FC, 4, 0,$1B,$FF,$F8
Frame_361D14: dc.w 1
dc.b $FC, 0, 0,$1D,$FF,$FC
Frame_361D1C: dc.w 1
dc.b $FC, 0, 0,$1E,$FF,$FC
Frame_361D24: dc.w 0
|
; ================================================================
; Macros
; ================================================================
if !def(incMacros)
incMacros set 1
; ================================================================
; Global macros
; ================================================================
; Copy a tileset to a specified VRAM address.
; USAGE: CopyTileset [tileset],[VRAM address],[number of tiles to copy]
; "tiles" refers to any tileset.
CopyTileset: macro
ld bc,$10*\3 ; number of tiles to copy
ld hl,\1 ; address of tiles to copy
ld de,$8000+\2 ; address to copy to
.loop
ld a,[hl+]
ld [de],a
inc de
dec bc
ld a,b
or c
jr nz,.loop
endm
; Copy a 1BPP tileset to a specified VRAM address.
; USAGE: CopyTileset1BPP [tileset],[VRAM address],[number of tiles to copy]
; "tiles" refers to any tileset.
CopyTileset1BPP: macro
ld bc,$10*\3 ; number of tiles to copy
ld hl,\1 ; address of tiles to copy
ld de,$8000+\2 ; address to copy to
.loop
ld a,[hl+] ; get tile
ld [de],a ; write tile
inc de ; increment destination address
ld [de],a ; write tile again
inc de ; increment destination address again
dec bc
dec bc ; since we're copying two tiles, we need to dec bc twice
ld a,b
or c
jr nz,.loop
endm
; ================================================================
; Project-specific macros
; ================================================================
; Insert project-specific macros here.
; ================================================================
; DevSound macros
; ================================================================
; Insert DevSound macros here.
endc |
lc r4, 0xfffffff4
lc r5, 0x00800000
gtu r6, r4, r5
halt
#@expected values
#r4 = 0xfffffff4
#r5 = 0x00800000
#r6 = 0x00000000
#pc = -2147483628
#e0 = 0
#e1 = 0
#e2 = 0
#e3 = 0
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2016 The Bitcoin Core developers
// Copyright (c) 2017-2018 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <amount.h>
#include <tinyformat.h>
const std::string CURRENCY_UNIT = "FCH";
std::string Amount::ToString() const {
return strprintf("%d.%08d %s", *this / COIN, (*this % COIN) / SATOSHI,
CURRENCY_UNIT);
}
|
/**
* Copyright (c) 2021 Darius Rückert
* Licensed under the MIT License.
* See LICENSE file for more information.
*/
#include "AssetRenderSystem.h"
#include "saiga/opengl/shader/shaderLoader.h"
namespace Saiga
{
AssetRenderSystem::AssetRenderSystem()
{
{
const char* shaderStr = "asset/ColoredAsset.glsl";
shader_colored_deferred =
shaderLoader.load<MVPColorShader>(shaderStr, {{GL_FRAGMENT_SHADER, "#define DEFERRED", 1}});
shader_colored_forward =
shaderLoader.load<MVPColorShader>(shaderStr, {{GL_FRAGMENT_SHADER, "#define DEPTH", 1}});
shader_colored_depth = shaderLoader.load<MVPColorShader>(shaderStr);
}
{
const char* shaderStr = "asset/texturedAsset.glsl";
shader_textured_deferred =
shaderLoader.load<MVPTextureShader>(shaderStr, {{GL_FRAGMENT_SHADER, "#define DEFERRED", 1}});
shader_textured_forward =
shaderLoader.load<MVPTextureShader>(shaderStr, {{GL_FRAGMENT_SHADER, "#define DEPTH", 1}});
shader_textured_depth = shaderLoader.load<MVPTextureShader>(shaderStr);
}
}
void AssetRenderSystem::Clear()
{
colored_assets.clear();
textured_assets.clear();
}
void AssetRenderSystem::Render(RenderInfo render_info)
{
if (render_info.render_pass == RenderPass::Deferred)
{
// Colored assets
if (!colored_assets.empty() && shader_colored_deferred->bind())
{
for (auto& data : colored_assets)
{
if (data.flags & RENDER_DEFAULT)
{
shader_colored_deferred->uploadModel(data.model);
data.asset->renderRaw();
}
}
shader_colored_deferred->unbind();
}
// Textured assets
if (!textured_assets.empty() && shader_textured_deferred->bind())
{
for (auto& data : textured_assets)
{
if (data.flags & RENDER_DEFAULT)
{
shader_textured_deferred->uploadModel(data.model);
data.asset->RenderNoShaderBind(shader_textured_deferred.get());
}
}
shader_textured_deferred->unbind();
}
}
else if (render_info.render_pass == RenderPass::Shadow || render_info.render_pass == RenderPass::DepthPrepass)
{
// Colored assets
if (!colored_assets.empty() && shader_colored_depth->bind())
{
for (auto& data : colored_assets)
{
if (data.flags & RENDER_SHADOW || render_info.render_pass == RenderPass::DepthPrepass)
{
shader_colored_depth->uploadModel(data.model);
data.asset->renderRaw();
}
}
shader_colored_depth->unbind();
}
}
}
void AssetRenderSystem::Add(std::shared_ptr<Asset> asset, const mat4& transformation, int render_flags)
{
if (auto a = std::dynamic_pointer_cast<ColoredAsset>(asset))
{
colored_assets.push_back({a, transformation, render_flags});
}
if (auto a = std::dynamic_pointer_cast<TexturedAsset>(asset))
{
textured_assets.push_back({a, transformation, render_flags});
}
}
} // namespace Saiga
|
%macro exit 0
mov eax, 1
xor ebx, ebx
int 0x80
%endmacro
section .rodata
n db 0xa
%macro write_nl 0
mov eax, 4
mov ebx, 1
mov edx, 1
mov ecx, n
int 0x80
%endmacro
section .bss
num resb 10
section .text
global _start
_start:
xor ecx,ecx
.loop:
inc ecx
add ecx, '0'
mov [num], ecx
push ecx
mov eax, 4
mov ebx, 1
mov edx, 1
mov ecx, num
int 0x80
pop ecx
sub ecx, '0'
cmp ecx, 9
jne .loop
write_nl
exit
|
org #c000 ; RAM goes to the 4th slot
RAM:
; ----------------------------------------------------------------
; RAM that is shared acorss all game states:
; ----------------------------------------------------------------
; Music variables:
MUSIC_tempo: ds virtual 1
beginning_of_sound_variables_except_tempo:
MUSIC_play: ds virtual 1
MUSIC_tempo_counter: ds virtual 1
MUSIC_instruments: ds virtual N_MUSIC_CHANNELS
MUSIC_channel3_instrument_buffer: ds virtual 1 ;; this stores the instrument of channel 3, which is special, since SFX might overwrite it
MUSIC_start_pointer: ds virtual 2
SFX_pointer: ds virtual 2
MUSIC_pointer: ds virtual 2
MUSIC_repeat_stack_ptr: ds virtual 2
MUSIC_repeat_stack: ds virtual 4*3
MUSIC_instrument_envelope_ptr: ds virtual N_MUSIC_CHANNELS*2
SFX_priority: ds virtual 1 ; the SFX from the game have more priority than those triggered by music
;MUSIC_transpose: ds virtual 1
MUSIC_time_step_required: ds virtual 1
end_of_sound_variables:
music_buffer: ds virtual 1152 ; size of the longest song
game_state: ds virtual 1
;; stores which exit the player entered, to know which map to load in the inter-map state
exit_entered:
;; temporary variable used in the title screen for storing animation state
title_state: ds virtual 1
title_state2: ds virtual 1
story_skip: ds virtual 1
MSXTurboRMode: ds virtual 1
; I ended up not using this, since I don't have enough bytes in the ROM to support it...
raycast_double_buffer: ds virtual 1 ;; This variable is only used in MSX2 or higher for using double buffering, and remove flickering when rendering
;; if "raycast_double_buffer = 0", we are showing in the usual VDP addresses
;; if "raycast_double_buffer != 0", we are showing the secondary buffer (usual addresses + #4000)
raycast_use_double_buffer: ds virtual 1 ;; this is 0 if the MSX only has 16KB of VRAM, and 1 otherwise, so we can use double buffering
interrupts_per_game_frame: ds virtual 1
SP_buffer_for_fast_memory_clear: ds virtual 2
previous_keymatrix0: ds virtual 1
game_interrupt_cycle: ds virtual 1
END_OF_COMMON_RAM:
; ----------------------------------------------------------------
; RAM that is needed during gameplay:
; ----------------------------------------------------------------
org END_OF_COMMON_RAM
; Space for ROMtoRAM:
RAM_gameStart:
player_precision_x: ds virtual 2
player_precision_y: ds virtual 2
player_angle: ds virtual 1
; game state variables:
game_cycle: ds virtual 1
player_map: ds virtual 1
player_x: ds virtual 1
player_y: ds virtual 1
player_health: ds virtual 1
available_weapons: ds virtual N_WEAPONS
available_secondary_weapons: ds virtual N_SECONDARY_WEAPONS
available_armors: ds virtual N_ARMORS
;; Table that stores which patterns are currently loaded on the VDP sprite
;; patterns 24 - 31.
;; the number here indexes the list of enemy sprite patterns (enemySpritePatterns)
spritePatternCacheTable: ds virtual 8
; texture_colors: ds virtual 11
initial_rendering_blocks: ds virtual 5
initial_rendering_address: ds virtual 8
amount_of_bytes_to_render: ds virtual 1
raycast_angle_offset: ds virtual 1
raycast_amount_to_clear: ds virtual 2
raycast_sprite_angle_cutoff: ds virtual 1
EndOfRAM_gameStart:
memoryToClearOnNewGame:
game_over_cycle: ds virtual 1
player_hit_timmer: ds virtual 1
player_mana: ds virtual 1
player_keys: ds virtual 1
player_state: ds virtual 1
player_state_cycle: ds virtual 1
spritePatternCacheTableNextToErase: ds virtual 1
; sprites:
knight_sprite_attributes: ds virtual 4
knight_sprite_outline_attributes: ds virtual 4
sword_sprite_attributes: ds virtual 4
other_sprite_attributes: ds virtual 4*(N_SPRITE_DEPTHS*N_SPRITES_PER_DEPTH)
knight_animation_frame: ds virtual 1
knight_animation_frame_in_vdp: ds virtual 1 ; so that if this is the same as knight_animation_frame, we don't need to upload it again
n_sprites_uploaded_last_cycle: ds virtual 1
sprites_available_per_depth: ds virtual N_SPRITE_DEPTHS
assignSprite_y: ds virtual 1
assignSprite_x: ds virtual 1
assignSprite_sprite: ds virtual 1
assignSprite_color: ds virtual 1
assignSprite_bank: ds virtual 1
assigningSpritesForAnEnemy: ds virtual 1
; position of the camera in the frame that is currently rendered in the screen:
last_raycast_camera_x: ds virtual 1
last_raycast_camera_y: ds virtual 1
last_raycast_player_angle: ds virtual 1
;; global game state:
globalState_doorsOpen: ds virtual N_MAPS*MAX_DOORS_PER_MAP
globalState_itemsPickedUp: ds virtual N_MAPS*MAX_PICKUPS_PER_MAP
globalState_BossesKilled: ds virtual 4
current_weapon: ds virtual 1
current_secondary_weapon: ds virtual 1
current_armor: ds virtual 1
current_armor_color: ds virtual 1
arrow_data: ds virtual ARROW_STRUCT_SIZE*MAX_ARROWS
hourglass_timer: ds virtual 1
current_UI_message: ds virtual 32
current_UI_message_timer: ds virtual 1
; whether SPACE/TRIGGER1 or M/TRIGGER2 were pressed in the previous game cycle or not
previous_trigger1: ds virtual 1
previous_trigger2: ds virtual 1
raycast_screen_size_change_requested: ds virtual 1
CPUmode_change_requested: ds virtual 1
endOfMemoryToClearOnNewGame:
message_skip: ds virtual 1
; raycast variables:
raycast_player_x: ds virtual 1
raycast_player_y: ds virtual 1
raycast_camera_x: ds virtual 1
raycast_camera_y: ds virtual 1
raycast_column_pixel_mask: ds virtual 1
raycast_player_angle: ds virtual 1
raycast_first_column: ds virtual 1
raycast_last_column: ds virtual 1
raycast_column: ds virtual 1
raycast_camera_offset: ds virtual 1
raycast_buffer_offset_bank1: ds virtual 2
raycast_buffer_offset_bank2: ds virtual 2
raycast_ceiling_type: ds virtual 1 ; 0: ceiling, 1: skybox
raycast_texture_set: ds virtual 1
raycast_floor_texture_color: ds virtual 1
raycast_ceiling_texture_color: ds virtual 1
raycast_column_x_offs_table_xangle_times_32: ds virtual 2
patternCopyBuffer2:
password_buffer: ds virtual 32
skybox_buffer: ds virtual 384
;; 256 - align several buffers, so that I can address them directly by
;; modifying the low byte of the registers
ds virtual ((($-1)/#100)+1)*#100-$
textures_before:
raycast_divide_by16_table: ds virtual 256 ; 256-alignned
textures: ds virtual 16*32*MAX_TEXTURES ; 256-alignned
currentMap: ds virtual 16*16 ; 256-alignned
raycast_buffer: ds virtual (32-RAYCAST_SIDE_BORDER*2)*4*16 ; 256-alignned
raycast_color_buffer: ds virtual (32-RAYCAST_SIDE_BORDER*2)*4*16 ; 256-alignned
patternCopyBuffer: ; this is used as an intermediate buffer, to copy patterns from one page of VDP to another
;; stores the texture of the floor (calculated in the ceiling)
raycast_floor_texture_buffer: ds virtual 32
currentMapPickups: ds virtual 1+4*MAX_PICKUPS_PER_MAP
currentMapEnemies: ds virtual 1+ENEMY_STRUCT_SIZE*MAX_ENEMIES_PER_MAP
currentMapEvents: ds virtual 1+3*MAX_EVENTS_PER_MAP
currentMapMessages: ds virtual 4*22*MAX_MESSAGES_PER_MAP
currentMapDoorLocations: ds virtual MAX_DOORS_PER_MAP
raycast_renderer: ds virtual 932 ; space where the raycasting routine will be decompressed
raycast_update_selfmodifying_ceiling_code_entry_point: equ raycast_renderer
raycast_render_to_buffer: equ raycast_renderer+3
endOfRAM:
|
// agents.cpp
/* testing
#include <fstream> */
#include <limits>
#include "agents.h"
using namespace std;
// Constructors and construction functions
Agent::Agent(string _name){
name = _name;
cr = NULL;
}
Asteroid::Asteroid(string _name) : Agent(_name) {
start_time = 480;
time_left = start_time;
}
Player::Player(string _name, set<string> _items) : Agent(_name) {
items = _items;
conditions.insert(pair<string, bool> ("core", false));
conditions.insert(pair<string, bool> ("power", false));
conditions.insert(pair<string, bool> ("comms", false));
conditions.insert(pair<string, bool> ("screw", false));
conditions.insert(pair<string, bool> ("rephull", false));
conditions.insert(pair<string, bool> ("repguid", false));
}
Player read_player_info(){
string new_name;
cout << "Enter your first name: ";
cin >> new_name;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << endl;
set<string> items;
items.insert("spacesuit");
return Player(new_name, items);
}
// GET functions
string Player::get_name() {
return name;
}
int Player::get_info(Asteroid &asteroid) {
string action, object, line, temp_line;
size_t pos = 0;
size_t last = string::npos;
cout << "What do you do " << name << "?: ";
/* production */
getline(cin, line);
/* testing
ifstream usefile_orig("usefile.txt");
ofstream temp("temp.txt");
int i = 0;
while(getline(usefile_orig, temp_line)) {
if(i == 0) {
line = temp_line;
} else {
temp << temp_line << endl;
}
++i;
} */
if((pos = line.find(' ')) != string::npos){
action = line.substr(0, pos);
line.erase(0, pos + 1);
} else {
action = "a";
}
if((pos = line.find(last))) {
object = line.substr(0, pos);
line.erase(0, numeric_limits<streamsize>::max());
} else {
object = "a";
}
/* testing
usefile_orig.close();
temp.close();
ofstream usefile_new("usefile.txt");
ifstream temp_new("temp.txt");
while(getline(temp_new, temp_line)) {
usefile_new << temp_line << endl;
}
temp_new.close();
usefile_new.close();
remove("temp.txt"); */
cout << endl;
if(asteroid.act(action, object)) {
return 2;
} else if(this->act(action, object)){
return 0;
} else {
return 1;
}
}
void Player::check_items(){
cout << "You have";
if(!items.empty()){
cout << ":" << endl;
set<string>::iterator item_it;
for(item_it = items.begin(); item_it != items.end(); ++item_it){
cout << *item_it << endl;
}
} else {
cout << " nothing." << endl;
}
cout << endl;
}
void Asteroid::get_time() {
cout << "T-MINUS: ";
if((time_left / 60) < 10){
cout << "0" << time_left / 60;
} else {
cout << time_left / 60;
}
cout << ":";
if(time_left % 60 < 10) {
cout << "0" << time_left % 60;
} else {
cout << time_left % 60;
}
cout << " UNTIL IMPACT" << endl << endl;
}
void Asteroid::get_end_time() {
cout << "You completed the game in ";
time_left = start_time - time_left;
if((time_left / 60) < 10){
cout << "0" << time_left / 60;
} else {
cout << time_left / 60;
}
cout << ":";
if(time_left % 60 < 10) {
cout << "0" << time_left % 60;
} else {
cout << time_left % 60;
}
cout << endl;
}
// SET functions
bool Player::take_item(string item) {
if(cr->items_here.find(item) != cr->items_here.end()){
items.insert(item);
cout << "You picked up the " << item << endl << endl;
return true;
} else {
cout << "That cannot be taken" << endl << endl;
return false;
}
}
bool Player::drop_item(string item) {
if(!(cr->get_name()[0] == 'v' && item == "spacesuit")){
if(items.find(item) != items.end()){
items.erase(item);
cout << "You dropped the " << item << endl << endl;
return true;
} else {
cout << "You can't drop something you don't have." << endl << endl;
return false;
}
} else {
cout << "You can't drop your spacesuit in space!" << endl << endl;
return false;
}
}
// ACTION functions
bool Player::use_item(string item){
if(items.find(item) != items.end()) {
if(cr->usables.find(item) != cr->usables.end()) {
if(item == "ignition-sequence") {
if( conditions["core"] && conditions["power"] && conditions["comms"] && conditions["rephull"] && conditions["repguid"]) {
items.erase(item);
cout << "You used the " << item << " on the " << cr->usables.find(item)->second << endl << endl;
return true;
} else {
if(items.find(item) != items.end()) {
cout << "The shuttle is still inoperable." << endl << endl;
} else {
cout << "You don't have that." << endl << endl;
}
return false;
}
} else
if(item == "hull-parts") {
if(conditions["screw"]) {
items.erase(item);
cout << "You used the " << item << " on the " << cr->usables.find(item)->second << endl << endl;
return true;
} else {
if(items.find(item) != items.end()) {
cout << "You need the correct tool to use that." << endl << endl;
} else {
cout << "You don't have that." << endl << endl;
}
return false;
}
} else
if(item == "guidance-unit") {
if(conditions["screw"]) {
items.erase(item);
cout << "You used the " << item << " on the " << cr->usables.find(item)->second << endl << endl;
return true;
} else {
if(items.find(item) != items.end()) {
cout << "You need the correct tool to use that." << endl << endl;
} else {
cout << "You don't have that." << endl << endl;
}
return false;
}
}
else {
if(items.find(item) != items.end()) {
items.erase(item);
cout << "You used the " << item << " on the " << cr->usables.find(item)->second << endl << endl;
return true;
} else {
cout << "You don't have that." << endl << endl;
return false;
}
}
} else {
if(items.find(item) != items.end()) {
cout << "You can't use this like that." << endl << endl;
} else {
cout << "You don't have that." << endl << endl;
}
return false;
}
} else {
cout << "You don't have that." << endl << endl;
return false;
}
}
bool Asteroid::act(string action, string object) {
if(action == "move") {
time_left -= 5;
} else if(action == "take" || action == "drop" || action == "use") {
time_left -= 2;
} else if(action == "look") {
if(object == "closely") {
time_left -= 3;
} else {
time_left -= 1;
}
} else if(action == "check") {
time_left -= 1;
}
if(time_left <= 0) {
return true;
} else {
get_time();
return false;
}
}
bool Player::act(string action, string object) {
if(action == "help" && object == "me"){
cout << endl << "Valid commands and syntax guide:" << endl;
cout << "Please note that the timer is NOT real time. Each action takes a set amount of time." << endl << endl;
cout << "move [direction] moves character in a valid direction." << endl;
cout << "look [around || closely] gives information about the room you are in." << endl;
cout << "take [object] picks up object in room." << endl;
cout << "drop [object] drop an item from your inventory." << endl;
cout << "use [object] uses object in inventory." << endl;
cout << "check items lists items in your inventory." << endl;
cout << "help me lists commands." << endl << endl;
} else
if(action == "move") {
if(cr->move_rules(items, object, conditions)) {
cr = cr->get_link(object);
} else {
cout << "You can't do that. Type \"help me\" for help" << endl << endl;
}
} else
if(action == "look") {
if(object == "around") {
cr->print_linked(false);
} else
if(object == "closely") {
cr->print_linked(true);
} else {
cout << "There is nothing to see there." << endl << endl;
}
} else
if(action == "take") {
if(take_item(object)){
if(object == "sonic-screwdriver") {
conditions["screw"] = true;
}
cr->remove_item(object);
}
} else
if(action == "drop") {
if(drop_item(object)){
if(object == "sonic-screwdriver") {
conditions["screw"] = false;
}
cr->add_item(object);
}
} else
if(action == "use") {
if(use_item(object)) {
cr->remove_usable(object);
if(object == "keyboard") {
cout << "You re-attach the keyboard to the terminal." << endl;
cout << "The terminal turns on and you see the power is out in the station." << endl;
cout << "You select the open Reactor Core hatch and below you a hatch opens." << endl << endl;
conditions["core"] = true;
}
if(object == "wrench") {
cout << "You close the open release valve and see the reactor shine brightly." << endl;
cout << "There is now a faint humming noise all throughout the station." << endl;
cout << "You hear a notification, \"STATION HUB HATCHES NOW OPEN\"" << endl << endl;
conditions["power"] = true;
}
if(object == "command-code") {
cout << "You use the command-code to access the command systems." << endl;
cout << "You activate the station's comms relays." << endl;
cout << "The escape shuttle will now have the ability to find location beacons." << endl << endl;
conditions["comms"] = true;
}
if(object == "guidance-unit") {
cout << "The shuttle now has an operable guidance-unit" << endl << endl;
conditions["repguid"] = true;
}
if(object == "hull-parts") {
cout << "The shuttle now has a patched hull and is structurally sound" << endl << endl;
conditions["rephull"] = true;
}
if(object == "ignition-sequence") {
return true;
}
}
} else
if(action == "check" && object == "items"){
check_items();
}
else {
cout << "You can't do that. Type \"help me\" for help" << endl << endl;
}
return false;
}
|
; size_t b_vector_append_n(b_vector_t *v, size_t n, int c)
SECTION code_adt_b_vector
PUBLIC b_vector_append_n
EXTERN asm_b_vector_append_n
b_vector_append_n:
pop af
pop bc
pop de
pop hl
push hl
push de
push bc
push af
jp asm_b_vector_append_n
|
;*********************************************************
;* MODULE: IO
;*
;* DESCRIPTION: INPUT/OUTPUT-RELATED FUNCTIONS
;* UART CONTROL, TIMER CONTROL, SOUND FUNCTIONS,
;* KEYBOARD FUNCTIONS, TERMINAL OUTPUT FUNCTIONS
;*
.module io
.title Input/Output module (term+sound)
.include '..\common\common.def'
TIMER = 0x40 ;TIMER PORT BASE
T_C0 = TIMER+0 ;COUNTER 0
T_C1 = TIMER+1 ;COUNTER 1
T_C2 = TIMER+2 ;COUNTER 2
T_CWR = TIMER+3 ;CONTROL WORD REGISTER
UART = 0x60 ;UART PORT BASE
U_RBR = UART+0 ;RECEIVER BUFFER REGISTER (READ ONLY)
U_THR = UART+0 ;TRANSMITTER HOLDING REGISTER (WRITE ONLY)
U_IER = UART+1 ;INTERRUPT ENABLE REGISTER
U_IIR = UART+2 ;INTERRUPT IDENTIFICATION REGISTER (READ ONLY)
U_LCR = UART+3 ;LINE CONTROL REGISTER
U_MCR = UART+4 ;MODEM CONTROL REGISTER
U_LSR = UART+5 ;LINE STATUS REGISTER
U_MSR = UART+6 ;MODEM STATUS REGISTER
U_SCR = UART+7 ;SCRATCH REGISTER
U_DLL = UART+0 ;DIVISOR LATCH (LSB)
U_DLM = UART+1 ;DIVISOR LATCH (MSB)
TERM_ATTN = 1
.area BOOT (ABS)
;*********************************************************
.org 0x0024
RST45:
DI
JMP INTTI0
;*********************************************************
.org 0x0034
RST65:
DI
JMP INTUART
.area _CODE
;*********************************************************
;* IO_INIT: INITIALIZES MODULE
IO_INIT::
CALL IO_INITTIMER ;INITIALIZE TIMER
CALL IO_INITUART ;INITIALIZE UART
CALL IO_INITKBBUF ;INITIALIZE KEYBOARD BUFFER
MVI A,7 ;LIGHT GRAY FG, BLACK BG
CALL IO_SETCOLOR ;SET CURRENT ATTRIBUTE
CALL IO_HOME ;SET CURRENT POS (HOME)
CALL IO_CLS ;CLEARS THE SCREEN
RET
;*********************************************************
;* UART ROUTINES
;*********************************************************
;*********************************************************
;* IO_INITKBBUF: INITIALIZES KEYBOARD BUFFER
IO_INITKBBUF::
LXI H,0 ;HL = 0
SHLD IO_KBUFPTR ;WORD AT IOKBUFPTR = 0
RET
;*********************************************************
;* IO_INITUART: INITIALIZES UART
IO_INITUART:
.if ~DEBUG
MVI A,0xA0 ;SET DLA MODE
OUT U_LCR
MVI A,0x0D ;BAUD RATE SETUP
OUT U_DLL ;9600 BAUDS (SOURCE 2MHz)
MVI A,0x00
OUT U_DLM
MVI A,0x03 ;LCR SETUP
OUT U_LCR ;8 DATA, 1 STOP, NO PARITY, DLA_OFF
MVI A,0x01 ;INTERRUPT ENABLE REGISTER
OUT U_IER ;ENABLE RECEIVED DATA AVAILABLE INTERRUPT
.endif
RET
;********************************************************
; INTUART: INTERRUPT HANDLER FOR UART (STUFF A CHAR IN THE KB BUFFER)
INTUART:
PUSH PSW
PUSH D
PUSH H
LHLD IO_KBUFPTR ;LOAD HL WITH WORD AT IOKBUFPTR
MOV A,H ;HI PTR IN A
INR A ;HI PTR + 1
ANI 0x0F ;HI PTR MOD 16
MOV H,A ;BACK IN H
CMP L ;COMPARE NEW HI PTR WITH LO PTR
JZ 1$ ;IF PTRS ARE EQUAL, BUFFER IS FULL
SHLD IO_KBUFPTR ;PUT BACK UPDATED PTR AT IOKBUFPTR
DCR A ;HI PTR -1
ANI 0x0F ;HI PTR MOD 16
MOV E,A ;0-H IN D-E (OFFSET TO ADD TO BUF ADDRESS)
MVI D,0
LXI H,IO_KBUF ;ADDRESS OF KB BUF IN H-L
DAD D ;NEW ADDRESS IN H-L
IN U_RBR ;GET THE BYTE
CPI 27 ;CHECK FOR ESCAPE
JZ 3$
MOV M,A ;NEW CHAR READ -> KB BUFFER
JMP 2$
1$:
IN U_RBR ;GET THE BYTE, DO NOTHING WITH IT
CPI 27 ;CHECK FOR ESCAPE
JZ 3$
2$:
POP H
POP D
POP PSW
EI
RET
3$: EI
RST 6
;********************************************************
; IO_XON: FLOW CONTROL - INDICATES TO REMOTE
; THAT WE ARE READY TO ACCEPT CHARS
IO_XON::
IN U_MCR ;READ MCR REGISTER
ORI 1 ;SET BIT ZERO (SET DTR)
OUT U_MCR ;PUT BACK
RET
;********************************************************
; IO_XOFF: FLOW CONTROL - INDICATES TO REMOTE
; TO STOP SENDING CHARS
IO_XOFF::
IN U_MCR ;READ MCR REGISTER
ANI 254 ;CLEAR BIT ZERO (RESET DTR)
OUT U_MCR
RET
;********************************************************
; IO_GETCHAR: GETS A CHAR FROM KEYBOARD BUFFER (RETURNED IN ACC - 0 IF EMPTY)
IO_GETCHAR::
PUSH B
PUSH D
PUSH H
LHLD IO_KBUFPTR ;LOAD HL WITH WORD AT IOKBUFPTR
MOV A,L ;LO PTR IN A
CMP H ;COMPARE LO PTR WITH HI PTR
JZ 1$ ;IF PTRS ARE EQUAL, BUFFER IS EMPTY
MOV C,L ;0-L IN B-C (OFFSET TO ADD TO BUF ADDRESS)
MVI B,0
XCHG ;HL <-> DE
LXI H,IO_KBUF ;ADDRESS OF KB BUF IN H-L
DAD B ;NEW ADDRESS IN H-L
MOV B,M ;KB BUFFER -> B
XCHG ;HL <-> DE
MOV A,L
INR A ;LO PTR + 1
ANI 0x0F ;LO PTR MOD 16
MOV L,A ;BACK IN LO
SHLD IO_KBUFPTR ;PUT BACK UPDATED PTR AT IOKBUFPTR
MOV A,B
JMP 2$
1$:
MVI A,0 ;NOTHING IN BUFFER
2$:
POP H
POP D
POP B
RET
;*********************************************************
;* OUTPUT ROUTINES
;*********************************************************
;********************************************************
; IO_PUTC: SENDS A CHAR (FROM ACC) TO THE TERMINAL
IO_PUTC::
.if ~DEBUG
PUSH PSW
1$:
IN U_LSR ;LINE STATUS REGISTER
ANI 0x20 ;CHECK IF UART IS READY
JZ 1$ ;IF NOT, WAIT FOR IT
POP PSW ;GET BACK CHAR
.endif
OUT U_THR
RET
;********************************************************
; IO_PUTCR: PRINTS NEW LINE CHARACTER
IO_PUTCR::
MVI A,13
JMP IO_PUTC
;********************************************************
; IO_PUTS: PUTS STRING - TERMINATED BY NULL OR HI BYTE=1
; PRE TO STRING IN HL
IO_PUTS::
PUSH H
1$:
MOV A,M ;LOAD CHAR FROM MEMORY
ORA A ;END OF STRING?
JZ 2$
JM 2$
CALL IO_PUTC ;PRINT CHAR
INX H ;INCREMENT ADDRESS
JMP 1$ ;LOOP
2$:
POP H
RET
;********************************************************
; IO_PUTSN: PUTS STRING - LENGTH IN B, PTR IN HL
IO_PUTSN::
PUSH B
1$:
MOV A,B ; CHECK COUNT
ORA A ; CHECK IF ZERO
JZ 2$
MOV A,M ;LOAD CHAR FROM MEMORY
CALL IO_PUTC ;PRINT CHAR
INX H ;INCREMENT ADDRESS
DCR B
JMP 1$ ;LOOP
2$:
POP B
RET
;********************************************************
; IO_PUTCB: PRINTS A BYTE (ACC) IN BINARY (I.E. 10011010)
IO_PUTCB::
PUSH B
MOV C,A ;KEEP IN NUMBER IN C
MVI B,8 ;8 BINARY DIGITS
1$:
MOV A,C ;GET NUMBER
RAL ;SHIFT LEFT
MOV C,A ;PUT BACK IN C
JC 2$ ;0 OR 1?
MVI A,#'0 ;WE HAVE A ZERO
JMP 3$
2$:
MVI A,#'1 ;WE HAVE A ONE
3$:
CALL IO_PUTC ;PRINT THE BIT
DCR B ;LOOP FOR 8 BITS
JNZ 1$
POP B
RET
;********************************************************
; IO_PUTCH: PRINTS A BYTE (ACC) IN HEX
IO_PUTCH::
PUSH PSW ;SAVE LOW DIGIT
RRC ;MAKE HIGH.
RRC ;DIGIT.
RRC ;INTO.
RRC ;LOW DIGIT.
CALL IO_PUTN ;PRINT HIGH DIGIT
POP PSW ;GET LOW DIGIT BACK
CALL IO_PUTN ;PRINT LOW DIGIT
RET
;********************************************************
; IO_PUTN: DISPLAYS NIBBLE IN LOWER 4 BITS OF A ('0'..'F')
IO_PUTN:
PUSH PSW
ANI 0x0F ;GET RID OF EXCESS BAGGAGE
ADI 0x30 ;CONVERT TO ASCII NUMBER
CPI 0x3A ;TEST FOR ALPHA CHARACTER
JC 1$ ;IF NOT, WE ARE OK
ADI 7 ;CONVERT TO CHARACTER
1$:
CALL IO_PUTC
POP PSW
RET
;********************************************************
; IO_PUTHLHEX: SHOW 16 BIT VALUE OF HL IN HEX
IO_PUTHLHEX::
MOV A,H ;GET H
CALL IO_PUTCH ;DISPLAY H IN HEX
MOV A,L ;GET L
CALL IO_PUTCH ;DISPLAY L IN HEX
RET
;*********************************************************
;* IO_CLS: CLEARS SCREEN (FILL WITH CURRENT ATTRIBUTE)
IO_CLS::
MVI A,TERM_ATTN ;TERM:ATTN
CALL IO_PUTC
MVI A,1 ;TERM:CLS
CALL IO_PUTC
RET
;********************************************************
; IO_HOME: MOVE CURSOR TO HOME POSITION (0,0)
IO_HOME::
MVI A,TERM_ATTN ;TERM:ATTN
CALL IO_PUTC
MVI A,12 ;TERM:HOME
CALL IO_PUTC
RET
;*********************************************************
;* IO_GOTOXY: SET CURSOR POSITION; X-Y IN H-L
IO_GOTOXY::
MVI A,TERM_ATTN ;TERM:ATTN
CALL IO_PUTC
MVI A,11 ;TERM:GOTOXY
CALL IO_PUTC
MOV A,H ;TERM:X
CALL IO_PUTC
MOV A,L ;TERM:Y
CALL IO_PUTC
RET
;*********************************************************
;* IO_SETFG: SET FOREGROUND COLOR (IN ACC) (0-15)
IO_SETFG::
PUSH B
ANI 0x0F ;CLEAR USELESS BITS
MOV B,A ;FG COLOR IN B
LDA IO_CURRATTR ;CURRENT COLOR IN ACC
ANI 0xF0 ;CLEAR UPPER BITS
ORA B ;MERGE WITH BG COLOR
CALL IO_SETCOLOR ;STORE NEW ATTR VALUE
POP B
RET
;*********************************************************
;* IO_SETBG: SET BACKGROUND COLOR (IN ACC) (0-15)
IO_SETBG::
PUSH B
ANI 0x0F ;CLEAR USELESS BITS
RLC
RLC
RLC ;SHIFT 4 BITS TO THE LEFT
RLC
MOV B,A ;BG COLOR IN B
LDA IO_CURRATTR ;CURRENT COLOR IN ACC
ANI 0x0F ;CLEAR UPPER BITS
ORA B ;MERGE WITH BG COLOR
CALL IO_SETCOLOR ;STORE NEW ATTR VALUE
POP B
RET
;*********************************************************
;* IO_SETCOLOR: SET COLOR; COMBINED COLOR IN ACC
IO_SETCOLOR::
PUSH PSW
MVI A,TERM_ATTN ;TERM:ATTN
CALL IO_PUTC
MVI A,2 ;TERM:SETCOLOR
CALL IO_PUTC
POP PSW
CALL IO_PUTC ;TERM:ATTRIBUTE
STA IO_CURRATTR ;STORE ATTRIBUTE
RET
;*********************************************************
;* IO_SETINPUTMODE: TOGGLES TO INPUT MODE
IO_SETINPUTMODE::
MVI A,TERM_ATTN ;TERM:ATTN
CALL IO_PUTC
MVI A,65 ;TERM:INPUTMODE
CALL IO_PUTC
RET
;*********************************************************
;* IO_SETINTERACTIVEMODE: TOGGLES TO INTERACTIVE MODE
IO_SETINTERACTIVEMODE::
MVI A,TERM_ATTN ;TERM:ATTN
CALL IO_PUTC
MVI A,64 ;TERM:INTERACTIVEMODE
CALL IO_PUTC
RET
;*********************************************************
;* TIMER ROUTINES
;*********************************************************
;*********************************************************
;* IO_INITTIMER: INITIALIZES TIMERS
IO_INITTIMER:
LXI H,0x0000 ;CLEAR H-L
SHLD TICNT ;H-L IN WORD AT 'TICNT'
;* SET COUNTER 0 (PRESCALER, 2MHz clock -> 20KHz)
MVI A,0x36 ;COUNTER 0, LSB+MSB, MODE 3, NOBCD
OUT T_CWR
;* SOURCE:2MHz, DEST:20KHz, DIVIDE BY 100 (0x0064)
MVI A,0x64 ;LSB
OUT T_C0
MVI A,0x00 ;MSB
OUT T_C0
;* SET COUNTER 1 (TIMER CLOCK, 10Hz)
MVI A,0x74 ;COUNTER 1, LSB+MSB, MODE 2, NOBCD
OUT T_CWR
;* SOURCE:20KHz, DEST:10HZ, DIVIDE BY 2000 (0x07D0)
MVI A,0xD0 ;LSB
OUT T_C1
MVI A,0x07 ;MSB
OUT T_C1
;* SET COUNTER 2 (SOUND, SOURCE = 20KHZ)
MVI A,0xB6 ;COUNTER 2, LSB+MSB, MODE 3, NOBCD
OUT T_CWR
RET
;*********************************************************
;* INTTI0: INTERRUPT HANDLER FOR TIMER 0. INCREMENTS TICNT
INTTI0:
PUSH H
LHLD TICNT
INX H
SHLD TICNT
POP H
EI
RET
;*********************************************************
;* IO_BEEP: MAKES A 440HZ BEEP FOR 1/2 SECOND
IO_BEEP::
.if ~DEBUG
MVI A,45 ;LA4 440HZ
CALL IO_SOUNDON
MVI A,5
CALL IO_DELAY ;WAIT 5 * 100 MS
CALL IO_SOUNDOFF
.endif
RET
;*********************************************************
;* IO_SOUNDON: PROGRAMS COUNTER 0 AND ENABLES SOUND OUTPUT
IO_SOUNDON::
.if ~DEBUG
PUSH H
PUSH B
CALL IO_SOUNDOFF ;TURNS OFF SOUND BEFORE REPROGRAMMING
RLC ;OFFSET *= 2 (TABLE CONTAINS WORDS)
MVI B,0
MOV C,A ;OFFSET IN B-C
LXI H,NOTES ;TABLE BASE IN H-L
DAD B ;ADD OFFSET TO H-L
MOV A,M ;BYTE AT H-L IN A (NOTE LSB)
OUT T_C2 ;DIVIDER LSB TO COUNTER
INX H ;H-L POINTS TO NEXT BYTE
MOV A,M ;BYTE AD H-L IN A (NOTE MSB)
OUT T_C2 ;DIVIDER MSB TO COUNTER
IN U_MCR ;INPUT MISC REGISTER
ORI 0x04 ;TURNS ON BIT 2
OUT U_MCR ;OUTPUT MISC REGISTER
POP B
POP H
.endif
RET
;*********************************************************
;* IO_SOUNDOFF: DISABLES SOUND OUTPUT
IO_SOUNDOFF::
.if ~DEBUG
PUSH PSW
IN U_MCR ;INPUT MISC REGISTER
ANI 0xFB ;TURNS OFF BIT 2
OUT U_MCR ;OUTPUT MISC REGISTER
POP PSW
.endif
RET
;*********************************************************
;* IO_DELAY, WAITS ACC * 100MS
IO_DELAY::
.if ~DEBUG
PUSH H
PUSH D
LHLD TICNT ;LOAD CURRENT COUNT IN H-L
MOV E,A ;COUNT IN D-E
MVI D,0
DAD D ;ADD TO H-L
XCHG ;EXCHANGE D&E, H&L, TARGET NOW IN D-E
1$: LHLD TICNT ;LOAD CURRENT COUNT IN H-L
MOV A,H ;MSB IN A
XRA D ;COMPARE WITH MSB OF TARGET
JNZ 1$ ;DIFFERENT -> LOOP
MOV A,L ;LSB IN A
XRA E ;COMPARE WITH LSB OF TARGET
JNZ 1$ ;DIFFERENT -> LOOP
;* WE ARE DONE!
POP D
POP H
.endif
RET
NOTES: .dw 0xDC29,0xCFCE,0xC424,0xB922,0xAEBE,0xA4EF,0x9BAE,0x92F1,0x8AB1,0x82E9,0x7B90,0x74A0
.dw 0x6E15,0x67E7,0x6212,0x5C91,0x575F,0x5278,0x4DD7,0x4978,0x4559,0x4174,0x3DC8,0x3A50
.dw 0x370A,0x33FA,0x3109,0x2E49,0x2BB0,0x293C,0x26EB,0x24BC,0x22AC,0x20BA,0x1EE4,0x1D28
.dw 0x1B85,0x19FA,0x1885,0x1724,0x15D8,0x149E,0x1376,0x125E,0x1156,0x105D,0x0F72,0x0E94
.dw 0x0DC3,0x0CFD,0x0C42,0x0B92,0x0AEC,0x0A4F,0x09BB,0x092F,0x08AB,0x082F,0x07B9,0x074A
.dw 0x06E1,0x067E,0x0621,0x05C9,0x0576,0x0527,0x04DD,0x0498,0x0456,0x0417,0x03DC,0x03A5
.dw 0x0371,0x033F,0x0311,0x02E5,0x02BB,0x0294,0x026F,0x024C,0x022B,0x020C,0x01EE,0x01D3
;*********************************************************
;* RAM VARIABLES
;*********************************************************
.area DATA (REL,CON)
TICNT:: .ds 2 ;TIMER - COUNTER
IO_KBUF: .ds 16 ;KEYBOARD BUFFER
IO_KBUFPTR: .ds 2 ;KEYBOARD BUFFER - BEGIN/END PTR
IO_CURRATTR: .ds 1 ;CONSOLE - CURRENT ATTRIBUTE
|
; A129232: a(n)=Floor(n*r)+Floor((n-2)*r)+Floor((n-4)*r)+...+Floor(k*r), where r = 2^(1/2) and k=0 if n is even, k=1 if n is odd.
; 0,1,2,5,7,12,15,21,26,33,40,48,56,66,75,87,97,111,122,137,150,166,181,198,214,233,250,271,289,312,331,355,376,401,424,450,474,502,527,557,583,614,642,674,704,737,769,803,836,872,906,944,979,1018,1055,1095
lpb $0
mov $2,$0
cal $2,1951 ; A Beatty sequence: a(n) = floor(n*sqrt(2)).
trn $0,2
add $1,$2
lpe
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/base/accelerators/menu_label_accelerator_util_linux.h"
#include "base/basictypes.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ui {
TEST(MenuLabelAcceleratorTest, ConvertAcceleratorsFromWindowsStyle) {
static const struct {
const char* input;
const char* output;
} cases[] = {
{ "", "" },
{ "nothing", "nothing" },
{ "foo &bar", "foo _bar" },
{ "foo &&bar", "foo &bar" },
{ "foo &&&bar", "foo &_bar" },
{ "&foo &&bar", "_foo &bar" },
{ "&foo &bar", "_foo _bar" },
};
for (size_t i = 0; i < arraysize(cases); ++i) {
std::string result = ConvertAcceleratorsFromWindowsStyle(cases[i].input);
EXPECT_EQ(cases[i].output, result);
}
}
TEST(MenuLabelAcceleratorTest, RemoveWindowsStyleAccelerators) {
static const struct {
const char* input;
const char* output;
} cases[] = {
{ "", "" },
{ "nothing", "nothing" },
{ "foo &bar", "foo bar" },
{ "foo &&bar", "foo &bar" },
{ "foo &&&bar", "foo &bar" },
{ "&foo &&bar", "foo &bar" },
{ "&foo &bar", "foo bar" },
};
for (size_t i = 0; i < arraysize(cases); ++i) {
std::string result = RemoveWindowsStyleAccelerators(cases[i].input);
EXPECT_EQ(cases[i].output, result);
}
}
TEST(MenuLabelAcceleratorTest, EscapeWindowsStyleAccelerators) {
static const struct {
const char* input;
const char* output;
} cases[] = {
{ "nothing", "nothing" },
{ "foo &bar", "foo &&bar" },
{ "foo &&bar", "foo &&&&bar" },
{ "foo &&&bar", "foo &&&&&&bar" },
{ "&foo bar", "&&foo bar" },
{ "&&foo bar", "&&&&foo bar" },
{ "&&&foo bar", "&&&&&&foo bar" },
{ "&foo &bar", "&&foo &&bar" },
{ "&&foo &&bar", "&&&&foo &&&&bar" },
{ "f&o&o ba&r", "f&&o&&o ba&&r" },
{ "foo_&_bar", "foo_&&_bar" },
{ "&_foo_bar_&", "&&_foo_bar_&&" },
};
for (size_t i = 0; i < arraysize(cases); ++i) {
std::string result = EscapeWindowsStyleAccelerators(cases[i].input);
EXPECT_EQ(cases[i].output, result);
}
}
} // namespace ui
|
#include "optionsdialog.h"
#include "ui_optionsdialog.h"
#include "bitcoinunits.h"
#include "monitoreddatamapper.h"
#include "netbase.h"
#include "optionsmodel.h"
#include <QDir>
#include <QIntValidator>
#include <QLocale>
#include <QMessageBox>
#include <QRegExp>
#include <QRegExpValidator>
OptionsDialog::OptionsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::OptionsDialog),
model(0),
mapper(0),
fRestartWarningDisplayed_Proxy(false),
fRestartWarningDisplayed_Lang(false),
fProxyIpValid(true)
{
ui->setupUi(this);
/* Network elements init */
#ifndef USE_UPNP
ui->mapPortUpnp->setEnabled(false);
#endif
ui->proxyIp->setEnabled(false);
ui->proxyPort->setEnabled(false);
ui->proxyPort->setValidator(new QIntValidator(1, 65535, this));
ui->socksVersion->setEnabled(false);
ui->socksVersion->addItem("5", 5);
ui->socksVersion->addItem("4", 4);
ui->socksVersion->setCurrentIndex(0);
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool)));
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool)));
connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->socksVersion, SLOT(setEnabled(bool)));
connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Proxy()));
ui->proxyIp->installEventFilter(this);
/* Window elements init */
#ifdef Q_OS_MAC
ui->tabWindow->setVisible(false);
#endif
/* Display elements init */
QDir translations(":translations");
ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
foreach(const QString &langStr, translations.entryList())
{
QLocale locale(langStr);
/** check if the locale name consists of 2 parts (language_country) */
if(langStr.contains("_"))
{
#if QT_VERSION >= 0x040800
/** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
#else
/** display language strings as "language - country (locale name)", e.g. "German - Germany (de)" */
ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" - ") + QLocale::countryToString(locale.country()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
#endif
}
else
{
#if QT_VERSION >= 0x040800
/** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */
ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
#else
/** display language strings as "language (locale name)", e.g. "German (de)" */
ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
#endif
}
}
ui->unit->setModel(new BitcoinUnits(this));
/* Widget-to-option mapper */
mapper = new MonitoredDataMapper(this);
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
mapper->setOrientation(Qt::Vertical);
/* enable apply button when data modified */
connect(mapper, SIGNAL(viewModified()), this, SLOT(enableApplyButton()));
/* disable apply button when new data loaded */
connect(mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(disableApplyButton()));
/* setup/change UI elements when proxy IP is invalid/valid */
connect(this, SIGNAL(proxyIpValid(QValidatedLineEdit *, bool)), this, SLOT(handleProxyIpValid(QValidatedLineEdit *, bool)));
}
OptionsDialog::~OptionsDialog()
{
delete ui;
}
void OptionsDialog::setModel(OptionsModel *model)
{
this->model = model;
if(model)
{
connect(model, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
mapper->setModel(model);
setMapper();
mapper->toFirst();
}
/* update the display unit, to not use the default ("BTC") */
updateDisplayUnit();
/* warn only when language selection changes by user action (placed here so init via mapper doesn't trigger this) */
connect(ui->lang, SIGNAL(valueChanged()), this, SLOT(showRestartWarning_Lang()));
/* disable apply button after settings are loaded as there is nothing to save */
disableApplyButton();
}
void OptionsDialog::setMapper()
{
/* Main */
mapper->addMapping(ui->transactionFee, OptionsModel::Fee);
mapper->addMapping(ui->reserveBalance, OptionsModel::ReserveBalance);
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
/* Network */
mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP);
mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse);
mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP);
mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort);
mapper->addMapping(ui->socksVersion, OptionsModel::ProxySocksVersion);
/* Window */
#ifndef Q_OS_MAC
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);
#endif
/* Display */
mapper->addMapping(ui->lang, OptionsModel::Language);
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
mapper->addMapping(ui->displayAddresses, OptionsModel::DisplayAddresses);
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
}
void OptionsDialog::enableApplyButton()
{
ui->applyButton->setEnabled(true);
}
void OptionsDialog::disableApplyButton()
{
ui->applyButton->setEnabled(false);
}
void OptionsDialog::enableSaveButtons()
{
/* prevent enabling of the save buttons when data modified, if there is an invalid proxy address present */
if(fProxyIpValid)
setSaveButtonState(true);
}
void OptionsDialog::disableSaveButtons()
{
setSaveButtonState(false);
}
void OptionsDialog::setSaveButtonState(bool fState)
{
ui->applyButton->setEnabled(fState);
ui->okButton->setEnabled(fState);
}
void OptionsDialog::on_okButton_clicked()
{
mapper->submit();
accept();
}
void OptionsDialog::on_cancelButton_clicked()
{
reject();
}
void OptionsDialog::on_applyButton_clicked()
{
mapper->submit();
disableApplyButton();
}
void OptionsDialog::showRestartWarning_Proxy()
{
if(!fRestartWarningDisplayed_Proxy)
{
QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Yllineum."), QMessageBox::Ok);
fRestartWarningDisplayed_Proxy = true;
}
}
void OptionsDialog::showRestartWarning_Lang()
{
if(!fRestartWarningDisplayed_Lang)
{
QMessageBox::warning(this, tr("Warning"), tr("This setting will take effect after restarting Yllineum."), QMessageBox::Ok);
fRestartWarningDisplayed_Lang = true;
}
}
void OptionsDialog::updateDisplayUnit()
{
if(model)
{
/* Update transactionFee with the current unit */
ui->transactionFee->setDisplayUnit(model->getDisplayUnit());
}
}
void OptionsDialog::handleProxyIpValid(QValidatedLineEdit *object, bool fState)
{
// this is used in a check before re-enabling the save buttons
fProxyIpValid = fState;
if(fProxyIpValid)
{
enableSaveButtons();
ui->statusLabel->clear();
}
else
{
disableSaveButtons();
object->setValid(fProxyIpValid);
ui->statusLabel->setStyleSheet("QLabel { color: red; }");
ui->statusLabel->setText(tr("The supplied proxy address is invalid."));
}
}
bool OptionsDialog::eventFilter(QObject *object, QEvent *event)
{
if(event->type() == QEvent::FocusOut)
{
if(object == ui->proxyIp)
{
CService addr;
/* Check proxyIp for a valid IPv4/IPv6 address and emit the proxyIpValid signal */
emit proxyIpValid(ui->proxyIp, LookupNumeric(ui->proxyIp->text().toStdString().c_str(), addr));
}
}
return QDialog::eventFilter(object, event);
}
|
.data
newLine: .asciiz "\n"
.text
main:
addi $s0, $zero, 10
jal increase
jal print_value
# End of Main
li $v0, 10
syscall
increase:
# Saving $s0 value
addi $sp, $sp, -8
sw $s0, 0($sp)
sw $ra, 4($sp)
addi $s0, $s0, 30
# Nested procedure
jal print_value
jal new_line
# Restoring $s0 value
lw $ra, 4($sp)
lw $s0, 0($sp)
addi $sp, $sp, 8
# Return address
jr $ra
new_line:
li $v0, 4
la $a0, newLine
syscall
# Return address
jr $ra
print_value:
li $v0, 1
move $a0, $s0
syscall
jr $ra |
; A037765: Base 4 digits are, in order, the first n terms of the periodic sequence with initial period 3,0,2,1.
; Submitted by Jon Maiga
; 3,12,50,201,807,3228,12914,51657,206631,826524,3306098,13224393,52897575,211590300,846361202,3385444809,13541779239,54167116956,216668467826,866673871305,3466695485223,13866781940892,55467127763570
add $0,1
mov $1,4
pow $1,$0
mul $1,67
div $1,85
mov $0,$1
|
; A168029: n*(n^6+1)/2.
; 0,1,65,1095,8194,39065,139971,411775,1048580,2391489,5000005,9743591,17915910,31374265,52706759,85429695,134217736,205169345,306110025,446935879,640000010,900544281,1247178955,1702412735,2293235724,3051757825,4015905101,5230176615,6746464270,8624938169,10935000015,13756307071,17179869200,21309221505,26261675089,32169648455,39182082066,47465938585,57207791315,68615503359,81920000020,97377136961,115269666645,135909305575,159638904854,186834726585,217908828631,253311560255,293534171160,339111536449,390625000025,448705338951,514035851290,587355569945,669462605019,761217617215,863547424796,977448746625,1103992083805,1244325742439,1399680000030,1571371418041,1760807303135,1969490319615,2199023255584,2451113945345,2727580350561,3030355802695,3361494409250,3723176626329,4117715000035,4547560079231,5015306502180,5523699259585,6075640136549,6674194335975,7322597285926,8024261633465,8782784427495,9601954493119,10485760000040,11438396227521,12464273528425,13568025494855,14754517327914,16028854414105,17396391110891,18862739743935,20433779818540,22115667447809,23914845000045,25838050967911,27892330061870,30085043530425,32423879709679,34916864804735,37572373905456,40399142239105,43406276662385,46603267395399,50000000000050,53606767605401,57434283382515,61493693271295,65796588961844,70355021132865,75181512949621,80289073823975,85691213439030,91401956040889,97435855000055,103808007644991,110534070370360,117630274022465,125113439564409,133000994023495,141310986723386,150062105803545,159273695028475,168965770889279,179159040000060,189874916791681,201135541505405,212963798488935,225383334797374,238418579101625,252094760906751,266437930082815,281474976710720,297233651245569,313742585000065,331031310950471,349130284867650,368070906775705,387885542740739,408607546992255,430271284379716,452912153166785,476566608165765,501272184214759,527067520000070,553992382226361,582087690137095,611395540387775,641959232274504,673823293320385,707033505222281,741636930160455,777681937473610,815218230701849,854296875000075,894970324924351,937292452593740,981318576230145,1027105489078669,1074711488711015,1124196406714446,1175621638768825,1229050175114255,1284546631411839,1342177280000080,1402010081549441,1464114717117585,1528562620607815,1595427011633234,1664782928789145,1736707263336211,1811278793296895,1888578217967700,1968688192849729,2051693365000085,2137680408806631,2226738062188630,2318957163225785,2414430687218199,2513253784179775,2615523816767576,2721340398649665,2830805433313945,2944023153320519,3061100160000090,3182145463600921,3307270523886875,3436589291189055,3570218247913564,3708276450507905,3850885571888541,3998169944332135,4150256602832990,4307275328929209,4469358695000095,4636642109037311,4809263859892320,4987365163002625,5171090206599329,5360586198398535,5556003412779106,5757495238449305,5965218226604835,6179332139580799,6400000000000100,6627388140420801,6861666253484965,7103007442571495,7351588272955494,7607588823476665,7871192738719271,8142587281706175,8421963387109480,8709515714980289,9005442705000105
mov $1,$0
pow $1,7
add $1,$0
div $1,2
|
;******************************************************************************
;* FFT transform with SSE/3DNow optimizations
;* Copyright (c) 2008 Loren Merritt
;* Copyright (c) 2011 Vitor Sessak
;*
;* This algorithm (though not any of the implementation details) is
;* based on libdjbfft by D. J. Bernstein.
;*
;* This file is part of Libav.
;*
;* Libav is free software; you can redistribute it and/or
;* modify it under the terms of the GNU Lesser General Public
;* License as published by the Free Software Foundation; either
;* version 2.1 of the License, or (at your option) any later version.
;*
;* Libav is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;* Lesser General Public License for more details.
;*
;* You should have received a copy of the GNU Lesser General Public
;* License along with Libav; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;******************************************************************************
; These functions are not individually interchangeable with the C versions.
; While C takes arrays of FFTComplex, SSE/3DNow leave intermediate results
; in blocks as conventient to the vector size.
; i.e. {4x real, 4x imaginary, 4x real, ...} (or 2x respectively)
%include "libavutil/x86/x86util.asm"
%if ARCH_X86_64
%define pointer resq
%else
%define pointer resd
%endif
struc FFTContext
.nbits: resd 1
.reverse: resd 1
.revtab: pointer 1
.tmpbuf: pointer 1
.mdctsize: resd 1
.mdctbits: resd 1
.tcos: pointer 1
.tsin: pointer 1
.fftperm: pointer 1
.fftcalc: pointer 1
.imdctcalc:pointer 1
.imdcthalf:pointer 1
endstruc
SECTION_RODATA
%define M_SQRT1_2 0.70710678118654752440
%define M_COS_PI_1_8 0.923879532511287
%define M_COS_PI_3_8 0.38268343236509
align 32
ps_cos16_1: dd 1.0, M_COS_PI_1_8, M_SQRT1_2, M_COS_PI_3_8, 1.0, M_COS_PI_1_8, M_SQRT1_2, M_COS_PI_3_8
ps_cos16_2: dd 0, M_COS_PI_3_8, M_SQRT1_2, M_COS_PI_1_8, 0, -M_COS_PI_3_8, -M_SQRT1_2, -M_COS_PI_1_8
ps_root2: times 8 dd M_SQRT1_2
ps_root2mppm: dd -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2, -M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, -M_SQRT1_2
ps_p1p1m1p1: dd 0, 0, 1<<31, 0, 0, 0, 1<<31, 0
perm1: dd 0x00, 0x02, 0x03, 0x01, 0x03, 0x00, 0x02, 0x01
perm2: dd 0x00, 0x01, 0x02, 0x03, 0x01, 0x00, 0x02, 0x03
ps_p1p1m1p1root2: dd 1.0, 1.0, -1.0, 1.0, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2, M_SQRT1_2
ps_m1m1p1m1p1m1m1m1: dd 1<<31, 1<<31, 0, 1<<31, 0, 1<<31, 1<<31, 1<<31
ps_m1m1m1m1: times 4 dd 1<<31
ps_m1p1: dd 1<<31, 0
%assign i 16
%rep 13
cextern cos_ %+ i
%assign i i<<1
%endrep
%if ARCH_X86_64
%define pointer dq
%else
%define pointer dd
%endif
%macro IF0 1+
%endmacro
%macro IF1 1+
%1
%endmacro
SECTION .text
%macro T2_3DNOW 4 ; z0, z1, mem0, mem1
mova %1, %3
mova %2, %1
pfadd %1, %4
pfsub %2, %4
%endmacro
%macro T4_3DNOW 6 ; z0, z1, z2, z3, tmp0, tmp1
mova %5, %3
pfsub %3, %4
pfadd %5, %4 ; {t6,t5}
pxor %3, [ps_m1p1] ; {t8,t7}
mova %6, %1
movd [r0+12], %3
punpckhdq %3, [r0+8]
pfadd %1, %5 ; {r0,i0}
pfsub %6, %5 ; {r2,i2}
mova %4, %2
pfadd %2, %3 ; {r1,i1}
pfsub %4, %3 ; {r3,i3}
SWAP %3, %6
%endmacro
; in: %1 = {r0,i0,r2,i2,r4,i4,r6,i6}
; %2 = {r1,i1,r3,i3,r5,i5,r7,i7}
; %3, %4, %5 tmp
; out: %1 = {r0,r1,r2,r3,i0,i1,i2,i3}
; %2 = {r4,r5,r6,r7,i4,i5,i6,i7}
%macro T8_AVX 5
vsubps %5, %1, %2 ; v = %1 - %2
vaddps %3, %1, %2 ; w = %1 + %2
vmulps %2, %5, [ps_p1p1m1p1root2] ; v *= vals1
vpermilps %2, %2, [perm1]
vblendps %1, %2, %3, 0x33 ; q = {w1,w2,v4,v2,w5,w6,v7,v6}
vshufps %5, %3, %2, 0x4e ; r = {w3,w4,v1,v3,w7,w8,v8,v5}
vsubps %4, %5, %1 ; s = r - q
vaddps %1, %5, %1 ; u = r + q
vpermilps %1, %1, [perm2] ; k = {u1,u2,u3,u4,u6,u5,u7,u8}
vshufps %5, %4, %1, 0xbb
vshufps %3, %4, %1, 0xee
vperm2f128 %3, %3, %5, 0x13
vxorps %4, %4, [ps_m1m1p1m1p1m1m1m1] ; s *= {1,1,-1,-1,1,-1,-1,-1}
vshufps %2, %1, %4, 0xdd
vshufps %1, %1, %4, 0x88
vperm2f128 %4, %2, %1, 0x02 ; v = {k1,k3,s1,s3,k2,k4,s2,s4}
vperm2f128 %1, %1, %2, 0x13 ; w = {k6,k8,s6,s8,k5,k7,s5,s7}
vsubps %5, %1, %3
vblendps %1, %5, %1, 0x55 ; w -= {0,s7,0,k7,0,s8,0,k8}
vsubps %2, %4, %1 ; %2 = v - w
vaddps %1, %4, %1 ; %1 = v + w
%endmacro
; In SSE mode do one fft4 transforms
; in: %1={r0,i0,r2,i2} %2={r1,i1,r3,i3}
; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3}
;
; In AVX mode do two fft4 transforms
; in: %1={r0,i0,r2,i2,r4,i4,r6,i6} %2={r1,i1,r3,i3,r5,i5,r7,i7}
; out: %1={r0,r1,r2,r3,r4,r5,r6,r7} %2={i0,i1,i2,i3,i4,i5,i6,i7}
%macro T4_SSE 3
subps %3, %1, %2 ; {t3,t4,-t8,t7}
addps %1, %1, %2 ; {t1,t2,t6,t5}
xorps %3, %3, [ps_p1p1m1p1]
shufps %2, %1, %3, 0xbe ; {t6,t5,t7,t8}
shufps %1, %1, %3, 0x44 ; {t1,t2,t3,t4}
subps %3, %1, %2 ; {r2,i2,r3,i3}
addps %1, %1, %2 ; {r0,i0,r1,i1}
shufps %2, %1, %3, 0xdd ; {i0,i1,i2,i3}
shufps %1, %1, %3, 0x88 ; {r0,r1,r2,r3}
%endmacro
; In SSE mode do one FFT8
; in: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %3={r4,i4,r6,i6} %4={r5,i5,r7,i7}
; out: %1={r0,r1,r2,r3} %2={i0,i1,i2,i3} %1={r4,r5,r6,r7} %2={i4,i5,i6,i7}
;
; In AVX mode do two FFT8
; in: %1={r0,i0,r2,i2,r8, i8, r10,i10} %2={r1,i1,r3,i3,r9, i9, r11,i11}
; %3={r4,i4,r6,i6,r12,i12,r14,i14} %4={r5,i5,r7,i7,r13,i13,r15,i15}
; out: %1={r0,r1,r2,r3,r8, r9, r10,r11} %2={i0,i1,i2,i3,i8, i9, i10,i11}
; %3={r4,r5,r6,r7,r12,r13,r14,r15} %4={i4,i5,i6,i7,i12,i13,i14,i15}
%macro T8_SSE 6
addps %6, %3, %4 ; {t1,t2,t3,t4}
subps %3, %3, %4 ; {r5,i5,r7,i7}
shufps %4, %3, %3, 0xb1 ; {i5,r5,i7,r7}
mulps %3, %3, [ps_root2mppm] ; {-r5,i5,r7,-i7}
mulps %4, %4, [ps_root2]
addps %3, %3, %4 ; {t8,t7,ta,t9}
shufps %4, %6, %3, 0x9c ; {t1,t4,t7,ta}
shufps %6, %6, %3, 0x36 ; {t3,t2,t9,t8}
subps %3, %6, %4 ; {t6,t5,tc,tb}
addps %6, %6, %4 ; {t1,t2,t9,ta}
shufps %5, %6, %3, 0x8d ; {t2,ta,t6,tc}
shufps %6, %6, %3, 0xd8 ; {t1,t9,t5,tb}
subps %3, %1, %6 ; {r4,r5,r6,r7}
addps %1, %1, %6 ; {r0,r1,r2,r3}
subps %4, %2, %5 ; {i4,i5,i6,i7}
addps %2, %2, %5 ; {i0,i1,i2,i3}
%endmacro
; scheduled for cpu-bound sizes
%macro PASS_SMALL 3 ; (to load m4-m7), wre, wim
IF%1 mova m4, Z(4)
IF%1 mova m5, Z(5)
mova m0, %2 ; wre
mova m1, %3 ; wim
mulps m2, m4, m0 ; r2*wre
IF%1 mova m6, Z2(6)
mulps m3, m5, m1 ; i2*wim
IF%1 mova m7, Z2(7)
mulps m4, m4, m1 ; r2*wim
mulps m5, m5, m0 ; i2*wre
addps m2, m2, m3 ; r2*wre + i2*wim
mulps m3, m1, m7 ; i3*wim
subps m5, m5, m4 ; i2*wre - r2*wim
mulps m1, m1, m6 ; r3*wim
mulps m4, m0, m6 ; r3*wre
mulps m0, m0, m7 ; i3*wre
subps m4, m4, m3 ; r3*wre - i3*wim
mova m3, Z(0)
addps m0, m0, m1 ; i3*wre + r3*wim
subps m1, m4, m2 ; t3
addps m4, m4, m2 ; t5
subps m3, m3, m4 ; r2
addps m4, m4, Z(0) ; r0
mova m6, Z(2)
mova Z(4), m3
mova Z(0), m4
subps m3, m5, m0 ; t4
subps m4, m6, m3 ; r3
addps m3, m3, m6 ; r1
mova Z2(6), m4
mova Z(2), m3
mova m2, Z(3)
addps m3, m5, m0 ; t6
subps m2, m2, m1 ; i3
mova m7, Z(1)
addps m1, m1, Z(3) ; i1
mova Z2(7), m2
mova Z(3), m1
subps m4, m7, m3 ; i2
addps m3, m3, m7 ; i0
mova Z(5), m4
mova Z(1), m3
%endmacro
; scheduled to avoid store->load aliasing
%macro PASS_BIG 1 ; (!interleave)
mova m4, Z(4) ; r2
mova m5, Z(5) ; i2
mova m0, [wq] ; wre
mova m1, [wq+o1q] ; wim
mulps m2, m4, m0 ; r2*wre
mova m6, Z2(6) ; r3
mulps m3, m5, m1 ; i2*wim
mova m7, Z2(7) ; i3
mulps m4, m4, m1 ; r2*wim
mulps m5, m5, m0 ; i2*wre
addps m2, m2, m3 ; r2*wre + i2*wim
mulps m3, m1, m7 ; i3*wim
mulps m1, m1, m6 ; r3*wim
subps m5, m5, m4 ; i2*wre - r2*wim
mulps m4, m0, m6 ; r3*wre
mulps m0, m0, m7 ; i3*wre
subps m4, m4, m3 ; r3*wre - i3*wim
mova m3, Z(0)
addps m0, m0, m1 ; i3*wre + r3*wim
subps m1, m4, m2 ; t3
addps m4, m4, m2 ; t5
subps m3, m3, m4 ; r2
addps m4, m4, Z(0) ; r0
mova m6, Z(2)
mova Z(4), m3
mova Z(0), m4
subps m3, m5, m0 ; t4
subps m4, m6, m3 ; r3
addps m3, m3, m6 ; r1
IF%1 mova Z2(6), m4
IF%1 mova Z(2), m3
mova m2, Z(3)
addps m5, m5, m0 ; t6
subps m2, m2, m1 ; i3
mova m7, Z(1)
addps m1, m1, Z(3) ; i1
IF%1 mova Z2(7), m2
IF%1 mova Z(3), m1
subps m6, m7, m5 ; i2
addps m5, m5, m7 ; i0
IF%1 mova Z(5), m6
IF%1 mova Z(1), m5
%if %1==0
INTERL m1, m3, m7, Z, 2
INTERL m2, m4, m0, Z2, 6
mova m1, Z(0)
mova m2, Z(4)
INTERL m5, m1, m3, Z, 0
INTERL m6, m2, m7, Z, 4
%endif
%endmacro
%macro PUNPCK 3
mova %3, %1
punpckldq %1, %2
punpckhdq %3, %2
%endmacro
%define Z(x) [r0+mmsize*x]
%define Z2(x) [r0+mmsize*x]
%define ZH(x) [r0+mmsize*x+mmsize/2]
INIT_YMM avx
align 16
fft8_avx:
mova m0, Z(0)
mova m1, Z(1)
T8_AVX m0, m1, m2, m3, m4
mova Z(0), m0
mova Z(1), m1
ret
align 16
fft16_avx:
mova m2, Z(2)
mova m3, Z(3)
T4_SSE m2, m3, m7
mova m0, Z(0)
mova m1, Z(1)
T8_AVX m0, m1, m4, m5, m7
mova m4, [ps_cos16_1]
mova m5, [ps_cos16_2]
vmulps m6, m2, m4
vmulps m7, m3, m5
vaddps m7, m7, m6
vmulps m2, m2, m5
vmulps m3, m3, m4
vsubps m3, m3, m2
vblendps m2, m7, m3, 0xf0
vperm2f128 m3, m7, m3, 0x21
vaddps m4, m2, m3
vsubps m2, m3, m2
vperm2f128 m2, m2, m2, 0x01
vsubps m3, m1, m2
vaddps m1, m1, m2
vsubps m5, m0, m4
vaddps m0, m0, m4
vextractf128 Z(0), m0, 0
vextractf128 ZH(0), m1, 0
vextractf128 Z(1), m0, 1
vextractf128 ZH(1), m1, 1
vextractf128 Z(2), m5, 0
vextractf128 ZH(2), m3, 0
vextractf128 Z(3), m5, 1
vextractf128 ZH(3), m3, 1
ret
align 16
fft32_avx:
call fft16_avx
mova m0, Z(4)
mova m1, Z(5)
T4_SSE m0, m1, m4
mova m2, Z(6)
mova m3, Z(7)
T8_SSE m0, m1, m2, m3, m4, m6
; m0={r0,r1,r2,r3,r8, r9, r10,r11} m1={i0,i1,i2,i3,i8, i9, i10,i11}
; m2={r4,r5,r6,r7,r12,r13,r14,r15} m3={i4,i5,i6,i7,i12,i13,i14,i15}
vperm2f128 m4, m0, m2, 0x20
vperm2f128 m5, m1, m3, 0x20
vperm2f128 m6, m0, m2, 0x31
vperm2f128 m7, m1, m3, 0x31
PASS_SMALL 0, [cos_32], [cos_32+32]
ret
fft32_interleave_avx:
call fft32_avx
mov r2d, 32
.deint_loop:
mova m2, Z(0)
mova m3, Z(1)
vunpcklps m0, m2, m3
vunpckhps m1, m2, m3
vextractf128 Z(0), m0, 0
vextractf128 ZH(0), m1, 0
vextractf128 Z(1), m0, 1
vextractf128 ZH(1), m1, 1
add r0, mmsize*2
sub r2d, mmsize/4
jg .deint_loop
ret
INIT_XMM sse
align 16
fft4_avx:
fft4_sse:
mova m0, Z(0)
mova m1, Z(1)
T4_SSE m0, m1, m2
mova Z(0), m0
mova Z(1), m1
ret
align 16
fft8_sse:
mova m0, Z(0)
mova m1, Z(1)
T4_SSE m0, m1, m2
mova m2, Z(2)
mova m3, Z(3)
T8_SSE m0, m1, m2, m3, m4, m5
mova Z(0), m0
mova Z(1), m1
mova Z(2), m2
mova Z(3), m3
ret
align 16
fft16_sse:
mova m0, Z(0)
mova m1, Z(1)
T4_SSE m0, m1, m2
mova m2, Z(2)
mova m3, Z(3)
T8_SSE m0, m1, m2, m3, m4, m5
mova m4, Z(4)
mova m5, Z(5)
mova Z(0), m0
mova Z(1), m1
mova Z(2), m2
mova Z(3), m3
T4_SSE m4, m5, m6
mova m6, Z2(6)
mova m7, Z2(7)
T4_SSE m6, m7, m0
PASS_SMALL 0, [cos_16], [cos_16+16]
ret
%macro FFT48_3DNOW 0
align 16
fft4 %+ SUFFIX:
T2_3DNOW m0, m1, Z(0), Z(1)
mova m2, Z(2)
mova m3, Z(3)
T4_3DNOW m0, m1, m2, m3, m4, m5
PUNPCK m0, m1, m4
PUNPCK m2, m3, m5
mova Z(0), m0
mova Z(1), m4
mova Z(2), m2
mova Z(3), m5
ret
align 16
fft8 %+ SUFFIX:
T2_3DNOW m0, m1, Z(0), Z(1)
mova m2, Z(2)
mova m3, Z(3)
T4_3DNOW m0, m1, m2, m3, m4, m5
mova Z(0), m0
mova Z(2), m2
T2_3DNOW m4, m5, Z(4), Z(5)
T2_3DNOW m6, m7, Z2(6), Z2(7)
PSWAPD m0, m5
PSWAPD m2, m7
pxor m0, [ps_m1p1]
pxor m2, [ps_m1p1]
pfsub m5, m0
pfadd m7, m2
pfmul m5, [ps_root2]
pfmul m7, [ps_root2]
T4_3DNOW m1, m3, m5, m7, m0, m2
mova Z(5), m5
mova Z2(7), m7
mova m0, Z(0)
mova m2, Z(2)
T4_3DNOW m0, m2, m4, m6, m5, m7
PUNPCK m0, m1, m5
PUNPCK m2, m3, m7
mova Z(0), m0
mova Z(1), m5
mova Z(2), m2
mova Z(3), m7
PUNPCK m4, Z(5), m5
PUNPCK m6, Z2(7), m7
mova Z(4), m4
mova Z(5), m5
mova Z2(6), m6
mova Z2(7), m7
ret
%endmacro
%if ARCH_X86_32
INIT_MMX 3dnowext
FFT48_3DNOW
INIT_MMX 3dnow
FFT48_3DNOW
%endif
%define Z(x) [zcq + o1q*(x&6) + mmsize*(x&1)]
%define Z2(x) [zcq + o3q + mmsize*(x&1)]
%define ZH(x) [zcq + o1q*(x&6) + mmsize*(x&1) + mmsize/2]
%define Z2H(x) [zcq + o3q + mmsize*(x&1) + mmsize/2]
%macro DECL_PASS 2+ ; name, payload
align 16
%1:
DEFINE_ARGS zc, w, n, o1, o3
lea o3q, [nq*3]
lea o1q, [nq*8]
shl o3q, 4
.loop:
%2
add zcq, mmsize*2
add wq, mmsize
sub nd, mmsize/8
jg .loop
rep ret
%endmacro
%macro FFT_DISPATCH 2; clobbers 5 GPRs, 8 XMMs
lea r2, [dispatch_tab%1]
mov r2, [r2 + (%2q-2)*gprsize]
%ifdef PIC
lea r3, [$$]
add r2, r3
%endif
call r2
%endmacro ; FFT_DISPATCH
INIT_YMM avx
%macro INTERL_AVX 5
vunpckhps %3, %2, %1
vunpcklps %2, %2, %1
vextractf128 %4(%5), %2, 0
vextractf128 %4 %+ H(%5), %3, 0
vextractf128 %4(%5 + 1), %2, 1
vextractf128 %4 %+ H(%5 + 1), %3, 1
%endmacro
%define INTERL INTERL_AVX
DECL_PASS pass_avx, PASS_BIG 1
DECL_PASS pass_interleave_avx, PASS_BIG 0
cglobal fft_calc, 2,5,8
mov r3d, [r0 + FFTContext.nbits]
mov r0, r1
mov r1, r3
FFT_DISPATCH _interleave %+ SUFFIX, r1
REP_RET
INIT_XMM sse
%macro INTERL_SSE 5
mova %3, %2
unpcklps %2, %1
unpckhps %3, %1
mova %4(%5), %2
mova %4(%5+1), %3
%endmacro
%define INTERL INTERL_SSE
DECL_PASS pass_sse, PASS_BIG 1
DECL_PASS pass_interleave_sse, PASS_BIG 0
%macro FFT_CALC_FUNC 0
cglobal fft_calc, 2,5,8
mov r3d, [r0 + FFTContext.nbits]
PUSH r1
PUSH r3
mov r0, r1
mov r1, r3
FFT_DISPATCH _interleave %+ SUFFIX, r1
POP rcx
POP r4
cmp rcx, 3+(mmsize/16)
jg .end
mov r2, -1
add rcx, 3
shl r2, cl
sub r4, r2
.loop:
%if mmsize == 8
PSWAPD m0, [r4 + r2 + 4]
mova [r4 + r2 + 4], m0
%else
movaps xmm0, [r4 + r2]
movaps xmm1, xmm0
unpcklps xmm0, [r4 + r2 + 16]
unpckhps xmm1, [r4 + r2 + 16]
movaps [r4 + r2], xmm0
movaps [r4 + r2 + 16], xmm1
%endif
add r2, mmsize*2
jl .loop
.end:
%if cpuflag(3dnow)
femms
RET
%else
REP_RET
%endif
%endmacro
%if ARCH_X86_32
INIT_MMX 3dnow
FFT_CALC_FUNC
INIT_MMX 3dnowext
FFT_CALC_FUNC
%endif
INIT_XMM sse
FFT_CALC_FUNC
cglobal fft_permute, 2,7,1
mov r4, [r0 + FFTContext.revtab]
mov r5, [r0 + FFTContext.tmpbuf]
mov ecx, [r0 + FFTContext.nbits]
mov r2, 1
shl r2, cl
xor r0, r0
%if ARCH_X86_32
mov r1, r1m
%endif
.loop:
movaps xmm0, [r1 + 8*r0]
movzx r6, word [r4 + 2*r0]
movzx r3, word [r4 + 2*r0 + 2]
movlps [r5 + 8*r6], xmm0
movhps [r5 + 8*r3], xmm0
add r0, 2
cmp r0, r2
jl .loop
shl r2, 3
add r1, r2
add r5, r2
neg r2
; nbits >= 2 (FFT4) and sizeof(FFTComplex)=8 => at least 32B
.loopcopy:
movaps xmm0, [r5 + r2]
movaps xmm1, [r5 + r2 + 16]
movaps [r1 + r2], xmm0
movaps [r1 + r2 + 16], xmm1
add r2, 32
jl .loopcopy
REP_RET
%macro IMDCT_CALC_FUNC 0
cglobal imdct_calc, 3,5,3
mov r3d, [r0 + FFTContext.mdctsize]
mov r4, [r0 + FFTContext.imdcthalf]
add r1, r3
PUSH r3
PUSH r1
%if ARCH_X86_32
push r2
push r1
push r0
%else
sub rsp, 8+32*WIN64 ; allocate win64 shadow space
%endif
call r4
%if ARCH_X86_32
add esp, 12
%else
add rsp, 8+32*WIN64
%endif
POP r1
POP r3
lea r0, [r1 + 2*r3]
mov r2, r3
sub r3, mmsize
neg r2
mova m2, [ps_m1m1m1m1]
.loop:
%if mmsize == 8
PSWAPD m0, [r1 + r3]
PSWAPD m1, [r0 + r2]
pxor m0, m2
%else
mova m0, [r1 + r3]
mova m1, [r0 + r2]
shufps m0, m0, 0x1b
shufps m1, m1, 0x1b
xorps m0, m2
%endif
mova [r0 + r3], m1
mova [r1 + r2], m0
sub r3, mmsize
add r2, mmsize
jl .loop
%if cpuflag(3dnow)
femms
RET
%else
REP_RET
%endif
%endmacro
%if ARCH_X86_32
INIT_MMX 3dnow
IMDCT_CALC_FUNC
INIT_MMX 3dnowext
IMDCT_CALC_FUNC
%endif
INIT_XMM sse
IMDCT_CALC_FUNC
%if ARCH_X86_32
INIT_MMX 3dnow
%define mulps pfmul
%define addps pfadd
%define subps pfsub
%define unpcklps punpckldq
%define unpckhps punpckhdq
DECL_PASS pass_3dnow, PASS_SMALL 1, [wq], [wq+o1q]
DECL_PASS pass_interleave_3dnow, PASS_BIG 0
%define pass_3dnowext pass_3dnow
%define pass_interleave_3dnowext pass_interleave_3dnow
%endif
%ifdef PIC
%define SECTION_REL - $$
%else
%define SECTION_REL
%endif
%macro DECL_FFT 1-2 ; nbits, suffix
%ifidn %0, 1
%xdefine fullsuffix SUFFIX
%else
%xdefine fullsuffix %2 %+ SUFFIX
%endif
%xdefine list_of_fft fft4 %+ SUFFIX SECTION_REL, fft8 %+ SUFFIX SECTION_REL
%if %1>=5
%xdefine list_of_fft list_of_fft, fft16 %+ SUFFIX SECTION_REL
%endif
%if %1>=6
%xdefine list_of_fft list_of_fft, fft32 %+ fullsuffix SECTION_REL
%endif
%assign n 1<<%1
%rep 17-%1
%assign n2 n/2
%assign n4 n/4
%xdefine list_of_fft list_of_fft, fft %+ n %+ fullsuffix SECTION_REL
align 16
fft %+ n %+ fullsuffix:
call fft %+ n2 %+ SUFFIX
add r0, n*4 - (n&(-2<<%1))
call fft %+ n4 %+ SUFFIX
add r0, n*2 - (n2&(-2<<%1))
call fft %+ n4 %+ SUFFIX
sub r0, n*6 + (n2&(-2<<%1))
lea r1, [cos_ %+ n]
mov r2d, n4/2
jmp pass %+ fullsuffix
%assign n n*2
%endrep
%undef n
align 8
dispatch_tab %+ fullsuffix: pointer list_of_fft
%endmacro ; DECL_FFT
INIT_YMM avx
DECL_FFT 6
DECL_FFT 6, _interleave
INIT_XMM sse
DECL_FFT 5
DECL_FFT 5, _interleave
%if ARCH_X86_32
INIT_MMX 3dnow
DECL_FFT 4
DECL_FFT 4, _interleave
INIT_MMX 3dnowext
DECL_FFT 4
DECL_FFT 4, _interleave
%endif
INIT_XMM sse
%undef mulps
%undef addps
%undef subps
%undef unpcklps
%undef unpckhps
%macro PREROTATER 5 ;-2*k, 2*k, input+n4, tcos+n8, tsin+n8
%if mmsize == 8 ; j*2+2-n4, n4-2-j*2, input+n4, tcos+n8, tsin+n8
PSWAPD m0, [%3+%2*4]
movq m2, [%3+%1*4-8]
movq m3, m0
punpckldq m0, m2
punpckhdq m2, m3
movd m1, [%4+%1*2-4] ; tcos[j]
movd m3, [%4+%2*2] ; tcos[n4-j-1]
punpckldq m1, [%5+%1*2-4] ; tsin[j]
punpckldq m3, [%5+%2*2] ; tsin[n4-j-1]
mova m4, m0
PSWAPD m5, m1
pfmul m0, m1
pfmul m4, m5
mova m6, m2
PSWAPD m5, m3
pfmul m2, m3
pfmul m6, m5
%if cpuflag(3dnowext)
pfpnacc m0, m4
pfpnacc m2, m6
%else
SBUTTERFLY dq, 0, 4, 1
SBUTTERFLY dq, 2, 6, 3
pxor m4, m7
pxor m6, m7
pfadd m0, m4
pfadd m2, m6
%endif
%else
movaps xmm0, [%3+%2*4]
movaps xmm1, [%3+%1*4-0x10]
movaps xmm2, xmm0
shufps xmm0, xmm1, 0x88
shufps xmm1, xmm2, 0x77
movlps xmm4, [%4+%2*2]
movlps xmm5, [%5+%2*2+0x0]
movhps xmm4, [%4+%1*2-0x8]
movhps xmm5, [%5+%1*2-0x8]
movaps xmm2, xmm0
movaps xmm3, xmm1
mulps xmm0, xmm5
mulps xmm1, xmm4
mulps xmm2, xmm4
mulps xmm3, xmm5
subps xmm1, xmm0
addps xmm2, xmm3
movaps xmm0, xmm1
unpcklps xmm1, xmm2
unpckhps xmm0, xmm2
%endif
%endmacro
%macro CMUL 6 ;j, xmm0, xmm1, 3, 4, 5
mulps m6, %3, [%5+%1]
mulps m7, %2, [%5+%1]
mulps %2, %2, [%6+%1]
mulps %3, %3, [%6+%1]
subps %2, %2, m6
addps %3, %3, m7
%endmacro
%macro POSROTATESHUF_AVX 5 ;j, k, z+n8, tcos+n8, tsin+n8
.post:
vmovaps ymm1, [%3+%1*2]
vmovaps ymm0, [%3+%1*2+0x20]
vmovaps ymm3, [%3+%2*2]
vmovaps ymm2, [%3+%2*2+0x20]
CMUL %1, ymm0, ymm1, %3, %4, %5
CMUL %2, ymm2, ymm3, %3, %4, %5
vshufps ymm1, ymm1, ymm1, 0x1b
vshufps ymm3, ymm3, ymm3, 0x1b
vperm2f128 ymm1, ymm1, ymm1, 0x01
vperm2f128 ymm3, ymm3, ymm3, 0x01
vunpcklps ymm6, ymm2, ymm1
vunpckhps ymm4, ymm2, ymm1
vunpcklps ymm7, ymm0, ymm3
vunpckhps ymm5, ymm0, ymm3
vextractf128 [%3+%1*2], ymm7, 0
vextractf128 [%3+%1*2+0x10], ymm5, 0
vextractf128 [%3+%1*2+0x20], ymm7, 1
vextractf128 [%3+%1*2+0x30], ymm5, 1
vextractf128 [%3+%2*2], ymm6, 0
vextractf128 [%3+%2*2+0x10], ymm4, 0
vextractf128 [%3+%2*2+0x20], ymm6, 1
vextractf128 [%3+%2*2+0x30], ymm4, 1
sub %2, 0x20
add %1, 0x20
jl .post
%endmacro
%macro POSROTATESHUF 5 ;j, k, z+n8, tcos+n8, tsin+n8
.post:
movaps xmm1, [%3+%1*2]
movaps xmm0, [%3+%1*2+0x10]
CMUL %1, xmm0, xmm1, %3, %4, %5
movaps xmm5, [%3+%2*2]
movaps xmm4, [%3+%2*2+0x10]
CMUL %2, xmm4, xmm5, %3, %4, %5
shufps xmm1, xmm1, 0x1b
shufps xmm5, xmm5, 0x1b
movaps xmm6, xmm4
unpckhps xmm4, xmm1
unpcklps xmm6, xmm1
movaps xmm2, xmm0
unpcklps xmm0, xmm5
unpckhps xmm2, xmm5
movaps [%3+%2*2], xmm6
movaps [%3+%2*2+0x10], xmm4
movaps [%3+%1*2], xmm0
movaps [%3+%1*2+0x10], xmm2
sub %2, 0x10
add %1, 0x10
jl .post
%endmacro
%macro CMUL_3DNOW 6
mova m6, [%1+%2*2]
mova %3, [%1+%2*2+8]
mova %4, m6
mova m7, %3
pfmul m6, [%5+%2]
pfmul %3, [%6+%2]
pfmul %4, [%6+%2]
pfmul m7, [%5+%2]
pfsub %3, m6
pfadd %4, m7
%endmacro
%macro POSROTATESHUF_3DNOW 5 ;j, k, z+n8, tcos+n8, tsin+n8
.post:
CMUL_3DNOW %3, %1, m0, m1, %4, %5
CMUL_3DNOW %3, %2, m2, m3, %4, %5
movd [%3+%1*2+ 0], m0
movd [%3+%2*2+12], m1
movd [%3+%2*2+ 0], m2
movd [%3+%1*2+12], m3
psrlq m0, 32
psrlq m1, 32
psrlq m2, 32
psrlq m3, 32
movd [%3+%1*2+ 8], m0
movd [%3+%2*2+ 4], m1
movd [%3+%2*2+ 8], m2
movd [%3+%1*2+ 4], m3
sub %2, 8
add %1, 8
jl .post
%endmacro
%macro DECL_IMDCT 1
cglobal imdct_half, 3,12,8; FFTContext *s, FFTSample *output, const FFTSample *input
%if ARCH_X86_64
%define rrevtab r7
%define rtcos r8
%define rtsin r9
%else
%define rrevtab r6
%define rtsin r6
%define rtcos r5
%endif
mov r3d, [r0+FFTContext.mdctsize]
add r2, r3
shr r3, 1
mov rtcos, [r0+FFTContext.tcos]
mov rtsin, [r0+FFTContext.tsin]
add rtcos, r3
add rtsin, r3
%if ARCH_X86_64 == 0
push rtcos
push rtsin
%endif
shr r3, 1
mov rrevtab, [r0+FFTContext.revtab]
add rrevtab, r3
%if ARCH_X86_64 == 0
push rrevtab
%endif
%if mmsize == 8
sub r3, 2
%else
sub r3, 4
%endif
%if ARCH_X86_64 || mmsize == 8
xor r4, r4
sub r4, r3
%endif
%if notcpuflag(3dnowext) && mmsize == 8
movd m7, [ps_m1m1m1m1]
%endif
.pre:
%if ARCH_X86_64 == 0
;unspill
%if mmsize != 8
xor r4, r4
sub r4, r3
%endif
mov rtcos, [esp+8]
mov rtsin, [esp+4]
%endif
PREROTATER r4, r3, r2, rtcos, rtsin
%if mmsize == 8
mov r6, [esp] ; rrevtab = ptr+n8
movzx r5, word [rrevtab+r4-2] ; rrevtab[j]
movzx r6, word [rrevtab+r3] ; rrevtab[n4-j-1]
mova [r1+r5*8], m0
mova [r1+r6*8], m2
add r4, 2
sub r3, 2
%else
%if ARCH_X86_64
movzx r5, word [rrevtab+r4-4]
movzx r6, word [rrevtab+r4-2]
movzx r10, word [rrevtab+r3]
movzx r11, word [rrevtab+r3+2]
movlps [r1+r5 *8], xmm0
movhps [r1+r6 *8], xmm0
movlps [r1+r10*8], xmm1
movhps [r1+r11*8], xmm1
add r4, 4
%else
mov r6, [esp]
movzx r5, word [r6+r4-4]
movzx r4, word [r6+r4-2]
movlps [r1+r5*8], xmm0
movhps [r1+r4*8], xmm0
movzx r5, word [r6+r3]
movzx r4, word [r6+r3+2]
movlps [r1+r5*8], xmm1
movhps [r1+r4*8], xmm1
%endif
sub r3, 4
%endif
jns .pre
mov r5, r0
mov r6, r1
mov r0, r1
mov r1d, [r5+FFTContext.nbits]
FFT_DISPATCH SUFFIX, r1
mov r0d, [r5+FFTContext.mdctsize]
add r6, r0
shr r0, 1
%if ARCH_X86_64 == 0
%define rtcos r2
%define rtsin r3
mov rtcos, [esp+8]
mov rtsin, [esp+4]
%endif
neg r0
mov r1, -mmsize
sub r1, r0
%1 r0, r1, r6, rtcos, rtsin
%if ARCH_X86_64 == 0
add esp, 12
%endif
%if mmsize == 8
femms
%endif
RET
%endmacro
DECL_IMDCT POSROTATESHUF
%if ARCH_X86_32
INIT_MMX 3dnow
DECL_IMDCT POSROTATESHUF_3DNOW
INIT_MMX 3dnowext
DECL_IMDCT POSROTATESHUF_3DNOW
%endif
INIT_YMM avx
DECL_IMDCT POSROTATESHUF_AVX
|
icl '../os/symbols.asm'
org BOOTADDR
mva #0 ROS8
lda #9
ldx #OS_SET_VIDEO_MODE
jsr OS_CALL
mwa SUBPAL_START VRAM_TO_RAM
jsr lib_vram_to_ram
ldy #0
lda #$9A
sta (RAM_TO_VRAM), y
iny
lda #$9F
sta (RAM_TO_VRAM), y
iny
lda #$C8
sta (RAM_TO_VRAM), y
iny
lda #$4C
sta (RAM_TO_VRAM), y
mwa DISPLAY_START VRAM_TO_RAM
jsr lib_vram_to_ram
ldx #20
copy_line
ldy #0
copy:
lda message, y
sta (RAM_TO_VRAM), y
iny
cpy #32
bne copy
adw RAM_TO_VRAM #160
dex
bne copy_line
stop:
jmp stop
message:
.byte $45, $45, $45, $45
.byte $12, $34, $56, $78
.byte $9A, $BC, $DE, $FF
.byte $11, $11, $11, $11
.byte $22, $22, $22, $22
.byte $33, $33, $33, $33
.byte $44, $44, $44, $44
.byte $55, $55, $55, $55
.byte $66, $66, $66, $66
.byte $77, $77, $77, $77
.byte $88, $88, $88, $88
icl '../os/stdlib.asm' |
SECTION code_clib
SECTION code_fp_math48
PUBLIC _fmax_callee
EXTERN cm48_sdccix_fmax_callee
defc _fmax_callee = cm48_sdccix_fmax_callee
|
errorlevel -302
#include "config.inc"
#ifndef RF_RX_PORT_RSSI
error "RF_RX_PORT_RSSI must be defined, for example: PORTA,0"
#endif
#ifndef RF_RX_PORT_RSSI_REF
error "RF_RX_PORT_RSSI_REF must be defined, for example: PORTA,0"
#endif
#ifndef RF_RX_LOCAL_ADDR
error "RF_RX_LOCAL_ADDR must be defined, for example: .1"
#endif
#ifndef CLOCKSPEED
error "CLOCKSPEED must be defined, for example: .8000000"
#endif
#define BUFFER_LEN 15
#define SUBLW_BUFFER_LEN sublw .15
RfRxData udata 0x50 ; 24 bytes
RfRxMsgBuffer res BUFFER_LEN
RfRxMsgLen res 1 ; counts number of bytes recorded in buffer
BitBuffer res 1 ; used to record bits
BitLen res 1 ; counts down towards zero, indicating remaining number og bits to read for this byte
Value res 1 ; hold the current RSSI value
d1 res 1 ;
d2 res 1 ;
temp res 2 ;
RfRxReceiveResult res 1 ; return value of receive routine.
global RfRxMsgBuffer
global RfRxMsgLen
global RfRxReceiveResult
; imported from the crc16 module
extern REG_CRC16_LO
extern REG_CRC16_HI
extern CRC16
code
RF_RX_Init
global RF_RX_Init
; configure comparator module C1
banksel ANSEL ;
BSF ANSEL, ANS0 ; C1IN+
BSF ANSEL, ANS1 ; C12IN0-
banksel TRISA
BSF TRISA, ANS0 ; C1IN+
BSF TRISA, ANS1 ; C12IN0-
banksel CM1CON0
movlw b'10000000'
movwf CM1CON0
banksel PORTA ; assume that this was the state upon entry :-)
return
;
; RfRxReceiveResult == 1 -> Success
; RfRxReceiveResult == 2 -> Error, in the middle of a byte
; RfRxReceiveResult == 3 -> buffer overflow
; RfRxReceiveResult == 4 -> message length too low
; RfRxReceiveResult == 5 -> invalid crc16
RF_RX_ReceiveMsg
global RF_RX_ReceiveMsg
; read message from the air into RfRxMsgBuffer
call ReadMessage
; only continue if RfRxReceiveResult == 1
movfw RfRxReceiveResult
sublw .1
btfss STATUS, Z
goto RF_RX_ReceiveMsg_done
; validate message length; need at least 6: DST, SRC, LEN, MSG1, CRC16, CRC16
movfw RfRxMsgLen
sublw .6
btfss STATUS, C
goto RF_RX_ReceiveMsg_msg_len_ok ; message len > 6
btfsc STATUS, Z
goto RF_RX_ReceiveMsg_msg_len_ok ; message len == 6
movlw .4 ; message len < 6
movwf RfRxReceiveResult
goto RF_RX_ReceiveMsg_done
RF_RX_ReceiveMsg_msg_len_ok
;
; validate CRC16
;
clrf REG_CRC16_LO
clrf REG_CRC16_HI
movfw RfRxMsgLen
movwf temp
decf temp, F ; do that we don't use the CRC itself in the calc
decf temp, F ; do that we don't use the CRC itself in the calc
; configure the address to which we write the current byte
movlw LOW RfRxMsgBuffer
movwf FSR
bcf STATUS, IRP
RF_RX_ReceiveMsg_crc_loop
movfw INDF
call CRC16
incf FSR, F
decfsz temp, F
goto RF_RX_ReceiveMsg_crc_loop
;
; 2) Does CRC match?
;
; read the 1st crc byte
movfw INDF
SUBWF REG_CRC16_LO, F
btfss STATUS, Z
goto RF_RX_ReceiveMsg_crc_error
; set the pointer one address forward
incf FSR, F
; read the 2nd crc byte
movfw INDF
SUBWF REG_CRC16_HI, F
btfss STATUS, Z
goto RF_RX_ReceiveMsg_crc_error
goto RF_RX_ReceiveMsg_crc_ok
RF_RX_ReceiveMsg_crc_error
movlw .5
movwf RfRxReceiveResult
goto RF_RX_ReceiveMsg_done
RF_RX_ReceiveMsg_crc_ok
; done
RF_RX_ReceiveMsg_done
return
;
; waits for a message to arrive and stores it into RfRxMsgBuffer and
; uses RfRxMsgLen to report number of bytes received. Possible return values:
;
; RfRxReceiveResult == 1 -> Success
; RfRxReceiveResult == 2 -> Ended in the middle of a byte
; RfRxReceiveResult == 3 -> went over BUFFER_LEN
;
; One complete bit (0->1 or 1->0) is assumed to take around 1ms
ReadMessage
movlw .2
movwf RfRxReceiveResult
clrf BitBuffer
clrf RfRxMsgLen
movlw .8
movwf BitLen
movlw LOW RfRxMsgBuffer
movwf FSR
bcf STATUS, IRP
ReadMessage_not_reading
call ReadValue
btfss Value, 0
goto ReadMessage_not_reading
ReadMessage_reading_bit
call Delay_750us
call ReadValue
btfss Value, 0
goto ReadMessage_reading_01
goto ReadMessage_reading_10
ReadMessage_reading_01 ; wait for 1 or give up after 0,5ms / 500us / (4Mhz: 500 cycles OR 8Mhz: 1000 cycles)
if CLOCKSPEED == .4000000
movlw .22 ; 22 * 23 cycles = 506 cycles
else
if CLOCKSPEED == .8000000
movlw .45 ; 45 * 23 cycles = 1035 cycles
endif
endif
movwf d1
ReadMessage_reading_01_loop ; 22 cycles
decfsz d1, F ; 1
goto ReadMessage_reading_01_ntimeout ; 2
goto ReadMessage_done ; give up with RfRxReceiveResult
ReadMessage_reading_01_ntimeout
call ReadValue ; 17
btfss Value, 0 ; 1
goto ReadMessage_reading_01_loop ; 2
call RecordBitHi
goto ReadMessage_reading_common
ReadMessage_reading_10
; wait for 0
call ReadValue
btfsc Value, 0
goto ReadMessage_reading_10
call RecordBitLo
goto ReadMessage_reading_common
ReadMessage_reading_common
; test for overflow
movfw RfRxReceiveResult
sublw .3
btfsc STATUS, Z
goto ReadMessage_done ; give up with RfRxReceiveResult == 3 - overflow
goto ReadMessage_reading_bit ; continue reading
ReadMessage_done
return
; Adds the bit from Value,0 to the buffer
;
; RfRxReceiveResult == 1 -> OK
; RfRxReceiveResult == 2 -> OK, but in the middle of a byte
; RfRxReceiveResult == 3 -> went over BUFFER_LEN
;
; 28 cycles inlucing the call instruction
RecordBitHi ; 2
bsf STATUS, C ; 1
rrf BitBuffer, F ; 1
goto RecordBit_cnt ; 2
RecordBitLo
bcf STATUS, C
rrf BitBuffer, F
goto RecordBit_cnt
RecordBit_cnt ; 6
decfsz BitLen, F ; are we done reading a whole byte?
goto RecordBit_keep_reading_byte ; not done reading a whole byte
goto RecordBit_record_byte
RecordBit_keep_reading_byte
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
movlw .2 ; 1
movwf RfRxReceiveResult ; 1
goto RecordBit_done ; 2
RecordBit_record_byte
; done reading a byte, but it into the buffer
movfw BitBuffer ; 1
movwf INDF ; 1
; prepare for the next byte
incf FSR, F ; 1
incf RfRxMsgLen, F ; 1
movlw .8 ; 1
movwf BitLen ; 1
; test if buffer is full
movfw RfRxMsgLen
#SUBLW_BUFFER_LEN
btfss STATUS, Z ; 2
goto RecordBit_record_byte_nooverfl ; 2
goto RecordBit_record_byte_overflow ; 2
RecordBit_record_byte_nooverfl
nop
movlw .1
movwf RfRxReceiveResult
goto RecordBit_done
RecordBit_record_byte_overflow
movlw .3 ; 1
movwf RfRxReceiveResult ; 1
goto RecordBit_done ; 2
RecordBit_done
return
; read the current RSSI value and stores it in Value,0
; 17 cycles inlucing the call instruction
ReadValue ; 2
banksel CM1CON0 ; 2
btfsc CM1CON0, C1OUT ; 2
goto ReadValue_hi ; 2
goto ReadValue_lo ; 2
ReadValue_hi
nop
banksel PORTA ; 2
bsf Value,0 ; 1
goto ReadValue_done ; 2
ReadValue_lo
banksel PORTA ; 2
bcf Value,0 ; 1
goto ReadValue_done ; 2
ReadValue_done
return ; 2
if CLOCKSPEED == .8000000
Delay_750us
;1493 cycles
movlw 0x2A
movwf d1
movlw 0x02
movwf d2
Delay_750us_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_750us_0
;3 cycles
goto $+1
nop
;4 cycles (including call)
return
else
if CLOCKSPEED == .4000000
Delay_750us
;745 cycles
movlw 0xF8
movwf d1
Delay_750us_0
decfsz d1, f
goto Delay_750ns_0
;1 cycle
nop
;4 cycles (including call)
return
endif
endif
end |
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r14
push %r15
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x1dbc8, %r14
clflush (%r14)
nop
nop
nop
dec %r13
mov (%r14), %r10d
nop
nop
add %r15, %r15
lea addresses_UC_ht+0x17d34, %rsi
lea addresses_WC_ht+0x18ac8, %rdi
nop
nop
nop
add %rdx, %rdx
mov $103, %rcx
rep movsl
nop
nop
nop
nop
nop
and %r14, %r14
lea addresses_WC_ht+0x18e48, %rsi
lea addresses_normal_ht+0x9734, %rdi
sub $58725, %r13
mov $14, %rcx
rep movsb
nop
nop
nop
sub $4897, %rcx
lea addresses_WC_ht+0x9dc8, %rcx
clflush (%rcx)
nop
nop
nop
nop
add %rdi, %rdi
mov (%rcx), %edx
nop
nop
xor $62387, %rdi
lea addresses_WC_ht+0x15df8, %r14
nop
nop
nop
nop
nop
cmp $58861, %rsi
mov $0x6162636465666768, %r15
movq %r15, (%r14)
nop
nop
nop
nop
and %rdi, %rdi
lea addresses_UC_ht+0xb410, %r13
nop
cmp $31829, %rdx
movw $0x6162, (%r13)
nop
nop
add %rcx, %rcx
lea addresses_D_ht+0x783c, %rsi
lea addresses_UC_ht+0x11c8, %rdi
add $64528, %r15
mov $32, %rcx
rep movsb
cmp $15087, %r10
lea addresses_WT_ht+0x133c8, %r15
inc %rcx
movl $0x61626364, (%r15)
nop
cmp $48393, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r15
pop %r14
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r15
push %r9
push %rax
push %rdi
push %rsi
// Store
lea addresses_PSE+0x153c8, %rsi
nop
cmp $50339, %rax
movl $0x51525354, (%rsi)
nop
nop
nop
nop
dec %rax
// Store
lea addresses_D+0x1b848, %rdi
mfence
movl $0x51525354, (%rdi)
nop
sub $2166, %r12
// Faulty Load
lea addresses_PSE+0x153c8, %rdi
nop
nop
sub $43871, %r13
movb (%rdi), %r12b
lea oracles, %r9
and $0xff, %r12
shlq $12, %r12
mov (%r9,%r12,1), %r12
pop %rsi
pop %rdi
pop %rax
pop %r9
pop %r15
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_PSE', 'same': True, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 7}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_PSE', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 0}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 2}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 2}, 'dst': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 8}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'54': 21829}
54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
*/
|
;==============================================================================
; Contents of this file are copyright Phillip Stevens
;
; You have permission to use this for NON COMMERCIAL USE ONLY
; If you wish to use it elsewhere, please include an acknowledgement to myself.
;
; https://github.com/feilipu/
;
; https://feilipu.me/
;
;==============================================================================
;
; REQUIRES
;
; Z180_VECTOR_BASE .EQU RAM vector address for Z180 Vectors
; INCLUDE "yaz180.h"
INCLUDE "yaz180.h"
;==============================================================================
;
; Z180 TRAP HANDLING
;
SECTION z180_vector_trap_handler
EXTERN Z180_INIT, Z180_TRAP
PUBLIC INIT, REINIT
INIT:
PUSH AF
; Set I/O Control Reg (ICR)
LD A,Z180_IO_BASE ; ICR = $00 [xx00 0000] for I/O Registers at $00 - $3F
OUT0 (ICR),A ; Standard I/O Mapping (0 Enabled)
IN0 A,(ITC) ; Check whether TRAP is set, or normal RESET
AND ITC_TRAP
JR NZ, Z180_TRAP_HANDLER ; Handle the TRAP event
POP AF
REINIT:
LD A,Z180_VECTOR_BASE/$100
LD I,A ; Set interrupt vector address high byte (I)
; IL = $40 [010x xxxx] for Vectors at $nn40 - $nn5F
LD A,Z180_VECTOR_BASE%$100
OUT0 (IL),A ; Set interrupt vector address low byte (IL)
IM 1 ; Interrupt mode 1 for INT0
XOR A ; Zero Accumulator
; Clear Refresh Control Reg (RCR)
OUT0 (RCR),A ; DRAM Refresh Enable (0 Disabled)
OUT0 (TCR),A ; Disable PRT downcounting
; Clear INT/TRAP Control Register (ITC)
OUT0 (ITC),A ; Disable all external interrupts.
; Set Operation Mode Control Reg (OMCR)
LD A,OMCR_M1E ; Enable M1 for single step, disable 64180 I/O _RD Mode
OUT0 (OMCR),A ; X80 Mode (M1 Disabled, IOC Disabled)
; Set internal clock = crystal x 2 = 36.864MHz
; if using ZS8180 or Z80182 at High-Speed
LD A,CMR_X2 ; Set Hi-Speed flag
OUT0 (CMR),A ; CPU Clock Multiplier Reg (CMR)
; DMA/Wait Control Reg Set I/O Wait States
LD A,DCNTL_IWI0
OUT0 (DCNTL),A ; 0 Memory Wait & 2 I/O Wait
LD HL,Z80_VECTOR_PROTO ; Establish Z80 RST Vector Table
LD DE,Z80_VECTOR_BASE
LD BC,Z80_VECTOR_SIZE
LDIR
LD HL,Z180_VECTOR_PROTO ; Establish Z180 Vector Table
LD DE,Z180_VECTOR_BASE
LD BC,Z180_VECTOR_SIZE
LDIR
JP Z180_INIT ; Start normal Configuration
Z180_TRAP_HANDLER:
XOR ITC_TRAP ; Clear TRAP bit, It must be set to get here.
OUT0 (ITC),A
POP AF
JP Z180_TRAP ; Jump to proper TRAP handling
;==============================================================================
;
; Z180 INTERRUPT VECTOR TABLE PROTOTYPE
;
; WILL BE DUPLICATED DURING INIT TO:
;
; .ORG Z180_VECTOR_BASE
SECTION z180_vector_table_prototype
EXTERN INT_INT1, INT_INT2, INT_PRT0, INT_PRT1
EXTERN INT_DMA0, INT_DMA1, INT_CSIO, INT_ASCI0, INT_ASCI1
;------------------------------------------------------------------------------
; Z180_VECTOR_INT1
DEFW INT_INT1
;------------------------------------------------------------------------------
; Z180_VECTOR_INT2
DEFW INT_INT2
;------------------------------------------------------------------------------
; Z180_VECTOR_PRT0
DEFW INT_PRT0
;------------------------------------------------------------------------------
; Z180_VECTOR_PRT1
DEFW INT_PRT1
;------------------------------------------------------------------------------
; Z180_VECTOR_DMA0
DEFW INT_DMA0
;------------------------------------------------------------------------------
; Z180_VECTOR_DMA1
DEFW INT_DMA1
;------------------------------------------------------------------------------
; Z180_VECTOR_CSIO
DEFW INT_CSIO
;------------------------------------------------------------------------------
; Z180_VECTOR_ASCI0
DEFW INT_ASCI0
;------------------------------------------------------------------------------
; Z180_VECTOR_ASCI1
DEFW INT_ASCI1
;==============================================================================
;
.END
;
;==============================================================================
|
icl '../os/symbols.asm'
org BOOTADDR
lda #1
sta ROS8
lda #0
ldx #OS_SET_VIDEO_MODE
jsr OS_CALL
mwa SUBPAL_START VRAM_TO_RAM
jsr lib_vram_to_ram
; use first 16 entries as subpal
ldy #0
set_subpal:
tya
sta (RAM_TO_VRAM), y
iny
cpy #16
bne set_subpal
; reset all attributes to $0F
mwa ATTRIB_START VRAM_TO_RAM
jsr lib_vram_to_ram
mwa RAM_TO_VRAM COPY_DST_ADDR
mwa SCREEN_SIZE COPY_SIZE
lda #$0F
jsr lib_vram_set_bytes
; copy test attrbutes
mwa ATTRIB_START VRAM_TO_RAM
jsr lib_vram_to_ram
ldy #0
copy_attribs:
lda attribs, y
beq display_message
sta (RAM_TO_VRAM), y
iny
bne copy_attribs
display_message:
mwa DISPLAY_START VRAM_TO_RAM
jsr lib_vram_to_ram
ldy #0
copy:
lda message, y
cmp #255
beq stop
sta (RAM_TO_VRAM), y
iny
bne copy
stop:
jmp stop
message:
.byte 40, 101, 108, 108, 111, 0, 55, 111, 114, 108, 100, 1, 1, 1, 1, 255
attribs:
.byte $0F, $01, $1E, $E1, $01, $02, $03, $04, $21, $22, $23, $24
.byte $1F, $2F, $3F, $4F, $5F, $00
icl '../os/stdlib.asm'
|
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0xee9f, %rsi
lea addresses_D_ht+0x559f, %rdi
nop
nop
nop
nop
and $42653, %rax
mov $32, %rcx
rep movsw
nop
nop
add %r15, %r15
lea addresses_A_ht+0xf86f, %rbp
nop
nop
sub $43498, %r14
mov $0x6162636465666768, %rsi
movq %rsi, %xmm1
movups %xmm1, (%rbp)
nop
nop
nop
nop
add $40600, %rdi
lea addresses_D_ht+0xae3f, %rsi
lea addresses_A_ht+0xfb47, %rdi
nop
nop
sub $24650, %rbp
mov $108, %rcx
rep movsb
nop
nop
nop
add $2857, %rdi
lea addresses_WT_ht+0x1e00f, %r15
nop
nop
sub $24506, %rsi
movl $0x61626364, (%r15)
nop
nop
nop
nop
nop
and %rbp, %rbp
lea addresses_A_ht+0x169f, %r15
nop
nop
nop
sub %rax, %rax
mov $0x6162636465666768, %rsi
movq %rsi, %xmm0
movups %xmm0, (%r15)
nop
nop
nop
nop
xor %rax, %rax
lea addresses_WC_ht+0x6def, %rax
nop
nop
nop
nop
inc %r14
mov $0x6162636465666768, %rcx
movq %rcx, %xmm4
vmovups %ymm4, (%rax)
and $62210, %r14
lea addresses_D_ht+0x1de9f, %rdi
nop
nop
inc %rsi
mov (%rdi), %ax
nop
nop
dec %rdi
lea addresses_WC_ht+0x1b29f, %rbp
nop
nop
nop
nop
nop
sub $10831, %rcx
movb (%rbp), %r14b
nop
nop
nop
nop
xor %r15, %r15
lea addresses_WT_ht+0x1a4df, %rsi
lea addresses_D_ht+0x549f, %rdi
nop
nop
nop
nop
nop
and $45844, %rbx
mov $38, %rcx
rep movsl
nop
nop
cmp $27588, %r14
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r15
push %r8
push %rbp
push %rdx
// Faulty Load
lea addresses_RW+0x2e9f, %r8
nop
nop
nop
nop
xor %r15, %r15
mov (%r8), %rbp
lea oracles, %r10
and $0xff, %rbp
shlq $12, %rbp
mov (%r10,%rbp,1), %rbp
pop %rdx
pop %rbp
pop %r8
pop %r15
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 11, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_A_ht'}}
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WT_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 1, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_D_ht'}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
; $Id: beeper.asm,v 1.4 2016/06/16 20:23:52 dom Exp $
;
; SAM Coupe 1 bit sound functions
;
; Stefano Bodrato - 28/9/2001
;
SECTION code_clib
PUBLIC beeper
PUBLIC _beeper
EXTERN bit_open_di
EXTERN bit_close_ei
.beeper
._beeper
call bit_open_di
call $016F
di
call bit_close_ei
ret
|
; A137203: Number of Fibonacci numbers less than or equal to n^2.
; 1,3,5,7,8,9,10,10,11,11,12,12,13,13,13,13,14,14,14,14,15,15,15,15,15,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20
mov $2,$0
mul $2,2
pow $2,4
add $2,4
pow $2,2
lpb $0,1
trn $0,$2
add $3,$2
lpe
add $3,16
add $1,$3
log $1,7
mul $1,2
sub $1,2
div $1,2
add $1,1
|
/**
* \file
* \author Lars Bilke
* \date 2009-11-04
* \brief Implementation of the MainWindow class.
*
* \copyright
* Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.net)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include "mainwindow.h"
// ThirdParty/logog
#include "logog/include/logog.hpp"
// BaseLib
#include "BaseLib/BuildInfo.h"
#include "BaseLib/FileTools.h"
#include "BaseLib/Histogram.h"
// GeoLib
#include "Raster.h"
#include "GeoLib/IO/Legacy/OGSIOVer4.h"
// MeshGeoLib
#include "MeshGeoToolsLib/GeoMapper.h"
//dialogs
#include "CreateStructuredGridDialog.h"
#include "DataExplorerSettingsDialog.h"
#include "DiagramPrefsDialog.h"
#include "GeoOnMeshMappingDialog.h"
#include "GMSHPrefsDialog.h"
#include "LicenseDialog.h"
#include "LineEditDialog.h"
#include "MergeGeometriesDialog.h"
#include "MeshAnalysisDialog.h"
#include "MeshElementRemovalDialog.h"
#include "MeshQualitySelectionDialog.h"
#include "NetCdfConfigureDialog.h"
#include "SetNameDialog.h"
#include "SHPImportDialog.h"
#include "VtkAddFilterDialog.h"
#include "GeoTreeModel.h"
#include "LastSavedFileDirectory.h"
#include "OGSError.h"
#include "RecentFiles.h"
#include "StationTreeModel.h"
#include "TreeModelIterator.h"
#include "VtkBGImageSource.h"
#include "VtkGeoImageSource.h"
#include "VtkRaster.h"
#include "VtkVisPipelineItem.h"
#include "MeshLib/Vtk/VtkMappedMeshSource.h"
// FileIO includes
#include "GMSInterface.h"
#include "MeshLib/IO/FEFLOW/FEFLOWMeshInterface.h"
#include "MeshLib/IO/Legacy/MeshIO.h"
#include "MeshLib/IO/readMeshFromFile.h"
#include "MeshLib/IO/GmshReader.h"
#include "FileIO/TetGenInterface.h"
#include "PetrelInterface.h"
#include "XmlIO/Qt/XmlGspInterface.h"
#include "GeoLib/IO/GMSHInterface.h"
#include "GeoLib/IO/FEFLOW/FEFLOWGeoInterface.h"
#include "GeoLib/IO/XmlIO/Qt/XmlGmlInterface.h"
#include "GeoLib/IO/XmlIO/Qt/XmlStnInterface.h"
// MeshLib
#include "Node.h"
#include "Mesh.h"
#include "Elements/Element.h"
#include "MeshSurfaceExtraction.h"
#include "convertMeshToGeo.h"
#include "MeshQuality/ElementQualityInterface.h"
// Qt includes
#include <QDesktopWidget>
#include <QFileDialog>
#include <QMessageBox>
#include <QObject>
#include <QSettings>
#include <QSignalMapper>
// VTK includes
#include <vtkOBJExporter.h>
#include <vtkRenderer.h>
#include <vtkVRMLExporter.h>
#include "Applications/Utils/OGSFileConverter/OGSFileConverter.h"
#include "BaseLib/BuildInfo.h"
using namespace FileIO;
MainWindow::MainWindow(QWidget* parent /* = 0*/)
: QMainWindow(parent), _project()
{
setupUi(this);
// Setup various models
_meshModel.reset(new MshModel(_project));
_elementModel.reset(new ElementTreeModel());
_processModel.reset(new TreeModel());
_geo_model.reset(new GEOModels{_project.getGEOObjects()});
geoTabWidget->treeView->setModel(_geo_model->getGeoModel());
stationTabWidget->treeView->setModel(_geo_model->getStationModel());
mshTabWidget->treeView->setModel(_meshModel.get());
mshTabWidget->elementView->setModel(_elementModel.get());
modellingTabWidget->treeView->setModel(_processModel.get());
// vtk visualization pipeline
_vtkVisPipeline.reset(new VtkVisPipeline(visualizationWidget->renderer()));
// station model connects
connect(stationTabWidget->treeView, SIGNAL(openStationListFile(int)),
this, SLOT(open(int)));
connect(stationTabWidget->treeView, SIGNAL(stationListExportRequested(std::string, std::string)),
this, SLOT(exportBoreholesToGMS(std::string, std::string))); // export Stationlist to GMS
connect(stationTabWidget->treeView, SIGNAL(stationListRemoved(std::string)), _geo_model.get(),
SLOT(removeStationVec(std::string))); // update model when stations are removed
connect(stationTabWidget->treeView, SIGNAL(stationListSaved(QString, QString)), this,
SLOT(writeStationListToFile(QString, QString))); // save Stationlist to File
connect(_geo_model.get(), SIGNAL(stationVectorRemoved(StationTreeModel *, std::string)),
this, SLOT(updateDataViews())); // update data view when stations are removed
connect(stationTabWidget->treeView, SIGNAL(diagramRequested(QModelIndex &)),
this, SLOT(showDiagramPrefsDialog(QModelIndex &))); // connect treeview to diagramview
// geo model connects
connect(geoTabWidget->treeView, SIGNAL(openGeometryFile(int)),
this, SLOT(open(int)));
connect(geoTabWidget->treeView, SIGNAL(listRemoved(std::string, GeoLib::GEOTYPE)),
_geo_model.get(), SLOT(removeGeometry(std::string, GeoLib::GEOTYPE)));
connect(geoTabWidget->treeView, SIGNAL(geometryMappingRequested(const std::string&)),
this, SLOT(mapGeometry(const std::string&)));
connect(geoTabWidget->treeView, SIGNAL(saveToFileRequested(QString, QString)),
this, SLOT(writeGeometryToFile(QString, QString))); // save geometry to file
connect(geoTabWidget->treeView, SIGNAL(requestLineEditDialog(const std::string &)),
this, SLOT(showLineEditDialog(const std::string &))); // open line edit dialog
connect(geoTabWidget->treeView, SIGNAL(requestNameChangeDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t)),
this, SLOT(showGeoNameDialog(const std::string&, const GeoLib::GEOTYPE, std::size_t)));
connect(_geo_model.get(), SIGNAL(geoDataAdded(GeoTreeModel *, std::string, GeoLib::GEOTYPE)),
this, SLOT(updateDataViews()));
connect(_geo_model.get(), SIGNAL(geoDataRemoved(GeoTreeModel *, std::string, GeoLib::GEOTYPE)),
this, SLOT(updateDataViews()));
connect(geoTabWidget->treeView, SIGNAL(geoItemSelected(const vtkPolyDataAlgorithm*, int)),
_vtkVisPipeline.get(), SLOT(highlightGeoObject(const vtkPolyDataAlgorithm*, int)));
connect(geoTabWidget->treeView, SIGNAL(removeGeoItemSelection()),
_vtkVisPipeline.get(), SLOT(removeHighlightedGeoObject()));
connect(stationTabWidget->treeView, SIGNAL(geoItemSelected(const vtkPolyDataAlgorithm*, int)),
_vtkVisPipeline.get(), SLOT(highlightGeoObject(const vtkPolyDataAlgorithm*, int)));
connect(stationTabWidget->treeView, SIGNAL(removeGeoItemSelection()),
_vtkVisPipeline.get(), SLOT(removeHighlightedGeoObject()));
// Setup connections for mesh models to GUI
connect(mshTabWidget->treeView, SIGNAL(openMeshFile(int)),
this, SLOT(open(int)));
connect(mshTabWidget->treeView, SIGNAL(requestMeshRemoval(const QModelIndex &)),
_meshModel.get(), SLOT(removeMesh(const QModelIndex &)));
connect(mshTabWidget->treeView, SIGNAL(requestMeshRemoval(const QModelIndex &)),
_elementModel.get(), SLOT(clearView()));
connect(mshTabWidget->treeView,
SIGNAL(qualityCheckRequested(MeshLib::VtkMappedMeshSource*)),
this,
SLOT(showMeshQualitySelectionDialog(MeshLib::VtkMappedMeshSource*)));
connect(mshTabWidget->treeView, SIGNAL(requestMeshToGeometryConversion(const MeshLib::Mesh*)),
this, SLOT(convertMeshToGeometry(const MeshLib::Mesh*)));
connect(mshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)),
_vtkVisPipeline.get(), SLOT(highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)));
connect(mshTabWidget->treeView, SIGNAL(meshSelected(MeshLib::Mesh const&)),
this->_elementModel.get(), SLOT(setMesh(MeshLib::Mesh const&)));
connect(mshTabWidget->treeView, SIGNAL(meshSelected(MeshLib::Mesh const&)),
mshTabWidget->elementView, SLOT(updateView()));
connect(mshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)),
this->_elementModel.get(), SLOT(setElement(vtkUnstructuredGridAlgorithm const*const, unsigned)));
connect(mshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)),
mshTabWidget->elementView, SLOT(updateView()));
connect(mshTabWidget->treeView, SIGNAL(elementSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)),
(QObject*) (visualizationWidget->interactorStyle()), SLOT(removeHighlightActor()));
connect(mshTabWidget->treeView, SIGNAL(removeSelectedMeshComponent()),
_vtkVisPipeline.get(), SLOT(removeHighlightedMeshComponent()));
connect(mshTabWidget->elementView, SIGNAL(nodeSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)),
(QObject*) (visualizationWidget->interactorStyle()), SLOT(removeHighlightActor()));
connect(mshTabWidget->elementView, SIGNAL(nodeSelected(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)),
_vtkVisPipeline.get(), SLOT(highlightMeshComponent(vtkUnstructuredGridAlgorithm const*const, unsigned, bool)));
connect(mshTabWidget->elementView, SIGNAL(removeSelectedMeshComponent()),
_vtkVisPipeline.get(), SLOT(removeHighlightedMeshComponent()));
// VisPipeline Connects
connect(_geo_model.get(), SIGNAL(geoDataAdded(GeoTreeModel *, std::string, GeoLib::GEOTYPE)),
_vtkVisPipeline.get(), SLOT(addPipelineItem(GeoTreeModel *, std::string, GeoLib::GEOTYPE)));
connect(_geo_model.get(), SIGNAL(geoDataRemoved(GeoTreeModel *, std::string, GeoLib::GEOTYPE)),
_vtkVisPipeline.get(), SLOT(removeSourceItem(GeoTreeModel *, std::string, GeoLib::GEOTYPE)));
connect(_geo_model.get(), SIGNAL(stationVectorAdded(StationTreeModel *, std::string)),
_vtkVisPipeline.get(), SLOT(addPipelineItem(StationTreeModel *, std::string)));
connect(_geo_model.get(), SIGNAL(stationVectorRemoved(StationTreeModel *, std::string)),
_vtkVisPipeline.get(), SLOT(removeSourceItem(StationTreeModel *, std::string)));
connect(_meshModel.get(), SIGNAL(meshAdded(MshModel *, QModelIndex)),
_vtkVisPipeline.get(), SLOT(addPipelineItem(MshModel *,QModelIndex)));
connect(_meshModel.get(), SIGNAL(meshRemoved(MshModel *, QModelIndex)),
_vtkVisPipeline.get(), SLOT(removeSourceItem(MshModel *, QModelIndex)));
connect(_vtkVisPipeline.get(), SIGNAL(vtkVisPipelineChanged()),
visualizationWidget->vtkWidget, SLOT(update()));
connect(_vtkVisPipeline.get(), SIGNAL(vtkVisPipelineChanged()),
vtkVisTabWidget->vtkVisPipelineView, SLOT(expandAll()));
connect(_vtkVisPipeline.get(), SIGNAL(itemSelected(const QModelIndex&)),
vtkVisTabWidget->vtkVisPipelineView, SLOT(selectItem(const QModelIndex&)));
vtkVisTabWidget->vtkVisPipelineView->setModel(_vtkVisPipeline.get());
connect(vtkVisTabWidget->vtkVisPipelineView, SIGNAL(requestRemovePipelineItem(QModelIndex)),
_vtkVisPipeline.get(), SLOT(removePipelineItem(QModelIndex)));
connect(vtkVisTabWidget->vtkVisPipelineView,
SIGNAL(requestAddPipelineFilterItem(QModelIndex)), this,
SLOT(showAddPipelineFilterItemDialog(QModelIndex)));
connect(vtkVisTabWidget, SIGNAL(requestViewUpdate()), visualizationWidget,
SLOT(updateView()));
connect(vtkVisTabWidget->vtkVisPipelineView,
SIGNAL(actorSelected(vtkProp3D*)),
(QObject*) (visualizationWidget->interactorStyle()),
SLOT(highlightActor(vtkProp3D*)));
connect((QObject*) (visualizationWidget->interactorStyle()),
SIGNAL(requestViewUpdate()),
visualizationWidget, SLOT(updateView()));
// Propagates selected vtk object in the pipeline to the pick interactor
connect(vtkVisTabWidget->vtkVisPipelineView,
SIGNAL(dataObjectSelected(vtkDataObject*)),
(QObject*) (visualizationWidget->interactorStyle()),
SLOT(pickableDataObject(vtkDataObject*)));
connect((QObject*) (visualizationWidget->vtkPickCallback()),
SIGNAL(actorPicked(vtkProp3D*)),
vtkVisTabWidget->vtkVisPipelineView, SLOT(selectItem(vtkProp3D*)));
connect((QObject*) (visualizationWidget->interactorStyle()),
SIGNAL(elementPicked(vtkUnstructuredGridAlgorithm const*const, const unsigned)),
this->_elementModel.get(), SLOT(setElement(vtkUnstructuredGridAlgorithm const*const, const unsigned)));
connect((QObject*) (visualizationWidget->interactorStyle()),
SIGNAL(elementPicked(vtkUnstructuredGridAlgorithm const*const, const unsigned)),
mshTabWidget->elementView, SLOT(updateView()));
connect((QObject*) (visualizationWidget->interactorStyle()), SIGNAL(clearElementView()),
this->_elementModel.get(), SLOT(clearView()));
connect((QObject*) (visualizationWidget->interactorStyle()),
SIGNAL(elementPicked(vtkUnstructuredGridAlgorithm const*const, const unsigned)),
this->_vtkVisPipeline.get(), SLOT(removeHighlightedMeshComponent()));
connect(vtkVisTabWidget->vtkVisPipelineView, SIGNAL(meshAdded(MeshLib::Mesh*)),
_meshModel.get(), SLOT(addMesh(MeshLib::Mesh*)));
// Stack the data dock widgets together
tabifyDockWidget(geoDock, mshDock);
tabifyDockWidget(mshDock, modellingDock);
tabifyDockWidget(modellingDock, stationDock);
// Restore window geometry
readSettings();
// Get info on screens geometry(ies)
_vtkWidget.reset(visualizationWidget->vtkWidget);
QDesktopWidget* desktopWidget = QApplication::desktop();
const unsigned int screenCount = desktopWidget->screenCount();
for (std::size_t i = 0; i < screenCount; ++i)
_screenGeometries.push_back(desktopWidget->availableGeometry((int)i));
// Setup import files menu
QMenu* import_files_menu = createImportFilesMenu(); //owned by MainWindow
menu_File->insertMenu(action_Exit, import_files_menu);
// Setup recent files menu
RecentFiles* recentFiles = new RecentFiles(this, SLOT(openRecentFile()), "recentFileList");
connect(this, SIGNAL(fileUsed(QString)), recentFiles,
SLOT(setCurrentFile(QString)));
menu_File->insertMenu(action_Exit, recentFiles->menu());
// Setup Windows menu
QAction* showGeoDockAction = geoDock->toggleViewAction();
showGeoDockAction->setStatusTip(tr("Shows / hides the geometry view"));
connect(showGeoDockAction, SIGNAL(triggered(bool)), this,
SLOT(showGeoDockWidget(bool)));
menuWindows->addAction(showGeoDockAction);
QAction* showStationDockAction = stationDock->toggleViewAction();
showStationDockAction->setStatusTip(tr("Shows / hides the station view"));
connect(showStationDockAction, SIGNAL(triggered(bool)), this,
SLOT(showStationDockWidget(bool)));
menuWindows->addAction(showStationDockAction);
QAction* showMshDockAction = mshDock->toggleViewAction();
showMshDockAction->setStatusTip(tr("Shows / hides the mesh view"));
connect(showMshDockAction, SIGNAL(triggered(bool)), this,
SLOT(showMshDockWidget(bool)));
menuWindows->addAction(showMshDockAction);
QAction* showModellingDockAction = modellingDock->toggleViewAction();
showModellingDockAction->setStatusTip(tr("Shows / hides the Process view"));
connect(showModellingDockAction, SIGNAL(triggered(bool)), this,
SLOT(showConditionDockWidget(bool)));
menuWindows->addAction(showModellingDockAction);
QAction* showVisDockAction = vtkVisDock->toggleViewAction();
showVisDockAction->setStatusTip(tr("Shows / hides the VTK Pipeline view"));
connect(showVisDockAction, SIGNAL(triggered(bool)), this,
SLOT(showVisDockWidget(bool)));
menuWindows->addAction(showVisDockAction);
// Presentation mode
QMenu* presentationMenu = new QMenu(this);
presentationMenu->setTitle("Presentation on");
connect(presentationMenu, SIGNAL(aboutToShow()), this,
SLOT(createPresentationMenu()));
menuWindows->insertMenu(showVisDockAction, presentationMenu);
_visPrefsDialog.reset(new VisPrefsDialog(*_vtkVisPipeline, *visualizationWidget));
}
void MainWindow::closeEvent(QCloseEvent* event)
{
writeSettings();
QWidget::closeEvent(event);
}
void MainWindow::showGeoDockWidget(bool show)
{
if (show)
geoDock->show();
else
geoDock->hide();
}
void MainWindow::showStationDockWidget(bool show)
{
if (show)
stationDock->show();
else
stationDock->hide();
}
void MainWindow::showMshDockWidget(bool show)
{
if (show)
mshDock->show();
else
mshDock->hide();
}
void MainWindow::showConditionDockWidget(bool show)
{
if (show)
modellingDock->show();
else
modellingDock->hide();
}
void MainWindow::showVisDockWidget(bool show)
{
if (show)
vtkVisDock->show();
else
vtkVisDock->hide();
}
void MainWindow::open(int file_type)
{
QSettings settings;
ImportFileType::type t = static_cast<ImportFileType::type>(file_type);
QString type_str = QString::fromStdString((ImportFileType::convertImportFileTypeToString(t)));
QString fileName = QFileDialog::getOpenFileName(this, "Select " + type_str + " file to import",
settings.value("lastOpenedFileDirectory").toString(),
QString::fromStdString(ImportFileType::getFileSuffixString(t)));
if (!fileName.isEmpty())
{
loadFile(t, fileName);
QDir dir = QDir(fileName);
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
}
}
void MainWindow::openRecentFile()
{
QAction* action = qobject_cast<QAction*> (sender());
if (action)
loadFile(ImportFileType::OGS, action->data().toString());
}
void MainWindow::save()
{
QString fileName = QFileDialog::getSaveFileName(
this,
"Save data as",
LastSavedFileDirectory::getDir(),
"GeoSys project (*.gsp);;GMSH geometry files (*.geo)");
if (fileName.isEmpty())
{
OGSError::box("No filename specified.");
return;
}
QFileInfo fi(fileName);
LastSavedFileDirectory::setDir(fileName);
if (fi.suffix().toLower() == "gsp")
{
XmlGspInterface xml(_project);
xml.writeToFile(fileName.toStdString());
}
else if (fi.suffix().toLower() == "geo")
{
std::vector<std::string> selected_geometries;
_project.getGEOObjects().getGeometryNames(selected_geometries);
GeoLib::IO::GMSHInterface gmsh_io(
_project.getGEOObjects(), true,
GeoLib::IO::GMSH::MeshDensityAlgorithm::AdaptiveMeshDensity, 0.05,
0.5, 2, selected_geometries);
gmsh_io.setPrecision(std::numeric_limits<double>::digits10);
bool const success = gmsh_io.writeToFile(fileName.toStdString());
if (!success)
OGSError::box(" No geometry available\n to write to geo-file");
}
}
void MainWindow::loadFile(ImportFileType::type t, const QString &fileName)
{
QFile file(fileName);
if (!file.exists())
{
QMessageBox::warning(this, tr("Application"), tr(
"Cannot read file %1:\n%2.").arg(fileName).arg(
file.errorString()));
return;
}
QApplication::setOverrideCursor(Qt::WaitCursor);
QFileInfo fi(fileName);
QSettings settings;
QDir dir = QDir(fileName);
std::string base = fi.absoluteDir().absoluteFilePath(fi.completeBaseName()).toStdString();
if (t == ImportFileType::OGS || t == ImportFileType::OGS_GEO || t == ImportFileType::OGS_STN || t == ImportFileType::OGS_MSH)
{
if (fi.suffix().toLower() == "gli")
{
std::string unique_name;
std::vector<std::string> errors;
if (!GeoLib::IO::Legacy::readGLIFileV4(fileName.toStdString(),
_project.getGEOObjects(),
unique_name, errors))
{
for (std::size_t k(0); k<errors.size(); k++)
OGSError::box(QString::fromStdString(errors[k]));
}
}
else if (fi.suffix().toLower() == "gsp")
{
XmlGspInterface xml(_project);
if (xml.readFile(fileName))
{
_meshModel->updateModel();
}
else
OGSError::box("Failed to load project file.\n Please see console for details.");
}
else if (fi.suffix().toLower() == "gml")
{
GeoLib::IO::XmlGmlInterface xml(_project.getGEOObjects());
if (!xml.readFile(fileName))
OGSError::box("Failed to load geometry.\n Please see console for details.");
}
// OpenGeoSys observation station files (incl. boreholes)
else if (fi.suffix().toLower() == "stn")
{
GeoLib::IO::XmlStnInterface xml(_project.getGEOObjects());
if (!xml.readFile(fileName))
OGSError::box("Failed to load station data.\n Please see console for details.");
}
// OpenGeoSys mesh files
else if (fi.suffix().toLower() == "msh" || fi.suffix().toLower() == "vtu")
{
#ifndef NDEBUG
QTime myTimer0, myTimer1;
myTimer0.start();
#endif
std::unique_ptr<MeshLib::Mesh> mesh(
MeshLib::IO::readMeshFromFile(fileName.toStdString()));
#ifndef NDEBUG
INFO("Mesh loading time: %d ms.", myTimer0.elapsed());
myTimer1.start();
#endif
if (mesh)
_meshModel->addMesh(std::move(mesh));
else
OGSError::box("Failed to load mesh file.");
#ifndef NDEBUG
INFO("Mesh model setup time: %d ms.", myTimer1.elapsed());
#endif
}
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
emit fileUsed(fileName);
}
else if (t == ImportFileType::FEFLOW)
{
if (fi.suffix().toLower() == "fem") // FEFLOW model files
{
MeshLib::IO::FEFLOWMeshInterface feflowMeshIO;
std::unique_ptr<MeshLib::Mesh> mesh(
feflowMeshIO.readFEFLOWFile(fileName.toStdString()));
if (mesh)
_meshModel->addMesh(std::move(mesh));
else
OGSError::box("Failed to load a FEFLOW mesh.");
GeoLib::IO::FEFLOWGeoInterface feflowGeoIO;
feflowGeoIO.readFEFLOWFile(fileName.toStdString(), _project.getGEOObjects());
}
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
}
else if (t == ImportFileType::GMS)
{
if (fi.suffix().toLower() == "txt") // GMS borehole files
{
auto boreholes = std::unique_ptr<std::vector<GeoLib::Point*>>(
new std::vector<GeoLib::Point*>());
std::string name = fi.baseName().toStdString();
if (GMSInterface::readBoreholesFromGMS(boreholes.get(), fileName.toStdString()))
_project.getGEOObjects().addStationVec(std::move(boreholes), name);
else
OGSError::box("Error reading GMS file.");
}
else if (fi.suffix().toLower() == "3dm") // GMS mesh files
{
std::string name = fileName.toStdString();
std::unique_ptr<MeshLib::Mesh> mesh(GMSInterface::readGMS3DMMesh(name));
if (mesh)
_meshModel->addMesh(std::move(mesh));
else
OGSError::box("Failed to load a GMS mesh.");
}
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
}
else if (t == ImportFileType::GMSH)
{
std::string msh_name (fileName.toStdString());
if (MeshLib::IO::GMSH::isGMSHMeshFile (msh_name))
{
std::unique_ptr<MeshLib::Mesh> mesh(MeshLib::IO::GMSH::readGMSHMesh(msh_name));
if (mesh)
_meshModel->addMesh(std::move(mesh));
else
OGSError::box("Failed to load a GMSH mesh.");
}
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
}
else if (t == ImportFileType::NETCDF) // CH 01.2012
{
NetCdfConfigureDialog dlg(fileName.toStdString());
dlg.exec();
if (dlg.getMesh())
{
std::unique_ptr<MeshLib::Mesh> mesh(dlg.getMesh());
mesh->setName(dlg.getName());
_meshModel->addMesh(std::move(mesh));
}
if (dlg.getRaster())
_vtkVisPipeline->addPipelineItem(dlg.getRaster());
settings.setValue("lastOpenedRasterFileDirectory", dir.absolutePath());
}
else if (t == ImportFileType::RASTER)
{
VtkGeoImageSource* geoImage = VtkGeoImageSource::New();
if (geoImage->readImage(fileName))
_vtkVisPipeline->addPipelineItem(geoImage);
else
{
geoImage->Delete();
OGSError::box("Error reading raster.");
}
settings.setValue("lastOpenedRasterFileDirectory", dir.absolutePath());
}
else if (t == ImportFileType::POLYRASTER)
{
QImage raster;
double origin[2];
double cellSize;
vtkImageAlgorithm* imageAlgorithm = VtkRaster::loadImage(fileName.toStdString(), origin[0], origin[1], cellSize);
VtkBGImageSource* bg = VtkBGImageSource::New();
bg->SetRaster(imageAlgorithm, origin[0], origin[1], cellSize);
bg->SetName(fileName);
_vtkVisPipeline->addPipelineItem(bg);
settings.setValue("lastOpenedRasterFileDirectory", dir.absolutePath());
}
else if (t == ImportFileType::SHAPE)
{
SHPImportDialog dlg(fileName.toStdString(), _project.getGEOObjects());
dlg.exec();
QDir dir = QDir(fileName);
settings.setValue("lastOpenedShapeFileDirectory", dir.absolutePath());
}
else if (t == ImportFileType::TETGEN)
{
if (fi.suffix().toLower().compare("poly") == 0 || fi.suffix().toLower().compare("smesh") == 0)
{
FileIO::TetGenInterface tetgen;
tetgen.readTetGenGeometry(fileName.toStdString(), _project.getGEOObjects());
}
else {
settings.setValue("lastOpenedTetgenFileDirectory", QFileInfo(fileName).absolutePath());
QString element_fname(fi.path() + "/" + fi.completeBaseName() + ".ele");
if (!fileName.isEmpty())
{
FileIO::TetGenInterface tetgen;
std::unique_ptr<MeshLib::Mesh> mesh(tetgen.readTetGenMesh(
fileName.toStdString(), element_fname.toStdString()));
if (mesh)
_meshModel->addMesh(std::move(mesh));
else
OGSError::box("Failed to load a TetGen mesh.");
}
}
}
else if (t == ImportFileType::VTK)
{
_vtkVisPipeline->loadFromFile(fileName);
settings.setValue("lastOpenedVtkFileDirectory", dir.absolutePath());
}
QApplication::restoreOverrideCursor();
updateDataViews();
}
void MainWindow::updateDataViews()
{
visualizationWidget->updateViewOnLoad();
geoTabWidget->treeView->updateView();
stationTabWidget->treeView->updateView();
mshTabWidget->treeView->updateView();
}
void MainWindow::readSettings()
{
QSettings settings;
restoreGeometry(settings.value("windowGeometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
}
void MainWindow::writeSettings()
{
QSettings settings;
settings.setValue("windowGeometry", saveGeometry());
settings.setValue("windowState", saveState());
}
void MainWindow::showLicense()
{
LicenseDialog dlg;
dlg.exec();
}
void MainWindow::about()
{
QString about("<a href='http://www.opengeosys.org'>http://www.opengeosys.org</a><br /><br />");
about.append(QString("Version: <a href='https://github.com/ufz/ogs/releases/tag/%2'>%1</a><br /><br />")
.arg(QString::fromStdString(BaseLib::BuildInfo::git_describe))
.arg(QString::fromStdString(BaseLib::BuildInfo::ogs_version)));
about.append(QString("Git commit: <a href='https://github.com/ufz/ogs/commit/%1'>%1</a><br />")
.arg(QString::fromStdString(BaseLib::BuildInfo::git_version_sha1_short)));
about.append(QString("Built date: %1<br />").arg(QDate::currentDate().toString(Qt::ISODate)));
QMessageBox::about(this, "About OpenGeoSys 6", about);
}
QMenu* MainWindow::createImportFilesMenu()
{
QSignalMapper* signal_mapper = new QSignalMapper(this); //owned by MainWindow
QMenu* importFiles = new QMenu("&Import Files", this);
QAction* feflowFiles = importFiles->addAction("&FEFLOW Files...");
connect(feflowFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()));
signal_mapper->setMapping(feflowFiles, ImportFileType::FEFLOW);
QAction* gmsFiles = importFiles->addAction("G&MS Files...");
connect(gmsFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()));
signal_mapper->setMapping(gmsFiles, ImportFileType::GMS);
QAction* gmshFiles = importFiles->addAction("&GMSH Files...");
connect(gmshFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()));
signal_mapper->setMapping(gmshFiles, ImportFileType::GMSH);
QAction* netcdfFiles = importFiles->addAction("&NetCDF Files...");
connect(netcdfFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()));
signal_mapper->setMapping(netcdfFiles, ImportFileType::NETCDF);
QAction* petrelFiles = importFiles->addAction("&Petrel Files...");
connect(petrelFiles, SIGNAL(triggered()), this, SLOT(loadPetrelFiles()));
QAction* rasterFiles = importFiles->addAction("&Raster Files...");
connect(rasterFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()));
signal_mapper->setMapping(rasterFiles, ImportFileType::RASTER);
#if defined VTKFBXCONVERTER_FOUND
QAction* rasterPolyFiles = importFiles->addAction("R&aster Files as PolyData...");
connect(rasterPolyFiles, SIGNAL(triggered()), this, SLOT(map()));
_signal_mapper->setMapping(rasterPolyFiles, ImportFileType::POLYRASTER);
#endif
QAction* shapeFiles = importFiles->addAction("&Shape Files...");
connect(shapeFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()));
signal_mapper->setMapping(shapeFiles, ImportFileType::SHAPE);
QAction* tetgenFiles = importFiles->addAction("&TetGen Files...");
connect( tetgenFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()) );
signal_mapper->setMapping(tetgenFiles, ImportFileType::TETGEN);
QAction* vtkFiles = importFiles->addAction("&VTK Files...");
connect( vtkFiles, SIGNAL(triggered()), signal_mapper, SLOT(map()) );
signal_mapper->setMapping(vtkFiles, ImportFileType::VTK);
connect(signal_mapper, SIGNAL(mapped(int)), this, SLOT(open(int)));
return importFiles;
}
void MainWindow::loadPetrelFiles()
{
QSettings settings;
QStringList sfc_file_names = QFileDialog::getOpenFileNames(
this, "Select surface data file(s) to import", "", "Petrel files (*)");
QStringList well_path_file_names = QFileDialog::getOpenFileNames(
this, "Select well path data file(s) to import", "", "Petrel files (*)");
if (sfc_file_names.size() != 0 || well_path_file_names.size() != 0)
{
QStringList::const_iterator it = sfc_file_names.begin();
std::list<std::string> sfc_files;
while (it != sfc_file_names.end())
{
sfc_files.push_back((*it).toStdString());
++it;
}
it = well_path_file_names.begin();
std::list<std::string> well_path_files;
while (it != well_path_file_names.end())
{
well_path_files.push_back((*it).toStdString());
++it;
}
std::string unique_str(*(sfc_files.begin()));
PetrelInterface(sfc_files, well_path_files, unique_str, &_project.getGEOObjects());
QDir dir = QDir(sfc_file_names.at(0));
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
}
}
void MainWindow::showAddPipelineFilterItemDialog(QModelIndex parentIndex)
{
VtkAddFilterDialog dlg(*_vtkVisPipeline, parentIndex);
dlg.exec();
}
void MainWindow::writeGeometryToFile(QString gliName, QString fileName)
{
#ifndef NDEBUG
QFileInfo fi(fileName);
if (fi.suffix().toLower() == "gli")
{
GeoLib::IO::Legacy::writeAllDataToGLIFileV4(fileName.toStdString(),
_project.getGEOObjects());
return;
}
#endif
GeoLib::IO::XmlGmlInterface xml(_project.getGEOObjects());
xml.setNameForExport(gliName.toStdString());
xml.writeToFile(fileName.toStdString());
}
void MainWindow::writeStationListToFile(QString listName, QString fileName)
{
GeoLib::IO::XmlStnInterface xml(_project.getGEOObjects());
xml.setNameForExport(listName.toStdString());
xml.writeToFile(fileName.toStdString());
}
void MainWindow::mapGeometry(const std::string &geo_name)
{
GeoOnMeshMappingDialog dlg(this->_project.getMeshObjects());
if (dlg.exec() != QDialog::Accepted)
return;
int choice (dlg.getDataSetChoice());
QString file_name("");
if (choice<2) // load something from a file
{
QString file_type[2] = {"OpenGeoSys mesh files (*.vtu *.msh)", "Raster files(*.asc *.grd)" };
QSettings settings;
file_name = QFileDialog::getOpenFileName( this,
"Select file for mapping",
settings.value("lastOpenedFileDirectory").toString(),
file_type[choice]);
if (file_name.isEmpty()) return;
QDir dir = QDir(file_name);
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
}
MeshGeoToolsLib::GeoMapper geo_mapper(_project.getGEOObjects(), geo_name);
QFileInfo fi(file_name);
if (choice == 1) // load raster from file
{
if (fi.suffix().toLower() == "asc" || fi.suffix().toLower() == "grd")
{
geo_mapper.mapOnDEM(file_name.toStdString());
_geo_model->updateGeometry(geo_name);
}
else
OGSError::box("The selected file is no supported raster file.");
return;
}
MeshLib::Mesh* mesh (nullptr);
if (choice == 0) // load mesh from file
{
if (fi.suffix().toLower() == "vtu" || fi.suffix().toLower() == "msh")
mesh = MeshLib::IO::readMeshFromFile(file_name.toStdString());
else
{
OGSError::box("The selected file is no supported mesh file.");
return;
}
}
else // use mesh from ProjectData
mesh = _project.getMeshObjects()[choice-2].get();
std::string const& new_geo_name = dlg.getNewGeoName();
if (new_geo_name.empty())
{
geo_mapper.mapOnMesh(mesh);
_geo_model->updateGeometry(geo_name);
}
else
{
geo_mapper.advancedMapOnMesh(mesh, new_geo_name);
_geo_model->updateGeometry(new_geo_name);
}
}
void MainWindow::convertMeshToGeometry(const MeshLib::Mesh* mesh)
{
MeshLib::convertMeshToGeo(*mesh, _project.getGEOObjects());
}
void MainWindow::exportBoreholesToGMS(std::string listName, std::string fileName)
{
const std::vector<GeoLib::Point*>* stations(_project.getGEOObjects().getStationVec(listName));
GMSInterface::writeBoreholesToGMS(stations, fileName);
}
void MainWindow::callGMSH(std::vector<std::string> & selectedGeometries,
unsigned param1, double param2, double param3, double param4,
bool delete_geo_file)
{
if (!selectedGeometries.empty())
{
INFO("Start meshing ...");
QString fileName("");
QString dir_str = this->getLastUsedDir();
if (!delete_geo_file)
fileName = QFileDialog::getSaveFileName(this, "Save GMSH-file as",
LastSavedFileDirectory::getDir() + "tmp_gmsh.geo",
"GMSH geometry files (*.geo)");
else
fileName = "tmp_gmsh.geo";
if (!fileName.isEmpty())
{
if (param4 == -1) { // adaptive meshing selected
GeoLib::IO::GMSHInterface gmsh_io(
_project.getGEOObjects(), true,
GeoLib::IO::GMSH::MeshDensityAlgorithm::AdaptiveMeshDensity,
param2, param3, param1, selectedGeometries);
gmsh_io.setPrecision(std::numeric_limits<double>::digits10);
gmsh_io.writeToFile(fileName.toStdString());
} else { // homogeneous meshing selected
GeoLib::IO::GMSHInterface gmsh_io(
_project.getGEOObjects(), true,
GeoLib::IO::GMSH::MeshDensityAlgorithm::FixedMeshDensity,
param4, param3, param1, selectedGeometries);
gmsh_io.setPrecision(std::numeric_limits<double>::digits10);
gmsh_io.writeToFile(fileName.toStdString());
}
if (system(NULL) != 0) // command processor available
{
QSettings settings;
std::string gmsh_path = settings.value("DataExplorerGmshPath").toString().toStdString();
if (!gmsh_path.empty())
{
std::string fname (fileName.toStdString());
std::string gmsh_command = "\"" + gmsh_path + "\" -2 -algo meshadapt " + fname;
std::size_t pos (fname.rfind ("."));
if (pos != std::string::npos)
fname = fname.substr (0, pos);
gmsh_command += " -o " + fname + ".msh";
system(gmsh_command.c_str());
this->loadFile(ImportFileType::GMSH, fileName.left(fileName.length() - 3).append("msh"));
}
else
OGSError::box("Location of GMSH not specified.", "Error");
}
else
OGSError::box("Error executing command gmsh - no command processor available", "Error");
if (delete_geo_file) // delete file
{
std::string remove_command ("rm ");
#ifdef _WIN32
remove_command = "del ";
#endif
remove_command += fileName.toStdString();
INFO("remove command: %s", remove_command.c_str());
system(remove_command.c_str());
}
}
}
else
INFO("No geometry information selected.");
QApplication::restoreOverrideCursor();
}
void MainWindow::showFileConverter()
{
OGSFileConverter* dlg = new OGSFileConverter(this);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->show();
dlg->raise();
}
void MainWindow::showDiagramPrefsDialog(QModelIndex &index)
{
QString listName;
GeoLib::Station* stn =
_geo_model->getStationModel()->stationFromIndex(index, listName);
if ((stn->type() == GeoLib::Station::StationType::STATION) && stn->getSensorData())
{
DiagramPrefsDialog* prefs ( new DiagramPrefsDialog(stn) );
prefs->setAttribute(Qt::WA_DeleteOnClose);
prefs->show();
}
if (stn->type() == GeoLib::Station::StationType::BOREHOLE)
OGSError::box("No time series data available for borehole.");
}
void MainWindow::showDiagramPrefsDialog()
{
QSettings settings;
QString fileName = QFileDialog::getOpenFileName( this, "Select data file to open",
settings.value("lastOpenedFileDirectory").toString(),
"Text files (*.txt);;All files (* *.*)");
if (!fileName.isEmpty())
{
QDir dir = QDir(fileName);
settings.setValue("lastOpenedFileDirectory", dir.absolutePath());
DiagramPrefsDialog* prefs = new DiagramPrefsDialog(fileName);
prefs->setAttribute(Qt::WA_DeleteOnClose);
prefs->show();
}
}
void MainWindow::showGeoNameDialog(const std::string &geometry_name, const GeoLib::GEOTYPE object_type, std::size_t id)
{
std::string old_name = _project.getGEOObjects().getElementNameByID(geometry_name, object_type, id);
SetNameDialog dlg(GeoLib::convertGeoTypeToString(object_type), id, old_name);
if (dlg.exec() != QDialog::Accepted)
return;
_geo_model->addNameForElement(geometry_name, object_type, id, dlg.getNewName());
static_cast<GeoTreeModel*>(this->geoTabWidget->treeView->model())->setNameForItem(geometry_name, object_type,
id, _project.getGEOObjects().getElementNameByID(geometry_name, object_type, id));
}
void MainWindow::showCreateStructuredGridDialog()
{
CreateStructuredGridDialog dlg;
connect(&dlg, SIGNAL(meshAdded(MeshLib::Mesh*)),
_meshModel.get(), SLOT(addMesh(MeshLib::Mesh*)));
dlg.exec();
}
void MainWindow::showMeshElementRemovalDialog()
{
MeshElementRemovalDialog dlg(this->_project);
connect(&dlg, SIGNAL(meshAdded(MeshLib::Mesh*)),
_meshModel.get(), SLOT(addMesh(MeshLib::Mesh*)));
dlg.exec();
}
void MainWindow::showMeshAnalysisDialog()
{
MeshAnalysisDialog* dlg = new MeshAnalysisDialog(this->_project.getMeshObjects());
dlg->exec();
}
void MainWindow::showLineEditDialog(const std::string &geoName)
{
LineEditDialog lineEdit(
*(_project.getGEOObjects().getPolylineVecObj(geoName)));
connect(&lineEdit, SIGNAL(connectPolylines(const std::string&,
std::vector<std::size_t>, double,
std::string, bool, bool)),
_geo_model.get(), SLOT(connectPolylineSegments(
const std::string&, std::vector<std::size_t>,
double, std::string, bool, bool)));
lineEdit.exec();
}
void MainWindow::showGMSHPrefsDialog()
{
GMSHPrefsDialog dlg(_project.getGEOObjects());
connect(&dlg, SIGNAL(requestMeshing(std::vector<std::string> &, unsigned, double, double, double, bool)),
this, SLOT(callGMSH(std::vector<std::string> &, unsigned, double, double, double, bool)));
dlg.exec();
}
void MainWindow::showMergeGeometriesDialog()
{
MergeGeometriesDialog dlg(_project.getGEOObjects());
if (dlg.exec() != QDialog::Accepted)
return;
std::string name (dlg.getGeometryName());
if (_project.getGEOObjects().mergeGeometries(dlg.getSelectedGeometries(), name) < 0)
OGSError::box("Points are missing for\n at least one geometry.");
}
void MainWindow::showMeshQualitySelectionDialog(MeshLib::VtkMappedMeshSource* mshSource)
{
if (mshSource == nullptr)
return;
MeshQualitySelectionDialog dlg;
if (dlg.exec() != QDialog::Accepted)
return;
MeshLib::MeshQualityType const type (dlg.getSelectedMetric());
MeshLib::ElementQualityInterface quality_interface(*mshSource->GetMesh(), type);
_vtkVisPipeline->showMeshElementQuality(mshSource, type, quality_interface.getQualityVector());
if (dlg.getHistogram())
quality_interface.writeHistogram(dlg.getHistogramPath());
}
void MainWindow::showVisalizationPrefsDialog()
{
_visPrefsDialog->show();
}
void MainWindow::showDataExplorerSettingsDialog()
{
DataExplorerSettingsDialog dlg;
dlg.exec();
}
void MainWindow::FEMTestStart()
{
}
void MainWindow::ShowWindow()
{
this->show();
}
void MainWindow::HideWindow()
{
this->hide();
}
void MainWindow::loadFileOnStartUp(const QString &fileName)
{
QString ext = QFileInfo(fileName).suffix();
if (ext=="msh" || ext=="vtu" || ext=="gli" || ext=="gml") {
this->loadFile(ImportFileType::OGS,fileName);
}
}
void MainWindow::on_actionExportVTK_triggered(bool checked /*= false*/)
{
Q_UNUSED(checked)
QSettings settings;
int count = 0;
QString filename = QFileDialog::getSaveFileName(this,
"Export object to vtk-files",
settings.value("lastExportedFileDirectory").toString(),
"VTK files (*.vtp *.vtu)");
if (!filename.isEmpty())
{
QDir dir = QDir(filename);
settings.setValue("lastExportedFileDirectory", dir.absolutePath());
std::string basename = QFileInfo(filename).path().toStdString();
basename.append("/" + QFileInfo(filename).baseName().toStdString());
TreeModelIterator it(_vtkVisPipeline.get());
++it;
while (*it)
{
count++;
static_cast<VtkVisPipelineItem*> (*it)->writeToFile(basename
+ std::to_string(count));
++it;
}
}
}
void MainWindow::on_actionExportVRML2_triggered(bool checked /*= false*/)
{
Q_UNUSED(checked)
QSettings settings;
QString fileName = QFileDialog::getSaveFileName(this, "Save scene to VRML file",
settings.value("lastExportedFileDirectory").toString(),
"VRML files (*.wrl);;");
if (!fileName.isEmpty())
{
QDir dir = QDir(fileName);
settings.setValue("lastExportedFileDirectory", dir.absolutePath());
vtkVRMLExporter* exporter = vtkVRMLExporter::New();
exporter->SetFileName(fileName.toStdString().c_str());
exporter->SetRenderWindow(
visualizationWidget->vtkWidget->GetRenderWindow());
exporter->Write();
exporter->Delete();
}
}
void MainWindow::on_actionExportObj_triggered(bool checked /*= false*/)
{
Q_UNUSED(checked)
QSettings settings;
QString fileName = QFileDialog::getSaveFileName(this, "Save scene to Wavefront OBJ files",
settings.value("lastExportedFileDirectory").toString(),
";;");
if (!fileName.isEmpty())
{
QDir dir = QDir(fileName);
settings.setValue("lastExportedFileDirectory", dir.absolutePath());
vtkOBJExporter* exporter = vtkOBJExporter::New();
exporter->SetFilePrefix(fileName.toStdString().c_str());
exporter->SetRenderWindow(
visualizationWidget->vtkWidget->GetRenderWindow());
exporter->Write();
exporter->Delete();
}
}
void MainWindow::createPresentationMenu()
{
QMenu* menu = static_cast<QMenu*> (QObject::sender());
menu->clear();
if (!_vtkWidget->parent())
{
QAction* action = new QAction("Quit presentation mode", menu);
connect(action, SIGNAL(triggered()), this, SLOT(quitPresentationMode()));
action->setShortcutContext(Qt::WidgetShortcut);
action->setShortcut(QKeySequence(Qt::Key_Escape));
menu->addAction(action);
}
else
{
int count = 0;
const int currentScreen = QApplication::desktop()->screenNumber(
visualizationWidget);
foreach (QRect screenGeo, _screenGeometries)
{
Q_UNUSED(screenGeo);
QAction* action = new QAction(
QString("On screen %1").arg(count), menu);
connect(action, SIGNAL(triggered()), this,
SLOT(startPresentationMode()));
if (count == currentScreen)
action->setEnabled(false);
menu->addAction(action);
++count;
}
}
}
void MainWindow::startPresentationMode()
{
// Save the QMainWindow state to restore when quitting presentation mode
_windowState = this->saveState();
// Get the screen number from the QAction which sent the signal
QString actionText = static_cast<QAction*> (QObject::sender())->text();
int screen = actionText.split(" ").back().toInt();
// Move the widget to the screen and maximize it
// Real fullscreen hides the menu
_vtkWidget->setParent(NULL, Qt::Window);
_vtkWidget->move(QPoint(_screenGeometries[screen].x(),
_screenGeometries[screen].y()));
//_vtkWidget->showFullScreen();
_vtkWidget->showMaximized();
// Create an action which quits the presentation mode when pressing
// ESCAPE when the the window has focus
QAction* action = new QAction("Quit presentation mode", this);
connect(action, SIGNAL(triggered()), this, SLOT(quitPresentationMode()));
action->setShortcutContext(Qt::WidgetShortcut);
action->setShortcut(QKeySequence(Qt::Key_Escape));
_vtkWidget->addAction(action);
// Hide the central widget to maximize the dock widgets
QMainWindow::centralWidget()->hide();
}
void MainWindow::quitPresentationMode()
{
// Remove the quit action
QAction* action = _vtkWidget->actions().back();
_vtkWidget->removeAction(action);
delete action;
// Add the widget back to visualization widget
visualizationWidget->layout()->addWidget(_vtkWidget.get());
QMainWindow::centralWidget()->show();
// Restore the previously saved QMainWindow state
this->restoreState(_windowState);
}
QString MainWindow::getLastUsedDir()
{
QSettings settings;
QString fileName("");
QStringList files = settings.value("recentFileList").toStringList();
if (files.size() != 0)
return QFileInfo(files[0]).absolutePath();
else
return QDir::homePath();
}
|
; ===============================================================
; Jan 2014
; ===============================================================
;
; unsigned long ftell(FILE *stream)
;
; Return current file position.
;
; ===============================================================
INCLUDE "clib_cfg.asm"
SECTION code_clib
SECTION code_stdio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC asm_ftell
EXTERN asm0_ftell_unlocked, __stdio_lock_release
asm_ftell:
; enter : ix = FILE *
;
; exit : ix = FILE *
;
; success
;
; dehl = current file position
; carry reset
;
; fail
;
; dehl = -1
; carry set
;
; uses : all except ix
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_STDIO & $01
EXTERN __stdio_verify_valid_lock, ftell_immediate_error_ebadf
call __stdio_verify_valid_lock
jp c, ftell_immediate_error_ebadf
ELSE
EXTERN __stdio_lock_acquire, ftell_immediate_error_enolck
call __stdio_lock_acquire
jp c, ftell_immediate_error_enolck
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
call asm0_ftell_unlocked
jp __stdio_lock_release
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC asm_ftell
EXTERN asm_ftell_unlocked
defc asm_ftell = asm_ftell_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
; Copyright © 2018, VideoLAN and dav1d authors
; Copyright © 2018, Two Orioles, LLC
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice, this
; list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%include "config.asm"
%include "ext/x86/x86inc.asm"
%if ARCH_X86_64
%macro JMP_TABLE 2-*
%xdefine %1_jmptable %%table
%xdefine %%base mangle(private_prefix %+ _%1_avx2)
%%table:
%rep %0 - 1
dd %%base %+ .%2 - %%table
%rotate 1
%endrep
%endmacro
%macro CDEF_FILTER_JMP_TABLE 1
JMP_TABLE cdef_filter_%1_8bpc, \
d6k0, d6k1, d7k0, d7k1, \
d0k0, d0k1, d1k0, d1k1, d2k0, d2k1, d3k0, d3k1, \
d4k0, d4k1, d5k0, d5k1, d6k0, d6k1, d7k0, d7k1, \
d0k0, d0k1, d1k0, d1k1
%endmacro
SECTION_RODATA 32
pd_47130256: dd 4, 7, 1, 3, 0, 2, 5, 6
blend_4x4: dd 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00
dd 0x80, 0x00, 0x00
blend_4x8_0: dd 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
blend_4x8_1: dd 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
dd 0x00, 0x00
blend_4x8_2: dd 0x0000, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080
dd 0x0000
blend_4x8_3: dd 0x0000, 0x0000, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080, 0x8080
dd 0x0000, 0x0000
blend_8x8_0: dq 0x00, 0x00, 0x80, 0x80, 0x80, 0x80
blend_8x8_1: dq 0x0000, 0x0000, 0x8080, 0x8080, 0x8080, 0x8080, 0x0000, 0x0000
div_table: dd 840, 420, 280, 210, 168, 140, 120, 105, 420, 210, 140, 105
shufw_6543210x:db 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 0, 1, 14, 15
shufb_lohi: db 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15
pw_128: times 2 dw 128
pw_2048: times 2 dw 2048
tap_table: ; masks for 8 bit shifts
db 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01
; weights
db 4, 2, 3, 3, 2, 1
db -1 * 16 + 1, -2 * 16 + 2
db 0 * 16 + 1, -1 * 16 + 2
db 0 * 16 + 1, 0 * 16 + 2
db 0 * 16 + 1, 1 * 16 + 2
db 1 * 16 + 1, 2 * 16 + 2
db 1 * 16 + 0, 2 * 16 + 1
db 1 * 16 + 0, 2 * 16 + 0
db 1 * 16 + 0, 2 * 16 - 1
; the last 6 are repeats of the first 6 so we don't need to & 7
db -1 * 16 + 1, -2 * 16 + 2
db 0 * 16 + 1, -1 * 16 + 2
db 0 * 16 + 1, 0 * 16 + 2
db 0 * 16 + 1, 1 * 16 + 2
db 1 * 16 + 1, 2 * 16 + 2
db 1 * 16 + 0, 2 * 16 + 1
CDEF_FILTER_JMP_TABLE 4x4
CDEF_FILTER_JMP_TABLE 4x8
CDEF_FILTER_JMP_TABLE 8x8
SECTION .text
%macro PREP_REGS 2 ; w, h
; off1/2/3[k] [6 total] from [tapq+12+(dir+0/2/6)*2+k]
mov dird, r7m
lea tableq, [cdef_filter_%1x%2_8bpc_jmptable]
lea dirq, [tableq+dirq*2*4]
%if %1 == 4
%if %2 == 4
DEFINE_ARGS dst, stride, left, top, bot, pri, sec, \
table, dir, dirjmp, stride3, k
%else
DEFINE_ARGS dst, stride, left, top, bot, pri, sec, \
table, dir, dirjmp, dst4, stride3, k
lea dst4q, [dstq+strideq*4]
%endif
%else
DEFINE_ARGS dst, stride, h, top1, bot, pri, sec, \
table, dir, dirjmp, top2, stride3, k
mov hq, -8
lea top1q, [top1q+strideq*0]
lea top2q, [top1q+strideq*1]
%endif
%if %1 == 4
lea stride3q, [strideq*3]
%endif
%endmacro
%macro LOAD_BLOCK 2-3 0 ; w, h, init_min_max
mov kd, 1
pxor m15, m15 ; sum
%if %2 == 8
pxor m12, m12
%if %1 == 4
movd xm4, [dstq +strideq*0]
movd xm6, [dstq +strideq*1]
movd xm5, [dstq +strideq*2]
movd xm7, [dstq +stride3q ]
vinserti128 m4, [dst4q+strideq*0], 1
vinserti128 m6, [dst4q+strideq*1], 1
vinserti128 m5, [dst4q+strideq*2], 1
vinserti128 m7, [dst4q+stride3q ], 1
punpckldq m4, m6
punpckldq m5, m7
%else
movq xm4, [dstq+strideq*0]
movq xm5, [dstq+strideq*1]
vinserti128 m4, [dstq+strideq*2], 1
vinserti128 m5, [dstq+stride3q ], 1
%endif
punpcklqdq m4, m5
%else
movd xm4, [dstq+strideq*0]
movd xm5, [dstq+strideq*1]
vinserti128 m4, [dstq+strideq*2], 1
vinserti128 m5, [dstq+stride3q ], 1
punpckldq m4, m5
%endif
%if %3 == 1
mova m7, m4 ; min
mova m8, m4 ; max
%endif
%endmacro
%macro ACCUMULATE_TAP_BYTE 7-8 0 ; tap_offset, shift, mask, strength
; mul_tap, w, h, clip
; load p0/p1
movsxd dirjmpq, [dirq+kq*4+%1*2*4]
add dirjmpq, tableq
call dirjmpq
%if %8 == 1
pmaxub m7, m5
pminub m8, m5
pmaxub m7, m6
pminub m8, m6
%endif
; accumulate sum[m15] over p0/p1
%if %7 == 4
punpcklbw m5, m6
punpcklbw m6, m4, m4
psubusb m9, m5, m6
psubusb m5, m6, m5
por m9, m5 ; abs_diff_p01(p01 - px)
pcmpeqb m5, m9
por m5, %5
psignb m6, %5, m5
psrlw m5, m9, %2 ; emulate 8-bit shift
pand m5, %3
psubusb m5, %4, m5
pminub m5, m9
pmaddubsw m5, m6
paddw m15, m5
%else
psubusb m9, m5, m4
psubusb m5, m4, m5
psubusb m11, m6, m4
psubusb m6, m4, m6
por m9, m5 ; abs_diff_p0(p0 - px)
por m11, m6 ; abs_diff_p1(p1 - px)
pcmpeqb m5, m9
pcmpeqb m6, m11
punpckhbw m10, m9, m11
punpcklbw m9, m11
por m5, %5
por m11, m6, %5
punpckhbw m6, m5, m11
punpcklbw m5, m11
psignb m11, %5, m6
psrlw m6, m10, %2 ; emulate 8-bit shift
pand m6, %3
psubusb m6, %4, m6
pminub m6, m10
pmaddubsw m6, m11
paddw m12, m6
psignb m11, %5, m5
psrlw m5, m9, %2 ; emulate 8-bit shift
pand m5, %3
psubusb m5, %4, m5
pminub m5, m9
pmaddubsw m5, m11
paddw m15, m5
%endif
%endmacro
%macro ADJUST_PIXEL 4-5 0 ; w, h, zero, pw_2048, clip
%if %2 == 4
%if %5 == 1
punpcklbw m4, %3
%endif
pcmpgtw %3, m15
paddw m15, %3
pmulhrsw m15, %4
%if %5 == 0
packsswb m15, m15
paddb m4, m15
%else
paddw m4, m15
packuswb m4, m4 ; clip px in [0x0,0xff]
pminub m4, m7
pmaxub m4, m8
%endif
vextracti128 xm5, m4, 1
movd [dstq+strideq*0], xm4
movd [dstq+strideq*2], xm5
pextrd [dstq+strideq*1], xm4, 1
pextrd [dstq+stride3q ], xm5, 1
%else
pcmpgtw m6, %3, m12
pcmpgtw m5, %3, m15
paddw m12, m6
paddw m15, m5
%if %5 == 1
punpckhbw m5, m4, %3
punpcklbw m4, %3
%endif
pmulhrsw m12, %4
pmulhrsw m15, %4
%if %5 == 0
packsswb m15, m12
paddb m4, m15
%else
paddw m5, m12
paddw m4, m15
packuswb m4, m5 ; clip px in [0x0,0xff]
pminub m4, m7
pmaxub m4, m8
%endif
vextracti128 xm5, m4, 1
%if %1 == 4
movd [dstq +strideq*0], xm4
movd [dst4q+strideq*0], xm5
pextrd [dstq +strideq*1], xm4, 1
pextrd [dst4q+strideq*1], xm5, 1
pextrd [dstq +strideq*2], xm4, 2
pextrd [dst4q+strideq*2], xm5, 2
pextrd [dstq +stride3q ], xm4, 3
pextrd [dst4q+stride3q ], xm5, 3
%else
movq [dstq+strideq*0], xm4
movq [dstq+strideq*2], xm5
movhps [dstq+strideq*1], xm4
movhps [dstq+stride3q ], xm5
%endif
%endif
%endmacro
%macro BORDER_PREP_REGS 2 ; w, h
; off1/2/3[k] [6 total] from [tapq+12+(dir+0/2/6)*2+k]
mov dird, r7m
lea dirq, [tableq+dirq*2+14]
%if %1*%2*2/mmsize > 1
%if %1 == 4
DEFINE_ARGS dst, stride, k, dir, stk, pri, sec, stride3, h, off
%else
DEFINE_ARGS dst, stride, k, dir, stk, pri, sec, h, off
%endif
mov hd, %1*%2*2/mmsize
%else
DEFINE_ARGS dst, stride, k, dir, stk, pri, sec, stride3, off
%endif
lea stkq, [px]
pxor m11, m11
%endmacro
%macro BORDER_LOAD_BLOCK 2-3 0 ; w, h, init_min_max
mov kd, 1
%if %1 == 4
movq xm4, [stkq+32*0]
movhps xm4, [stkq+32*1]
movq xm5, [stkq+32*2]
movhps xm5, [stkq+32*3]
vinserti128 m4, xm5, 1
%else
mova xm4, [stkq+32*0] ; px
vinserti128 m4, [stkq+32*1], 1
%endif
pxor m15, m15 ; sum
%if %3 == 1
mova m7, m4 ; max
mova m8, m4 ; min
%endif
%endmacro
%macro ACCUMULATE_TAP_WORD 6-7 0 ; tap_offset, shift, mask, strength
; mul_tap, w, clip
; load p0/p1
movsx offq, byte [dirq+kq+%1] ; off1
%if %6 == 4
movq xm5, [stkq+offq*2+32*0] ; p0
movq xm6, [stkq+offq*2+32*2]
movhps xm5, [stkq+offq*2+32*1]
movhps xm6, [stkq+offq*2+32*3]
vinserti128 m5, xm6, 1
%else
movu xm5, [stkq+offq*2+32*0] ; p0
vinserti128 m5, [stkq+offq*2+32*1], 1
%endif
neg offq ; -off1
%if %6 == 4
movq xm6, [stkq+offq*2+32*0] ; p1
movq xm9, [stkq+offq*2+32*2]
movhps xm6, [stkq+offq*2+32*1]
movhps xm9, [stkq+offq*2+32*3]
vinserti128 m6, xm9, 1
%else
movu xm6, [stkq+offq*2+32*0] ; p1
vinserti128 m6, [stkq+offq*2+32*1], 1
%endif
%if %7 == 1
; out of bounds values are set to a value that is a both a large unsigned
; value and a negative signed value.
; use signed max and unsigned min to remove them
pmaxsw m7, m5 ; max after p0
pminuw m8, m5 ; min after p0
pmaxsw m7, m6 ; max after p1
pminuw m8, m6 ; min after p1
%endif
; accumulate sum[m15] over p0/p1
; calculate difference before converting
psubw m5, m4 ; diff_p0(p0 - px)
psubw m6, m4 ; diff_p1(p1 - px)
; convert to 8-bits with signed saturation
; saturating to large diffs has no impact on the results
packsswb m5, m6
; group into pairs so we can accumulate using maddubsw
pshufb m5, m12
pabsb m9, m5
psignb m10, %5, m5
psrlw m5, m9, %2 ; emulate 8-bit shift
pand m5, %3
psubusb m5, %4, m5
; use unsigned min since abs diff can equal 0x80
pminub m5, m9
pmaddubsw m5, m10
paddw m15, m5
%endmacro
%macro BORDER_ADJUST_PIXEL 2-3 0 ; w, pw_2048, clip
pcmpgtw m9, m11, m15
paddw m15, m9
pmulhrsw m15, %2
paddw m4, m15
%if %3 == 1
pminsw m4, m7
pmaxsw m4, m8
%endif
packuswb m4, m4
vextracti128 xm5, m4, 1
%if %1 == 4
movd [dstq+strideq*0], xm4
pextrd [dstq+strideq*1], xm4, 1
movd [dstq+strideq*2], xm5
pextrd [dstq+stride3q ], xm5, 1
%else
movq [dstq+strideq*0], xm4
movq [dstq+strideq*1], xm5
%endif
%endmacro
%macro CDEF_FILTER 2 ; w, h
INIT_YMM avx2
cglobal cdef_filter_%1x%2_8bpc, 5, 10, 0, dst, stride, left, top, bot, \
pri, sec, dir, damping, edge
%assign stack_offset_entry stack_offset
mov edged, edgem
cmp edged, 0xf
jne .border_block
PUSH r10
PUSH r11
%if %2 == 4
%assign regs_used 12
%if STACK_ALIGNMENT < 32
PUSH r%+regs_used
%assign regs_used regs_used+1
%endif
ALLOC_STACK 0x60, 16
pmovzxbw xm0, [leftq+1]
vpermq m0, m0, q0110
psrldq m1, m0, 4
vpalignr m2, m0, m0, 12
movu [rsp+0x10], m0
movu [rsp+0x28], m1
movu [rsp+0x40], m2
%elif %1 == 4
PUSH r12
%assign regs_used 13
%if STACK_ALIGNMENT < 32
PUSH r%+regs_used
%assign regs_used regs_used+1
%endif
ALLOC_STACK 8*2+%1*%2*1, 16
pmovzxwd m0, [leftq]
mova [rsp+0x10], m0
%else
PUSH r12
PUSH r13
%assign regs_used 14
%if STACK_ALIGNMENT < 32
PUSH r%+regs_used
%assign regs_used regs_used+1
%endif
ALLOC_STACK 8*4+%1*%2*2+32, 16
lea r11, [strideq*3]
movu xm4, [dstq+strideq*2]
pmovzxwq m0, [leftq+0]
pmovzxwq m1, [leftq+8]
vinserti128 m4, [dstq+r11], 1
pmovzxbd m2, [leftq+1]
pmovzxbd m3, [leftq+9]
mov [rsp+16], botq
mova [rsp+0x20], m0
mova [rsp+0x40], m1
mova [rsp+0x60], m2
mova [rsp+0x80], m3
mova [rsp+0xa0], m4
lea botq, [dstq+strideq*4]
%endif
DEFINE_ARGS dst, stride, left, top, bot, pri, secdmp, zero, pridmp, damping
mov dampingd, r8m
xor zerod, zerod
movifnidn prid, prim
sub dampingd, 31
movifnidn secdmpd, secdmpm
test prid, prid
jz .sec_only
movd xm0, prid
lzcnt pridmpd, prid
add pridmpd, dampingd
cmovs pridmpd, zerod
mov [rsp+0], pridmpq ; pri_shift
test secdmpd, secdmpd
jz .pri_only
movd xm1, secdmpd
lzcnt secdmpd, secdmpd
add secdmpd, dampingd
mov [rsp+8], secdmpq ; sec_shift
DEFINE_ARGS dst, stride, left, top, bot, pri, secdmp, table, pridmp
lea tableq, [tap_table]
vpbroadcastb m13, [tableq+pridmpq] ; pri_shift_mask
vpbroadcastb m14, [tableq+secdmpq] ; sec_shift_mask
; pri/sec_taps[k] [4 total]
DEFINE_ARGS dst, stride, left, top, bot, pri, sec, table, dir
vpbroadcastb m0, xm0 ; pri_strength
vpbroadcastb m1, xm1 ; sec_strength
and prid, 1
lea priq, [tableq+priq*2+8] ; pri_taps
lea secq, [tableq+12] ; sec_taps
PREP_REGS %1, %2
%if %1*%2 > mmsize
.v_loop:
%endif
LOAD_BLOCK %1, %2, 1
.k_loop:
vpbroadcastb m2, [priq+kq] ; pri_taps
vpbroadcastb m3, [secq+kq] ; sec_taps
ACCUMULATE_TAP_BYTE 2, [rsp+0], m13, m0, m2, %1, %2, 1 ; dir + 0
ACCUMULATE_TAP_BYTE 4, [rsp+8], m14, m1, m3, %1, %2, 1 ; dir + 2
ACCUMULATE_TAP_BYTE 0, [rsp+8], m14, m1, m3, %1, %2, 1 ; dir - 2
dec kq
jge .k_loop
vpbroadcastd m10, [pw_2048]
pxor m9, m9
ADJUST_PIXEL %1, %2, m9, m10, 1
%if %1*%2 > mmsize
lea dstq, [dstq+strideq*4]
lea top1q, [rsp+0xa0]
lea top2q, [rsp+0xb0]
mov botq, [rsp+16]
add hq, 4
jl .v_loop
%endif
RET
.pri_only:
DEFINE_ARGS dst, stride, left, top, bot, pri, _, table, pridmp
lea tableq, [tap_table]
vpbroadcastb m13, [tableq+pridmpq] ; pri_shift_mask
; pri/sec_taps[k] [4 total]
DEFINE_ARGS dst, stride, left, top, bot, pri, _, table, dir
vpbroadcastb m0, xm0 ; pri_strength
and prid, 1
lea priq, [tableq+priq*2+8] ; pri_taps
PREP_REGS %1, %2
vpbroadcastd m3, [pw_2048]
pxor m1, m1
%if %1*%2 > mmsize
.pri_v_loop:
%endif
LOAD_BLOCK %1, %2
.pri_k_loop:
vpbroadcastb m2, [priq+kq] ; pri_taps
ACCUMULATE_TAP_BYTE 2, [rsp+0], m13, m0, m2, %1, %2 ; dir + 0
dec kq
jge .pri_k_loop
ADJUST_PIXEL %1, %2, m1, m3
%if %1*%2 > mmsize
lea dstq, [dstq+strideq*4]
lea top1q, [rsp+0xa0]
lea top2q, [rsp+0xb0]
mov botq, [rsp+16]
add hq, 4
jl .pri_v_loop
%endif
RET
.sec_only:
DEFINE_ARGS dst, stride, left, top, bot, _, secdmp, zero, _, damping
movd xm1, secdmpd
lzcnt secdmpd, secdmpd
add secdmpd, dampingd
mov [rsp+8], secdmpq ; sec_shift
DEFINE_ARGS dst, stride, left, top, bot, _, secdmp, table
lea tableq, [tap_table]
vpbroadcastb m14, [tableq+secdmpq] ; sec_shift_mask
; pri/sec_taps[k] [4 total]
DEFINE_ARGS dst, stride, left, top, bot, _, sec, table, dir
vpbroadcastb m1, xm1 ; sec_strength
lea secq, [tableq+12] ; sec_taps
PREP_REGS %1, %2
vpbroadcastd m2, [pw_2048]
pxor m0, m0
%if %1*%2 > mmsize
.sec_v_loop:
%endif
LOAD_BLOCK %1, %2
.sec_k_loop:
vpbroadcastb m3, [secq+kq] ; sec_taps
ACCUMULATE_TAP_BYTE 4, [rsp+8], m14, m1, m3, %1, %2 ; dir + 2
ACCUMULATE_TAP_BYTE 0, [rsp+8], m14, m1, m3, %1, %2 ; dir - 2
dec kq
jge .sec_k_loop
ADJUST_PIXEL %1, %2, m0, m2
%if %1*%2 > mmsize
lea dstq, [dstq+strideq*4]
lea top1q, [rsp+0xa0]
lea top2q, [rsp+0xb0]
mov botq, [rsp+16]
add hq, 4
jl .sec_v_loop
%endif
RET
.d0k0:
%if %1 == 4
%if %2 == 4
vpbroadcastq m6, [dstq+strideq*1-1]
vpbroadcastq m10, [dstq+strideq*2-1]
movd xm5, [topq+strideq*1+1]
movd xm9, [dstq+strideq*0+1]
psrldq m11, m6, 2
psrldq m12, m10, 2
vinserti128 m6, [dstq+stride3q -1], 1
vinserti128 m10, [botq -1], 1
vpblendd m5, m11, 0x10
vpblendd m9, m12, 0x10
movu m11, [blend_4x4+16]
punpckldq m6, m10
punpckldq m5, m9
vpblendvb m6, [rsp+gprsize+0x28], m11
%else
movd xm5, [topq +strideq*1+1]
movq xm6, [dstq +strideq*1-1]
movq xm10, [dstq +stride3q -1]
movq xm11, [dst4q+strideq*1-1]
pinsrd xm5, [dstq +strideq*0+1], 1
movhps xm6, [dstq +strideq*2-1]
movhps xm10, [dst4q+strideq*0-1]
movhps xm11, [dst4q+strideq*2-1]
psrldq xm9, xm6, 2
shufps xm5, xm9, q2010 ; -1 +0 +1 +2
shufps xm6, xm10, q2020 ; +1 +2 +3 +4
psrldq xm9, xm11, 2
psrldq xm10, 2
shufps xm10, xm9, q2020 ; +3 +4 +5 +6
movd xm9, [dst4q+stride3q -1]
pinsrd xm9, [botq -1], 1
shufps xm11, xm9, q1020 ; +5 +6 +7 +8
pmovzxbw m9, [leftq+3]
vinserti128 m6, xm11, 1
movu m11, [blend_4x8_0+4]
vinserti128 m5, xm10, 1
vpblendvb m6, m9, m11
%endif
%else
lea r13, [blend_8x8_0+16]
movq xm5, [top2q +1]
vbroadcasti128 m10, [dstq+strideq*1-1]
vbroadcasti128 m11, [dstq+strideq*2-1]
movhps xm5, [dstq+strideq*0+1]
vinserti128 m6, m10, [dstq+stride3q-1], 1
vinserti128 m9, m11, [botq -1], 1
psrldq m10, 2
psrldq m11, 2
punpcklqdq m6, m9
movu m9, [r13+hq*2*1+16*1]
punpcklqdq m10, m11
vpblendd m5, m10, 0xF0
vpblendvb m6, [rsp+gprsize+0x60+hq*8+64+8*1], m9
%endif
ret
.d1k0:
.d2k0:
.d3k0:
%if %1 == 4
%if %2 == 4
movq xm6, [dstq+strideq*0-1]
movq xm9, [dstq+strideq*1-1]
vinserti128 m6, [dstq+strideq*2-1], 1
vinserti128 m9, [dstq+stride3q -1], 1
movu m11, [rsp+gprsize+0x10]
pcmpeqd m12, m12
psrldq m5, m6, 2
psrldq m10, m9, 2
psrld m12, 24
punpckldq m6, m9
punpckldq m5, m10
vpblendvb m6, m11, m12
%else
movq xm6, [dstq +strideq*0-1]
movq xm9, [dstq +strideq*2-1]
movhps xm6, [dstq +strideq*1-1]
movhps xm9, [dstq +stride3q -1]
movq xm10, [dst4q+strideq*0-1]
movhps xm10, [dst4q+strideq*1-1]
psrldq xm5, xm6, 2
psrldq xm11, xm9, 2
shufps xm5, xm11, q2020
movq xm11, [dst4q+strideq*2-1]
movhps xm11, [dst4q+stride3q -1]
shufps xm6, xm9, q2020
shufps xm9, xm10, xm11, q2020
vinserti128 m6, xm9, 1
pmovzxbw m9, [leftq+1]
psrldq xm10, 2
psrldq xm11, 2
shufps xm10, xm11, q2020
vpbroadcastd m11, [blend_4x8_0+4]
vinserti128 m5, xm10, 1
vpblendvb m6, m9, m11
%endif
%else
movu xm5, [dstq+strideq*0-1]
movu xm9, [dstq+strideq*1-1]
vinserti128 m5, [dstq+strideq*2-1], 1
vinserti128 m9, [dstq+stride3q -1], 1
movu m10, [blend_8x8_0+16]
punpcklqdq m6, m5, m9
vpblendvb m6, [rsp+gprsize+0x60+hq*8+64], m10
psrldq m5, 2
psrldq m9, 2
punpcklqdq m5, m9
%endif
ret
.d4k0:
%if %1 == 4
%if %2 == 4
vpbroadcastq m10, [dstq+strideq*1-1]
vpbroadcastq m11, [dstq+strideq*2-1]
movd xm6, [topq+strideq*1-1]
movd xm9, [dstq+strideq*0-1]
psrldq m5, m10, 2
psrldq m12, m11, 2
vpblendd m6, m10, 0x10
vpblendd m9, m11, 0x10
movu m10, [blend_4x4]
vinserti128 m5, [dstq+stride3q +1], 1
vinserti128 m12, [botq +1], 1
punpckldq m6, m9
punpckldq m5, m12
vpblendvb m6, [rsp+gprsize+0x40], m10
%else
movd xm6, [topq +strideq*1-1]
movq xm9, [dstq +strideq*1-1]
movq xm10, [dstq +stride3q -1]
movq xm11, [dst4q+strideq*1-1]
pinsrd xm6, [dstq +strideq*0-1], 1
movhps xm9, [dstq +strideq*2-1]
movhps xm10, [dst4q+strideq*0-1]
movhps xm11, [dst4q+strideq*2-1]
psrldq xm5, xm9, 2
shufps xm6, xm9, q2010
psrldq xm9, xm10, 2
shufps xm5, xm9, q2020
shufps xm10, xm11, q2020
movd xm9, [dst4q+stride3q +1]
vinserti128 m6, xm10, 1
pinsrd xm9, [botq +1], 1
psrldq xm11, 2
pmovzxbw m10, [leftq-1]
shufps xm11, xm9, q1020
movu m9, [blend_4x8_0]
vinserti128 m5, xm11, 1
vpblendvb m6, m10, m9
%endif
%else
lea r13, [blend_8x8_0+8]
movq xm6, [top2q -1]
vbroadcasti128 m5, [dstq+strideq*1-1]
vbroadcasti128 m9, [dstq+strideq*2-1]
movhps xm6, [dstq+strideq*0-1]
movu m11, [r13+hq*2*1+16*1]
punpcklqdq m10, m5, m9
vinserti128 m5, [dstq+stride3q -1], 1
vinserti128 m9, [botq -1], 1
vpblendd m6, m10, 0xF0
vpblendvb m6, [rsp+gprsize+0x60+hq*8+64-8*1], m11
psrldq m5, 2
psrldq m9, 2
punpcklqdq m5, m9
%endif
ret
.d5k0:
.d6k0:
.d7k0:
%if %1 == 4
%if %2 == 4
movd xm6, [topq+strideq*1 ]
vpbroadcastd m5, [dstq+strideq*1 ]
vpbroadcastd m9, [dstq+strideq*2 ]
vpblendd xm6, [dstq+strideq*0-4], 0x2
vpblendd m5, m9, 0x22
vpblendd m6, m5, 0x30
vinserti128 m5, [dstq+stride3q ], 1
vpblendd m5, [botq -20], 0x20
%else
movd xm6, [topq +strideq*1]
movd xm5, [dstq +strideq*1]
movd xm9, [dstq +stride3q ]
movd xm10, [dst4q+strideq*1]
movd xm11, [dst4q+stride3q ]
pinsrd xm6, [dstq +strideq*0], 1
pinsrd xm5, [dstq +strideq*2], 1
pinsrd xm9, [dst4q+strideq*0], 1
pinsrd xm10, [dst4q+strideq*2], 1
pinsrd xm11, [botq ], 1
punpcklqdq xm6, xm5
punpcklqdq xm5, xm9
punpcklqdq xm9, xm10
punpcklqdq xm10, xm11
vinserti128 m6, xm9, 1
vinserti128 m5, xm10, 1
%endif
%else
movq xm6, [top2q ]
movq xm5, [dstq+strideq*1]
movq xm9, [dstq+stride3q ]
movhps xm6, [dstq+strideq*0]
movhps xm5, [dstq+strideq*2]
movhps xm9, [botq ]
vinserti128 m6, xm5, 1
vinserti128 m5, xm9, 1
%endif
ret
.d0k1:
%if %1 == 4
%if %2 == 4
movd xm6, [dstq+strideq*2-2]
movd xm9, [dstq+stride3q -2]
movd xm5, [topq+strideq*0+2]
movd xm10, [topq+strideq*1+2]
pinsrw xm6, [leftq+4], 0
pinsrw xm9, [leftq+6], 0
vinserti128 m5, [dstq+strideq*0+2], 1
vinserti128 m10, [dstq+strideq*1+2], 1
vinserti128 m6, [botq+strideq*0-2], 1
vinserti128 m9, [botq+strideq*1-2], 1
punpckldq m5, m10
punpckldq m6, m9
%else
movq xm6, [dstq +strideq*2-2]
movd xm10, [dst4q+strideq*2-2]
movd xm5, [topq +strideq*0+2]
movq xm9, [dst4q+strideq*0-2]
movhps xm6, [dstq +stride3q -2]
pinsrw xm10, [dst4q+stride3q ], 3
pinsrd xm5, [topq +strideq*1+2], 1
movhps xm9, [dst4q+strideq*1-2]
pinsrd xm10, [botq +strideq*0-2], 2
pinsrd xm5, [dstq +strideq*0+2], 2
pinsrd xm10, [botq +strideq*1-2], 3
pinsrd xm5, [dstq +strideq*1+2], 3
shufps xm11, xm6, xm9, q3131
shufps xm6, xm9, q2020
movu m9, [blend_4x8_3+8]
vinserti128 m6, xm10, 1
vinserti128 m5, xm11, 1
vpblendvb m6, [rsp+gprsize+0x10+8], m9
%endif
%else
lea r13, [blend_8x8_1+16]
movq xm6, [dstq+strideq*2-2]
movq xm9, [dstq+stride3q -2]
movq xm5, [top1q +2]
movq xm10, [top2q +2]
movu m11, [r13+hq*2*2+16*2]
vinserti128 m6, [botq+strideq*0-2], 1
vinserti128 m9, [botq+strideq*1-2], 1
vinserti128 m5, [dstq+strideq*0+2], 1
vinserti128 m10, [dstq+strideq*1+2], 1
punpcklqdq m6, m9
punpcklqdq m5, m10
vpblendvb m6, [rsp+gprsize+0x20+hq*8+64+8*2], m11
%endif
ret
.d1k1:
%if %1 == 4
%if %2 == 4
vpbroadcastq m6, [dstq+strideq*1-2]
vpbroadcastq m9, [dstq+strideq*2-2]
movd xm5, [topq+strideq*1+2]
movd xm10, [dstq+strideq*0+2]
psrldq m11, m6, 4
psrldq m12, m9, 4
vpblendd m5, m11, 0x10
movq xm11, [leftq+2]
vinserti128 m6, [dstq+stride3q-2], 1
punpckldq xm11, xm11
vpblendd m10, m12, 0x10
pcmpeqd m12, m12
pmovzxwd m11, xm11
psrld m12, 16
punpckldq m6, m9
vpbroadcastd m9, [botq-2]
vpblendvb m6, m11, m12
punpckldq m5, m10
vpblendd m6, m9, 0x20
%else
movd xm5, [topq +strideq*1+2]
movq xm6, [dstq +strideq*1-2]
movq xm9, [dstq +stride3q -2]
movq xm10, [dst4q+strideq*1-2]
movd xm11, [dst4q+stride3q -2]
pinsrd xm5, [dstq +strideq*0+2], 1
movhps xm6, [dstq +strideq*2-2]
movhps xm9, [dst4q+strideq*0-2]
movhps xm10, [dst4q+strideq*2-2]
pinsrd xm11, [botq -2], 1
shufps xm5, xm6, q3110
shufps xm6, xm9, q2020
shufps xm9, xm10, q3131
shufps xm10, xm11, q1020
movu m11, [blend_4x8_2+4]
vinserti128 m6, xm10, 1
vinserti128 m5, xm9, 1
vpblendvb m6, [rsp+gprsize+0x10+4], m11
%endif
%else
lea r13, [blend_8x8_1+16]
movq xm5, [top2q +2]
vbroadcasti128 m6, [dstq+strideq*1-2]
vbroadcasti128 m9, [dstq+strideq*2-2]
movhps xm5, [dstq+strideq*0+2]
shufps m10, m6, m9, q2121
vinserti128 m6, [dstq+stride3q -2], 1
vinserti128 m9, [botq -2], 1
movu m11, [r13+hq*2*1+16*1]
vpblendd m5, m10, 0xF0
punpcklqdq m6, m9
vpblendvb m6, [rsp+gprsize+0x20+hq*8+64+8*1], m11
%endif
ret
.d2k1:
%if %1 == 4
%if %2 == 4
movq xm11, [leftq]
movq xm6, [dstq+strideq*0-2]
movq xm9, [dstq+strideq*1-2]
vinserti128 m6, [dstq+strideq*2-2], 1
vinserti128 m9, [dstq+stride3q -2], 1
punpckldq xm11, xm11
psrldq m5, m6, 4
psrldq m10, m9, 4
pmovzxwd m11, xm11
punpckldq m6, m9
punpckldq m5, m10
pblendw m6, m11, 0x05
%else
movq xm5, [dstq +strideq*0-2]
movq xm9, [dstq +strideq*2-2]
movq xm10, [dst4q+strideq*0-2]
movq xm11, [dst4q+strideq*2-2]
movhps xm5, [dstq +strideq*1-2]
movhps xm9, [dstq +stride3q -2]
movhps xm10, [dst4q+strideq*1-2]
movhps xm11, [dst4q+stride3q -2]
shufps xm6, xm5, xm9, q2020
shufps xm5, xm9, q3131
shufps xm9, xm10, xm11, q2020
shufps xm10, xm11, q3131
pmovzxwd m11, [leftq]
vinserti128 m6, xm9, 1
vinserti128 m5, xm10, 1
pblendw m6, m11, 0x55
%endif
%else
mova m11, [rsp+gprsize+0x20+hq*8+64]
movu xm5, [dstq+strideq*0-2]
movu xm9, [dstq+strideq*1-2]
vinserti128 m5, [dstq+strideq*2-2], 1
vinserti128 m9, [dstq+stride3q -2], 1
shufps m6, m5, m9, q1010
shufps m5, m9, q2121
pblendw m6, m11, 0x11
%endif
ret
.d3k1:
%if %1 == 4
%if %2 == 4
vpbroadcastq m11, [dstq+strideq*1-2]
vpbroadcastq m12, [dstq+strideq*2-2]
movd xm6, [topq+strideq*1-2]
movd xm9, [dstq+strideq*0-2]
pblendw m11, [leftq-16+2], 0x01
pblendw m12, [leftq-16+4], 0x01
pinsrw xm9, [leftq- 0+0], 0
psrldq m5, m11, 4
psrldq m10, m12, 4
vinserti128 m5, [dstq+stride3q +2], 1
vinserti128 m10, [botq +2], 1
vpblendd m6, m11, 0x10
vpblendd m9, m12, 0x10
punpckldq m6, m9
punpckldq m5, m10
%else
movd xm6, [topq +strideq*1-2]
movq xm5, [dstq +strideq*1-2]
movq xm9, [dstq +stride3q -2]
movq xm10, [dst4q+strideq*1-2]
movd xm11, [dst4q+stride3q +2]
pinsrw xm6, [dstq +strideq*0 ], 3
movhps xm5, [dstq +strideq*2-2]
movhps xm9, [dst4q+strideq*0-2]
movhps xm10, [dst4q+strideq*2-2]
pinsrd xm11, [botq +2], 1
shufps xm6, xm5, q2010
shufps xm5, xm9, q3131
shufps xm9, xm10, q2020
shufps xm10, xm11, q1031
movu m11, [blend_4x8_2]
vinserti128 m6, xm9, 1
vinserti128 m5, xm10, 1
vpblendvb m6, [rsp+gprsize+0x10-4], m11
%endif
%else
lea r13, [blend_8x8_1+8]
movq xm6, [top2q -2]
vbroadcasti128 m5, [dstq+strideq*1-2]
vbroadcasti128 m10, [dstq+strideq*2-2]
movhps xm6, [dstq+strideq*0-2]
punpcklqdq m9, m5, m10
vinserti128 m5, [dstq+stride3q -2], 1
vinserti128 m10, [botq -2], 1
movu m11, [r13+hq*2*1+16*1]
vpblendd m6, m9, 0xF0
shufps m5, m10, q2121
vpblendvb m6, [rsp+gprsize+0x20+hq*8+64-8*1], m11
%endif
ret
.d4k1:
%if %1 == 4
%if %2 == 4
vinserti128 m6, [dstq+strideq*0-2], 1
vinserti128 m9, [dstq+strideq*1-2], 1
movd xm5, [dstq+strideq*2+2]
movd xm10, [dstq+stride3q +2]
pblendw m6, [leftq-16+0], 0x01
pblendw m9, [leftq-16+2], 0x01
vinserti128 m5, [botq+strideq*0+2], 1
vinserti128 m10, [botq+strideq*1+2], 1
vpblendd m6, [topq+strideq*0-2], 0x01
vpblendd m9, [topq+strideq*1-2], 0x01
punpckldq m5, m10
punpckldq m6, m9
%else
movd xm6, [topq +strideq*0-2]
movq xm5, [dstq +strideq*2-2]
movq xm9, [dst4q+strideq*0-2]
movd xm10, [dst4q+strideq*2+2]
pinsrd xm6, [topq +strideq*1-2], 1
movhps xm5, [dstq +stride3q -2]
movhps xm9, [dst4q+strideq*1-2]
pinsrd xm10, [dst4q+stride3q +2], 1
pinsrd xm6, [dstq +strideq*0-2], 2
pinsrd xm10, [botq +strideq*0+2], 2
pinsrd xm6, [dstq +strideq*1-2], 3
pinsrd xm10, [botq +strideq*1+2], 3
shufps xm11, xm5, xm9, q2020
shufps xm5, xm9, q3131
movu m9, [blend_4x8_3]
vinserti128 m6, xm11, 1
vinserti128 m5, xm10, 1
vpblendvb m6, [rsp+gprsize+0x10-8], m9
%endif
%else
lea r13, [blend_8x8_1]
movu m11, [r13+hq*2*2+16*2]
movq xm6, [top1q -2]
movq xm9, [top2q -2]
movq xm5, [dstq+strideq*2+2]
movq xm10, [dstq+stride3q +2]
vinserti128 m6, [dstq+strideq*0-2], 1
vinserti128 m9, [dstq+strideq*1-2], 1
vinserti128 m5, [botq+strideq*0+2], 1
vinserti128 m10, [botq+strideq*1+2], 1
punpcklqdq m6, m9
vpblendvb m6, [rsp+gprsize+0x20+hq*8+64-8*2], m11
punpcklqdq m5, m10
%endif
ret
.d5k1:
%if %1 == 4
%if %2 == 4
movd xm6, [topq+strideq*0-1]
movd xm9, [topq+strideq*1-1]
movd xm5, [dstq+strideq*2+1]
movd xm10, [dstq+stride3q +1]
pcmpeqd m12, m12
pmovzxbw m11, [leftq-8+1]
psrld m12, 24
vinserti128 m6, [dstq+strideq*0-1], 1
vinserti128 m9, [dstq+strideq*1-1], 1
vinserti128 m5, [botq+strideq*0+1], 1
vinserti128 m10, [botq+strideq*1+1], 1
punpckldq m6, m9
pxor m9, m9
vpblendd m12, m9, 0x0F
punpckldq m5, m10
vpblendvb m6, m11, m12
%else
movd xm6, [topq +strideq*0-1]
movq xm5, [dstq +strideq*2-1]
movq xm9, [dst4q+strideq*0-1]
movd xm10, [dst4q+strideq*2+1]
pinsrd xm6, [topq +strideq*1-1], 1
movhps xm5, [dstq +stride3q -1]
movhps xm9, [dst4q+strideq*1-1]
pinsrd xm10, [dst4q+stride3q +1], 1
pinsrd xm6, [dstq +strideq*0-1], 2
pinsrd xm10, [botq +strideq*0+1], 2
pinsrd xm6, [dstq +strideq*1-1], 3
pinsrd xm10, [botq +strideq*1+1], 3
shufps xm11, xm5, xm9, q2020
vinserti128 m6, xm11, 1
pmovzxbw m11, [leftq-3]
psrldq xm5, 2
psrldq xm9, 2
shufps xm5, xm9, q2020
movu m9, [blend_4x8_1]
vinserti128 m5, xm10, 1
vpblendvb m6, m11, m9
%endif
%else
lea r13, [blend_8x8_0]
movu m11, [r13+hq*2*2+16*2]
movq xm6, [top1q -1]
movq xm9, [top2q -1]
movq xm5, [dstq+strideq*2+1]
movq xm10, [dstq+stride3q +1]
vinserti128 m6, [dstq+strideq*0-1], 1
vinserti128 m9, [dstq+strideq*1-1], 1
vinserti128 m5, [botq+strideq*0+1], 1
vinserti128 m10, [botq+strideq*1+1], 1
punpcklqdq m6, m9
punpcklqdq m5, m10
vpblendvb m6, [rsp+gprsize+0x60+hq*8+64-8*2], m11
%endif
ret
.d6k1:
%if %1 == 4
%if %2 == 4
movd xm6, [topq+strideq*0]
movd xm9, [topq+strideq*1]
movd xm5, [dstq+strideq*2]
movd xm10, [dstq+stride3q ]
vinserti128 m6, [dstq+strideq*0], 1
vinserti128 m9, [dstq+strideq*1], 1
vinserti128 m5, [botq+strideq*0], 1
vinserti128 m10, [botq+strideq*1], 1
punpckldq m6, m9
punpckldq m5, m10
%else
movd xm5, [dstq +strideq*2]
movd xm6, [topq +strideq*0]
movd xm9, [dst4q+strideq*2]
pinsrd xm5, [dstq +stride3q ], 1
pinsrd xm6, [topq +strideq*1], 1
pinsrd xm9, [dst4q+stride3q ], 1
pinsrd xm5, [dst4q+strideq*0], 2
pinsrd xm6, [dstq +strideq*0], 2
pinsrd xm9, [botq +strideq*0], 2
pinsrd xm5, [dst4q+strideq*1], 3
pinsrd xm6, [dstq +strideq*1], 3
pinsrd xm9, [botq +strideq*1], 3
vinserti128 m6, xm5, 1
vinserti128 m5, xm9, 1
%endif
%else
movq xm5, [dstq+strideq*2]
movq xm9, [botq+strideq*0]
movq xm6, [top1q ]
movq xm10, [dstq+strideq*0]
movhps xm5, [dstq+stride3q ]
movhps xm9, [botq+strideq*1]
movhps xm6, [top2q ]
movhps xm10, [dstq+strideq*1]
vinserti128 m5, xm9, 1
vinserti128 m6, xm10, 1
%endif
ret
.d7k1:
%if %1 == 4
%if %2 == 4
movd xm5, [dstq+strideq*2-1]
movd xm9, [dstq+stride3q -1]
movd xm6, [topq+strideq*0+1]
movd xm10, [topq+strideq*1+1]
pinsrb xm5, [leftq+ 5], 0
pinsrb xm9, [leftq+ 7], 0
vinserti128 m6, [dstq+strideq*0+1], 1
vinserti128 m10, [dstq+strideq*1+1], 1
vinserti128 m5, [botq+strideq*0-1], 1
vinserti128 m9, [botq+strideq*1-1], 1
punpckldq m6, m10
punpckldq m5, m9
%else
movd xm6, [topq +strideq*0+1]
movq xm9, [dstq +strideq*2-1]
movq xm10, [dst4q+strideq*0-1]
movd xm11, [dst4q+strideq*2-1]
pinsrd xm6, [topq +strideq*1+1], 1
movhps xm9, [dstq +stride3q -1]
movhps xm10, [dst4q+strideq*1-1]
pinsrd xm11, [dst4q+stride3q -1], 1
pinsrd xm6, [dstq +strideq*0+1], 2
pinsrd xm11, [botq +strideq*0-1], 2
pinsrd xm6, [dstq +strideq*1+1], 3
pinsrd xm11, [botq +strideq*1-1], 3
shufps xm5, xm9, xm10, q2020
vinserti128 m5, xm11, 1
pmovzxbw m11, [leftq+5]
psrldq xm9, 2
psrldq xm10, 2
shufps xm9, xm10, q2020
movu m10, [blend_4x8_1+8]
vinserti128 m6, xm9, 1
vpblendvb m5, m11, m10
%endif
%else
lea r13, [blend_8x8_0+16]
movq xm5, [dstq+strideq*2-1]
movq xm9, [botq+strideq*0-1]
movq xm6, [top1q +1]
movq xm10, [dstq+strideq*0+1]
movhps xm5, [dstq+stride3q -1]
movhps xm9, [botq+strideq*1-1]
movhps xm6, [top2q +1]
movhps xm10, [dstq+strideq*1+1]
movu m11, [r13+hq*2*2+16*2]
vinserti128 m5, xm9, 1
vinserti128 m6, xm10, 1
vpblendvb m5, [rsp+gprsize+0x60+hq*8+64+8*2], m11
%endif
ret
.border_block:
DEFINE_ARGS dst, stride, left, top, bot, pri, sec, stride3, dst4, edge
%define rstk rsp
%assign stack_offset stack_offset_entry
%assign regs_used 10
%if STACK_ALIGNMENT < 32
PUSH r%+regs_used
%assign regs_used regs_used+1
%endif
ALLOC_STACK 2*16+(%2+4)*32, 16
%define px rsp+2*16+2*32
pcmpeqw m14, m14
psllw m14, 15 ; 0x8000
; prepare pixel buffers - body/right
%if %1 == 4
INIT_XMM avx2
%endif
%if %2 == 8
lea dst4q, [dstq+strideq*4]
%endif
lea stride3q, [strideq*3]
test edgeb, 2 ; have_right
jz .no_right
pmovzxbw m1, [dstq+strideq*0]
pmovzxbw m2, [dstq+strideq*1]
pmovzxbw m3, [dstq+strideq*2]
pmovzxbw m4, [dstq+stride3q]
mova [px+0*32], m1
mova [px+1*32], m2
mova [px+2*32], m3
mova [px+3*32], m4
%if %2 == 8
pmovzxbw m1, [dst4q+strideq*0]
pmovzxbw m2, [dst4q+strideq*1]
pmovzxbw m3, [dst4q+strideq*2]
pmovzxbw m4, [dst4q+stride3q]
mova [px+4*32], m1
mova [px+5*32], m2
mova [px+6*32], m3
mova [px+7*32], m4
%endif
jmp .body_done
.no_right:
%if %1 == 4
movd xm1, [dstq+strideq*0]
movd xm2, [dstq+strideq*1]
movd xm3, [dstq+strideq*2]
movd xm4, [dstq+stride3q]
pmovzxbw xm1, xm1
pmovzxbw xm2, xm2
pmovzxbw xm3, xm3
pmovzxbw xm4, xm4
movq [px+0*32], xm1
movq [px+1*32], xm2
movq [px+2*32], xm3
movq [px+3*32], xm4
%else
pmovzxbw xm1, [dstq+strideq*0]
pmovzxbw xm2, [dstq+strideq*1]
pmovzxbw xm3, [dstq+strideq*2]
pmovzxbw xm4, [dstq+stride3q]
mova [px+0*32], xm1
mova [px+1*32], xm2
mova [px+2*32], xm3
mova [px+3*32], xm4
%endif
movd [px+0*32+%1*2], xm14
movd [px+1*32+%1*2], xm14
movd [px+2*32+%1*2], xm14
movd [px+3*32+%1*2], xm14
%if %2 == 8
%if %1 == 4
movd xm1, [dst4q+strideq*0]
movd xm2, [dst4q+strideq*1]
movd xm3, [dst4q+strideq*2]
movd xm4, [dst4q+stride3q]
pmovzxbw xm1, xm1
pmovzxbw xm2, xm2
pmovzxbw xm3, xm3
pmovzxbw xm4, xm4
movq [px+4*32], xm1
movq [px+5*32], xm2
movq [px+6*32], xm3
movq [px+7*32], xm4
%else
pmovzxbw xm1, [dst4q+strideq*0]
pmovzxbw xm2, [dst4q+strideq*1]
pmovzxbw xm3, [dst4q+strideq*2]
pmovzxbw xm4, [dst4q+stride3q]
mova [px+4*32], xm1
mova [px+5*32], xm2
mova [px+6*32], xm3
mova [px+7*32], xm4
%endif
movd [px+4*32+%1*2], xm14
movd [px+5*32+%1*2], xm14
movd [px+6*32+%1*2], xm14
movd [px+7*32+%1*2], xm14
%endif
.body_done:
; top
test edgeb, 4 ; have_top
jz .no_top
test edgeb, 1 ; have_left
jz .top_no_left
test edgeb, 2 ; have_right
jz .top_no_right
pmovzxbw m1, [topq+strideq*0-(%1/2)]
pmovzxbw m2, [topq+strideq*1-(%1/2)]
movu [px-2*32-%1], m1
movu [px-1*32-%1], m2
jmp .top_done
.top_no_right:
pmovzxbw m1, [topq+strideq*0-%1]
pmovzxbw m2, [topq+strideq*1-%1]
movu [px-2*32-%1*2], m1
movu [px-1*32-%1*2], m2
movd [px-2*32+%1*2], xm14
movd [px-1*32+%1*2], xm14
jmp .top_done
.top_no_left:
test edgeb, 2 ; have_right
jz .top_no_left_right
pmovzxbw m1, [topq+strideq*0]
pmovzxbw m2, [topq+strideq*1]
mova [px-2*32+0], m1
mova [px-1*32+0], m2
movd [px-2*32-4], xm14
movd [px-1*32-4], xm14
jmp .top_done
.top_no_left_right:
%if %1 == 4
movd xm1, [topq+strideq*0]
pinsrd xm1, [topq+strideq*1], 1
pmovzxbw xm1, xm1
movq [px-2*32+0], xm1
movhps [px-1*32+0], xm1
%else
pmovzxbw xm1, [topq+strideq*0]
pmovzxbw xm2, [topq+strideq*1]
mova [px-2*32+0], xm1
mova [px-1*32+0], xm2
%endif
movd [px-2*32-4], xm14
movd [px-1*32-4], xm14
movd [px-2*32+%1*2], xm14
movd [px-1*32+%1*2], xm14
jmp .top_done
.no_top:
movu [px-2*32-%1], m14
movu [px-1*32-%1], m14
.top_done:
; left
test edgeb, 1 ; have_left
jz .no_left
pmovzxbw xm1, [leftq+ 0]
%if %2 == 8
pmovzxbw xm2, [leftq+ 8]
%endif
movd [px+0*32-4], xm1
pextrd [px+1*32-4], xm1, 1
pextrd [px+2*32-4], xm1, 2
pextrd [px+3*32-4], xm1, 3
%if %2 == 8
movd [px+4*32-4], xm2
pextrd [px+5*32-4], xm2, 1
pextrd [px+6*32-4], xm2, 2
pextrd [px+7*32-4], xm2, 3
%endif
jmp .left_done
.no_left:
movd [px+0*32-4], xm14
movd [px+1*32-4], xm14
movd [px+2*32-4], xm14
movd [px+3*32-4], xm14
%if %2 == 8
movd [px+4*32-4], xm14
movd [px+5*32-4], xm14
movd [px+6*32-4], xm14
movd [px+7*32-4], xm14
%endif
.left_done:
; bottom
DEFINE_ARGS dst, stride, _, _, bot, pri, sec, stride3, _, edge
test edgeb, 8 ; have_bottom
jz .no_bottom
test edgeb, 1 ; have_left
jz .bottom_no_left
test edgeb, 2 ; have_right
jz .bottom_no_right
pmovzxbw m1, [botq+strideq*0-(%1/2)]
pmovzxbw m2, [botq+strideq*1-(%1/2)]
movu [px+(%2+0)*32-%1], m1
movu [px+(%2+1)*32-%1], m2
jmp .bottom_done
.bottom_no_right:
pmovzxbw m1, [botq+strideq*0-%1]
pmovzxbw m2, [botq+strideq*1-%1]
movu [px+(%2+0)*32-%1*2], m1
movu [px+(%2+1)*32-%1*2], m2
%if %1 == 8
movd [px+(%2-1)*32+%1*2], xm14 ; overwritten by previous movu
%endif
movd [px+(%2+0)*32+%1*2], xm14
movd [px+(%2+1)*32+%1*2], xm14
jmp .bottom_done
.bottom_no_left:
test edgeb, 2 ; have_right
jz .bottom_no_left_right
pmovzxbw m1, [botq+strideq*0]
pmovzxbw m2, [botq+strideq*1]
mova [px+(%2+0)*32+0], m1
mova [px+(%2+1)*32+0], m2
movd [px+(%2+0)*32-4], xm14
movd [px+(%2+1)*32-4], xm14
jmp .bottom_done
.bottom_no_left_right:
%if %1 == 4
movd xm1, [botq+strideq*0]
pinsrd xm1, [botq+strideq*1], 1
pmovzxbw xm1, xm1
movq [px+(%2+0)*32+0], xm1
movhps [px+(%2+1)*32+0], xm1
%else
pmovzxbw xm1, [botq+strideq*0]
pmovzxbw xm2, [botq+strideq*1]
mova [px+(%2+0)*32+0], xm1
mova [px+(%2+1)*32+0], xm2
%endif
movd [px+(%2+0)*32-4], xm14
movd [px+(%2+1)*32-4], xm14
movd [px+(%2+0)*32+%1*2], xm14
movd [px+(%2+1)*32+%1*2], xm14
jmp .bottom_done
.no_bottom:
movu [px+(%2+0)*32-%1], m14
movu [px+(%2+1)*32-%1], m14
.bottom_done:
; actual filter
INIT_YMM avx2
DEFINE_ARGS dst, stride, _, pridmp, damping, pri, secdmp, stride3, zero
%undef edged
; register to shuffle values into after packing
vbroadcasti128 m12, [shufb_lohi]
mov dampingd, r8m
xor zerod, zerod
movifnidn prid, prim
sub dampingd, 31
movifnidn secdmpd, secdmpm
test prid, prid
jz .border_sec_only
movd xm0, prid
lzcnt pridmpd, prid
add pridmpd, dampingd
cmovs pridmpd, zerod
mov [rsp+0], pridmpq ; pri_shift
test secdmpd, secdmpd
jz .border_pri_only
movd xm1, secdmpd
lzcnt secdmpd, secdmpd
add secdmpd, dampingd
mov [rsp+8], secdmpq ; sec_shift
DEFINE_ARGS dst, stride, _, pridmp, table, pri, secdmp, stride3
lea tableq, [tap_table]
vpbroadcastb m13, [tableq+pridmpq] ; pri_shift_mask
vpbroadcastb m14, [tableq+secdmpq] ; sec_shift_mask
; pri/sec_taps[k] [4 total]
DEFINE_ARGS dst, stride, _, dir, table, pri, sec, stride3
vpbroadcastb m0, xm0 ; pri_strength
vpbroadcastb m1, xm1 ; sec_strength
and prid, 1
lea priq, [tableq+priq*2+8] ; pri_taps
lea secq, [tableq+12] ; sec_taps
BORDER_PREP_REGS %1, %2
%if %1*%2*2/mmsize > 1
.border_v_loop:
%endif
BORDER_LOAD_BLOCK %1, %2, 1
.border_k_loop:
vpbroadcastb m2, [priq+kq] ; pri_taps
vpbroadcastb m3, [secq+kq] ; sec_taps
ACCUMULATE_TAP_WORD 0*2, [rsp+0], m13, m0, m2, %1, 1
ACCUMULATE_TAP_WORD 2*2, [rsp+8], m14, m1, m3, %1, 1
ACCUMULATE_TAP_WORD 6*2, [rsp+8], m14, m1, m3, %1, 1
dec kq
jge .border_k_loop
vpbroadcastd m10, [pw_2048]
BORDER_ADJUST_PIXEL %1, m10, 1
%if %1*%2*2/mmsize > 1
%define vloop_lines (mmsize/(%1*2))
lea dstq, [dstq+strideq*vloop_lines]
add stkq, 32*vloop_lines
dec hd
jg .border_v_loop
%endif
RET
.border_pri_only:
DEFINE_ARGS dst, stride, _, pridmp, table, pri, _, stride3
lea tableq, [tap_table]
vpbroadcastb m13, [tableq+pridmpq] ; pri_shift_mask
DEFINE_ARGS dst, stride, _, dir, table, pri, _, stride3
vpbroadcastb m0, xm0 ; pri_strength
and prid, 1
lea priq, [tableq+priq*2+8] ; pri_taps
BORDER_PREP_REGS %1, %2
vpbroadcastd m1, [pw_2048]
%if %1*%2*2/mmsize > 1
.border_pri_v_loop:
%endif
BORDER_LOAD_BLOCK %1, %2
.border_pri_k_loop:
vpbroadcastb m2, [priq+kq] ; pri_taps
ACCUMULATE_TAP_WORD 0*2, [rsp+0], m13, m0, m2, %1
dec kq
jge .border_pri_k_loop
BORDER_ADJUST_PIXEL %1, m1
%if %1*%2*2/mmsize > 1
%define vloop_lines (mmsize/(%1*2))
lea dstq, [dstq+strideq*vloop_lines]
add stkq, 32*vloop_lines
dec hd
jg .border_pri_v_loop
%endif
RET
.border_sec_only:
DEFINE_ARGS dst, stride, _, _, damping, _, secdmp, stride3
movd xm1, secdmpd
lzcnt secdmpd, secdmpd
add secdmpd, dampingd
mov [rsp+8], secdmpq ; sec_shift
DEFINE_ARGS dst, stride, _, _, table, _, secdmp, stride3
lea tableq, [tap_table]
vpbroadcastb m14, [tableq+secdmpq] ; sec_shift_mask
DEFINE_ARGS dst, stride, _, dir, table, _, sec, stride3
vpbroadcastb m1, xm1 ; sec_strength
lea secq, [tableq+12] ; sec_taps
BORDER_PREP_REGS %1, %2
vpbroadcastd m0, [pw_2048]
%if %1*%2*2/mmsize > 1
.border_sec_v_loop:
%endif
BORDER_LOAD_BLOCK %1, %2
.border_sec_k_loop:
vpbroadcastb m3, [secq+kq] ; sec_taps
ACCUMULATE_TAP_WORD 2*2, [rsp+8], m14, m1, m3, %1
ACCUMULATE_TAP_WORD 6*2, [rsp+8], m14, m1, m3, %1
dec kq
jge .border_sec_k_loop
BORDER_ADJUST_PIXEL %1, m0
%if %1*%2*2/mmsize > 1
%define vloop_lines (mmsize/(%1*2))
lea dstq, [dstq+strideq*vloop_lines]
add stkq, 32*vloop_lines
dec hd
jg .border_sec_v_loop
%endif
RET
%endmacro
CDEF_FILTER 8, 8
CDEF_FILTER 4, 8
CDEF_FILTER 4, 4
INIT_YMM avx2
cglobal cdef_dir_8bpc, 3, 4, 6, src, stride, var, stride3
lea stride3q, [strideq*3]
movq xm0, [srcq+strideq*0]
movq xm1, [srcq+strideq*1]
movq xm2, [srcq+strideq*2]
movq xm3, [srcq+stride3q ]
lea srcq, [srcq+strideq*4]
vpbroadcastq m4, [srcq+stride3q ]
vpbroadcastq m5, [srcq+strideq*2]
vpblendd m0, m4, 0xf0
vpblendd m1, m5, 0xf0
vpbroadcastq m4, [srcq+strideq*1]
vpbroadcastq m5, [srcq+strideq*0]
vpblendd m2, m4, 0xf0
vpblendd m3, m5, 0xf0
pxor m4, m4
punpcklbw m0, m4
punpcklbw m1, m4
punpcklbw m2, m4
punpcklbw m3, m4
cglobal_label .main
vpbroadcastd m4, [pw_128]
PROLOGUE 3, 4, 15
psubw m0, m4
psubw m1, m4
psubw m2, m4
psubw m3, m4
; shuffle registers to generate partial_sum_diag[0-1] together
vperm2i128 m7, m0, m0, 0x01
vperm2i128 m6, m1, m1, 0x01
vperm2i128 m5, m2, m2, 0x01
vperm2i128 m4, m3, m3, 0x01
; start with partial_sum_hv[0-1]
paddw m8, m0, m1
paddw m9, m2, m3
phaddw m10, m0, m1
phaddw m11, m2, m3
paddw m8, m9
phaddw m10, m11
vextracti128 xm9, m8, 1
vextracti128 xm11, m10, 1
paddw xm8, xm9 ; partial_sum_hv[1]
phaddw xm10, xm11 ; partial_sum_hv[0]
vinserti128 m8, xm10, 1
vpbroadcastd m9, [div_table+44]
pmaddwd m8, m8
pmulld m8, m9 ; cost6[2a-d] | cost2[a-d]
; create aggregates [lower half]:
; m9 = m0:01234567+m1:x0123456+m2:xx012345+m3:xxx01234+
; m4:xxxx0123+m5:xxxxx012+m6:xxxxxx01+m7:xxxxxxx0
; m10= m1:7xxxxxxx+m2:67xxxxxx+m3:567xxxxx+
; m4:4567xxxx+m5:34567xxx+m6:234567xx+m7:1234567x
; and [upper half]:
; m9 = m0:xxxxxxx0+m1:xxxxxx01+m2:xxxxx012+m3:xxxx0123+
; m4:xxx01234+m5:xx012345+m6:x0123456+m7:01234567
; m10= m0:1234567x+m1:234567xx+m2:34567xxx+m3:4567xxxx+
; m4:567xxxxx+m5:67xxxxxx+m6:7xxxxxxx
; and then shuffle m11 [shufw_6543210x], unpcklwd, pmaddwd, pmulld, paddd
pslldq m9, m1, 2
psrldq m10, m1, 14
pslldq m11, m2, 4
psrldq m12, m2, 12
pslldq m13, m3, 6
psrldq m14, m3, 10
paddw m9, m11
paddw m10, m12
paddw m9, m13
paddw m10, m14
pslldq m11, m4, 8
psrldq m12, m4, 8
pslldq m13, m5, 10
psrldq m14, m5, 6
paddw m9, m11
paddw m10, m12
paddw m9, m13
paddw m10, m14
pslldq m11, m6, 12
psrldq m12, m6, 4
pslldq m13, m7, 14
psrldq m14, m7, 2
paddw m9, m11
paddw m10, m12
paddw m9, m13
paddw m10, m14 ; partial_sum_diag[0/1][8-14,zero]
vbroadcasti128 m14, [shufw_6543210x]
vbroadcasti128 m13, [div_table+16]
vbroadcasti128 m12, [div_table+0]
paddw m9, m0 ; partial_sum_diag[0/1][0-7]
pshufb m10, m14
punpckhwd m11, m9, m10
punpcklwd m9, m10
pmaddwd m11, m11
pmaddwd m9, m9
pmulld m11, m13
pmulld m9, m12
paddd m9, m11 ; cost0[a-d] | cost4[a-d]
; merge horizontally and vertically for partial_sum_alt[0-3]
paddw m10, m0, m1
paddw m11, m2, m3
paddw m12, m4, m5
paddw m13, m6, m7
phaddw m0, m4
phaddw m1, m5
phaddw m2, m6
phaddw m3, m7
; create aggregates [lower half]:
; m4 = m10:01234567+m11:x0123456+m12:xx012345+m13:xxx01234
; m11= m11:7xxxxxxx+m12:67xxxxxx+m13:567xxxxx
; and [upper half]:
; m4 = m10:xxx01234+m11:xx012345+m12:x0123456+m13:01234567
; m11= m10:567xxxxx+m11:67xxxxxx+m12:7xxxxxxx
; and then pshuflw m11 3012, unpcklwd, pmaddwd, pmulld, paddd
pslldq m4, m11, 2
psrldq m11, 14
pslldq m5, m12, 4
psrldq m12, 12
pslldq m6, m13, 6
psrldq m13, 10
paddw m4, m10
paddw m11, m12
vpbroadcastd m12, [div_table+44]
paddw m5, m6
paddw m11, m13 ; partial_sum_alt[3/2] right
vbroadcasti128 m13, [div_table+32]
paddw m4, m5 ; partial_sum_alt[3/2] left
pshuflw m5, m11, q3012
punpckhwd m6, m11, m4
punpcklwd m4, m5
pmaddwd m6, m6
pmaddwd m4, m4
pmulld m6, m12
pmulld m4, m13
paddd m4, m6 ; cost7[a-d] | cost5[a-d]
; create aggregates [lower half]:
; m5 = m0:01234567+m1:x0123456+m2:xx012345+m3:xxx01234
; m1 = m1:7xxxxxxx+m2:67xxxxxx+m3:567xxxxx
; and [upper half]:
; m5 = m0:xxx01234+m1:xx012345+m2:x0123456+m3:01234567
; m1 = m0:567xxxxx+m1:67xxxxxx+m2:7xxxxxxx
; and then pshuflw m1 3012, unpcklwd, pmaddwd, pmulld, paddd
pslldq m5, m1, 2
psrldq m1, 14
pslldq m6, m2, 4
psrldq m2, 12
pslldq m7, m3, 6
psrldq m3, 10
paddw m5, m0
paddw m1, m2
paddw m6, m7
paddw m1, m3 ; partial_sum_alt[0/1] right
paddw m5, m6 ; partial_sum_alt[0/1] left
pshuflw m0, m1, q3012
punpckhwd m1, m5
punpcklwd m5, m0
pmaddwd m1, m1
pmaddwd m5, m5
pmulld m1, m12
pmulld m5, m13
paddd m5, m1 ; cost1[a-d] | cost3[a-d]
mova xm0, [pd_47130256+ 16]
mova m1, [pd_47130256]
phaddd m9, m8
phaddd m5, m4
phaddd m9, m5
vpermd m0, m9 ; cost[0-3]
vpermd m1, m9 ; cost[4-7] | cost[0-3]
; now find the best cost
pmaxsd xm2, xm0, xm1
pshufd xm3, xm2, q1032
pmaxsd xm2, xm3
pshufd xm3, xm2, q2301
pmaxsd xm2, xm3 ; best cost
; find the idx using minpos
; make everything other than the best cost negative via subtraction
; find the min of unsigned 16-bit ints to sort out the negative values
psubd xm4, xm1, xm2
psubd xm3, xm0, xm2
packssdw xm3, xm4
phminposuw xm3, xm3
; convert idx to 32-bits
psrld xm3, 16
movd eax, xm3
; get idx^4 complement
vpermd m3, m1
psubd xm2, xm3
psrld xm2, 10
movd [varq], xm2
RET
%endif ; ARCH_X86_64
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r14
push %r15
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x113fb, %rax
nop
nop
nop
cmp $14492, %r15
mov (%rax), %r14
nop
nop
nop
nop
nop
xor %rbx, %rbx
lea addresses_D_ht+0x667b, %rax
nop
nop
and $8283, %r15
mov $0x6162636465666768, %r10
movq %r10, %xmm5
vmovups %ymm5, (%rax)
nop
nop
nop
nop
nop
and $12992, %rbx
lea addresses_WC_ht+0xbc3b, %r10
nop
xor %rsi, %rsi
mov $0x6162636465666768, %rax
movq %rax, %xmm4
and $0xffffffffffffffc0, %r10
vmovntdq %ymm4, (%r10)
nop
nop
nop
sub %rax, %rax
lea addresses_normal_ht+0x174bb, %rsi
nop
nop
nop
nop
and $14925, %rbp
vmovups (%rsi), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $0, %xmm7, %rax
nop
nop
sub $54265, %rsi
lea addresses_A_ht+0x1c5c9, %r10
nop
nop
nop
cmp %rax, %rax
movb (%r10), %r15b
nop
nop
cmp %rsi, %rsi
lea addresses_D_ht+0x1c67b, %rsi
nop
nop
sub $39117, %rbp
mov $0x6162636465666768, %r14
movq %r14, %xmm0
vmovups %ymm0, (%rsi)
sub %rbp, %rbp
lea addresses_UC_ht+0x14e25, %rsi
lea addresses_WC_ht+0x12637, %rdi
nop
nop
nop
add $55250, %r10
mov $73, %rcx
rep movsw
nop
nop
cmp $50816, %rbp
lea addresses_UC_ht+0x567b, %rcx
clflush (%rcx)
sub %r10, %r10
mov $0x6162636465666768, %r15
movq %r15, %xmm5
vmovups %ymm5, (%rcx)
nop
nop
nop
nop
nop
add %rcx, %rcx
lea addresses_D_ht+0x1067b, %rsi
lea addresses_normal_ht+0xd97b, %rdi
and %r15, %r15
mov $93, %rcx
rep movsq
nop
nop
nop
xor %r15, %r15
lea addresses_WT_ht+0x19efb, %rbx
dec %rcx
movups (%rbx), %xmm7
vpextrq $1, %xmm7, %rdi
lfence
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r15
pop %r14
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %rax
push %rbp
push %rcx
push %rdx
push %rsi
// Store
lea addresses_D+0xe67b, %r15
nop
inc %rax
mov $0x5152535455565758, %r12
movq %r12, %xmm5
vmovups %ymm5, (%r15)
nop
nop
nop
nop
and %rsi, %rsi
// Store
lea addresses_A+0xb22b, %rbp
nop
add $45953, %rcx
movl $0x51525354, (%rbp)
nop
nop
nop
nop
nop
cmp $1573, %r15
// Faulty Load
lea addresses_D+0xe67b, %r12
clflush (%r12)
nop
nop
add %rcx, %rcx
mov (%r12), %si
lea oracles, %r15
and $0xff, %rsi
shlq $12, %rsi
mov (%r15,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rcx
pop %rbp
pop %rax
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 4}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_D', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': True, 'type': 'addresses_WC_ht', 'same': True, 'AVXalign': False, 'congruent': 4}}
{'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 1}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 1}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 11}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 11}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 7}}
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
extern m7_ippsRSA_SetPrivateKeyType1:function
extern n8_ippsRSA_SetPrivateKeyType1:function
extern y8_ippsRSA_SetPrivateKeyType1:function
extern e9_ippsRSA_SetPrivateKeyType1:function
extern l9_ippsRSA_SetPrivateKeyType1:function
extern n0_ippsRSA_SetPrivateKeyType1:function
extern k0_ippsRSA_SetPrivateKeyType1:function
extern ippcpJumpIndexForMergedLibs
extern ippcpSafeInit:function
segment .data
align 8
dq .Lin_ippsRSA_SetPrivateKeyType1
.Larraddr_ippsRSA_SetPrivateKeyType1:
dq m7_ippsRSA_SetPrivateKeyType1
dq n8_ippsRSA_SetPrivateKeyType1
dq y8_ippsRSA_SetPrivateKeyType1
dq e9_ippsRSA_SetPrivateKeyType1
dq l9_ippsRSA_SetPrivateKeyType1
dq n0_ippsRSA_SetPrivateKeyType1
dq k0_ippsRSA_SetPrivateKeyType1
segment .text
global ippsRSA_SetPrivateKeyType1:function (ippsRSA_SetPrivateKeyType1.LEndippsRSA_SetPrivateKeyType1 - ippsRSA_SetPrivateKeyType1)
.Lin_ippsRSA_SetPrivateKeyType1:
db 0xf3, 0x0f, 0x1e, 0xfa
call ippcpSafeInit wrt ..plt
align 16
ippsRSA_SetPrivateKeyType1:
db 0xf3, 0x0f, 0x1e, 0xfa
mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc]
movsxd rax, dword [rax]
lea r11, [rel .Larraddr_ippsRSA_SetPrivateKeyType1]
mov r11, qword [r11+rax*8]
jmp r11
.LEndippsRSA_SetPrivateKeyType1:
|
Title Irvine32 Link Library Source Code (Irvine32.asm)
Comment @
To view this file with proper indentation, set your
editor's tab stops to columns 5, 11, 35, and 40.
Recent Updates:
05/02/09: Str_trim
12/11/2011: StrLength
This library was created exlusively for use with the book,
"Assembly Language for Intel-Based Computers", 4th, 5th, and 6th Editions,
by Kip R. Irvine, 2002-2010.
Copyright 2002-2012, Prentice-Hall Publishing. No part of this file may be
reproduced, in any form or by any other means, without permission in writing
from the author or publisher.
Acknowledgements:
------------------------------
Most of the code in this library was written by Kip Irvine.
Special thanks to Gerald Cahill for his many insights, suggestions, and bug fixes.
Thanks to Richard Stam for his development of Readkey-related procedures.
Thanks to James Brink for helping to test the library.
Alphabetical Listing of Public Procedures
----------------------------------
(Unless otherwise marked, all procedures are documented in Chapter 5.)
CloseFile
Clrscr
CreateOutputFile
Crlf
Delay
DumpMem
DumpRegs
GetCommandTail
GetDateTime Chapter 11
GetMaxXY
GetMseconds
GetTextColor
Gotoxy
IsDigit
MsgBox
MsgBoxAsk
OpenInputFile
ParseDecimal32
ParseInteger32
Random32
Randomize
RandomRange
ReadChar
ReadDec
ReadFromFile
ReadHex
ReadInt
ReadKey
ReadKeyFlush
ReadString
SetTextColor
Str_compare Chapter 9
Str_copy Chapter 9
Str_length Chapter 9
Str_trim Chapter 9
Str_ucase Chapter 9
WaitMsg
WriteBin
WriteBinB
WriteChar
WriteDec
WriteHex
WriteHexB
WriteInt
WriteStackFrame Chapter 8 (James Brink)
WriteStackFrameName Chapter 8 (James Brink)
WriteString
WriteToFile
WriteWindowsMsg
Implementation Notes:
--------------------
1. The Windows Sleep function modifies the contents of ECX.
2. Remember to save and restore all 32-bit general purpose
registers (except EAX) before calling MS-Windows API functions.
---------------------------------------------------------------------@
;OPTION CASEMAP:NONE ; optional: force case-sensitivity
INCLUDE Irvine32.inc ; function prototypes for this library
INCLUDE Macros.inc ; macro definitions
;*************************************************************
;* MACROS *
;*************************************************************
;---------------------------------------------------------------------
ShowFlag MACRO flagName,shiftCount
LOCAL flagStr, flagVal, L1
;
; Helper macro.
; Display a single CPU flag value
; Directly accesses the eflags variable in Irvine16.asm/Irvine32.asm
; (This macro cannot be placed in Macros.inc)
;---------------------------------------------------------------------
.data
flagStr DB " &flagName="
flagVal DB ?,0
.code
push eax
push edx
mov eax,eflags ; retrieve the flags
mov flagVal,'1'
shr eax,shiftCount ; shift into carry flag
jc L1
mov flagVal,'0'
L1:
mov edx,OFFSET flagStr ; display flag name and value
call WriteString
pop edx
pop eax
ENDM
;-------------------------------------------------------------
CheckInit MACRO
;
; Helper macro
; Check to see if the console handles have been initialized
; If not, initialize them now.
;-------------------------------------------------------------
LOCAL exit
cmp InitFlag,0
jne exit
call Initialize
exit:
ENDM
;*************************************************************
;* SHARED DATA *
;*************************************************************
MAX_DIGITS = 80
.data ; initialized data
InitFlag DB 0 ; initialization flag
xtable BYTE "0123456789ABCDEF"
.data? ; uninitialized data
consoleInHandle DWORD ? ; handle to console input device
consoleOutHandle DWORD ? ; handle to standard output device
bytesWritten DWORD ? ; number of bytes written
eflags DWORD ?
digitBuffer BYTE MAX_DIGITS DUP(?),?
buffer DB 512 DUP(?)
bufferMax = ($ - buffer)
bytesRead DD ?
sysTime SYSTEMTIME <> ; system time structure
;*************************************************************
;* PUBLIC PROCEDURES *
;*************************************************************
.code
;--------------------------------------------------------
CloseFile PROC
;
; Closes a file using its handle as an identifier.
; Receives: EAX = file handle
; Returns: EAX = nonzero if the file is successfully
; closed.
; Last update: 6/8/2005
;--------------------------------------------------------
INVOKE CloseHandle, eax
ret
CloseFile ENDP
;-------------------------------------------------------------
Clrscr PROC
LOCAL bufInfo:CONSOLE_SCREEN_BUFFER_INFO
;
; Clear the screen by writing blanks to all positions
; Receives: nothing
; Returns: nothing
; Last update: 10/15/02
;
; The original version of this procedure incorrectly assumed the
; console window dimensions were 80 X 25 (the default MS-DOS screen).
; This new version writes both blanks and attribute values to each
; buffer position. Restriction: Only the first 512 columns of each
; line are cleared. The name capitalization was changed to "Clrscr".
;-------------------------------------------------------------
MAX_COLS = 512
.data
blanks BYTE MAX_COLS DUP(' ') ; one screen line
attribs WORD MAX_COLS DUP(0)
lineLength DWORD 0
cursorLoc COORD <0,0>
count DWORD ?
.code
pushad
CheckInit
; Get the console buffer size and attributes
INVOKE GetConsoleScreenBufferInfo, consoleOutHandle, ADDR bufInfo
mov ax,bufInfo.dwSize.X;
mov WORD PTR lineLength,ax
.IF lineLength > MAX_COLS
mov lineLength,MAX_COLS
.ENDIF
; Fill the attribs array
mov ax,bufInfo.wAttributes
mov ecx,lineLength
mov edi,OFFSET attribs
rep stosw
movzx ecx,bufInfo.dwSize.Y ; loop counter: number of lines
L1: push ecx
; Write a blank line to the screen buffer
INVOKE WriteConsoleOutputCharacter,
consoleOutHandle,
ADDR blanks, ; pointer to buffer
lineLength, ; number of blanks to write
cursorLoc, ; first cell coordinates
ADDR count ; output count
; Fill all buffer positions with the current attribute
INVOKE WriteConsoleOutputAttribute,
consoleOutHandle,
ADDR attribs, ; point to attribute array
lineLength, ; number of attributes to write
cursorLoc, ; first cell coordinates
ADDR count ; output count
add cursorLoc.Y, 1 ; point to the next buffer line
pop ecx
Loop L1
; Move cursor to 0,0
mov cursorLoc.Y,0
INVOKE SetConsoleCursorPosition, consoleOutHandle, cursorLoc
popad
ret
Clrscr ENDP
;------------------------------------------------------
CreateOutputFile PROC
;
; Creates a new file and opens it in output mode.
; Receives: EDX points to the filename.
; Returns: If the file was created successfully, EAX
; contains a valid file handle. Otherwise, EAX
; equals INVALID_HANDLE_VALUE.
;------------------------------------------------------
INVOKE CreateFile,
edx, GENERIC_WRITE, DO_NOT_SHARE, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
ret
CreateOutputFile ENDP
;-----------------------------------------------------
Crlf PROC
;
; Writes a carriage return / linefeed
; sequence (0Dh,0Ah) to standard output.
;-----------------------------------------------------
CheckInit
mWrite <0dh,0ah> ; invoke a macro
ret
Crlf ENDP
;------------------------------------------------------
Delay PROC
;
; THIS FUNCTION IS NOT IN THE IRVINE16 LIBRARY
; Delay (pause) the current process for a given number
; of milliseconds.
; Receives: EAX = number of milliseconds
; Returns: nothing
; Last update: 7/11/01
;------------------------------------------------------
pushad
INVOKE Sleep,eax
popad
ret
Delay ENDP
;---------------------------------------------------
DumpMem PROC
LOCAL unitsize:dword, byteCount:word
;
; Writes a range of memory to standard output
; in hexadecimal.
; Receives: ESI = starting offset, ECX = number of units,
; EBX = unit size (1=byte, 2=word, or 4=doubleword)
; Returns: nothing
; Last update: 7/11/01
;---------------------------------------------------
.data
oneSpace DB ' ',0
dumpPrompt DB 13,10,"Dump of offset ",0
dashLine DB "-------------------------------",13,10,0
.code
pushad
mov edx,OFFSET dumpPrompt
call WriteString
mov eax,esi ; get memory offset to dump
call WriteHex
call Crlf
mov edx,OFFSET dashLine
call WriteString
mov byteCount,0
mov unitsize,ebx
cmp ebx,4 ; select output size
je L1
cmp ebx,2
je L2
jmp L3
; 32-bit doubleword output
L1:
mov eax,[esi]
call WriteHex
mWriteSpace 2
add esi,ebx
Loop L1
jmp L4
; 16-bit word output
L2:
mov ax,[esi] ; get a word from memory
ror ax,8 ; display high byte
call HexByte
ror ax,8 ; display low byte
call HexByte
mWriteSpace 1 ; display 1 space
add esi,unitsize ; point to next word
Loop L2
jmp L4
; 8-bit byte output, 16 bytes per line
L3:
mov al,[esi]
call HexByte
inc byteCount
mWriteSpace 1
inc esi
; if( byteCount mod 16 == 0 ) call Crlf
mov dx,0
mov ax,byteCount
mov bx,16
div bx
cmp dx,0
jne L3B
call Crlf
L3B:
Loop L3
jmp L4
L4:
call Crlf
popad
ret
DumpMem ENDP
;---------------------------------------------------
DumpRegs PROC
;
; Displays EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP in
; hexadecimal. Also displays the Zero, Sign, Carry, and
; Overflow flags.
; Receives: nothing.
; Returns: nothing.
; Last update: 6/22/2005
;
; Warning: do not create any local variables or stack
; parameters, because they will alter the EBP register.
;---------------------------------------------------
.data
saveIP DWORD ?
saveESP DWORD ?
.code
pop saveIP ; get current EIP
mov saveESP,esp ; save ESP's value at entry
push saveIP ; replace it on stack
push eax ; save EAX (restore on exit)
pushfd ; push extended flags
pushfd ; push flags again, and
pop eflags ; save them in a variable
call Crlf
mShowRegister EAX,EAX
mShowRegister EBX,EBX
mShowRegister ECX,ECX
mShowRegister EDX,EDX
call Crlf
mShowRegister ESI,ESI
mShowRegister EDI,EDI
mShowRegister EBP,EBP
mov eax,saveESP
mShowRegister ESP,EAX
call Crlf
mov eax,saveIP
mShowRegister EIP,EAX
mov eax,eflags
mShowRegister EFL,EAX
; Show the flags (using the eflags variable). The integer parameter indicates
; how many times EFLAGS must be shifted right to shift the selected flag
; into the Carry flag.
ShowFlag CF,1
ShowFlag SF,8
ShowFlag ZF,7
ShowFlag OF,12
ShowFlag AF,5
ShowFlag PF,3
call Crlf
call Crlf
popfd
pop eax
ret
DumpRegs ENDP
;-------------------------------------------------------------
GetCommandTail PROC
;
; Copies the tail of the program command line into a buffer
; (after stripping off the first argument - the program's name)
; Receives: EDX points to a 129-byte buffer that will receive
; the data.
; Returns: Carry Flag = 1 if no command tail, otherwise CF=0
;
; Calls the WIN API function GetCommandLine, and scan_for_quote,
; a private helper procedure. Each argument in the command line tail
; is followed by a space except for the last argument which is
; followed only by null.
;
; Implementation notes:
;
; Running in a console window:
; When the command line is blank, GetCommandLine under Windows 95/98
; returns the program name followed by a space and a null. Windows 2000/XP
; returns the program name followed by only null (the space is omitted).
;
; Running from an IDE such as TextPad or JCreator:
; When the command line is blank, GetCommandLine returns the program
; name followed by a space and a null for all versions of Windows.
;
; Contributed by Gerald Cahill, 9/26/2002
; Modified by Kip Irvine, 6/13/2005.
;-------------------------------------------------------------
QUOTE_MARK = 22h
pushad
INVOKE GetCommandLine ; returns pointer in EAX
; Initialize first byte of user's buffer to null, in case the
; buffer already contains text.
mov BYTE PTR [edx],0
; Copy the command-line string to the array. Read past the program's
; EXE filename (may include the path). This code will not work correctly
; if the path contains an embedded space.
mov esi,eax
L0: mov al,[esi] ; strip off first argument
inc esi
.IF al == QUOTE_MARK ; quotation mark found?
call scan_for_quote ; scan until next quote mark
jmp LB ; and get the rest of the line
.ENDIF
cmp al,' ' ; look for blank
je LB ; found it
cmp al,1 ; look for null
jc L2 ; found it (set CF=1)
jmp L0 ; not found yet
; Check if the rest of the tail is empty.
LB: cmp BYTE PTR [esi],1 ; first byte in tail < 1?
jc L2 ; the tail is empty (CF=1)
; Copy all bytes from the command tail to the buffer.
L1: mov al,[esi] ; get byte from cmd tail
mov [edx],al ; copy to buffer
inc esi
inc edx
cmp al,0 ; null byte found?
jne L1 ; no, loop
clc ; CF=0 means a tail was found
L2: popad
ret
GetCommandTail ENDP
;------------------------------------------------------------
scan_for_quote PROC PRIVATE
;
; Helper procedure that looks for a closing quotation mark. This
; procedure lets us handle path names with embedded spaces.
; Called by: GetCommandTail
;
; Receives: ESI points to the current position in the command tail.
; Returns: ESI points one position beyond the quotation mark.
;------------------------------------------------------------
L0: mov al,[esi] ; get a byte
inc esi ; point beyond it
cmp al,QUOTE_MARK ; quotation mark found?
jne L0 ; not found yet
ret
scan_for_quote ENDP
;--------------------------------------------------
GetDateTime PROC,
pDateTime:PTR QWORD
LOCAL flTime:FILETIME
;
; Gets the current local date and time, storing it as a
; 64-bit integer (Win32 FILETIME format) in memory at
; the address specified by the input parameter.
; Receives: pointer to a QWORD variable (inout parameter)
; Returns: nothing
; Updated 10/20/2002
;--------------------------------------------------
pushad
; Get the system local time.
INVOKE GetLocalTime,
ADDR sysTime
; Convert the SYSTEMTIME to FILETIME.
INVOKE SystemTimeToFileTime,
ADDR sysTime,
ADDR flTime
; Copy the FILETIME to a Quadword.
mov esi,pDateTime
mov eax,flTime.loDateTime
mov DWORD PTR [esi],eax
mov eax,flTime.hiDateTime
mov DWORD PTR [esi+4],eax
popad
ret
GetDateTime ENDP
;----------------------------------------------------------------
GetMaxXY PROC
LOCAL bufInfo:CONSOLE_SCREEN_BUFFER_INFO
;
; Returns the current columns (X) and rows (Y) of the console
; window buffer. These values can change while a program is running
; if the user modifies the properties of the application window.
; Receives: nothing
; Returns: AX = rows (Y); DX = columns (X)
;
;----------------------------------------------------------------
CheckInit
; Get the console buffer size and attributes
pushad
INVOKE GetConsoleScreenBufferInfo, consoleOutHandle, ADDR bufInfo
popad
mov dx,bufInfo.dwSize.X
mov ax,bufInfo.dwSize.Y
ret
GetMaxXY ENDP
;----------------------------------------------------------------
GetMseconds PROC USES ebx edx
LOCAL hours:DWORD, min:DWORD, sec:DWORD
;
Comment !
Returns the number of milliseconds that have elapsed past midnight.
Receives: nothing; Returns: milliseconds
Implementation Notes:
Calculation: ((hours * 3600) + (minutes * 60) + seconds)) * 1000 + milliseconds
Under Win NT/ 2000/ XT, the resolution is 10ms. Under Win 98/ ME/ or any
DOS-based version, the resolution is 55ms (average).
Last update: 1/30/03
-----------------------------------------------------------------!
pushad
INVOKE GetLocalTime,OFFSET sysTime
; convert hours to seconds
popad
movzx eax,sysTime.wHour
mov ebx,3600
mul ebx
mov hours,eax
; convert minutes to seconds
movzx eax,sysTime.wMinute
mov ebx,60
mul ebx
mov min,eax
; add seconds to total seconds
movzx eax,sysTime.wSecond
mov sec,eax
; multiply seconds by 1000
mov eax,hours
add eax,min
add eax,sec
mov ebx,1000
mul ebx
; add milliseconds to total
movzx ebx,sysTime.wMilliseconds
add eax,ebx
ret
GetMseconds ENDP
;--------------------------------------------------
GetTextColor PROC
LOCAL bufInfo:CONSOLE_SCREEN_BUFFER_INFO
;
;
; Get the console window's color attributes.
; Receives: nothing
; Returns: AH = background color, AL = foreground
; color
;--------------------------------------------------
pushad
CheckInit
; Get the console buffer size and attributes
INVOKE GetConsoleScreenBufferInfo, consoleOutHandle, ADDR bufInfo
popad
mov ax,bufInfo.wAttributes
ret
GetTextColor ENDP
;--------------------------------------------------
Gotoxy PROC
;
; Locate the cursor
; Receives: DH = screen row, DL = screen column
; Last update: 7/11/01
;--------------------------------------------------------
.data
_cursorPosition COORD <>
.code
pushad
CheckInit ; was console initialized?
movzx ax,dl
mov _cursorPosition.X, ax
movzx ax,dh
mov _cursorPosition.Y, ax
INVOKE SetConsoleCursorPosition, consoleOutHandle, _cursorPosition
popad
ret
Gotoxy ENDP
;----------------------------------------------------
Initialize PROC private
;
; Get the standard console handles for input and output,
; and set a flag indicating that it has been done.
; Updated 03/17/2003
;----------------------------------------------------
pushad
INVOKE GetStdHandle, STD_INPUT_HANDLE
mov [consoleInHandle],eax
INVOKE GetStdHandle, STD_OUTPUT_HANDLE
mov [consoleOutHandle],eax
mov InitFlag,1
popad
ret
Initialize ENDP
;-----------------------------------------------
IsDigit PROC
;
; Determines whether the character in AL is a
; valid decimal digit.
; Receives: AL = character
; Returns: ZF=1 if AL contains a valid decimal
; digit; otherwise, ZF=0.
;-----------------------------------------------
cmp al,'0'
jb ID1
cmp al,'9'
ja ID1
test ax,0 ; set ZF = 1
ID1: ret
IsDigit ENDP
;-----------------------------------------------
MsgBox PROC
;
; Displays a popup message box.
; Receives: EDX = offset of message, EBX =
; offset of caption (or 0 if no caption)
; Returns: nothing
;-----------------------------------------------
.data
@zx02abc_def_caption BYTE " ",0
.code
pushad
.IF ebx == 0
mov ebx,OFFSET @zx02abc_def_caption
.ENDIF
INVOKE MessageBox, 0, edx, ebx, 0
popad
ret
MsgBox ENDP
;--------------------------------------------------
MsgBoxAsk PROC uses ebx ecx edx esi edi
;
; Displays a message box with a question icon and
; Yes/No buttons.
; Receives: EDX = offset of message. For a blank
; caption, set EBX to NULL; otherwise, EBX = offset
; of the caption string.
; Returns: EAX equals IDYES (6) or IDNO (7).
;--------------------------------------------------
.data
@zq02abc_def_caption BYTE " ",0
.code
.IF ebx == NULL
mov ebx,OFFSET @zq02abc_def_caption
.ENDIF
INVOKE MessageBox, NULL, edx, ebx,
MB_YESNO + MB_ICONQUESTION
ret
MsgBoxAsk ENDP
;------------------------------------------------------
OpenInputFile PROC
;
; Opens an existing file for input.
; Receives: EDX points to the filename.
; Returns: If the file was opened successfully, EAX
; contains a valid file handle. Otherwise, EAX equals
; INVALID_HANDLE_VALUE.
; Last update: 6/8/2005
;------------------------------------------------------
INVOKE CreateFile,
edx, GENERIC_READ, DO_NOT_SHARE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0
ret
OpenInputFile ENDP
;--------------------------------------------------------
ParseDecimal32 PROC USES ebx ecx edx esi
LOCAL saveDigit:DWORD
;
; Converts (parses) a string containing an unsigned decimal
; integer, and converts it to binary. All valid digits occurring
; before a non-numeric character are converted.
; Leading spaces are ignored.
; Receives: EDX = offset of string, ECX = length
; Returns:
; If the integer is blank, EAX=0 and CF=1
; If the integer contains only spaces, EAX=0 and CF=1
; If the integer is larger than 2^32-1, EAX=0 and CF=1
; Otherwise, EAX=converted integer, and CF=0
;
; Created 7/15/05 (from the old ReadDec procedure)
;--------------------------------------------------------
mov esi,edx ; save offset in ESI
cmp ecx,0 ; length greater than zero?
jne L1 ; yes: continue
mov eax,0 ; no: set return value
jmp L5 ; and exit with CF=1
; Skip over leading spaces, tabs
L1: mov al,[esi] ; get a character from buffer
cmp al,' ' ; space character found?
je L1A ; yes: skip it
cmp al,TAB ; TAB found?
je L1A ; yes: skip it
jmp L2 ; no: goto next step
L1A:
inc esi ; yes: point to next char
loop L1 ; continue searching until end of string
jmp L5 ; exit with CF=1 if all spaces
; Replaced code (7/19/05)---------------------------------------------
;L1:mov al,[esi] ; get a character from buffer
; cmp al,' ' ; space character found?
; jne L2 ; no: goto next step
; inc esi ; yes: point to next char
; loop L1 ; all spaces?
; jmp L5 ; yes: exit with CF=1
;---------------------------------------------------------------------
; Start to convert the number.
L2: mov eax,0 ; clear accumulator
mov ebx,10 ; EBX is the divisor
; Repeat loop for each digit.
L3: mov dl,[esi] ; get character from buffer
cmp dl,'0' ; character < '0'?
jb L4
cmp dl,'9' ; character > '9'?
ja L4
and edx,0Fh ; no: convert to binary
mov saveDigit,edx
mul ebx ; EDX:EAX = EAX * EBX
jc L5 ; quit if Carry (EDX > 0)
mov edx,saveDigit
add eax,edx ; add new digit to sum
jc L5 ; quit if Carry generated
inc esi ; point to next digit
jmp L3 ; get next digit
L4: clc ; succesful completion (CF=0)
jmp L6
L5: mov eax,0 ; clear result to zero
stc ; signal an error (CF=1)
L6: ret
ParseDecimal32 ENDP
;--------------------------------------------------------
ParseInteger32 PROC USES ebx ecx edx esi
LOCAL Lsign:SDWORD, saveDigit:DWORD
;
; Converts a string containing a signed decimal integer to
; binary.
;
; All valid digits occurring before a non-numeric character
; are converted. Leading spaces are ignored, and an optional
; leading + or - sign is permitted. If the string is blank,
; a value of zero is returned.
;
; Receives: EDX = string offset, ECX = string length
; Returns: If OF=0, the integer is valid, and EAX = binary value.
; If OF=1, the integer is invalid and EAX = 0.
;
; Created 7/15/05, using Gerald Cahill's 10/10/03 corrections.
; Updated 7/19/05, to skip over tabs
; Comments updated 11/20/09
;--------------------------------------------------------
.data
overflow_msgL BYTE " <32-bit integer overflow>",0
invalid_msgL BYTE " <invalid integer>",0
.code
mov Lsign,1 ; assume number is positive
mov esi,edx ; save offset in SI
cmp ecx,0 ; length greater than zero?
jne L1 ; yes: continue
mov eax,0 ; no: set return value
jmp L10 ; and exit
; Skip over leading spaces and tabs.
L1: mov al,[esi] ; get a character from buffer
cmp al,' ' ; space character found?
je L1A ; yes: skip it
cmp al,TAB ; TAB found?
je L1A ; yes: skip it
jmp L2 ; no: goto next step
L1A:
inc esi ; yes: point to next char
loop L1 ; continue searching until end of string
mov eax,0 ; all spaces?
jmp L10 ; return 0 as a valid value
;-- Replaced code (7/19/05)---------------------------------------
;L1: mov al,[esi] ; get a character from buffer
; cmp al,' ' ; space character found?
; jne L2 ; no: check for a sign
; inc esi ; yes: point to next char
; loop L1
; mov eax,0 ; all spaces?
; jmp L10 ; return zero as valid value
;------------------------------------------------------------------
; Check for a leading sign.
L2: cmp al,'-' ; minus sign found?
jne L3 ; no: look for plus sign
mov Lsign,-1 ; yes: sign is negative
dec ecx ; subtract from counter
inc esi ; point to next char
jmp L3A
L3: cmp al,'+' ; plus sign found?
jne L3A ; no: skip
inc esi ; yes: move past the sign
dec ecx ; subtract from digit counter
; Test the first digit, and exit if nonnumeric.
L3A: mov al,[esi] ; get first character
call IsDigit ; is it a digit?
jnz L7A ; no: show error message
; Start to convert the number.
L4: mov eax,0 ; clear accumulator
mov ebx,10 ; EBX is the divisor
; Repeat loop for each digit.
L5: mov dl,[esi] ; get character from buffer
cmp dl,'0' ; character < '0'?
jb L9
cmp dl,'9' ; character > '9'?
ja L9
and edx,0Fh ; no: convert to binary
mov saveDigit,edx
imul ebx ; EDX:EAX = EAX * EBX
mov edx,saveDigit
jo L6 ; quit if overflow
add eax,edx ; add new digit to AX
jo L6 ; quit if overflow
inc esi ; point to next digit
jmp L5 ; get next digit
; Overflow has occured, unlesss EAX = 80000000h
; and the sign is negative:
L6: cmp eax,80000000h
jne L7
cmp Lsign,-1
jne L7 ; overflow occurred
jmp L9 ; the integer is valid
; Choose "integer overflow" messsage.
L7: mov edx,OFFSET overflow_msgL
jmp L8
; Choose "invalid integer" message.
L7A:
mov edx,OFFSET invalid_msgL
; Display the error message pointed to by EDX, and set the Overflow flag.
L8: call WriteString
call Crlf
mov al,127
add al,1 ; set Overflow flag
mov eax,0 ; set return value to zero
jmp L10 ; and exit
; IMUL leaves the Sign flag in an undeterminate state, so the OR instruction
; determines the sign of the iteger in EAX.
L9: imul Lsign ; EAX = EAX * sign
or eax,eax ; determine the number's Sign
L10:ret
ParseInteger32 ENDP
;--------------------------------------------------------------
Random32 PROC
;
; Generates an unsigned pseudo-random 32-bit integer
; in the range 0 - FFFFFFFFh.
; Receives: nothing
; Returns: EAX = random integer
; Last update: 7/11/01
;--------------------------------------------------------------
.data
seed DWORD 1
.code
push edx
mov eax, 343FDh
imul seed
add eax, 269EC3h
mov seed, eax ; save the seed for the next call
ror eax,8 ; rotate out the lowest digit (10/22/00)
pop edx
ret
Random32 ENDP
;--------------------------------------------------------------
RandomRange PROC
;
; Returns an unsigned pseudo-random 32-bit integer
; in EAX, between 0 and n-1. Input parameter:
; EAX = n.
; Last update: 09/06/2002
;--------------------------------------------------------------
push ebx
push edx
mov ebx,eax ; maximum value
call Random32 ; eax = random number
mov edx,0
div ebx ; divide by max value
mov eax,edx ; return the remainder
pop edx
pop ebx
ret
RandomRange ENDP
;--------------------------------------------------------
Randomize PROC
;
; Re-seeds the random number generator with the current time
; in seconds. Calls GetSystemTime, which is accurate to 10ms.
; Receives: nothing
; Returns: nothing
; Last update: 09/06/2002
;--------------------------------------------------------
pushad
INVOKE GetSystemTime,OFFSET sysTime
movzx eax,sysTime.wMilliseconds
mov seed,eax
popad
ret
Randomize ENDP
;------------------------------------------------------------
ReadChar PROC USES ebx edx
;
; Reads one character from the keyboard. The character is
; not echoed on the screen. Waits for the character if none is
; currently in the input buffer.
; Returns: AL = ASCII code, AH = scan code
; Last update: 7/6/05
;----------------------------------------------------------
L1: mov eax,10 ; give Windows 10ms to process messages
call Delay
call ReadKey ; look for key in buffer
jz L1 ; no key in buffer if ZF=1
ret
ReadChar ENDP
;--------------------------------------------------------
ReadDec PROC USES ecx edx
;
; Reads a 32-bit unsigned decimal integer from the keyboard,
; stopping when the Enter key is pressed.All valid digits occurring
; before a non-numeric character are converted to the integer value.
; Leading spaces are ignored.
; Receives: nothing
; Returns:
; If the integer is blank, EAX=0 and CF=1
; If the integer contains only spaces, EAX=0 and CF=1
; If the integer is larger than 2^32-1, EAX=0 and CF=1
; Otherwise, EAX=converted integer, and CF=0
;
; Last update: 7/15/05
;--------------------------------------------------------
mov edx,OFFSET digitBuffer
mov ecx,MAX_DIGITS
call ReadString
mov ecx,eax ; save length
call ParseDecimal32 ; returns EAX
ret
ReadDec ENDP
;--------------------------------------------------------
ReadFromFile PROC
;
; Reads an input file into a buffer.
; Receives: EAX = file handle, EDX = buffer offset,
; ECX = number of bytes to read
; Returns: If CF = 0, EAX = number of bytes read; if
; CF = 1, EAX contains the system error code returned
; by the GetLastError Win32 API function.
; Last update: 7/6/2005
;--------------------------------------------------------
INVOKE ReadFile,
eax, ; file handle
edx, ; buffer pointer
ecx, ; max bytes to read
ADDR bytesRead, ; number of bytes read
0 ; overlapped execution flag
cmp eax,0 ; failed?
jne L1 ; no: return bytesRead
INVOKE GetLastError ; yes: EAX = error code
stc ; set Carry flag
jmp L2
L1: mov eax,bytesRead ; success
clc ; clear Carry flag
L2: ret
ReadFromFile ENDP
;--------------------------------------------------------
ReadHex PROC USES ebx ecx edx esi
;
; Reads a 32-bit hexadecimal integer from the keyboard,
; stopping when the Enter key is pressed.
; Receives: nothing
; Returns: EAX = binary integer value
; Returns:
; If the integer is blank, EAX=0 and CF=1
; If the integer contains only spaces, EAX=0 and CF=1
; Otherwise, EAX=converted integer, and CF=0
; Remarks: No error checking performed for bad digits
; or excess digits.
; Last update: 7/19/05 (skip leading spaces and tabs)
;--------------------------------------------------------
.data
xbtable BYTE 0,1,2,3,4,5,6,7,8,9,7 DUP(0FFh),10,11,12,13,14,15
numVal DWORD ?
charVal BYTE ?
.code
mov edx,OFFSET digitBuffer
mov esi,edx ; save in ESI also
mov ecx,MAX_DIGITS
call ReadString ; input the string
mov ecx,eax ; save length in ECX
cmp ecx,0 ; greater than zero?
jne B1 ; yes: continue
jmp B8 ; no: exit with CF=1
; Skip over leading spaces and tabs.
B1: mov al,[esi] ; get a character from buffer
cmp al,' ' ; space character found?
je B1A ; yes: skip it
cmp al,TAB ; TAB found?
je B1A ; yes: skip it
jmp B4 ; no: goto next step
B1A:
inc esi ; yes: point to next char
loop B1 ; all spaces?
jmp B8 ; yes: exit with CF=1
;--- Replaced code (7/19/05)-------------------------------------
;B1: mov al,[esi] ; get a character from buffer
; cmp al,' ' ; space character found?
; jne B4 ; no: goto next step
; inc esi ; yes: point to next char
; loop B1 ; all spaces?
; jmp B8 ; yes: exit with CF=1
;------------------------------------------------------------------
; Start to convert the number.
B4: mov numVal,0 ; clear accumulator
mov ebx,OFFSET xbtable ; translate table
; Repeat loop for each digit.
B5: mov al,[esi] ; get character from buffer
cmp al,'F' ; lowercase letter?
jbe B6 ; no
and al,11011111b ; yes: convert to uppercase
B6: sub al,30h ; adjust for table
xlat ; translate to binary
mov charVal,al
mov eax,16 ; numVal *= 16
mul numVal
mov numVal,eax
movzx eax,charVal ; numVal += charVal
add numVal,eax
inc esi ; point to next digit
loop B5 ; repeat, decrement counter
B7: mov eax,numVal ; return valid value
clc ; CF=0
jmp B9
B8: mov eax,0 ; error: return 0
stc ; CF=1
B9: ret
ReadHex ENDP
;--------------------------------------------------------
ReadInt PROC USES ecx edx
;
; Reads a 32-bit signed decimal integer from standard
; input, stopping when the Enter key is pressed.
; All valid digits occurring before a non-numeric character
; are converted to the integer value. Leading spaces are
; ignored, and an optional leading + or - sign is permitted.
; All spaces return a valid integer, value zero.
; Receives: nothing
; Returns: If OF=0, the integer is valid, and EAX = binary value.
; If OF=1, the integer is invalid and EAX = 0.
;
; Updated: 7/15/05, comments updated 11/20/09
;--------------------------------------------------------
; Input a signed decimal string.
mov edx,OFFSET digitBuffer
mov ecx,MAX_DIGITS
call ReadString
mov ecx,eax ; save length in ECX
; Convert to binary (EDX -> string, ECX = length)
call ParseInteger32 ; returns EAX, CF
ret
ReadInt ENDP
;------------------------------------------------------------------------------
ReadKey PROC USES ecx
LOCAL evEvents:DWORD, saveFlags:DWORD
;
; Performs a no-wait keyboard check and single character read if available.
; If Ascii is zero, special keys can be processed by checking scans and VKeys
; Receives: nothing
; Returns: ZF is set if no keys are available, clear if we have read the key
; al = key Ascii code (is set to zero for special extended codes)
; ah = Keyboard scan code (as in inside cover of book)
; dx = Virtual key code
; ebx = Keyboard flags (Alt,Ctrl,Caps,etc.)
; Upper halves of EAX and EDX are overwritten
;
; ** Note: calling ReadKey prevents Ctrl-C from being used to terminate a program.
;
; Written by Richard Stam, used by permission.
; Revision history:
; Irvine, 6/21/05 -changed evEvents from WORD to DWORD
;------------------------------------------------------------------------------
.data
evBuffer INPUT_RECORD <> ; Buffers our key "INPUT_RECORD"
evRepeat WORD 0 ; Controls key repeat counting
.code
CheckInit ; call Inititialize, if not already called
; Save console flags
INVOKE GetConsoleMode,consoleInHandle,ADDR saveFlags
; Clear console flags, making it possible to detect Ctrl-C and Ctrl-S.
INVOKE SetConsoleMode,consoleInHandle,0
cmp evRepeat,0 ; key already processed by previous call to this function?
ja HaveKey ; if so, process the key
Peek:
; Peek to see if we have a pending event. If so, read it.
INVOKE PeekConsoleInput, consoleInHandle, ADDR evBuffer, 1, ADDR evEvents
test evEvents,0FFFFh
jz NoKey ; No pending events, so done.
INVOKE ReadConsoleInput, consoleInHandle, ADDR evBuffer, 1, ADDR evEvents
test evEvents,0FFFFh
jz NoKey ; No pending events, so done.
cmp evBuffer.eventType,KEY_EVENT ; Is it a key event?
jne Peek ; No -> Peek for next event
TEST evBuffer.Event.bKeyDown, KBDOWN_FLAG ; is it a key down event?
jz Peek ; No -> Peek for next event
mov ax,evBuffer.Event.wRepeatCount ; Set our internal repeat counter
mov evRepeat,ax
HaveKey:
mov al,evBuffer.Event.uChar.AsciiChar ; copy Ascii char to al
mov ah,BYTE PTR evBuffer.Event.wVirtualScanCode ; copy Scan code to ah
mov dx,evBuffer.Event.wVirtualKeyCode ; copy Virtual key code to dx
mov ebx,evBuffer.Event.dwControlKeyState ; copy keyboard flags to ebx
; Ignore the key press events for Shift, Ctrl, Alt, etc.
; Don't process them unless used in combination with another key
.IF dx == VK_SHIFT || dx == VK_CONTROL || dx == VK_MENU || \
dx == VK_CAPITAL || dx == VK_NUMLOCK || dx == VK_SCROLL
jmp Peek ; Don't process -> Peek for next event
.ENDIF
call ReadKeyTranslate ; Translate scan code compatability
dec evRepeat ; Decrement our repeat counter
or dx,dx ; Have key: clear the Zero flag
jmp Done
NoKey:
mov evRepeat,0 ; Reset our repeat counter
test eax,0 ; No key: set ZF=1 and quit
Done:
pushfd ; save Zero flag
pushad
; Restore Console mode
INVOKE SetConsoleMode,consoleInHandle,saveFlags
; Unless we call ReadKeyFlush in Windows 98, the key we just read
; reappears the next time ReadString is called. We don't know why this happens.
call ReadKeyFlush
popad
popfd ; restore Zero flag
ret
ReadKey ENDP
;------------------------------------------------------------------------------
ReadKeyFlush PROC
; Flushes the console input buffer and clears our internal repeat counter.
; Can be used to get faster keyboard reponse in arcade-style games, where
; we don't want to processes accumulated keyboard data that would slow down
; the program's response time.
; Receives: nothing
; Returns: nothing
; By Richard Stam, used by permission.
; Modified 4/5/03 by Irvine
;------------------------------------------------------------------------------
INVOKE FlushConsoleInputBuffer, consoleInHandle ; Flush the buffer
mov evRepeat,0 ; Reset our repeat counter
ret
ReadKeyFlush ENDP
;------------------------------------------------------------------------------
ReadKeyTranslate PROC PRIVATE USES ebx ecx edx esi
; Translates special scan codes to be compatible with DOS/BIOS return values.
; Called directly by ReadKey.
; Receives:
; al = key Ascii code
; ah = Virtual scan code
; dx = Virtual key code
; ebx = Keyboard flags (Alt,Ctrl,Caps,etc.)
; Returns:
; ah = Updated scan code (for Alt/Ctrl/Shift & special cases)
; al = Updated key Ascii code (set to 0 for special keys)
; Written by Richard Stam, used by permission.
; Modified 4/5/03 by Irvine
;------------------------------------------------------------------------------
.data ; Special key scan code translation table
; order: VirtualKey,NormalScan,CtrlScan,AltScan
SpecialCases \
BYTE VK_LEFT, 4Bh, 73h, 4Bh
CaseSize = ($ - SpecialCases) ; Special case table element size
BYTE VK_RIGHT, 4Dh, 74h, 4Dh
BYTE VK_UP, 48h, 8Dh, 48h
BYTE VK_DOWN, 50h, 91h, 50h
BYTE VK_PRIOR, 49h, 84h, 49h ; PgUp
BYTE VK_NEXT, 51h, 76h, 51h ; PgDn
BYTE VK_HOME, 47h, 77h, 47h
BYTE VK_END, 4Fh, 75h, 4Fh
BYTE VK_INSERT,52h, 92h, 52h
BYTE VK_DELETE,53h, 93h, 53h
BYTE VK_ADD, 4Eh, 90h, 4Eh
BYTE VK_SUBTRACT,4Ah,8Eh, 4Ah
BYTE VK_F11, 85h, 85h, 85h
BYTE VK_F12, 86h, 86h, 86h
BYTE VK_11, 0Ch, 0Ch, 82h ; see above
BYTE VK_12, 0Dh, 0Dh, 83h ; see above
BYTE 0 ; End of Table
.code
pushfd ; Push flags to save ZF of ReadKey
mov esi,0
; Search through the special cases table
Search:
cmp SpecialCases[esi],0 ; Check for end of search table
je NotFound
cmp dl,SpecialCases[esi] ; Check if special case is found
je Found
add esi,CaseSize ; Increment our table index
jmp Search ; Continue searching
Found:
.IF ebx & CTRL_MASK
mov ah,SpecialCases[esi+2] ; Specify the Ctrl scan code
mov al,0 ; Updated char for special keys
.ELSEIF ebx & ALT_MASK
mov ah,SpecialCases[esi+3] ; Specify the Alt scan code
mov al,0 ; Updated char for special keys
.ELSE
mov ah,SpecialCases[esi+1] ; Specify the normal scan code
.ENDIF
jmp Done
NotFound:
.IF ! (ebx & KEY_MASKS) ; Done if not shift/ctrl/alt combo
jmp Done
.ENDIF
.IF dx >= VK_F1 && dx <= VK_F10 ; Check for F1 to F10 keys
.IF ebx & CTRL_MASK
add ah,23h ; 23h = Hex diff for Ctrl/Fn keys
.ELSEIF ebx & ALT_MASK
add ah,2Dh ; 2Dh = Hex diff for Alt/Fn keys
.ELSEIF ebx & SHIFT_MASK
add ah,19h ; 19h = Hex diff for Shift/Fn keys
.ENDIF
.ELSEIF al >= '0' && al <= '9' ; Check for Alt/1 to Alt/9
.IF ebx & ALT_MASK
add ah,76h ; 76h = Hex diff for Alt/n keys
mov al,0
.ENDIF
.ELSEIF dx == VK_TAB ; Check for Shift/Tab (backtab)
.IF ebx & SHIFT_MASK
mov al,0 ; ah already has 0Fh, al=0 for special
.ENDIF
.ENDIF
Done:
popfd ; Pop flags to restore ZF of ReadKey
ret
ReadKeyTranslate ENDP
;--------------------------------------------------------
ReadString PROC
LOCAL bufSize:DWORD, saveFlags:DWORD, junk:DWORD
;
; Reads a string from the keyboard and places the characters
; in a buffer.
; Receives: EDX offset of the input buffer
; ECX = maximum characters to input (including terminal null)
; Returns: EAX = size of the input string.
; Comments: Stops when Enter key (0Dh,0Ah) is pressed. If the user
; types more characters than (ECX-1), the excess characters
; are ignored.
; Written by Kip Irvine and Gerald Cahill
; Last update: 11/19/92, 03/20/2003
;--------------------------------------------------------
.data
_$$temp DWORD ? ; added 03/20/03
.code
pushad
CheckInit
mov edi,edx ; set EDI to buffer offset
mov bufSize,ecx ; save buffer size
push edx
INVOKE ReadConsole,
consoleInHandle, ; console input handle
edx, ; buffer offset
ecx, ; max count
OFFSET bytesRead,
0
pop edx
cmp bytesRead,0
jz L5 ; skip move if zero chars input
dec bytesRead ; make first adjustment to bytesRead
cld ; search forward
mov ecx,bufSize ; repetition count for SCASB
mov al,0Ah ; scan for 0Ah (Line Feed) terminal character
repne scasb
jne L1 ; if not found, jump to L1
;if we reach this line, length of input string <= (bufsize - 2)
dec bytesRead ; second adjustment to bytesRead
sub edi,2 ; 0Ah found: back up two positions
cmp edi,edx ; don't back up to before the user's buffer
jae L2
mov edi,edx ; 0Ah must be the only byte in the buffer
jmp L2 ; and jump to L2
L1: mov edi,edx ; point to last byte in buffer
add edi,bufSize
dec edi
mov BYTE PTR [edi],0 ; insert null byte
; Save the current console mode
INVOKE GetConsoleMode,consoleInHandle,ADDR saveFlags
; Switch to single character mode
INVOKE SetConsoleMode,consoleInHandle,0
; Clear excess characters from the buffer, 1 byte at a time
L6: INVOKE ReadConsole,consoleInHandle,ADDR junk,1,ADDR _$$temp,0
mov al,BYTE PTR junk
cmp al,0Ah ; the terminal line feed character
jne L6 ; keep looking, it must be there somewhere
INVOKE SetConsoleMode,consoleInHandle,saveFlags ; restore console mode.
jmp L5
L2: mov BYTE PTR [edi],0 ; insert null byte at end of string
L5: popad
mov eax,bytesRead
ret
ReadString ENDP
;------------------------------------------------------------
SetTextColor PROC
;
; Change the color of all subsequent text output.
; Receives: AX = attribute. Bits 0-3 are the foreground
; color, and bits 4-7 are the background color.
; Returns: nothing
; Last update: 6/20/05
;------------------------------------------------------------
pushad
CheckInit
INVOKE SetConsoleTextAttribute, consoleOutHandle, ax
popad
ret
SetTextColor ENDP
;---------------------------------------------------------
StrLength PROC
;
; Returns the length of a null-terminated string.
; Receives: EDX points to the string.
; Returns: EAX = string length.
; Re-enabled 12/11/2011 (was previously commented out)
;---------------------------------------------------------
push edx
mov eax,0 ; holds character count
L1: cmp BYTE PTR [edx],0 ; end of string?
je L2 ; yes: quit
inc edx ; no: point to next
inc eax ; add 1 to count
jmp L1
L2: pop edx
ret
StrLength ENDP
;----------------------------------------------------------
Str_compare PROC USES eax edx esi edi,
string1:PTR BYTE,
string2:PTR BYTE
;
; Compare two strings. Affects the Zero and Carry flags
; exactly as they would be by the CMP instruction.
; Returns: nothing
;-----------------------------------------------------
mov esi,string1
mov edi,string2
L1: mov al,[esi]
mov dl,[edi]
cmp al,0 ; end of string1?
jne L2 ; no
cmp dl,0 ; yes: end of string2?
jne L2 ; no
jmp L3 ; yes, exit with ZF = 1
L2: inc esi ; point to next
inc edi
cmp al,dl ; chars equal?
je L1 ; yes: continue loop
; no: exit with flags set
L3: ret
Str_compare ENDP
;---------------------------------------------------------
Str_copy PROC USES eax ecx esi edi,
source:PTR BYTE, ; source string
target:PTR BYTE ; target string
;
; Copy a string from source to target.
; Returns: nothing
; Requires: the target string must contain enough
; space to hold a copy of the source string.
;----------------------------------------------------------
INVOKE Str_length,source ; EAX = length source
mov ecx,eax ; REP count
inc ecx ; add 1 for null byte
mov esi,source
mov edi,target
cld ; direction = up
rep movsb ; copy the string
ret
Str_copy ENDP
;---------------------------------------------------------
Str_length PROC USES edi,
pString:PTR BYTE ; pointer to string
;
; Return the length of a null-terminated string.
; Receives: pString - pointer to a string
; Returns: EAX = string length
;---------------------------------------------------------
mov edi,pString
mov eax,0 ; character count
L1:
cmp BYTE PTR [edi],0 ; end of string?
je L2 ; yes: quit
inc edi ; no: point to next
inc eax ; add 1 to count
jmp L1
L2: ret
Str_length ENDP
;-----------------------------------------------------------
Str_trim PROC USES eax ecx edi,
pString:PTR BYTE, ; points to string
char:BYTE ; char to remove
;
; Remove all occurences of a given character from
; the end of a string.
; Returns: nothing
; Last update: 5/2/09
;-----------------------------------------------------------
mov edi,pString
INVOKE Str_length,edi ; puts length in EAX
cmp eax,0 ; length zero?
je L3 ; yes: exit now
mov ecx,eax ; no: ECX = string length
dec eax
add edi,eax ; point to null byte at end
L1: mov al,[edi] ; get a character
cmp al,char ; character to be trimmed?
jne L2 ; no: insert null byte
dec edi ; yes: keep backing up
loop L1 ; until beginning reached
L2: mov BYTE PTR [edi+1],0 ; insert a null byte
L3: ret
Str_trim ENDP
COMMENT !
******************* OLD VERSION - NO LONGER USED ************
;-----------------------------------------------------------
Str_trim PROC USES eax ecx edi,
pString:PTR BYTE, ; points to string
char:BYTE ; char to remove
;
; Remove all occurences of a given character from
; the end of a string.
; Returns: nothing
; Last update: 1/18/02
;-----------------------------------------------------------
mov edi,pString
INVOKE Str_length,edi ; returns length in EAX
cmp eax,0 ; zero-length string?
je L2 ; yes: exit
mov ecx,eax ; no: counter = string length
dec eax
add edi,eax ; EDI points to last char
mov al,char ; char to trim
std ; direction = reverse
repe scasb ; skip past trim character
jne L1 ; removed first character?
dec edi ; adjust EDI: ZF=1 && ECX=0
L1: mov BYTE PTR [edi+2],0 ; insert null byte
L2: ret
Str_trim ENDP
********************************************************** !
;---------------------------------------------------
Str_ucase PROC USES eax esi,
pString:PTR BYTE
; Convert a null-terminated string to upper case.
; Receives: pString - a pointer to the string
; Returns: nothing
; Last update: 1/18/02
;---------------------------------------------------
mov esi,pString
L1:
mov al,[esi] ; get char
cmp al,0 ; end of string?
je L3 ; yes: quit
cmp al,'a' ; below "a"?
jb L2
cmp al,'z' ; above "z"?
ja L2
and BYTE PTR [esi],11011111b ; convert the char
L2: inc esi ; next char
jmp L1
L3: ret
Str_ucase ENDP
;------------------------------------------------------
WaitMsg PROC
;
; Displays a prompt and waits for the user to press a key.
; Receives: nothing
; Returns: nothing
; Last update: 6/9/05
;------------------------------------------------------
.data
waitmsgstr BYTE "Press any key to continue...",0
.code
pushad
mov edx,OFFSET waitmsgstr
call WriteString
call ReadChar
popad
ret
WaitMsg ENDP
;------------------------------------------------------
WriteBin PROC
;
; Writes a 32-bit integer to the console window in
; binary format. Converted to a shell that calls the
; WriteBinB procedure, to be compatible with the
; library documentation in Chapter 5.
; Receives: EAX = the integer to write
; Returns: nothing
;
; Last update: 11/18/02
;------------------------------------------------------
push ebx
mov ebx,4 ; select doubleword format
call WriteBinB
pop ebx
ret
WriteBin ENDP
;------------------------------------------------------
WriteBinB PROC
;
; Writes a 32-bit integer to the console window in
; binary format.
; Receives: EAX = the integer to write
; EBX = display size (1,2,4)
; Returns: nothing
;
; Last update: 11/18/02 (added)
;------------------------------------------------------
pushad
cmp ebx,1 ; ensure EBX is 1, 2, or 4
jz WB0
cmp ebx,2
jz WB0
mov ebx,4 ; set to 4 (default) even if it was 4
WB0:
mov ecx,ebx
shl ecx,1 ; number of 4-bit groups in low end of EAX
cmp ebx,4
jz WB0A
ror eax,8 ; assume TYPE==1 and ROR byte
cmp ebx,1
jz WB0A ; good assumption
ror eax,8 ; TYPE==2 so ROR another byte
WB0A:
mov esi,OFFSET buffer
WB1:
push ecx ; save loop count
mov ecx,4 ; 4 bits in each group
WB1A:
shl eax,1 ; shift EAX left into Carry flag
mov BYTE PTR [esi],'0' ; choose '0' as default digit
jnc WB2 ; if no carry, then jump to L2
mov BYTE PTR [esi],'1' ; else move '1' to DL
WB2:
inc esi
Loop WB1A ; go to next bit within group
mov BYTE PTR [esi],' ' ; insert a blank space
inc esi ; between groups
pop ecx ; restore outer loop count
loop WB1 ; begin next 4-bit group
dec esi ; eliminate the trailing space
mov BYTE PTR [esi],0 ; insert null byte at end
mov edx,OFFSET buffer ; display the buffer
call WriteString
popad
ret
WriteBinB ENDP
;------------------------------------------------------
WriteChar PROC
;
; Write a character to the console window
; Recevies: AL = character
; Last update: 10/30/02
; Note: WriteConole will not work unless direction flag is clear.
;------------------------------------------------------
pushad
pushfd ; save flags
CheckInit
mov buffer,al
cld ; clear direction flag
INVOKE WriteConsole,
consoleOutHandle, ; console output handle
OFFSET buffer, ; points to string
1, ; string length
OFFSET bytesWritten, ; returns number of bytes written
0
popfd ; restore flags
popad
ret
WriteChar ENDP
;-----------------------------------------------------
WriteDec PROC
;
; Writes an unsigned 32-bit decimal number to
; the console window. Input parameters: EAX = the
; number to write.
; Last update: 6/8/2005
;------------------------------------------------------
.data
; There will be as many as 10 digits.
WDBUFFER_SIZE = 12
bufferL BYTE WDBUFFER_SIZE DUP(?),0
.code
pushad
CheckInit
mov ecx,0 ; digit counter
mov edi,OFFSET bufferL
add edi,(WDBUFFER_SIZE - 1)
mov ebx,10 ; decimal number base
WI1:mov edx,0 ; clear dividend to zero
div ebx ; divide EAX by the radix
xchg eax,edx ; swap quotient, remainder
call AsciiDigit ; convert AL to ASCII
mov [edi],al ; save the digit
dec edi ; back up in buffer
xchg eax,edx ; swap quotient, remainder
inc ecx ; increment digit count
or eax,eax ; quotient = 0?
jnz WI1 ; no, divide again
; Display the digits (CX = count)
WI3:
inc edi
mov edx,edi
call WriteString
WI4:
popad ; restore 32-bit registers
ret
WriteDec ENDP
;------------------------------------------------------
WriteHex PROC
;
; Writes an unsigned 32-bit hexadecimal number to
; the console window.
; Input parameters: EAX = the number to write.
; Shell interface for WriteHexB, to retain compatibility
; with the documentation in Chapter 5.
;
; Last update: 11/18/02
;------------------------------------------------------
push ebx
mov ebx,4
call WriteHexB
pop ebx
ret
WriteHex ENDP
;------------------------------------------------------
WriteHexB PROC
LOCAL displaySize:DWORD
;
; Writes an unsigned 32-bit hexadecimal number to
; the console window.
; Receives: EAX = the number to write. EBX = display size (1,2,4)
; Returns: nothing
;
; Last update: 11/18/02
;------------------------------------------------------
DOUBLEWORD_BUFSIZE = 8
.data
bufferLHB BYTE DOUBLEWORD_BUFSIZE DUP(?),0
.code
pushad ; save all 32-bit data registers
mov displaySize,ebx ; save component size
; Clear unused bits from EAX to avoid a divide overflow.
; Also, verify that EBX contains either 1, 2, or 4. If any
; other value is found, default to 4.
.IF EBX == 1 ; check specified display size
and eax,0FFh ; byte == 1
.ELSE
.IF EBX == 2
and eax,0FFFFh ; word == 2
.ELSE
mov displaySize,4 ; default (doubleword) == 4
.ENDIF
.ENDIF
CheckInit
mov edi,displaySize ; let EDI point to the end of the buffer:
shl edi,1 ; multiply by 2 (2 digits per byte)
mov bufferLHB[edi],0 ; store null string terminator
dec edi ; back up one position
mov ecx,0 ; digit counter
mov ebx,16 ; hexadecimal base (divisor)
L1:
mov edx,0 ; clear upper dividend
div ebx ; divide EAX by the base
xchg eax,edx ; swap quotient, remainder
call AsciiDigit ; convert AL to ASCII
mov bufferLHB[edi],al ; save the digit
dec edi ; back up in buffer
xchg eax,edx ; swap quotient, remainder
inc ecx ; increment digit count
or eax,eax ; quotient = 0?
jnz L1 ; no, divide again
; Insert leading zeros
mov eax,displaySize ; set EAX to the
shl eax,1 ; number of digits to print
sub eax,ecx ; subtract the actual digit count
jz L3 ; display now if no leading zeros required
mov ecx,eax ; CX = number of leading zeros to insert
L2:
mov bufferLHB[edi],'0' ; insert a zero
dec edi ; back up
loop L2 ; continue the loop
; Display the digits. ECX contains the number of
; digits to display, and EDX points to the first digit.
L3:
mov ecx,displaySize ; output format size
shl ecx,1 ; multiply by 2
inc edi
mov edx,OFFSET bufferLHB
add edx,edi
call WriteString
popad ; restore 32-bit registers
ret
WriteHexB ENDP
;-----------------------------------------------------
WriteInt PROC
;
; Writes a 32-bit signed binary integer to the console window
; in ASCII decimal.
; Receives: EAX = the integer
; Returns: nothing
; Comments: Displays a leading sign, no leading zeros.
; Last update: 7/11/01
;-----------------------------------------------------
WI_Bufsize = 12
true = 1
false = 0
.data
buffer_B BYTE WI_Bufsize DUP(0),0 ; buffer to hold digits
neg_flag BYTE ?
.code
pushad
CheckInit
mov neg_flag,false ; assume neg_flag is false
or eax,eax ; is AX positive?
jns WIS1 ; yes: jump to B1
neg eax ; no: make it positive
mov neg_flag,true ; set neg_flag to true
WIS1:
mov ecx,0 ; digit count = 0
mov edi,OFFSET buffer_B
add edi,(WI_Bufsize-1)
mov ebx,10 ; will divide by 10
WIS2:
mov edx,0 ; set dividend to 0
div ebx ; divide AX by 10
or dl,30h ; convert remainder to ASCII
dec edi ; reverse through the buffer
mov [edi],dl ; store ASCII digit
inc ecx ; increment digit count
or eax,eax ; quotient > 0?
jnz WIS2 ; yes: divide again
; Insert the sign.
dec edi ; back up in the buffer
inc ecx ; increment counter
mov BYTE PTR [edi],'+' ; insert plus sign
cmp neg_flag,false ; was the number positive?
jz WIS3 ; yes
mov BYTE PTR [edi],'-' ; no: insert negative sign
WIS3: ; Display the number
mov edx,edi
call WriteString
popad
ret
WriteInt ENDP
NoNameCode = 1; Special nonprintable code to signal that
; WriteStackFrame was called.
WriteStackFrameNameSize = 64 ; Size of WriteStackFrameName's stack frame
WriteStackFrameSize = 20 ; Size of WriteStackFrame's stack frame
.code
;---------------------------------------------------
WriteStackFrameName PROC USES EAX EBX ECX EDX ESI,
numParam:DWORD, ; number of parameters passed to the procedure
numLocalVal: DWORD, ; number of DWord local variables
numSavedReg: DWORD, ; number of saved registers
procName: PTR BYTE ; pointer to name of procedure
LOCAL theReturn: DWORD, theBase: DWORD, \
firstLocal: DWORD, firstSaved: DWORD, \
specialFirstSaved: DWORD
; When called properly from a procedure with a stack frame, it prints
; out the stack frame for the procedure. Each item is labeled with its
; purpose: parameter, return address, saved ebp, local variable or saved
; register. The items pointed by ebp and esp are marked.
; Requires: The procedure has a stack frame including the return address
; and saved base pointer.
; It is suffient that procedure's PROC statement includes either
; at least one local variable or one parameter. If the procedure's
; PROC statement does not include either of these items, it is
; sufficient if the procedure begins with
; push ebp
; mov ebp, esp
; and the stack frame is completed before this procedure is
; INVOKEd providing the procedure does not have a USES clause.
; If there is a USES clause, but no parameters or local variables,
; the modified structure is printed
; Parameters passed on stack using STDCALL:
; numParam: number of parameters
; numLocalVal: number of DWORDS of local variables
; numSavedReg: number of saved registers
; ptrProcName: pointer to name of procedure
; Returns: nothing
; Sample use:
; myProc PROC USES ebx, ecx, edx ; saves 3 registers
; val:DWORD; ; has 1 parameter
; LOCAL a:DWORD, b:DWORD ; has 2 local varables
; .data
; myProcName BYTE "myProc", 0
; .code
; INVOKE writeStackFrameName, 1, 2, 3, ADDR myProcName
; Comment: The number parameters are ordered by the order of the
; corresponding items in the stack frame.
;
; Author: James Brink, Pacific Lutheran University
; Last update: 4/6/2005
;---------------------------------------------------
.data
LblStack BYTE "Stack Frame ", 0
LblFor Byte "for ", 0
LblEbp BYTE " ebp", 0 ; used for offsets from ebp
LblParam BYTE " (parameter)", 0
LblEbpPtr BYTE " (saved ebp) <--- ebp", 0
LblSaved BYTE " (saved register)", 0
LblLocal BYTE " (local variable)", 0
LblReturn BYTE " (return address)", 0
LblEsp BYTE " <--- esp", 13, 10, 0 ; adds blank line at end of stack frame
BadStackFrameMsg BYTE "The stack frame is invalid", 0
.code
; register usage:
; eax: value to be printed
; ebx: offset from ebp
; ecx: item counter
; edx: location of string being printed
; esi: memory location of stack frame item
; print title
mov edx, OFFSET LblStack
call writeString
mov esi, procName
; NOTE: esi must not be changed until we get to
; the section for calculating the location
; of the caller's ebp at L0a:
cmp BYTE PTR [esi], 0 ; is the name string blank?
je L0 ; if so, just go to a new line
cmp BYTE PTR [esi], NoNameCode
; is the name the special code
; from WriteStackFrame?
je L0 ; if so, just go to a new line
mov edx, OFFSET LblFor ; if not, add "for "
call writeString
mov edx, procName ; and print name
call writeString
L0: call crlf
call crlf
mov ecx, 0 ; initialize sum of items in stack frame
mov ebx, 0 ; initialize sum of items in stack frame
; preceding the base pointer
; check for special stack frame condition
mov eax, numLocalVal ; Special condition: numLocalVal = 0
cmp eax, 0
ja Normal
mov eax, numParam ; Special condition: numParm = 0
cmp eax, 0
ja Normal
mov eax, numSavedReg ; Special condition: numSaveReg > 0
cmp eax, 0
ja Special
Normal: mov eax, numSavedReg ; get number of parameters
add ecx, eax ; add to number of items in stack frame
mov firstSaved, ecx ; save item number of the first saved register
mov specialFirstSaved, 0
; no special saved registers
mov eax, numLocalVal ; get number of local variable DWords
add ecx, eax ; add to number of items in stack frame
mov firstLocal, ecx ; save item number of first local variable
add ecx, 1 ; add 1 for the saved ebp
mov theBase, ecx ; save item number of the base pointer
add ecx, 1 ; add 1 for the return address
add ebx, 1 ; add 1 for items stored above ebp ; add for the return address/preceding ebp
mov theReturn, ecx ; save item number of the return pointer
mov eax, numParam ; get number of parameters
add ecx, eax ; add to number of items in stack frame
add ebx, eax ; add for the parameters/preceding ebp
jmp L0z
Special:
; MASM does not create a stack frame under these conditions:
; The number of parameters is 0
; The number of local variables is 0
; The number of saved (USES) registers is positive.
; The following assumes the procedure processed ebp manually
; because MASM does not push it under these conditions.
mov firstSaved, ecx ; there are no "regular" saved registers
mov firstLocal, ecx ; there are no local variables
add ecx, 1 ; add 1 for the saved ebp
mov theBase, ecx ; save item number of the base pointer
mov eax, numSavedReg ; get number of saved registers
add ecx, eax ; add to number of items in the stack frame
add ebx, eax ; add for the items preceding ebp
mov specialFirstSaved, ecx
add ecx, 1 ; add 1 for the return address
add ebx, 1 ; add 1 for items stored above ebp ; add for the return address/preceding ebp
mov theReturn, ecx ; save item number of the return pointer
mov eax, esp
add eax, 44
cmp eax, esi
L0z:
; ecx now contains the number of items in the stack frame
; ebx now contains the number of items preceding the base pointer
; determine the size of those items preceding the base pointer
shl ebx, 2 ; multiply by 4
; determine location of caller's saved ebp
L0a: cmp BYTE PTR [esi], NoNameCode
; check for special code
L0b: mov esi, [ebp] ; get the ebp (1 indirection
; mov does not change flags
jne L0c ; if not special code, skip the next step
mov esi, [esi] ; 2nd indirection if called by WriteStackFrame
L0c: ; esi has pointer into caller's stack frame
; At this point esi contains the location for the caller's saved ebp
; Check special case to make sure ebp and esp agree.
; Printing the stack frame cannot be printed if ebp has not been pushed
mov eax, specialFirstSaved ; Was this a special case?
cmp eax, 0 ; If so specialFirstSaved would be 0
je L0e ; If not, continue normal processing
mov eax, esp ; Calculate loc. of last entry before
; of WriteStackFrameNames stack frame
add eax, WriteStackFrameNameSize
cmp eax, esi ; does it equal the location of the base pointer?
je L0e ; if so, continue normal processing
; if not chec to see if procedure was called
; by writeStackFrame
add eax, WriteStackFrameSize
cmp eax, esi ; does it equal the location of the base pointer?
jne badStackFrame ; if not, the stack frame is invalid
; These are not perfect test as we haven't
; checked to see which case we are in.
; Continue normal processing by calculating its stack frame size
L0e: add esi, ebx ; calculate beginning of the caller's stack
; frame (highest memory used)
; *** loop to print stack frame
; Note: the order of some the following checks is important ck frame ***
L1: ; write value and beginning offset from basepointer
mov eax, [esi] ; write item in stack frame
call writeHex
mov edx, OFFSET LblEbp ; write " ebp"
call writeString
mov eax, ebx ; write offset from base pointer
call writeInt
; check for special labels
cmp ecx, theReturn ; check for return address item
jne L2
mov edx, OFFSET LblReturn
jmp LPrint
L2: cmp ecx, theBase ; check for base pointer
jne L2a
mov edx, OFFSET LblEbpPtr
jmp LPrint
L2a: cmp ecx, specialFirstSaved ; Check for special saved registers
ja L3
mov edx, OFFSET LblSaved
jmp LPrint
L3: cmp ecx, firstSaved ; check for saved registers
ja L4
mov edx, OFFSET LblSaved
jmp LPrint
L4: cmp ecx, firstLocal ; check for local variables
ja L5
mov edx, OFFSET LblLocal
jmp LPrint
L5: mov edx, OFFSET LblParam
LPrint: call writeString
cmp ecx, 1 ; check for last item in stack frame
jne LDone
mov edx, OFFSET LblEsp
call writeString
LDone: ; complete output for line
call crlf
; get ready for the next line
sub esi, 4 ; decrement memory location by 4
sub ebx, 4 ; decrement offset by 4
loop LDoneX
jmp Return
LDoneX: jmp L1
Return:
ret
; Stack frame invalid
BadStackFrame:
lea edx, BadStackFrameMsg
; load message
call writeString ; write message
call crlf
ret ; return without printing stack frame
WriteStackFrameName ENDP
;---------------------------------------------------
WriteStackFrame PROC,
numParam:DWORD, ; number of parameters passed to the procedure
numLocalVal: DWORD, ; number of DWord local variables
numSavedReg: DWORD ; number of saved registers
; When called properly from a procedure with a stack frame, it prints
; out the stack frame for the procedure. Each item is labeled with its
; purpose: parameter, return address, saved ebp, local variable or saved
; register. The items pointed by ebp and esp are marked.
; Requires: The procedure has a stack frame including the return address
; and saved base pointer.
; It is suffient that procedure's PROC statement includes either
; at least one local variable or one parameter. If the procedure's
; PROC statement does not include either of these items, it is
; sufficient if the procedure begins with
; push ebp
; mov ebp, esp
; and the stack frame is completed before this procedure is
; INVOKEd providing the procedure does not have a USES clause.
; If there is a USES clause, but no parameters or local variables,
; the modified structure is printed
; Parameters passed on stack using STDCALL:
; numParam: number of parameters
; numLocalVal: number of DWORDS of local variables
; numSavedReg: number of saved registers
; Returns: nothing
; Sample use:
; myProc PROC USES ebx, ecx, edx ; saves 3 registers
; val:DWORD; ; has 1 parameter
; LOCAL a:DWORD, b:DWORD ; has 2 local varables
; .data
; myProcName BYTE "myProc", 0
; .code
; INVOKE writeStackFrame, 1, 2, 3
;
; Comments: The parameters are ordered by the order of the corresponding
; items in the stack frame.
;
; Author: James Brink, Pacific Lutheran University
; Last update: 4/6/2005
;---------------------------------------------------
.data
NoName BYTE NoNameCode
.code
INVOKE WriteStackFrameName, numParam, numLocalVal, \
NumSavedReg, ADDR NoName
; NoNameCode
; Special signal that WriteStackFrameName
; is being called from WriteStackFrame
ret
WriteStackFrame ENDP
;--------------------------------------------------------
WriteString PROC
;
; Writes a null-terminated string to standard
; output. Input parameter: EDX points to the
; string.
; Last update: 9/7/01
;--------------------------------------------------------
pushad
CheckInit
INVOKE Str_length,edx ; return length of string in EAX
cld ; must do this before WriteConsole
INVOKE WriteConsole,
consoleOutHandle, ; console output handle
edx, ; points to string
eax, ; string length
OFFSET bytesWritten, ; returns number of bytes written
0
popad
ret
WriteString ENDP
;--------------------------------------------------------
WriteToFile PROC
;
; Writes a buffer to an output file.
; Receives: EAX = file handle, EDX = buffer offset,
; ECX = number of bytes to write
; Returns: EAX = number of bytes written to the file.
; Last update: 6/8/2005
;--------------------------------------------------------
.data
WriteToFile_1 DWORD ? ; number of bytes written
.code
INVOKE WriteFile, ; write buffer to file
eax, ; file handle
edx, ; buffer pointer
ecx, ; number of bytes to write
ADDR WriteToFile_1, ; number of bytes written
0 ; overlapped execution flag
mov eax,WriteToFile_1 ; return value
ret
WriteToFile ENDP
;----------------------------------------------------
WriteWindowsMsg PROC USES eax edx
;
; Displays a string containing the most recent error
; generated by MS-Windows.
; Receives: nothing
; Returns: nothing
; Last updated: 6/10/05
;----------------------------------------------------
.data
WriteWindowsMsg_1 BYTE "Error ",0
WriteWindowsMsg_2 BYTE ": ",0
pErrorMsg DWORD ? ; points to error message
messageId DWORD ?
.code
call GetLastError
mov messageId,eax
; Display the error number.
mov edx,OFFSET WriteWindowsMsg_1
call WriteString
call WriteDec ; show error number
mov edx,OFFSET WriteWindowsMsg_2
call WriteString
; Get the corresponding message string.
INVOKE FormatMessage, FORMAT_MESSAGE_ALLOCATE_BUFFER + \
FORMAT_MESSAGE_FROM_SYSTEM, NULL, messageID, NULL,
ADDR pErrorMsg, NULL, NULL
; Display the error message generated by MS-Windows.
mov edx,pErrorMsg
call WriteString
; Free the error message string.
INVOKE LocalFree, pErrorMsg
ret
WriteWindowsMsg ENDP
;*************************************************************
;* PRIVATE PROCEDURES *
;*************************************************************
; Convert AL to an ASCII digit. Used by WriteHex & WriteDec
AsciiDigit PROC PRIVATE
push ebx
mov ebx,OFFSET xtable
xlat
pop ebx
ret
AsciiDigit ENDP
HexByte PROC PRIVATE
; Display the byte in AL in hexadecimal
pushad
mov dl,al
rol dl,4
mov al,dl
and al,0Fh
mov ebx,OFFSET xtable
xlat
mov buffer,al ; save first char
rol dl,4
mov al,dl
and al,0Fh
xlat
mov [buffer+1],al ; save second char
mov [buffer+2],0 ; null byte
mov edx,OFFSET buffer ; display the buffer
call WriteString
popad
ret
HexByte ENDP
END
;****************************************************************
; ARCHIVE AREA
;
; The following code has been 'retired', but may still be useful
; as a reference.
;****************************************************************
;------------------------------------------------------------
ReadChar PROC
;
; Retired 7/5/05
;
; Reads one character from the keyboard. The character is
; not echoed on the screen. Waits for the character if none is
; currently in the input buffer.
; Returns: AL = ASCII code
;----------------------------------------------------------
push ebx
push eax
L1: mov eax,10 ; give Windows 10ms to process messages
call Delay
call ReadKey ; look for key in buffer
jz L1 ; no key in buffer if ZF=1
; Special epilogue code used here to return AL, yet
; preserve the high 24 bits of EAX.
mov bl,al ; save ASCII code
pop eax
mov al,bl
pop ebx
ret
ReadChar ENDP
;--------------------------------------------------------
ReadDec PROC USES ebx ecx edx esi
LOCAL saveDigit:DWORD
;
; Retired 7/15/05
;
; Reads a 32-bit unsigned decimal integer from the keyboard,
; stopping when the Enter key is pressed.All valid digits occurring
; before a non-numeric character are converted to the integer value.
; Leading spaces are ignored.
; Receives: nothing
; Returns:
; If the integer is blank, EAX=0 and CF=1
; If the integer contains only spaces, EAX=0 and CF=1
; If the integer is larger than 2^32-1, EAX=0 and CF=1
; Otherwise, EAX=converted integer, and CF=0
;
; Last update: 11/11/02
;--------------------------------------------------------
; Input a string of digits using ReadString.
mov edx,OFFSET digitBuffer
mov esi,edx ; save offset in ESI
mov ecx,MAX_DIGITS
call ReadString
mov ecx,eax ; save length in CX
cmp ecx,0 ; greater than zero?
jne L1 ; yes: continue
mov eax,0 ; no: set return value
jmp L5 ; and exit with CF=1
; Skip over any leading spaces.
L1: mov al,[esi] ; get a character from buffer
cmp al,' ' ; space character found?
jne L2 ; no: goto next step
inc esi ; yes: point to next char
loop L1 ; all spaces?
jmp L5 ; yes: exit with CF=1
; Start to convert the number.
L2: mov eax,0 ; clear accumulator
mov ebx,10 ; EBX is the divisor
; Repeat loop for each digit.
L3: mov dl,[esi] ; get character from buffer
cmp dl,'0' ; character < '0'?
jb L4
cmp dl,'9' ; character > '9'?
ja L4
and edx,0Fh ; no: convert to binary
mov saveDigit,edx
mul ebx ; EDX:EAX = EAX * EBX
jc L5 ; quit if Carry (EDX > 0)
mov edx,saveDigit
add eax,edx ; add new digit to sum
jc L5 ; quit if Carry generated
inc esi ; point to next digit
jmp L3 ; get next digit
L4: clc ; succesful completion (CF=0)
jmp L6
L5: mov eax,0 ; clear result to zero
stc ; signal an error (CF=1)
L6:
ret
ReadDec ENDP
;--------------------------------------------------------
ReadFromFile PROC
;
; Retired 7/6/05
;
; Reads an input file into a buffer.
; Receives: EAX = file handle, EDX = buffer offset,
; ECX = number of bytes to read
; Returns: EAX = number of bytes read.
; Last update: 6/8/2005
;--------------------------------------------------------
.data
ReadFromFile_1 DWORD ? ; number of bytes read
.code
INVOKE ReadFile,
eax, ; file handle
edx, ; buffer pointer
ecx, ; max bytes to read
ADDR ReadFromFile_1, ; number of bytes read
0 ; overlapped execution flag
mov eax,ReadFromFile_1
ret
ReadFromFile ENDP
;--------------------------------------------------------
ReadInt PROC USES ebx ecx edx esi
LOCAL Lsign:SDWORD, saveDigit:DWORD
;
; Retired 7/15/05
;
; Reads a 32-bit signed decimal integer from standard
; input, stopping when the Enter key is pressed.
; All valid digits occurring before a non-numeric character
; are converted to the integer value. Leading spaces are
; ignored, and an optional leading + or - sign is permitted.
; All spaces return a valid integer, value zero.
; Receives: nothing
; Returns: If CF=0, the integer is valid, and EAX = binary value.
; If CF=1, the integer is invalid and EAX = 0.
;
; Contains corrections by Gerald Cahill
; Updated: 10/10/2003
;--------------------------------------------------------
.data
overflow_msgL BYTE " <32-bit integer overflow>",0
invalid_msgL BYTE " <invalid integer>",0
;allspace_msgL BYTE " <all spaces input>",0
.code
; Input a string of digits using ReadString.
mov Lsign,1 ; assume number is positive
mov edx,OFFSET digitBuffer
mov esi,edx ; save offset in SI
mov ecx,MAX_DIGITS
call ReadString
mov ecx,eax ; save length in ECX
cmp ecx,0 ; length greater than zero?
jne L1 ; yes: continue
mov eax,0 ; no: set return value
jmp L10 ; and exit
; Skip over any leading spaces.
L1: mov al,[esi] ; get a character from buffer
cmp al,' ' ; space character found?
jne L2 ; no: check for a sign
inc esi ; yes: point to next char
loop L1
mov eax,0 ; all spaces?
jmp L10 ; return zero as valid value
; mov edx,OFFSET allspace_msgL (line removed)
; jcxz L8 (line removed)
; Check for a leading sign.
L2: cmp al,'-' ; minus sign found?
jne L3 ; no: look for plus sign
mov Lsign,-1 ; yes: sign is negative
dec ecx ; subtract from counter
inc esi ; point to next char
jmp L3A
L3: cmp al,'+' ; plus sign found?
jne L3A ; no: skip
inc esi ; yes: move past the sign
dec ecx ; subtract from digit counter
; Test the first digit, and exit if nonnumeric.
L3A:mov al,[esi] ; get first character
call IsDigit ; is it a digit?
jnz L7A ; no: show error message
; Start to convert the number.
L4: mov eax,0 ; clear accumulator
mov ebx,10 ; EBX is the divisor
; Repeat loop for each digit.
L5: mov dl,[esi] ; get character from buffer
cmp dl,'0' ; character < '0'?
jb L9
cmp dl,'9' ; character > '9'?
ja L9
and edx,0Fh ; no: convert to binary
mov saveDigit,edx
imul ebx ; EDX:EAX = EAX * EBX
mov edx,saveDigit
jo L6 ; quit if overflow
add eax,edx ; add new digit to AX
jo L6 ; quit if overflow
inc esi ; point to next digit
jmp L5 ; get next digit
; Overflow has occured, unlesss EAX = 80000000h
; and the sign is negative:
L6: cmp eax,80000000h
jne L7
cmp Lsign,-1
jne L7 ; overflow occurred
jmp L9 ; the integer is valid
; Choose "integer overflow" messsage.
L7: mov edx,OFFSET overflow_msgL
jmp L8
; Choose "invalid integer" message.
L7A:
mov edx,OFFSET invalid_msgL
; Display the error message pointed to by EDX, and set the Overflow flag.
L8: call WriteString
call Crlf
mov al,127
add al,1 ; set Overflow flag
mov eax,0 ; set return value to zero
jmp L10 ; and exit
; IMUL leaves the Sign flag in an undeterminate state, so the OR instruction
; determines the sign of the iteger in EAX.
L9: imul Lsign ; EAX = EAX * sign
or eax,eax ; determine the number's Sign
L10:ret
ReadInt ENDP
|
/*
The MIT License (MIT)
Copyright (c) [2016] [BTC.COM]
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 "StratumMinerCkb.h"
#include "StratumSessionCkb.h"
#include "StratumServerCkb.h"
#include "DiffController.h"
#include <boost/functional/hash.hpp>
StratumMinerCkb::StratumMinerCkb(
StratumSessionCkb &session,
const DiffController &diffController,
const std::string &clientAgent,
const std::string &workerName,
int64_t workerId)
: StratumMinerBase(
session, diffController, clientAgent, workerName, workerId) {
}
void StratumMinerCkb::handleRequest(
const std::string &idStr,
const std::string &method,
const JsonNode &jparams,
const JsonNode &jroot) {
if (method == "mining.submit") {
handleRequest_Submit(idStr, jparams);
}
}
void StratumMinerCkb::handleRequest_Submit(
const string &idStr, const JsonNode &jparams) {
JsonNode &jsonParams = const_cast<JsonNode &>(jparams);
auto &session = getSession();
if (session.getState() != StratumSession::AUTHENTICATED) {
handleShare(idStr, StratumStatus::UNAUTHORIZED, 0, session.getChainId());
LOG(WARNING) << "session.getState() != StratumSession::AUTHENTICATED";
return;
}
if (jsonParams.children()->size() < 3 ||
jsonParams.children()->at(1).type() != Utilities::JS::type::Str ||
jsonParams.children()->at(2).type() != Utilities::JS::type::Str) {
LOG(WARNING) << "submit params count < 3";
handleShare(idStr, StratumStatus::ILLEGAL_PARARMS, 0, session.getChainId());
return;
}
//{"id":102,"method":"mining.submit","params":["ckb1qyq2znu0gempdahctxsm49sa9jdzq9vnka7qt9ntff.worker1","17282f3f","eaf71970c0"]}
// params: [username, jobId, nonce2]
uint64_t extraNonce2 = 0;
string extranonce = jsonParams.children()->at(2).str();
uint64_t JobId = jsonParams.children()->at(1).uint64_hex();
auto localJob = session.findLocalJob(JobId);
// can't find local job
if (localJob == nullptr) {
DLOG(WARNING) << "can't find local job";
handleShare(idStr, StratumStatus::JOB_NOT_FOUND, 0, session.getChainId());
return;
}
auto &server = session.getServer();
auto &worker = session.getWorker();
uint32_t sessionId = session.getSessionId();
shared_ptr<StratumJobEx> exjob = server.GetJobRepository(localJob->chainId_)
->getStratumJobEx(localJob->jobId_);
// can't find stratum job
if (exjob.get() == nullptr) {
DLOG(WARNING) << "can't find stratum job";
handleShare(idStr, StratumStatus::JOB_NOT_FOUND, 0, localJob->chainId_);
return;
}
auto sjob = std::static_pointer_cast<StratumJobCkb>(exjob->sjob_);
auto iter = jobDiffs_.find(localJob);
if (iter == jobDiffs_.end()) {
handleShare(idStr, StratumStatus::JOB_NOT_FOUND, 0, localJob->chainId_);
LOG(ERROR) << "can't find session's diff, worker: " << worker.fullName_;
return;
}
auto &jobDiff = iter->second;
ShareCkb share;
share.set_version(ShareCkb::CURRENT_VERSION);
share.set_jobid(sjob->jobId_);
share.set_workerhashid(workerId_);
share.set_userid(worker.userId(localJob->chainId_));
share.set_timestamp((uint64_t)time(nullptr));
share.set_status(StratumStatus::REJECT_NO_REASON);
share.set_sharediff(jobDiff.currentJobDiff_);
share.set_blockbits(UintToArith256(uint256S(sjob->target_)).GetCompact());
uint64_t networkdiff = (UintToArith256(uint256S(ckbdiffone)) /
UintToArith256(uint256S(sjob->target_)))
.GetLow64();
share.set_blockdiff(networkdiff);
share.set_height(sjob->height_);
if (extranonce.length() >= 16) {
extraNonce2 = strtoull(&extranonce[extranonce.length() - 16], nullptr, 16);
} else {
extraNonce2 = strtoull(extranonce.c_str(), nullptr, 16);
}
share.set_nonce(extraNonce2);
string extranonce1_s;
uint32_t sessionId_t = htobe32(sessionId);
Bin2Hex((uint8_t *)&sessionId_t, 4, extranonce1_s);
string ckbnonce = extranonce1_s + extranonce;
share.set_ckbnonce(ckbnonce);
DLOG(INFO) << "sessionid : " << std::hex << sessionId
<< "\nextranonce : " << extraNonce2 << "\nckbnonce : " << ckbnonce;
share.set_sessionid(sessionId); // TODO: fix it, set as real session id.
share.set_username(worker.userName_);
share.set_workername(workerName());
IpAddress ip;
ip.fromIpv4Int(session.getClientIp());
share.set_ip(ip.toString());
LocalShare localShare(extraNonce2, sessionId, JobId);
// can't add local share
if (!localJob->addLocalShare(localShare)) {
handleShare(
idStr,
StratumStatus::DUPLICATE_SHARE,
jobDiff.currentJobDiff_,
localJob->chainId_);
// add invalid share to counter
invalidSharesCounter_.insert((int64_t)time(nullptr), 1);
return;
}
DLOG(INFO) << " share received : " << share.toString();
uint256 blockHash;
server.checkAndUpdateShare(
localJob->chainId_,
share,
exjob,
jobDiff.jobDiffs_,
worker.fullName_,
blockHash);
if (StratumStatus::isAccepted(share.status())) {
uint256 jobtarget;
CkbDifficulty::DiffToTarget(share.sharediff(), jobtarget);
DLOG(INFO) << "share reached the job target: "
<< UintToArith256(jobtarget).GetHex();
} else {
uint256 jobtarget;
CkbDifficulty::DiffToTarget(share.sharediff(), jobtarget);
DLOG(INFO) << "share not reached the job target: "
<< UintToArith256(jobtarget).GetHex();
}
// we send share to kafka by default, but if there are lots of invalid
// shares in a short time, we just drop them.
if (handleShare(
idStr, share.status(), share.sharediff(), localJob->chainId_)) {
if (StratumStatus::isSolved(share.status())) {
server.sendSolvedShare2Kafka(
localJob->chainId_, share, exjob, worker, blockHash);
// mark jobs as stale
server.GetJobRepository(localJob->chainId_)
->markAllJobsAsStale(sjob->height());
}
} else {
// check if there is invalid share spamming
int64_t invalidSharesNum = invalidSharesCounter_.sum(
time(nullptr), INVALID_SHARE_SLIDING_WINDOWS_SIZE);
// too much invalid shares, don't send them to kafka
if (invalidSharesNum >= INVALID_SHARE_SLIDING_WINDOWS_MAX_LIMIT) {
LOG(WARNING) << "invalid share spamming, worker: " << worker.fullName_
<< ", " << share.toString();
return;
}
}
std::string message;
if (!share.SerializeToStringWithVersion(message)) {
LOG(ERROR) << "share SerializeToStringWithVersion failed!"
<< share.toString();
return;
}
server.sendShare2Kafka(localJob->chainId_, message.data(), message.size());
}
|
; void SMS_VRAMmemsetW(unsigned int dst,unsigned int value,unsigned int size)
SECTION code_clib
SECTION code_SMSlib
PUBLIC SMS_VRAMmemsetW_callee
EXTERN asm_SMSlib_VRAMmemsetW
SMS_VRAMmemsetW_callee:
pop hl
pop bc
pop de
ex (sp),hl
jp asm_SMSlib_VRAMmemsetW
|
; ==========================================
; pmtest3.asm
; 编译方法:nasm pmtest3.asm -o pmtest3.com
; ==========================================
%include "pm.inc" ; 常量, 宏, 以及一些说明
org 0100h
jmp LABEL_BEGIN
[SECTION .gdt]
; GDT
; 段基址, 段界限 , 属性
LABEL_GDT: Descriptor 0, 0, 0 ; 空描述符
LABEL_DESC_NORMAL: Descriptor 0, 0ffffh, DA_DRW ; Normal 描述符
LABEL_DESC_CODE32: Descriptor 0, SegCode32Len - 1, DA_C + DA_32 ; 非一致代码段, 32
LABEL_DESC_CODE16: Descriptor 0, 0ffffh, DA_C ; 非一致代码段, 16
LABEL_DESC_DATA: Descriptor 0, DataLen - 1, DA_DRW+DA_DPL1 ; Data
LABEL_DESC_STACK: Descriptor 0, TopOfStack, DA_DRWA + DA_32; Stack, 32 位
LABEL_DESC_LDT: Descriptor 0, LDTLen - 1, DA_LDT ; LDT
LABEL_DESC_VIDEO: Descriptor 0B8000h, 0ffffh, DA_DRW ; 显存首地址
; GDT 结束
GdtLen equ $ - LABEL_GDT ; GDT长度
GdtPtr dw GdtLen - 1 ; GDT界限
dd 0 ; GDT基地址
; GDT 选择子
SelectorNormal equ LABEL_DESC_NORMAL - LABEL_GDT
SelectorCode32 equ LABEL_DESC_CODE32 - LABEL_GDT
SelectorCode16 equ LABEL_DESC_CODE16 - LABEL_GDT
SelectorData equ LABEL_DESC_DATA - LABEL_GDT
SelectorStack equ LABEL_DESC_STACK - LABEL_GDT
SelectorLDT equ LABEL_DESC_LDT - LABEL_GDT
SelectorVideo equ LABEL_DESC_VIDEO - LABEL_GDT
; END of [SECTION .gdt]
[SECTION .data1] ; 数据段
ALIGN 32
[BITS 32]
LABEL_DATA:
SPValueInRealMode dw 0
; 字符串
PMMessage: db "In Protect Mode now. ^-^", 0 ; 进入保护模式后显示此字符串
OffsetPMMessage equ PMMessage - $$
StrTest: db "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0
OffsetStrTest equ StrTest - $$
DataLen equ $ - LABEL_DATA
; END of [SECTION .data1]
; 全局堆栈段
[SECTION .gs]
ALIGN 32
[BITS 32]
LABEL_STACK:
times 512 db 0
TopOfStack equ $ - LABEL_STACK - 1
; END of [SECTION .gs]
[SECTION .s16]
[BITS 16]
LABEL_BEGIN:
mov ax, cs
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0100h
mov [LABEL_GO_BACK_TO_REAL+3], ax
mov [SPValueInRealMode], sp
; 初始化 16 位代码段描述符
mov ax, cs
movzx eax, ax
shl eax, 4
add eax, LABEL_SEG_CODE16
mov word [LABEL_DESC_CODE16 + 2], ax
shr eax, 16
mov byte [LABEL_DESC_CODE16 + 4], al
mov byte [LABEL_DESC_CODE16 + 7], ah
; 初始化 32 位代码段描述符
xor eax, eax
mov ax, cs
shl eax, 4
add eax, LABEL_SEG_CODE32
mov word [LABEL_DESC_CODE32 + 2], ax
shr eax, 16
mov byte [LABEL_DESC_CODE32 + 4], al
mov byte [LABEL_DESC_CODE32 + 7], ah
; 初始化数据段描述符
xor eax, eax
mov ax, ds
shl eax, 4
add eax, LABEL_DATA
mov word [LABEL_DESC_DATA + 2], ax
shr eax, 16
mov byte [LABEL_DESC_DATA + 4], al
mov byte [LABEL_DESC_DATA + 7], ah
; 初始化堆栈段描述符
xor eax, eax
mov ax, ds
shl eax, 4
add eax, LABEL_STACK
mov word [LABEL_DESC_STACK + 2], ax
shr eax, 16
mov byte [LABEL_DESC_STACK + 4], al
mov byte [LABEL_DESC_STACK + 7], ah
; 初始化 LDT 在 GDT 中的描述符
xor eax, eax
mov ax, ds
shl eax, 4
add eax, LABEL_LDT
mov word [LABEL_DESC_LDT + 2], ax
shr eax, 16
mov byte [LABEL_DESC_LDT + 4], al
mov byte [LABEL_DESC_LDT + 7], ah
; 初始化 LDT 中的描述符
xor eax, eax
mov ax, ds
shl eax, 4
add eax, LABEL_CODE_A
mov word [LABEL_LDT_DESC_CODEA + 2], ax
shr eax, 16
mov byte [LABEL_LDT_DESC_CODEA + 4], al
mov byte [LABEL_LDT_DESC_CODEA + 7], ah
; 为加载 GDTR 作准备
xor eax, eax
mov ax, ds
shl eax, 4
add eax, LABEL_GDT ; eax <- gdt 基地址
mov dword [GdtPtr + 2], eax ; [GdtPtr + 2] <- gdt 基地址
; 加载 GDTR
lgdt [GdtPtr]
; 关中断
cli
; 打开地址线A20
in al, 92h
or al, 00000010b
out 92h, al
; 准备切换到保护模式
mov eax, cr0
or eax, 1
mov cr0, eax
; 真正进入保护模式
jmp dword SelectorCode32:0 ; 执行这一句会把 SelectorCode32 装入 cs, 并跳转到 Code32Selector:0 处
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LABEL_REAL_ENTRY: ; 从保护模式跳回到实模式就到了这里
mov ax, cs
mov ds, ax
mov es, ax
mov ss, ax
mov sp, [SPValueInRealMode]
in al, 92h ; ┓
and al, 11111101b ; ┣ 关闭 A20 地址线
out 92h, al ; ┛
sti ; 开中断
mov ax, 4c00h ; ┓
int 21h ; ┛回到 DOS
; END of [SECTION .s16]
[SECTION .s32]; 32 位代码段. 由实模式跳入.
[BITS 32]
LABEL_SEG_CODE32:
mov ax, SelectorData
mov ds, ax ; 数据段选择子
mov ax, SelectorVideo
mov gs, ax ; 视频段选择子
mov ax, SelectorStack
mov ss, ax ; 堆栈段选择子
mov esp, TopOfStack
; 下面显示一个字符串
mov ah, 0Ch ; 0000: 黑底 1100: 红字
xor esi, esi
xor edi, edi
mov esi, OffsetPMMessage ; 源数据偏移
mov edi, (80 * 10 + 0) * 2 ; 目的数据偏移。屏幕第 10 行, 第 0 列。
cld
.1:
lodsb
test al, al
jz .2
mov [gs:edi], ax
add edi, 2
jmp .1
.2: ; 显示完毕
call DispReturn
; Load LDT
mov ax, SelectorLDT
lldt ax
jmp SelectorLDTCodeA:0 ; 跳入局部任务
; ------------------------------------------------------------------------
DispReturn:
push eax
push ebx
mov eax, edi
mov bl, 160
div bl
and eax, 0FFh
inc eax
mov bl, 160
mul bl
mov edi, eax
pop ebx
pop eax
ret
; DispReturn 结束---------------------------------------------------------
SegCode32Len equ $ - LABEL_SEG_CODE32
; END of [SECTION .s32]
; 16 位代码段. 由 32 位代码段跳入, 跳出后到实模式
[SECTION .s16code]
ALIGN 32
[BITS 16]
LABEL_SEG_CODE16:
; 跳回实模式:
mov ax, SelectorNormal
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov eax, cr0
and al, 11111110b
mov cr0, eax
LABEL_GO_BACK_TO_REAL:
jmp 0:LABEL_REAL_ENTRY ; 段地址会在程序开始处被设置成正确的值
Code16Len equ $ - LABEL_SEG_CODE16
; END of [SECTION .s16code]
; LDT
[SECTION .ldt]
ALIGN 32
LABEL_LDT:
; 段基址 段界限 属性
LABEL_LDT_DESC_CODEA: Descriptor 0, CodeALen - 1, DA_C + DA_32 ; Code, 32 位
LDTLen equ $ - LABEL_LDT
; LDT 选择子
SelectorLDTCodeA equ LABEL_LDT_DESC_CODEA - LABEL_LDT + SA_TIL
; END of [SECTION .ldt]
; CodeA (LDT, 32 位代码段)
[SECTION .la]
ALIGN 32
[BITS 32]
LABEL_CODE_A:
mov ax, SelectorVideo
mov gs, ax ; 视频段选择子(目的)
mov edi, (80 * 12 + 0) * 2 ; 屏幕第 10 行, 第 0 列。
mov ah, 0Ch ; 0000: 黑底 1100: 红字
mov al, 'L'
mov [gs:edi], ax
; 准备经由16位代码段跳回实模式
jmp SelectorCode16:0
CodeALen equ $ - LABEL_CODE_A
; END of [SECTION .la]
|
icl "stac_boot.inc"
icl "stac_boot_block_1.asm"
icl "stac_boot_block_2.asm"
|
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2020 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Andrey Abramov
/// @author Vasiliy Nabatchikov
////////////////////////////////////////////////////////////////////////////////
#include "Mocks/Servers.h" // this must be first because windows
#include "src/api/api.h" // must inclide V8 _before_ "catch.cpp' or CATCH() macro will be broken
// #include "src/objects-inl.h" // (required to avoid compile warnings) must inclide V8 _before_ "catch.cpp' or CATCH() macro will be broken
#include "src/objects/scope-info.h" // must inclide V8 _before_ "catch.cpp' or CATCH() macro will be broken
#include "Aql/OptimizerRulesFeature.h"
#include "gtest/gtest.h"
#include "analysis/analyzers.hpp"
#include "analysis/token_attributes.hpp"
#include <velocypack/Iterator.h>
#include <velocypack/Parser.h>
#include <velocypack/velocypack-aliases.h>
#include "IResearch/common.h"
#include "Mocks/LogLevels.h"
#include "Aql/QueryRegistry.h"
#include "GeneralServer/AuthenticationFeature.h"
#include "IResearch/IResearchAnalyzerFeature.h"
#include "IResearch/IResearchCommon.h"
#include "IResearch/VelocyPackHelper.h"
#include "RestServer/AqlFeature.h"
#include "RestServer/DatabaseFeature.h"
#include "RestServer/QueryRegistryFeature.h"
#include "RestServer/SystemDatabaseFeature.h"
#include "StorageEngine/EngineSelectorFeature.h"
#include "Utils/ExecContext.h"
#include "V8/v8-conv.h"
#include "V8/v8-utils.h"
#include "V8/v8-vpack.h"
#include "V8Server/V8DealerFeature.h"
#include "V8Server/v8-analyzers.h"
#include "V8Server/v8-externals.h"
#include "VocBase/Methods/Collections.h"
#if USE_ENTERPRISE
#include "Enterprise/Ldap/LdapFeature.h"
#endif
using namespace std::string_literals;
namespace {
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t length) override {
void* data = AllocateUninitialized(length);
return data == nullptr ? data : memset(data, 0, length);
}
virtual void* AllocateUninitialized(size_t length) override {
return malloc(length);
}
virtual void Free(void* data, size_t) override { free(data); }
};
class EmptyAnalyzer : public irs::analysis::analyzer {
public:
static constexpr irs::string_ref type_name() noexcept {
return "v8-analyzer-empty";
}
EmptyAnalyzer() : irs::analysis::analyzer(irs::type<EmptyAnalyzer>::get()) {
}
virtual irs::attribute* get_mutable(irs::type_info::type_id type) noexcept override {
if (type == irs::type<irs::frequency>::id()) {
return &_attr;
}
return nullptr;
}
static ptr make(irs::string_ref const&) {
PTR_NAMED(EmptyAnalyzer, ptr);
return ptr;
}
static bool normalize(irs::string_ref const& args, std::string& out) {
auto slice = arangodb::iresearch::slice(args);
if (slice.isNull()) throw std::exception();
if (slice.isNone()) return false;
arangodb::velocypack::Builder builder;
if (slice.isString()) {
VPackObjectBuilder scope(&builder);
arangodb::iresearch::addStringRef(builder, "args",
arangodb::iresearch::getStringRef(slice));
} else if (slice.isObject() && slice.hasKey("args") && slice.get("args").isString()) {
VPackObjectBuilder scope(&builder);
arangodb::iresearch::addStringRef(builder, "args",
arangodb::iresearch::getStringRef(slice.get("args")));
} else {
return false;
}
out = builder.buffer()->toString();
return true;
}
virtual bool next() override { return false; }
virtual bool reset(irs::string_ref const& data) override { return true; }
private:
irs::frequency _attr;
};
REGISTER_ANALYZER_VPACK(EmptyAnalyzer, EmptyAnalyzer::make, EmptyAnalyzer::normalize);
} // namespace
// -----------------------------------------------------------------------------
// --SECTION-- setup / tear-down
// -----------------------------------------------------------------------------
class V8AnalyzerTest
: public ::testing::Test,
public arangodb::tests::LogSuppressor<arangodb::Logger::AUTHENTICATION, arangodb::LogLevel::ERR> {
protected:
arangodb::tests::mocks::MockAqlServer server;
V8AnalyzerTest() {
arangodb::tests::v8Init(); // one-time initialize V8
}
};
v8::Local<v8::Object> getAnalyzerManagerInstance(TRI_v8_global_t *v8g,
v8::Isolate *isolate) {
return v8::Local<v8::ObjectTemplate>::New(isolate, v8g->IResearchAnalyzerManagerTempl)->NewInstance(TRI_IGETC).FromMaybe(v8::Local<v8::Object>());
}
v8::Local<v8::Object> getAnalyzersInstance(TRI_v8_global_t *v8g,
v8::Isolate *isolate) {
return v8::Local<v8::ObjectTemplate>::New(isolate, v8g->IResearchAnalyzerInstanceTempl)->NewInstance(TRI_IGETC).FromMaybe(v8::Local<v8::Object>());
}
v8::Local<v8::Function> getAnalyzersMethodFunction(TRI_v8_global_t *v8g,
v8::Isolate *isolate,
v8::Local<v8::Object>& analyzerObj,
const char* name) {
auto fn = analyzerObj->Get
(TRI_IGETC,
TRI_V8_ASCII_STRING(isolate, name)).FromMaybe(v8::Local<v8::Value>());
bool isFunction = fn->IsFunction();
EXPECT_TRUE(isFunction);
return v8::Local<v8::Function>::Cast(fn);
}
// -----------------------------------------------------------------------------
// --SECTION-- test suite
// -----------------------------------------------------------------------------
TEST_F(V8AnalyzerTest, test_instance_accessors) {
auto& analyzers = server.getFeature<arangodb::iresearch::IResearchAnalyzerFeature>();
auto& dbFeature = server.getFeature<arangodb::DatabaseFeature>();
{
auto vocbase = dbFeature.useDatabase(arangodb::StaticStrings::SystemDatabase);
std::shared_ptr<arangodb::LogicalCollection> ignored;
arangodb::OperationOptions options(arangodb::ExecContext::current());
arangodb::methods::Collections::createSystem(*vocbase, options,
arangodb::tests::AnalyzerCollectionName,
false, ignored);
}
arangodb::iresearch::IResearchAnalyzerFeature::EmplaceResult result;
ASSERT_TRUE(analyzers.emplace(result, arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1",
"identity", VPackSlice::noneSlice()).ok());
auto analyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer1", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
ASSERT_FALSE(!analyzer);
struct ExecContext : public arangodb::ExecContext {
ExecContext()
: arangodb::ExecContext(arangodb::ExecContext::Type::Default, "", "",
arangodb::auth::Level::NONE,
arangodb::auth::Level::NONE, false) {}
} execContext;
arangodb::ExecContextScope execContextScope(&execContext);
auto& authFeature = server.getFeature<arangodb::AuthenticationFeature>();
auto* userManager = authFeature.userManager();
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, systemDBInfo(server.server()));
v8::Isolate::CreateParams isolateParams;
ArrayBufferAllocator arrayBufferAllocator;
isolateParams.array_buffer_allocator = &arrayBufferAllocator;
auto isolate =
std::shared_ptr<v8::Isolate>(v8::Isolate::New(isolateParams),
[](v8::Isolate* p) -> void { p->Dispose(); });
ASSERT_NE(nullptr, isolate);
v8::Isolate::Scope isolateScope(isolate.get()); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::internal::Isolate::Current()->InitializeLoggingAndCounters(); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::HandleScope handleScope(isolate.get()); // required for v8::Context::New(...), v8::ObjectTemplate::New(...) and TRI_AddMethodVocbase(...)
auto context = v8::Context::New(isolate.get());
v8::Context::Scope contextScope(context); // required for TRI_AddMethodVocbase(...)
std::unique_ptr<TRI_v8_global_t> v8g(TRI_CreateV8Globals(server.server(),isolate.get(), 0)); // create and set inside 'isolate' for use with 'TRI_GET_GLOBALS()'
v8g->ArangoErrorTempl.Reset(isolate.get(), v8::ObjectTemplate::New(isolate.get())); // otherwise v8:-utils::CreateErrorObject(...) will fail
v8g->_vocbase = &vocbase;
arangodb::iresearch::TRI_InitV8Analyzers(*v8g, isolate.get());
auto v8Analyzer = getAnalyzersInstance(v8g.get(), isolate.get());
auto fn_name = getAnalyzersMethodFunction(v8g.get(), isolate.get(), v8Analyzer, "name");
auto fn_type = getAnalyzersMethodFunction(v8g.get(), isolate.get(), v8Analyzer, "type");
auto fn_properties = getAnalyzersMethodFunction(v8g.get(), isolate.get(), v8Analyzer, "properties");
auto fn_features = getAnalyzersMethodFunction(v8g.get(), isolate.get(), v8Analyzer, "features");
v8Analyzer->SetInternalField(SLOT_CLASS_TYPE,
v8::Integer::New(isolate.get(), WRP_IRESEARCH_ANALYZER_TYPE));
v8Analyzer->SetInternalField(SLOT_CLASS,
v8::External::New(isolate.get(), analyzer.get()));
// test name (authorised)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_name->CallAsFunction(context, v8Analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsString());
EXPECT_TRUE((analyzer->name() ==
TRI_ObjectToString(isolate.get(), result.ToLocalChecked())));
}
// test name (not authorised)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_name->CallAsFunction(context, v8Analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
EXPECT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// test type (authorised)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_type->CallAsFunction(context, v8Analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsString());
EXPECT_TRUE((analyzer->type() ==
TRI_ObjectToString(isolate.get(), result.ToLocalChecked())));
}
// test type (not authorised)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_type->CallAsFunction(context, v8Analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
EXPECT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// test properties (authorised)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_properties->CallAsFunction(context, v8Analyzer,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsObject());
VPackBuilder resultVPack;
TRI_V8ToVPack(isolate.get(), resultVPack, result.ToLocalChecked(), false);
EXPECT_EQUAL_SLICES(
resultVPack.slice(),
VPackSlice::emptyObjectSlice());
}
// test properties (not authorised)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_properties->CallAsFunction(context, v8Analyzer,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// test features (authorised)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_features->CallAsFunction(context, v8Analyzer,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsArray());
auto v8Result = v8::Handle<v8::Array>::Cast(result.ToLocalChecked());
EXPECT_EQ(analyzer->features().size(), v8Result->Length());
}
// test features (not authorised)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_features->CallAsFunction(context, v8Analyzer,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
EXPECT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
}
TEST_F(V8AnalyzerTest, test_manager_create) {
auto& analyzers = server.getFeature<arangodb::iresearch::IResearchAnalyzerFeature>();
auto& dbFeature = server.getFeature<arangodb::DatabaseFeature>();
{
auto vocbase = dbFeature.useDatabase(arangodb::StaticStrings::SystemDatabase);
std::shared_ptr<arangodb::LogicalCollection> ignored;
arangodb::OperationOptions options(arangodb::ExecContext::current());
arangodb::methods::Collections::createSystem(*vocbase, options,
arangodb::tests::AnalyzerCollectionName,
false, ignored);
}
arangodb::iresearch::IResearchAnalyzerFeature::EmplaceResult result;
{
const auto name = arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1";
ASSERT_TRUE(
analyzers.emplace(result, name, "identity", VPackSlice::noneSlice()).ok());
}
{
const auto name = arangodb::StaticStrings::SystemDatabase + "::emptyAnalyzer";
ASSERT_TRUE(analyzers
.emplace(result, name, "v8-analyzer-empty",
VPackParser::fromJson("{\"args\":\"12312\"}")->slice(),
irs::flags{irs::type<irs::frequency>::get()})
.ok());
}
struct ExecContext : public arangodb::ExecContext {
ExecContext()
: arangodb::ExecContext(arangodb::ExecContext::Type::Default, "", "",
arangodb::auth::Level::NONE,
arangodb::auth::Level::NONE, false) {}
} execContext;
arangodb::ExecContextScope execContextScope(&execContext);
auto& authFeature = server.getFeature<arangodb::AuthenticationFeature>();
auto* userManager = authFeature.userManager();
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, systemDBInfo(server.server()));
v8::Isolate::CreateParams isolateParams;
ArrayBufferAllocator arrayBufferAllocator;
isolateParams.array_buffer_allocator = &arrayBufferAllocator;
auto isolate =
std::shared_ptr<v8::Isolate>(v8::Isolate::New(isolateParams),
[](v8::Isolate* p) -> void { p->Dispose(); });
ASSERT_NE(nullptr, isolate);
v8::Isolate::Scope isolateScope(isolate.get()); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::internal::Isolate::Current()->InitializeLoggingAndCounters(); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::HandleScope handleScope(isolate.get()); // required for v8::Context::New(...), v8::ObjectTemplate::New(...) and TRI_AddMethodVocbase(...)
auto context = v8::Context::New(isolate.get());
v8::Context::Scope contextScope(context); // required for TRI_AddMethodVocbase(...)
std::unique_ptr<TRI_v8_global_t> v8g(TRI_CreateV8Globals(server.server(),isolate.get(), 0)); // create and set inside 'isolate' for use with 'TRI_GET_GLOBALS()'
v8g->ArangoErrorTempl.Reset(isolate.get(), v8::ObjectTemplate::New(isolate.get())); // otherwise v8:-utils::CreateErrorObject(...) will fail
v8g->_vocbase = &vocbase;
arangodb::iresearch::TRI_InitV8Analyzers(*v8g, isolate.get());
auto v8AnalyzerManager = getAnalyzerManagerInstance(v8g.get(), isolate.get());
auto fn_save = getAnalyzersMethodFunction(v8g.get(), isolate.get(), v8AnalyzerManager, "save");
// invalid params (no args)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_BAD_PARAMETER ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// invalid params (invalid type)
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), arangodb::StaticStrings::SystemDatabase + "::testAnalyzer2"),
v8::True(isolate.get()),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_BAD_PARAMETER ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// invalid params (invalid name)
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), arangodb::StaticStrings::SystemDatabase + "::test:Analyzer2"),
TRI_V8_ASCII_STRING(isolate.get(), "identity"),
v8::True(isolate.get()),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_BAD_PARAMETER ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// invalid params (invalid name)
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), "::test:Analyzer2"s),
TRI_V8_ASCII_STRING(isolate.get(), "identity"),
v8::True(isolate.get()),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_BAD_PARAMETER ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// invalid params (invalid name)
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "unknownVocbase::testAnalyzer"),
TRI_V8_ASCII_STRING(isolate.get(), "identity"),
v8::Null(isolate.get()),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN == ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// name collision
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), "emptyAnalyzer"s),
TRI_V8_ASCII_STRING(isolate.get(), "v8-analyzer-empty"),
TRI_V8_ASCII_STRING(isolate.get(), "{\"abc\":1}"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_BAD_PARAMETER ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// duplicate matching
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), "testAnalyzer1"s),
TRI_V8_ASCII_STRING(isolate.get(), "identity"),
v8::Null(isolate.get()),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
result.ToLocalChecked()->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_EQ(arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1", v8AnalyzerWeak->name());
ASSERT_EQ("identity", v8AnalyzerWeak->type());
EXPECT_EQUAL_SLICES(
VPackSlice::emptyObjectSlice(),
v8AnalyzerWeak->properties());
ASSERT_TRUE(v8AnalyzerWeak->features().empty());
auto analyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer1", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_FALSE(!analyzer);
}
// not authorised
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), "testAnalyzer2"s),
TRI_V8_ASCII_STRING(isolate.get(), "identity"),
TRI_V8_ASCII_STRING(isolate.get(), "{\"abc\":1}"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// successful creation
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), "testAnalyzer2"s),
TRI_V8_ASCII_STRING(isolate.get(), "identity"),
TRI_V8_ASCII_STRING(isolate.get(), "{\"abc\":1}")
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
result.ToLocalChecked()->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_EQ(arangodb::StaticStrings::SystemDatabase + "::testAnalyzer2", v8AnalyzerWeak->name());
ASSERT_EQ("identity", v8AnalyzerWeak->type());
EXPECT_EQUAL_SLICES(
VPackSlice::emptyObjectSlice(),
v8AnalyzerWeak->properties());
ASSERT_TRUE(v8AnalyzerWeak->features().empty());
auto analyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer2", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_FALSE(!analyzer);
}
// successful creation with DB name prefix
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), vocbase.name() + "::testAnalyzer3"s),
TRI_V8_ASCII_STRING(isolate.get(), "identity"),
TRI_V8_ASCII_STRING(isolate.get(), "{\"abc\":1}")
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
result.ToLocalChecked()->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_EQ(vocbase.name() + "::testAnalyzer3", v8AnalyzerWeak->name());
ASSERT_EQ("identity", v8AnalyzerWeak->type());
EXPECT_EQUAL_SLICES(
VPackSlice::emptyObjectSlice(),
v8AnalyzerWeak->properties());
ASSERT_TRUE(v8AnalyzerWeak->features().empty());
auto analyzer = analyzers.get(vocbase.name() + "::testAnalyzer3", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_FALSE(!analyzer);
}
// successful creation in system db by :: prefix
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), "::testAnalyzer4"s),
TRI_V8_ASCII_STRING(isolate.get(), "identity"),
TRI_V8_ASCII_STRING(isolate.get(), "{\"abc\":1}")
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_save->CallAsFunction(context, fn_save,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
result.ToLocalChecked()->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_EQ(vocbase.name() + "::testAnalyzer4", v8AnalyzerWeak->name());
ASSERT_EQ("identity", v8AnalyzerWeak->type());
EXPECT_EQUAL_SLICES(
VPackSlice::emptyObjectSlice(),
v8AnalyzerWeak->properties());
ASSERT_TRUE(v8AnalyzerWeak->features().empty());
auto analyzer = analyzers.get(vocbase.name() + "::testAnalyzer4", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_NE(nullptr, analyzer);
}
}
TEST_F(V8AnalyzerTest, test_manager_get) {
auto& analyzers = server.getFeature<arangodb::iresearch::IResearchAnalyzerFeature>();
auto& dbFeature = server.getFeature<arangodb::DatabaseFeature>();
{
auto const databases = arangodb::velocypack::Parser::fromJson(
std::string("[ {\"name\" : \"testVocbase\"} ]"));
ASSERT_EQ(TRI_ERROR_NO_ERROR, dbFeature.loadDatabases(databases->slice()));
}
arangodb::OperationOptions options(arangodb::ExecContext::current());
{
auto vocbase = dbFeature.useDatabase(arangodb::StaticStrings::SystemDatabase);
std::shared_ptr<arangodb::LogicalCollection> ignored;
arangodb::methods::Collections::createSystem(*vocbase, options,
arangodb::tests::AnalyzerCollectionName,
false, ignored);
}
{
auto vocbase = dbFeature.useDatabase("testVocbase");
std::shared_ptr<arangodb::LogicalCollection> ignored;
arangodb::methods::Collections::createSystem(*vocbase, options,
arangodb::tests::AnalyzerCollectionName,
false, ignored);
}
arangodb::iresearch::IResearchAnalyzerFeature::EmplaceResult result;
ASSERT_TRUE((analyzers
.emplace(result, arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1",
"identity", VPackSlice::noneSlice())
.ok()));
ASSERT_TRUE((analyzers
.emplace(result, "testVocbase::testAnalyzer1", "identity",
VPackSlice::noneSlice())
.ok()));
struct ExecContext : public arangodb::ExecContext {
ExecContext()
: arangodb::ExecContext(arangodb::ExecContext::Type::Default, "", "",
arangodb::auth::Level::NONE,
arangodb::auth::Level::NONE, false) {}
} execContext;
arangodb::ExecContextScope execContextScope(&execContext);
auto& authFeature = server.getFeature<arangodb::AuthenticationFeature>();
auto* userManager = authFeature.userManager();
TRI_vocbase_t vocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, systemDBInfo(server.server()));
v8::Isolate::CreateParams isolateParams;
ArrayBufferAllocator arrayBufferAllocator;
isolateParams.array_buffer_allocator = &arrayBufferAllocator;
auto isolate =
std::shared_ptr<v8::Isolate>(v8::Isolate::New(isolateParams),
[](v8::Isolate* p) -> void { p->Dispose(); });
ASSERT_NE(nullptr, isolate);
v8::Isolate::Scope isolateScope(isolate.get()); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::internal::Isolate::Current()->InitializeLoggingAndCounters(); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::HandleScope handleScope(isolate.get()); // required for v8::Context::New(...), v8::ObjectTemplate::New(...) and TRI_AddMethodVocbase(...)
auto context = v8::Context::New(isolate.get());
v8::Context::Scope contextScope(context); // required for TRI_AddMethodVocbase(...)
std::unique_ptr<TRI_v8_global_t> v8g(TRI_CreateV8Globals(server.server(),isolate.get(), 0)); // create and set inside 'isolate' for use with 'TRI_GET_GLOBALS()'
v8g->ArangoErrorTempl.Reset(isolate.get(), v8::ObjectTemplate::New(isolate.get())); // otherwise v8:-utils::CreateErrorObject(...) will fail
v8g->_vocbase = &vocbase;
arangodb::iresearch::TRI_InitV8Analyzers(*v8g, isolate.get());
auto v8AnalyzerManager = getAnalyzerManagerInstance(v8g.get(), isolate.get());
auto fn_analyzer = getAnalyzersMethodFunction(v8g.get(), isolate.get(), v8AnalyzerManager, "analyzer");
// invalid params (no name)
{
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_BAD_PARAMETER ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// get static (known analyzer)
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "identity"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
result.ToLocalChecked()->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_EQ(std::string("identity"), v8AnalyzerWeak->name());
ASSERT_EQ(std::string("identity"), v8AnalyzerWeak->type());
EXPECT_EQUAL_SLICES(
VPackSlice::emptyObjectSlice(),
v8AnalyzerWeak->properties());
EXPECT_EQ(2, v8AnalyzerWeak->features().size());
}
// get static (unknown analyzer)
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "unknown"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
EXPECT_TRUE(result.FromMaybe(v8::Local<v8::Value>())->IsNull());
}
// get custom (known analyzer) authorized
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
result.ToLocalChecked()->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_TRUE((arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1" ==
v8AnalyzerWeak->name()));
ASSERT_EQ(std::string("identity"), v8AnalyzerWeak->type());
EXPECT_EQUAL_SLICES(
VPackSlice::emptyObjectSlice(),
v8AnalyzerWeak->properties());
EXPECT_TRUE(v8AnalyzerWeak->features().empty());
}
// get custom (known analyzer) authorized but wrong current db
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "testVocbase::testAnalyzer1"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
user.grantDatabase("testVocbase", arangodb::auth::Level::RO);
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
v8::TryCatch tryCatch(isolate.get());
arangodb::velocypack::Builder response;
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// get custom (known analyzer) authorized from system with another current db
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(
isolate.get(), arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(arangodb::StaticStrings::SystemDatabase, arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
user.grantDatabase("testVocbase", arangodb::auth::Level::RO);
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
result.ToLocalChecked()->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_TRUE((arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1" ==
v8AnalyzerWeak->name()));
ASSERT_EQ(std::string("identity"), v8AnalyzerWeak->type());
EXPECT_EQUAL_SLICES(
VPackSlice::emptyObjectSlice(),
v8AnalyzerWeak->properties());
EXPECT_TRUE(v8AnalyzerWeak->features().empty());
}
// get custom (known analyzer) not authorized
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// get custom (unknown analyzer) authorized
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), arangodb::StaticStrings::SystemDatabase + "::unknown"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
EXPECT_TRUE(result.FromMaybe(v8::Local<v8::Value>())->IsNull());
}
// get custom (unknown analyzer) not authorized
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_STD_STRING(isolate.get(), arangodb::StaticStrings::SystemDatabase + "::unknown"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// get custom (unknown analyzer, unknown vocbase) authorized
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "unknownVocbase::unknown"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
v8::TryCatch tryCatch(isolate.get());
arangodb::velocypack::Builder response;
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase("unknownVocbase", arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
ASSERT_TRUE(result.IsEmpty());
}
// get custom (unknown analyzer, unknown vocbase) not authorized
{
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "unknownVocbase::unknown"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(vocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = fn_analyzer->CallAsFunction(context, fn_analyzer,
static_cast<int>(args.size()),
args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
}
TEST_F(V8AnalyzerTest, test_manager_list) {
auto& analyzers = server.getFeature<arangodb::iresearch::IResearchAnalyzerFeature>();
auto& dbFeature = server.getFeature<arangodb::DatabaseFeature>();
arangodb::OperationOptions options(arangodb::ExecContext::current());
{
auto vocbase = dbFeature.useDatabase(arangodb::StaticStrings::SystemDatabase);
std::shared_ptr<arangodb::LogicalCollection> ignored;
arangodb::methods::Collections::createSystem(*vocbase, options,
arangodb::tests::AnalyzerCollectionName,
false, ignored);
}
{
TRI_vocbase_t* vocbase;
arangodb::Result res = dbFeature.createDatabase(testDBInfo(server.server()), vocbase);
ASSERT_TRUE(res.ok());
std::shared_ptr<arangodb::LogicalCollection> ignored;
arangodb::methods::Collections::createSystem(*vocbase, options,
arangodb::tests::AnalyzerCollectionName,
false, ignored);
}
arangodb::iresearch::IResearchAnalyzerFeature::EmplaceResult result;
auto res = analyzers.emplace(result,
arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer1",
"identity", VPackSlice::noneSlice());
ASSERT_TRUE(res.ok());
res = analyzers.emplace(result, "testVocbase::testAnalyzer2", "identity",
VPackSlice::noneSlice());
ASSERT_TRUE(res.ok());
struct ExecContext : public arangodb::ExecContext {
ExecContext()
: arangodb::ExecContext(arangodb::ExecContext::Type::Default, "", "",
arangodb::auth::Level::NONE,
arangodb::auth::Level::NONE, false) {}
} execContext;
arangodb::ExecContextScope execContextScope(&execContext);
auto& authFeature = server.getFeature<arangodb::AuthenticationFeature>();
auto* userManager = authFeature.userManager();
TRI_vocbase_t systemDBVocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, systemDBInfo(server.server()));
TRI_vocbase_t testDBVocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, testDBInfo(server.server()));
v8::Isolate::CreateParams isolateParams;
ArrayBufferAllocator arrayBufferAllocator;
isolateParams.array_buffer_allocator = &arrayBufferAllocator;
auto isolate =
std::shared_ptr<v8::Isolate>(v8::Isolate::New(isolateParams),
[](v8::Isolate* p) -> void { p->Dispose(); });
ASSERT_NE(nullptr, isolate);
v8::Isolate::Scope isolateScope(isolate.get()); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::internal::Isolate::Current()->InitializeLoggingAndCounters(); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::HandleScope handleScope(isolate.get()); // required for v8::Context::New(...), v8::ObjectTemplate::New(...) and TRI_AddMethodVocbase(...)
auto context = v8::Context::New(isolate.get());
v8::Context::Scope contextScope(context); // required for TRI_AddMethodVocbase(...)
std::unique_ptr<TRI_v8_global_t> v8g(TRI_CreateV8Globals(server.server(),isolate.get(), 0)); // create and set inside 'isolate' for use with 'TRI_GET_GLOBALS()'
v8g->ArangoErrorTempl.Reset(isolate.get(), v8::ObjectTemplate::New(isolate.get())); // otherwise v8:-utils::CreateErrorObject(...) will fail
arangodb::iresearch::TRI_InitV8Analyzers(*v8g, isolate.get());
auto v8AnalyzerManager = getAnalyzerManagerInstance(v8g.get(), isolate.get());
auto fn_toArray = getAnalyzersMethodFunction(v8g.get(), isolate.get(), v8AnalyzerManager, "toArray");
// system database (authorised)
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
std::set<std::string> expected = {
"identity", "text_de", "text_en", "text_es", "text_fi",
"text_fr", "text_it", "text_nl", "text_no", "text_pt",
"text_ru", "text_sv", "text_zh",
arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1",
};
auto result = fn_toArray->CallAsFunction(context, fn_toArray,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsArray());
auto v8Result = v8::Handle<v8::Array>::Cast(result.ToLocalChecked());
for (uint32_t i = 0, count = v8Result->Length(); i < count; ++i) {
auto v8Analyzer = v8Result->Get(context, i).FromMaybe(v8::Local<v8::Value>());
ASSERT_FALSE(v8Analyzer.IsEmpty());
ASSERT_TRUE(v8Analyzer->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
v8Analyzer->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_EQ(1, expected.erase(v8AnalyzerWeak->name()));
}
EXPECT_TRUE(expected.empty());
}
// system database (not authorised)
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
std::set<std::string> expected = {
"identity", "text_de", "text_en", "text_es", "text_fi",
"text_fr", "text_it", "text_nl", "text_no", "text_pt",
"text_ru", "text_sv", "text_zh",
};
auto result = fn_toArray->CallAsFunction(context, fn_toArray,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsArray());
auto v8Result = v8::Handle<v8::Array>::Cast(result.ToLocalChecked());
for (uint32_t i = 0, count = v8Result->Length(); i < count; ++i) {
auto v8Analyzer = v8Result->Get(context, i).FromMaybe(v8::Local<v8::Value>());
ASSERT_FALSE(v8Analyzer.IsEmpty());
ASSERT_TRUE(v8Analyzer->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
v8Analyzer->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_EQ(1, expected.erase(v8AnalyzerWeak->name()));
}
EXPECT_TRUE(expected.empty());
}
// non-system database (authorised, system authorised)
{
v8g->_vocbase = &testDBVocbase;
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(arangodb::StaticStrings::SystemDatabase, arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
user.grantDatabase(testDBVocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
std::set<std::string> expected = {
"identity", "text_de", "text_en", "text_es", "text_fi",
"text_fr", "text_it", "text_nl", "text_no", "text_pt",
"text_ru", "text_sv", "text_zh",
arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1",
"testVocbase::testAnalyzer2",
};
auto result = fn_toArray->CallAsFunction(context, fn_toArray,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsArray());
auto v8Result = v8::Handle<v8::Array>::Cast(result.ToLocalChecked());
for (uint32_t i = 0, count = v8Result->Length(); i < count; ++i) {
auto v8Analyzer = v8Result->Get(context, i).FromMaybe(v8::Local<v8::Value>());
EXPECT_FALSE(v8Analyzer.IsEmpty());
EXPECT_TRUE(v8Analyzer->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
v8Analyzer->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
EXPECT_FALSE(!v8AnalyzerWeak);
EXPECT_EQ(1, expected.erase(v8AnalyzerWeak->name()));
}
EXPECT_TRUE(expected.empty());
}
// non-system database (not authorised, system authorised)
{
v8g->_vocbase = &testDBVocbase;
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(arangodb::StaticStrings::SystemDatabase, arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
user.grantDatabase(testDBVocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
std::set<std::string> expected = {
"identity", "text_de", "text_en", "text_es", "text_fi",
"text_fr", "text_it", "text_nl", "text_no", "text_pt",
"text_ru", "text_sv", "text_zh",
arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1",
};
auto result = fn_toArray->CallAsFunction(context, fn_toArray,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsArray());
auto v8Result = v8::Handle<v8::Array>::Cast(result.ToLocalChecked());
for (uint32_t i = 0, count = v8Result->Length(); i < count; ++i) {
auto v8Analyzer = v8Result->Get(context, i).FromMaybe(v8::Local<v8::Value>());
ASSERT_FALSE(v8Analyzer.IsEmpty());
ASSERT_TRUE(v8Analyzer->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
v8Analyzer->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
EXPECT_FALSE(!v8AnalyzerWeak);
EXPECT_EQ(1, expected.erase(v8AnalyzerWeak->name()));
}
EXPECT_TRUE(expected.empty());
}
// non-system database (authorised, system not authorised)
{
v8g->_vocbase = &testDBVocbase;
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(arangodb::StaticStrings::SystemDatabase, arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
user.grantDatabase(testDBVocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
std::set<std::string> expected = {
"identity", "text_de", "text_en", "text_es", "text_fi",
"text_fr", "text_it", "text_nl", "text_no", "text_pt",
"text_ru", "text_sv", "text_zh",
"testVocbase::testAnalyzer2",
};
auto result = fn_toArray->CallAsFunction(context, fn_toArray,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsArray());
auto v8Result = v8::Handle<v8::Array>::Cast(result.ToLocalChecked());
for (uint32_t i = 0, count = v8Result->Length(); i < count; ++i) {
auto v8Analyzer = v8Result->Get(context, i).FromMaybe(v8::Local<v8::Value>());
ASSERT_FALSE(v8Analyzer.IsEmpty());
ASSERT_TRUE(v8Analyzer->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
v8Analyzer->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_EQ(1, expected.erase(v8AnalyzerWeak->name()));
}
EXPECT_TRUE(expected.empty());
}
// non-system database (not authorised, system not authorised)
{
v8g->_vocbase = &testDBVocbase;
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(arangodb::StaticStrings::SystemDatabase, arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
user.grantDatabase(testDBVocbase.name(), arangodb::auth::Level::NONE); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
std::set<std::string> expected = {
"identity", "text_de", "text_en", "text_es", "text_fi",
"text_fr", "text_it", "text_nl", "text_no", "text_pt",
"text_ru", "text_sv", "text_zh",
};
auto result = fn_toArray->CallAsFunction(context, fn_toArray,
static_cast<int>(args.size()),
args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsArray());
auto v8Result = v8::Handle<v8::Array>::Cast(result.ToLocalChecked());
for (uint32_t i = 0, count = v8Result->Length(); i < count; ++i) {
auto v8Analyzer = v8Result->Get(context, i).FromMaybe(v8::Local<v8::Value>());
ASSERT_FALSE(v8Analyzer.IsEmpty());
ASSERT_TRUE(v8Analyzer->IsObject());
auto* v8AnalyzerWeak = TRI_UnwrapClass<arangodb::iresearch::AnalyzerPool>(
v8Analyzer->ToObject(TRI_IGETC).FromMaybe(v8::Local<v8::Object>()),
WRP_IRESEARCH_ANALYZER_TYPE, TRI_IGETC);
ASSERT_FALSE(!v8AnalyzerWeak);
ASSERT_EQ(1, expected.erase(v8AnalyzerWeak->name()));
}
EXPECT_TRUE(expected.empty());
}
}
TEST_F(V8AnalyzerTest, test_manager_remove) {
auto& analyzers = server.getFeature<arangodb::iresearch::IResearchAnalyzerFeature>();
auto& dbFeature = server.getFeature<arangodb::DatabaseFeature>();
arangodb::OperationOptions options(arangodb::ExecContext::current());
{
auto vocbase = dbFeature.useDatabase(arangodb::StaticStrings::SystemDatabase);
std::shared_ptr<arangodb::LogicalCollection> ignored;
arangodb::methods::Collections::createSystem(*vocbase, options,
arangodb::tests::AnalyzerCollectionName,
false, ignored);
}
{
TRI_vocbase_t* vocbase;
arangodb::Result res = dbFeature.createDatabase(testDBInfo(server.server()), vocbase);
ASSERT_TRUE(res.ok());
std::shared_ptr<arangodb::LogicalCollection> ignored;
arangodb::methods::Collections::createSystem(*vocbase, options,
arangodb::tests::AnalyzerCollectionName,
false, ignored);
}
{
arangodb::iresearch::IResearchAnalyzerFeature::EmplaceResult result;
ASSERT_TRUE((analyzers
.emplace(result, arangodb::StaticStrings::SystemDatabase + "::testAnalyzer1",
"identity", VPackSlice::noneSlice())
.ok()));
ASSERT_TRUE((analyzers
.emplace(result, arangodb::StaticStrings::SystemDatabase + "::testAnalyzer2",
"identity", VPackSlice::noneSlice())
.ok()));
ASSERT_TRUE((analyzers
.emplace(result, arangodb::StaticStrings::SystemDatabase + "::testAnalyzer3",
"identity", VPackSlice::noneSlice())
.ok()));
ASSERT_TRUE((analyzers
.emplace(result, "testVocbase::testAnalyzer1", "identity",
VPackSlice::noneSlice())
.ok()));
ASSERT_TRUE((analyzers
.emplace(result, "testVocbase::testAnalyzer2", "identity",
VPackSlice::noneSlice())
.ok()));
ASSERT_TRUE((analyzers
.emplace(result, "testVocbase::testAnalyzer3", "identity",
VPackSlice::noneSlice())
.ok()));
}
struct ExecContext : public arangodb::ExecContext {
ExecContext()
: arangodb::ExecContext(arangodb::ExecContext::Type::Default, "", "",
arangodb::auth::Level::NONE,
arangodb::auth::Level::NONE, false) {}
} execContext;
arangodb::ExecContextScope execContextScope(&execContext);
auto& authFeature = server.getFeature<arangodb::AuthenticationFeature>();
auto* userManager = authFeature.userManager();
TRI_vocbase_t systemDBVocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, systemDBInfo(server.server()));
TRI_vocbase_t testDBVocbase(TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL, testDBInfo(server.server()));
v8::Isolate::CreateParams isolateParams;
ArrayBufferAllocator arrayBufferAllocator;
isolateParams.array_buffer_allocator = &arrayBufferAllocator;
auto isolate =
std::shared_ptr<v8::Isolate>(v8::Isolate::New(isolateParams),
[](v8::Isolate* p) -> void { p->Dispose(); });
ASSERT_NE(nullptr, isolate);
v8::Isolate::Scope isolateScope(isolate.get()); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::internal::Isolate::Current()->InitializeLoggingAndCounters(); // otherwise v8::Isolate::Logger() will fail (called from v8::Exception::Error)
v8::HandleScope handleScope(isolate.get()); // required for v8::Context::New(...), v8::ObjectTemplate::New(...) and TRI_AddMethodVocbase(...)
auto context = v8::Context::New(isolate.get());
v8::Context::Scope contextScope(context); // required for TRI_AddMethodVocbase(...)
std::unique_ptr<TRI_v8_global_t> v8g(TRI_CreateV8Globals(server.server(),isolate.get(), 0)); // create and set inside 'isolate' for use with 'TRI_GET_GLOBALS()'
v8g->ArangoErrorTempl.Reset(isolate.get(), v8::ObjectTemplate::New(isolate.get())); // otherwise v8:-utils::CreateErrorObject(...) will fail
arangodb::iresearch::TRI_InitV8Analyzers(*v8g, isolate.get());
auto v8AnalyzerManager = getAnalyzerManagerInstance(v8g.get(), isolate.get());
auto fn_remove = getAnalyzersMethodFunction(v8g.get(), isolate.get(), v8AnalyzerManager, "remove");
// invalid params (no name)
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_BAD_PARAMETER ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// unknown analyzer
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "unknown"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
EXPECT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
}
// not authorised
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "testAnalyzer1"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::RO); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
ASSERT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
auto analyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer1", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_FALSE(!analyzer);
}
// still in use (fail)
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "testAnalyzer2"),
v8::False(isolate.get()),
};
auto inUseAnalyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer2", arangodb::QueryAnalyzerRevisions::QUERY_LATEST); // hold ref to mark in-use
ASSERT_FALSE(!inUseAnalyzer);
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
ASSERT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_ARANGO_CONFLICT ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
auto analyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer2", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_FALSE(!analyzer);
}
// still in use + force (success)
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "testAnalyzer2"),
v8::True(isolate.get()),
};
auto inUseAnalyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer2", arangodb::QueryAnalyzerRevisions::QUERY_LATEST); // hold ref to mark in-use
ASSERT_FALSE(!inUseAnalyzer);
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsUndefined());
auto analyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer2", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_FALSE(analyzer);
}
// success removal
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "testAnalyzer1"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsUndefined());
auto analyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer1", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_FALSE(analyzer);
}
// removal by system db name with ::
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "::testAnalyzer3"),
v8::False(isolate.get()),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsUndefined());
auto analyzer = analyzers.get(arangodb::StaticStrings::SystemDatabase +
"::testAnalyzer3", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_EQ(nullptr, analyzer);
}
// removal from wrong db
{
v8g->_vocbase = &systemDBVocbase;
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "testVocbase::testAnalyzer1"),
v8::False(isolate.get()),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(systemDBVocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
user.grantDatabase("testVocbase", arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
arangodb::velocypack::Builder response;
v8::TryCatch tryCatch(isolate.get());
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_TRUE(result.IsEmpty());
ASSERT_TRUE(tryCatch.HasCaught());
TRI_V8ToVPack(isolate.get(), response, tryCatch.Exception(), false);
auto slice = response.slice();
ASSERT_TRUE(slice.isObject());
ASSERT_TRUE((slice.hasKey(arangodb::StaticStrings::ErrorNum) &&
slice.get(arangodb::StaticStrings::ErrorNum).isNumber<int>() &&
TRI_ERROR_FORBIDDEN ==
ErrorCode{slice.get(arangodb::StaticStrings::ErrorNum).getNumber<int>()}));
auto analyzer = analyzers.get("testVocbase::testAnalyzer1", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_NE(nullptr, analyzer);
}
// success removal from non-system db
{
v8g->_vocbase = &testDBVocbase;
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "testAnalyzer2"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(testDBVocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsUndefined());
auto analyzer = analyzers.get("testVocbase::testAnalyzer2", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_EQ(nullptr, analyzer);
}
// success removal with db name prefix
{
v8g->_vocbase = &testDBVocbase;
std::vector<v8::Local<v8::Value>> args = {
TRI_V8_ASCII_STRING(isolate.get(), "testVocbase::testAnalyzer3"),
};
arangodb::auth::UserMap userMap; // empty map, no user -> no permissions
auto& user =
userMap
.emplace("", arangodb::auth::User::newUser("", "", arangodb::auth::Source::LDAP))
.first->second;
user.grantDatabase(testDBVocbase.name(), arangodb::auth::Level::RW); // for system collections User::collectionAuthLevel(...) returns database auth::Level
userManager->setAuthInfo(userMap); // set user map to avoid loading configuration from system database
auto result = v8::Function::Cast(*fn_remove)
->CallAsFunction(context, fn_remove,
static_cast<int>(args.size()), args.data());
ASSERT_FALSE(result.IsEmpty());
ASSERT_TRUE(result.ToLocalChecked()->IsUndefined());
auto analyzer = analyzers.get("testVocbase::testAnalyzer3", arangodb::QueryAnalyzerRevisions::QUERY_LATEST);
EXPECT_EQ(nullptr, analyzer);
}
}
|
/// @ref ext_vector_int3_sized
/// @file glm/ext/vector_int3_sized.hpp
///
/// @defgroup ext_vector_int3_sized GLM_EXT_vector_int3_sized
/// @ingroup ext
///
/// Exposes sized signed integer vector of 3 components type.
///
/// Include <glm/ext/vector_int3_sized.hpp> to use the features of this extension.
///
/// @see ext_scalar_int_sized
/// @see ext_vector_uint3_sized
#pragma once
#include "../ext/vector_int3.hpp"
#include "../ext/scalar_int_sized.hpp"
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
# pragma message("GLM: GLM_EXT_vector_int3_sized extension included")
#endif
namespace glm
{
/// @addtogroup ext_vector_int3_sized
/// @{
/// 8 bit signed integer vector of 3 components type.
///
/// @see ext_vector_int3_sized
typedef vec<3, int8, defaultp> i8vec3;
/// 16 bit signed integer vector of 3 components type.
///
/// @see ext_vector_int3_sized
typedef vec<3, int16, defaultp> i16vec3;
/// 32 bit signed integer vector of 3 components type.
///
/// @see ext_vector_int3_sized
typedef vec<3, int32, defaultp> i32vec3;
/// 64 bit signed integer vector of 3 components type.
///
/// @see ext_vector_int3_sized
typedef vec<3, int64, defaultp> i64vec3;
/// @}
}//namespace glm
|
; A057933: Floor[(80/81)*10^n].
; 9,98,987,9876,98765,987654,9876543,98765432,987654320,9876543209,98765432098,987654320987,9876543209876,98765432098765,987654320987654,9876543209876543,98765432098765432,987654320987654320
mov $1,10
pow $1,$0
mul $1,9
add $1,10
div $1,9
mul $1,10
sub $1,17
mul $1,10
div $1,18
mul $1,16
div $1,9
add $1,8
mov $0,$1
|
#include <iostream>
using namespace std;
void merge(int arr[], int lo, int mid, int hi) {
int len = hi - lo;
int temp[len];
int i = lo, j = mid, k = 0;
while (i < mid && j < hi) {
if (arr[i] < arr[j]) {
temp[k++] = arr[i++];
} else {
temp[k++] = arr[j++];
}
}
while (i < mid) {
temp[k++] = arr[i++];
}
while (j < hi) {
temp[k++] = arr[j++];
}
for (int m = lo, n = 0; m < hi; ++m, ++n) {
arr[m] = temp[n];
}
}
void merge_sort(int arr[], int lo, int hi) {
if (hi == lo)
return;
int mid = (hi + lo) / 2;
merge_sort(arr, lo, mid);
merge_sort(arr, mid + 1, hi);
merge(arr, lo, mid, hi);
}
int main(int argc, const char *argv[]) {
int arr[] = {1, 3, 6, 8, 4, 12, 9, 10, 5};
int len = (sizeof(arr) / sizeof(int));
merge_sort(arr, 0, len);
for (int i = 0; i < len; ++i) {
cout << arr[i] << " " << flush;
}
cout << endl;
return 0;
} |
org 0x100
cpu 8086
mov ax,1
int 0x10
mov dx,0x3d8
mov al,8
out dx,al
mov dl,0xd4
mov ax,0x7f04
out dx,ax
mov ax,0x6406
out dx,ax
mov ax,0x7007
out dx,ax
mov ax,0x0109
out dx,ax
mov ax,0xb800
mov es,ax
mov ax,0xb000
mov cx,40*100
rep stosw
std
mov bx,-79
; 160 entry sine table scaled to 0x7fff
sineTable:
dw 0x0000, 0x0506, 0x0A0A, 0x0F0B, 0x1405, 0x18F8, 0x1DE1, 0x22BE
dw 0x278D, 0x2C4D, 0x30FB, 0x3596, 0x3A1B, 0x3E8A, 0x42E0, 0x471C
dw 0x4B3B, 0x4F3D, 0x5320, 0x56E2, 0x5A81, 0x5DFD, 0x6154, 0x6484
dw 0x678D, 0x6A6C, 0x6D22, 0x6FAD, 0x720B, 0x743D, 0x7640, 0x7815
dw 0x79BB, 0x7B30, 0x7C75, 0x7D89, 0x7E6B, 0x7F1B, 0x7F99, 0x7FE5
dw 0x7FFF, 0x7FE5, 0x7F99, 0x7F1B, 0x7E6B, 0x7D89, 0x7C75, 0x7B30
dw 0x79BB, 0x7815, 0x7640, 0x743D, 0x720B, 0x6FAD, 0x6D22, 0x6A6C
dw 0x678D, 0x6484, 0x6154, 0x5DFD, 0x5A81, 0x56E2, 0x5320, 0x4F3D
dw 0x4B3B, 0x471C, 0x42E0, 0x3E8A, 0x3A1B, 0x3596, 0x30FB, 0x2C4D
dw 0x278D, 0x22BE, 0x1DE1, 0x18F8, 0x1405, 0x0F0B, 0x0A0A, 0x0506
dw 0x0000, 0xFAFA, 0xF5F6, 0xF0F5, 0xEBFB, 0xE708, 0xE21F, 0xDD42
dw 0xD873, 0xD3B3, 0xCF05, 0xCA6A, 0xC5E5, 0xC176, 0xBD20, 0xB8E4
dw 0xB4C5, 0xB0C3, 0xACE0, 0xA91E, 0xA57F, 0xA203, 0x9EAC, 0x9B7C
dw 0x9873, 0x9594, 0x92DE, 0x9053, 0x8DF5, 0x8BC3, 0x89C0, 0x87EB
dw 0x8645, 0x84D0, 0x838B, 0x8277, 0x8195, 0x80E5, 0x8067, 0x801B
dw 0x8001, 0x801B, 0x8067, 0x80E5, 0x8195, 0x8277, 0x838B, 0x84D0
dw 0x8645, 0x87EB, 0x89C0, 0x8BC3, 0x8DF5, 0x9053, 0x92DE, 0x9594
dw 0x9873, 0x9B7C, 0x9EAC, 0xA203, 0xA57F, 0xA91E, 0xACE0, 0xB0C3
dw 0xB4C5, 0xB8E4, 0xBD20, 0xC176, 0xC5E5, 0xCA6A, 0xCF05, 0xD3B3
dw 0xD873, 0xDD42, 0xE21F, 0xE708, 0xEBFB, 0xF0F5, 0xF5F6, 0xFAFA
; Our texture samples in each direction don't have to be evenly spaced.
; It makes sense to have those in the far distance further apart.
; Space them on a quadratic curve.
distanceTable:
db 1, 2, 3, 4, 5, 7, 9, 11, 13, 15, 17, 20, 22, 25, 28, 31
db 34, 38, 41, 45, 49, 53, 57, 61, 65, 70, 75, 80, 85, 90, 95,101
|
;*************************************************************************
; SOFTWARE BUFFERS MODULE
;
; Version 0.10
; 17/07/2005
;
; Li-Wen Yip
; Ad Hoc Radio Networking Research Project
; School Of Engineering
; James Cook University
;
;
; The RAM allocated for each buffer must not overlap two RAM banks. This allows
; faster loading and saving of the pointer values.
;
; Resources Requiring Exclusive Use:
; RAM Bank 4, FSR0
;
; Notes:
;
;
; What you need to understand to work with this code:
;
;
;
;
;*************************************************************************
; INCLUDE FILES
LIST P=18C452, F=INHX32 ;directive to define processor and file format
#include <P18C452.INC> ;processor specific variable definitions
#include "macrolib.inc" ; common macros
;*************************************************************************
; CONFIGURATION SECTION
; How many buffers do you want?
#define NUM_BUFS d'02'
; Lengths of the buffers
BUF0_LEN equ d'64'
BUF1_LEN equ d'64'
;*************************************************************************
; CONSTANTS
; Status Flag Positions
BUF_FULL equ 0 ; Buffer Full
BUF_NE equ 1 ; Buffer Not Empty
BUF_RDEOF equ 2 ; Buffer Read End Of Data
BUF_GTEOF equ 3 ; Buffer Get End Of Data
BUF_LOCK equ 4 ; Buffer Locked
;*************************************************************************
; VARIABLES
udata
; temp storage
temp res 1
; Buffer status/control registers
; These two pointers indicate which part of the buffer is locked for procesing.
BUFLKS0 res 1 ; Buffer 0 Locked Start Position
BUFLKE0 res 1 ; Buffer 0 Locked End Position
BUFPUT0 res 1 ; Buffer 0 Putting Pointer - writes to unlocked section.
BUFGET0 res 1 ; Buffer 0 Getting Pointer - reads from locked section.
BUFREAD0 res 1 ; Buffer 0 Reading Pointer - reads from unlocked section.
BUFSTAT0 res 1 ; Buffer 0 Status Register
global BUFSTAT0
BUFPUT1 res 1 ; Buffer 1 Putting Pointer
BUFGET1 res 1 ; Buffer 1 Getting Pointer
BUFSTAT1 res 1 ; Buffer 1 Status Register
global BUFSTAT1
; Put all buffer storage in a high bank, as it will never be addressed directly
.BUFFERS UDATA 0x400
BUF0 res BUF0_LEN ; Buffer 0 - Receive Buffer
BUF1 res BUF1_LEN ; Buffer 1 - Transmit Buffer
;*************************************************************************
; START OF CODE
CODE
;***************************************************************
; MACRO: INCP <f>, <base>, <ptr>, <len>
;
; Description: Load and increment a circular pointer.
; base + ptr -> FSRf, (ptr + 1) % len -> ptr
;
; Arguments: f - FSR register to use.
; base - base address (12 bit literal)
; ptr - pointer offset (8 bit file register)
; len - length of buffer (8 bit literal)
; Precond'ns: -
; Postcond'ns: -
; Regs Used: WREG, FSRf
;***************************************************************
ldincp macro f, base, ptr, len
; Load the address and pointer offset.
; k + p -> FSRf
lfsr f, base ; Load the base address.
movf ptr, w ; Add the offset.
addwf FSR#v(f)L ; ...
;clrf 0x00 ; ...
;addwfc FSR#v(f)H ; ...
; Increment the circular pointer.
; (p + 1) % length -> p
incf ptr ; ptr + 1 -> p
movlw len ; len -> WREG
cpfslt ptr ; Is the ptr < len ?
clrf ptr ; NO: 0 -> ptr
endm
;***************************************************************
; Macro: PUT <n>
;
; Description: Puts the contents of WREG into BUFFER n.
; Precond'ns: Data to be PUT must be loaded to WREG.
; User must check BUF_FULL before calling.
; Postcond'ns: BUF_FULL will be set if the buffer is full.
; Regs Used: WREG, FSR0, BUFFER n registers.
;***************************************************************
PUT MACRO n
; Save the data byte.
movwf temp
; Load and increment the circular pointer.
ldincp 0, BUF#v(n), BUFPUT#v(n), BUF#v(n)_LEN
; Put the data, and set the BUF_NE flag.
movff temp, INDF0 ; temp -> *FSR0
bsf BUFSTAT#v(n), BUF_NE ; Buffer is not empty.
; Check if the buffer is full, then return.
movlw BUFLKS1#v(n) ; Load the start pos of the locked section.
cpfseq BUFPUT#v(n) ; Is BUFPUTn = BUFLKSn?
return ; NO - return.
bsf BUFSTAT#v(n), BUF_FULL ; YES - Set BUF_FULL flag, return.
return
endm
;***************************************************************
; Macro: GET <n>
;
; Description: Gets a byte from the locked section of BUFFER n
; and puts it into WREG.
; Precond'ns: Must check that BUF_NE is set and BUF_EOF is not
; set before calling.
; Postcond'ns: BUF_GTEOF will be set if the end of the buffer is reached.
; Regs Used: WREG, FSR0, BUFFER n registers.
;***************************************************************
GET MACRO n
; Load and increment the circular pointer.
ldincp 0, BUF#v(n), BUFGET#v(n), BUF#v(n)_LEN
; Check if we have reached the end of the locked section
movf BUFLKE#v(n), w ; Load the end pos of the locked section.
cpfseq BUFGET#v(n) ; Is BUFGETn == BUFLKEn ?
bra _GETDATA#v(n) ; NO - just get the data.
bsf BUFSTAT#v(n), BUF_GTEOF ; YES - set EOF Flag.
_GETDATA#v(n):
; Get the data and return.
movf INDF0, W ; *FSR0 -> WREG
return
endm
;***************************************************************
; Macro: READ <n>
;
; Description: Gets a byte from the unlocked section of BUFFER n
; and puts it into WREG.
; Precond'ns: Must check that BUF_NE is set and BUF_EOF is not
; set before calling.
; Postcond'ns: BUF_EOF will be set if the end of the buffer is reached.
; Regs Used: WREG, FSR0, BUFFER n registers.
;***************************************************************
GET MACRO n
; Load and increment the circular pointer.
ldincp 0, BUF#v(n), BUFGET#v(n), BUF#v(n)_LEN
; Check if we have reached the end of the locked section
movf BUFLKE#v(n), w ; Load the end pos of the locked section.
cpfseq BUFGET#v(n) ; Is BUFGETn == BUFLKEn ?
bra _GETDATA#v(n) ; NO - just get the data.
bsf BUFSTAT#v(n), BUF_GTEOF ; YES - set EOF Flag.
_GETDATA#v(n):
; Get the data and return.
movf INDF0, W ; *FSR0 -> WREG
return
endm
;***************************************************************
; Macro: RST <n>
;
; Description: Resets the getting pointer of BUFFER n.
; Clears the BUF_EOF flag.
;
; Regs Used: WREG, FSR0, BUFFER n registers.
;***************************************************************
RST MACRO n
clrf BUFGET#v(n) ; Reset get pointer.
bcf BUFSTAT#v(n), BUF_EOF ; Clear EOF flag.
return
endm
;***************************************************************
; Macro: CLR <n>
;
; Description: Clears BUFFER n.
;
; Regs Used: WREG, FSR0, BUFFER n registers.
;***************************************************************
CLR MACRO n
; Clear pointers and status flags
clrf BUFPUT#v(n) ; Reset put pointer.
clrf BUFGET#v(n) ; Reset get pointer.
clrf BUFSTAT#v(n) ; Reset flags.
return
endm
;****************************************************************
; Here we define subroutines to call the macros for each buffer.
PUT0: PUT 0
GET0: GET 0
CLR0: CLR 0
RST0: RST 0
global PUT0, GET0, CLR0, RST0
PUT1: PUT 1
GET1: GET 1
CLR1: CLR 1
RST1: RST 1
global PUT1, GET1, CLR1, RST1
end
|
; A300067: Period 6: repeat [0, 0, 0, 1, 2, 2].
; 0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2,0,0,0,1,2,2
mod $0,6
mul $0,2
sub $0,2
div $0,3
mov $1,$0
|
; A082044: Main diagonal of A082043: a(n) = n^4 + 2n^2 + 1.
; 1,4,25,100,289,676,1369,2500,4225,6724,10201,14884,21025,28900,38809,51076,66049,84100,105625,131044,160801,195364,235225,280900,332929,391876,458329,532900,616225,708964,811801,925444,1050625,1188100
pow $0,2
add $0,1
mov $1,$0
pow $1,2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.