text stringlengths 1 1.05M |
|---|
// ----------------------------------------------------------------------------
// - Open3D: www.open3d.org -
// ----------------------------------------------------------------------------
// The MIT License (MIT)
//
// Copyright (c) 2018-2021 www.open3d.org
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------
#include "pybind/core/nns/nearest_neighbor_search.h"
#include "open3d/core/Tensor.h"
#include "open3d/core/nns/NearestNeighborSearch.h"
#include "pybind/core/tensor_converter.h"
#include "pybind/docstring.h"
#include "pybind/open3d_pybind.h"
#include "pybind/pybind_utils.h"
namespace open3d {
namespace core {
namespace nns {
void pybind_core_nns(py::module &m_nns) {
static const std::unordered_map<std::string, std::string>
map_nearest_neighbor_search_method_docs = {
{"query_points", "The query tensor of shape {n_query, d}."},
{"radii",
"Tensor of shape {n_query,} containing multiple radii, "
"one for each query point."},
{"radius", "Radius value for radius search."},
{"max_knn",
"Maximum number of neighbors to search per query point."},
{"knn", "Number of neighbors to search per query point."}};
py::class_<NearestNeighborSearch, std::shared_ptr<NearestNeighborSearch>>
nns(m_nns, "NearestNeighborSearch",
"NearestNeighborSearch class for nearest neighbor search. "
"Construct a NearestNeighborSearch object with input "
"dataset_points of shape {n_dataset, d}.");
// Constructors.
nns.def(py::init<const Tensor &, const Dtype>(), "dataset_points"_a,
"index_dtype"_a = core::Int64);
// Index functions.
nns.def("knn_index", &NearestNeighborSearch::KnnIndex,
"Set index for knn search.");
nns.def(
"fixed_radius_index",
[](NearestNeighborSearch &self, utility::optional<double> radius) {
if (!radius.has_value()) {
return self.FixedRadiusIndex();
} else {
return self.FixedRadiusIndex(radius.value());
}
},
py::arg("radius") = py::none());
nns.def("multi_radius_index", &NearestNeighborSearch::MultiRadiusIndex,
"Set index for multi-radius search.");
nns.def(
"hybrid_index",
[](NearestNeighborSearch &self, utility::optional<double> radius) {
if (!radius.has_value()) {
return self.HybridIndex();
} else {
return self.HybridIndex(radius.value());
}
},
py::arg("radius") = py::none());
// Search functions.
nns.def("knn_search", &NearestNeighborSearch::KnnSearch, "query_points"_a,
"knn"_a, "Perform knn search.");
nns.def(
"fixed_radius_search",
[](NearestNeighborSearch &self, Tensor query_points, double radius,
utility::optional<bool> sort) {
if (!sort.has_value()) {
return self.FixedRadiusSearch(query_points, radius, true);
} else {
return self.FixedRadiusSearch(query_points, radius,
sort.value());
}
},
py::arg("query_points"), py::arg("radius"),
py::arg("sort") = py::none());
nns.def("multi_radius_search", &NearestNeighborSearch::MultiRadiusSearch,
"query_points"_a, "radii"_a,
"Perform multi-radius search. Each query point has an independent "
"radius.");
nns.def("hybrid_search", &NearestNeighborSearch::HybridSearch,
"query_points"_a, "radius"_a, "max_knn"_a,
"Perform hybrid search.");
// Docstrings.
docstring::ClassMethodDocInject(m_nns, "NearestNeighborSearch",
"knn_search",
map_nearest_neighbor_search_method_docs);
docstring::ClassMethodDocInject(m_nns, "NearestNeighborSearch",
"multi_radius_search",
map_nearest_neighbor_search_method_docs);
docstring::ClassMethodDocInject(m_nns, "NearestNeighborSearch",
"fixed_radius_search",
map_nearest_neighbor_search_method_docs);
docstring::ClassMethodDocInject(m_nns, "NearestNeighborSearch",
"hybrid_search",
map_nearest_neighbor_search_method_docs);
}
} // namespace nns
} // namespace core
} // namespace open3d
|
; A007661: Triple factorial numbers a(n) = n!!!, defined by a(n) = n*a(n-3), a(0) = a(1) = 1, a(2) = 2. Sometimes written n!3.
; 1,1,2,3,4,10,18,28,80,162,280,880,1944,3640,12320,29160,58240,209440,524880,1106560,4188800,11022480,24344320,96342400,264539520,608608000,2504902400,7142567040,17041024000,72642169600,214277011200,528271744000,2324549427200,7071141369600,17961239296000,81359229952000,254561089305600,664565853952000,3091650738176000,9927882482918400,26582634158080000,126757680265216000,416971064282572800,1143053268797440000,5577337931669504000,18763697892715776000,52580450364682240000,262134882788466688000,900657498850357248000,2576442067869429760000,13106744139423334400000,45933532441368219648000,133974987529210347520000,694657439389436723200000,2480410751833883860992000,7368624314106569113600000,38900816605808456499200000,141383412854531380076544000,427380210218181008588800000,2295148179742698933452800000,8483004771271882804592640000,26070192823309041523916800000,142299187144047333874073600000,534429300590128616689336320000,1668492340691778657530675200000,9249447164363076701814784000000,35272333838948488701496197120000,111788986826349170054555238400000,628962407176689215723405312000000,2433791034887445720403237601280000,7825229077844441903818866688000000,44656330909544934316361777152000000,175232954511896091869033107292160000,571241722682644258978777268224000000
mov $1,1
lpb $0
mul $1,$0
trn $0,3
lpe
mov $0,$1
|
;
;=============================================================================
; MMC/SD/SDHC/SDXC CARD STORAGE DRIVER
;=============================================================================
;
; 1) TESTING
; - TRY TO TEST GOIDLE, FIND CARD THAT REQUIRES 2 REQUESTS
; - DUAL CARDS
; - TEST XC CARD TYPE DETECTION
; - TRY TO GET INIT TO FAIL, REMOVE DELAYS AT START OF GOIDLE?
;
;------------------------------------------------------------------------------
; SD Signal Active JUHA N8 CSIO PPI UART DSD MK4
; ------------ ------- ------- ------- ------- ------- ------- ------- -------
; CS (DAT3) LO -> RTC:2 RTC:2 RTC:2 ~PC:4 ~MCR:3 OPR:2 MK4_SD:2
; CLK HI -> RTC:1 RTC:1 N/A PC:1 ~MCR:2 OPR:1 N/A
; DI (CMD) HI -> RTC:0 RTC:0 N/A PC:0 ~MCR:0 OPR:0 N/A
; DO (DAT0) HI -> RTC:7 RTC:6 N/A PB:7 ~MSR:5 OPR:0 N/A
;------------------------------------------------------------------------------
;
; CS = CHIP SELECT (AKA DAT3 FOR NON-SPI MODE)
; CLK = CLOCK
; DI = DATA IN (HOST -> CARD, AKA CMD FOR NON-SPI MODE)
; DO = DATA OUT (HOST <- CARD, AKA DAT0 FOR NON-SPI MODE)
;
; NOTES:
; 1) SIGNAL NAMES ARE FROM THE SD CARD SPEC AND ARE NAMED FROM THE
; PERSPECTIVE OF THE SD CARD (SLAVE):
; DI = DATA IN: HOST -> CARD = MOSI (MASTER OUT/SLAVE IN)
; DO = DATA OUT: HOST <- CARD = MISO (MASTER IN/SLAVE OUT)
;
; 2) THE QUIESCENT STATE OF THE OUTPUT SIGNALS (HOST -> CARD) IS:
; CS = HI (NOT SELECTED)
; CLK = LO (HI FOR CSIO)
; DI = HI (ACTIVE IS THE NATURAL/DEFAULT STATE FOR DATA IN)
;
; 3) SPI MODE 0 IMPLEMENTATION IS USED (CPOL=0, CPHA=0)
; THE DATA MUST BE AVAILABLE BEFORE THE FIRST CLOCK SIGNAL RISING.
; THE CLOCK IDLE STATE IS ZERO. THE DATA ON MISO AND MOSI LINES
; MUST BE STABLE WHILE THE CLOCK IS HIGH AND CAN BE CHANGED WHEN
; THE CLOCK IS LOW. THE DATA IS CAPTURED ON THE CLOCK'S LOW-TO-HIGH
; TRANSITION AND PROPAGATED ON HIGH-TO-LOW CLOCK TRANSITION.
;
; NOTE: THE CSIO IMPLEMENTATION (INCLUDE MK4) USES SPI MODE 4
; (CPOL=1, CPHA=1) BECAUSE THAT IS THE WAY THAT THE Z180 CSIO
; INTERFACE WORKS. ALL OF THE CLOCK TRANSITIONS LISTED ABOVE
; ARE REVERSED FOR CSIO.
;
; 4) DI SHOULD BE LEFT HI (ACTIVE) WHENEVER UNUSED (FOR EXAMPLE, WHEN
; HOST IS RECEIVING DATA (HOST <- CARD)).
;
;------------------------------------------------------------------------------
;
; === R1 RESPONSE ===
; ALL COMMAND RESPONSES START WITH R1
;
; 7 6 5 4 3 2 1 0
; +---+---+---+---+---+---+---+---+
; | 0 | X | X | X | X | X | X | X |
; +---+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; | | | | | | |
; | | | | | | +--- IDLE
; | | | | | +------- ERASE RESET
; | | | | +----------- ILLEGAL COMMAND
; | | | +--------------- COM CRC ERROR
; | | +------------------- ERASE SEQUENCE ERROR
; | +----------------------- ADDRESS ERROR
; +--------------------------- PARAMETER ERROR
;
; === DATA ERROR TOKEN ===
;
; 7 6 5 4 3 2 1 0
; +---+---+---+---+---+---+---+---+
; | 0 | 0 | 0 | 0 | X | X | X | X |
; +---+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; | | | |
; | | | +--- ERROR - GENERAL OR UNKNOWN ERROR
; | | +------- CC ERROR - INTERNAL CARD CONTROLER ERROR
; | +----------- CARD ECC FAILED - CARD INTERNAL ECC FAILED TO CORRECT DATA
; +--------------- OUT OF RANGE - PARAMAETER OUT OF RANGE ALLOWED FOR CARD
;
#IF (SDMODE == SDMODE_JUHA) ; JUHA MINI-BOARD
SD_DEVCNT .EQU 1 ; NUMBER OF PHYSICAL UNITS (SOCKETS)
SD_OPRREG .EQU RTC ; USES RTC LATCHES FOR OPERATION
SD_OPRDEF .EQU %00000001 ; QUIESCENT STATE???
SD_INPREG .EQU RTC ; INPUT REGISTER IS RTC
SD_CS .EQU %00000100 ; RTC:2 IS SELECT
SD_CLK .EQU %00000010 ; RTC:1 IS CLOCK
SD_DI .EQU %00000001 ; RTC:0 IS DATA IN (CARD <- CPU)
SD_DO .EQU %10000000 ; RTC:7 IS DATA OUT (CARD -> CPU)
#ENDIF
;
#IF (SDMODE == SDMODE_N8) ; UNMODIFIED N8-2511
SD_DEVCNT .EQU 1 ; NUMBER OF PHYSICAL UNITS (SOCKETS)
SD_OPRREG .EQU RTC ; USES RTC LATCHES FOR OPERATION
SD_OPRDEF .EQU %00000001 ; QUIESCENT STATE???
SD_INPREG .EQU RTC ; INPUT REGISTER IS RTC
SD_CS .EQU %00000100 ; RTC:2 IS SELECT
SD_CLK .EQU %00000010 ; RTC:1 IS CLOCK
SD_DI .EQU %00000001 ; RTC:0 IS DATA IN (CARD <- CPU)
SD_DO .EQU %01000000 ; RTC:6 IS DATA OUT (CARD -> CPU)
#ENDIF
;
#IF (SDMODE == SDMODE_CSIO) ; N8-2312
SD_DEVCNT .EQU 1 ; NUMBER OF PHYSICAL UNITS (SOCKETS)
SD_OPRREG .EQU RTC ; USES RTC LATCHES FOR OPERATION
SD_OPRDEF .EQU %00000000 ; QUIESCENT STATE
SD_CS .EQU %00000100 ; RTC:2 IS SELECT
SD_CNTR .EQU Z180_CNTR
SD_TRDR .EQU Z180_TRDR
#ENDIF
;
#IF (SDMODE == SDMODE_PPI) ; PPISD
SD_DEVCNT .EQU 1 ; NUMBER OF PHYSICAL UNITS (SOCKETS)
SD_PPIBASE .EQU PPIBASE ; BASE IO PORT FOR PPI
SD_PPIB .EQU PPIBASE + 1 ; PPI PORT B (INPUT: DOUT)
SD_PPIC .EQU PPIBASE + 2 ; PPI PORT C (OUTPUT: CS, CLK, DIN)
SD_PPIX .EQU PPIBASE + 3 ; PPI CONTROL PORT
SD_OPRREG .EQU SD_PPIC ; PPI PORT C IS OPR REG
SD_OPRDEF .EQU %00110001 ; CS HI, DI HI
SD_INPREG .EQU SD_PPIB ; INPUT REGISTER IS PPI PORT B
SD_CS .EQU %00010000 ; PPIC:4 IS SELECT
SD_CLK .EQU %00000010 ; PPIC:1 IS CLOCK
SD_DI .EQU %00000001 ; PPIC:0 IS DATA IN (CARD <- CPU)
SD_DO .EQU %10000000 ; PPIB:7 IS DATA OUT (CARD -> CPU)
#ENDIF
;
#IF (SDMODE == SDMODE_UART)
SD_DEVCNT .EQU 1 ; NUMBER OF PHYSICAL UNITS (SOCKETS)
SD_OPRREG .EQU SIO_MCR ; UART MCR PORT (OUTPUT: CS, CLK, DIN)
SD_OPRDEF .EQU %00001100 ; QUIESCENT STATE
SD_INPREG .EQU SIO_MSR ; INPUT REGISTER IS MSR
SD_CS .EQU %00001000 ; UART MCR:3 IS SELECT
SD_CLK .EQU %00000100 ; UART MCR:2 IS CLOCK
SD_DI .EQU %00000001 ; UART MCR:0 IS DATA IN (CARD <- CPU)
SD_DO .EQU %00100000 ; UART MSR:5 IS DATA OUT (CARD -> CPU)
#ENDIF
;
#IF (SDMODE == SDMODE_DSD) ; DUAL SD
SD_DEVCNT .EQU 2 ; NUMBER OF PHYSICAL UNITS (SOCKETS)
SD_OPRREG .EQU $08 ; DEDICATED OPERATIONS REGISTER
SD_OPRDEF .EQU %00000001 ; QUIESCENT STATE
SD_INPREG .EQU SD_OPRREG ; INPUT REGISTER IS OPRREG
SD_SELREG .EQU SD_OPRREG + 1 ; DEDICATED SELECTION REGISTER
SD_SELDEF .EQU %00000000 ; SELECTION REGISTER DEFAULT
SD_CS .EQU %00000100 ; RTC:2 IS SELECT
SD_CLK .EQU %00000010 ; RTC:1 IS CLOCK
SD_DI .EQU %00000001 ; RTC:6 IS DATA IN (CARD <- CPU)
SD_DO .EQU %00000001 ; RTC:0 IS DATA OUT (CARD -> CPU)
#ENDIF
;
#IF (SDMODE == SDMODE_MK4) ; MARK IV (CSIO STYLE INTERFACE)
SD_DEVCNT .EQU 1 ; NUMBER OF PHYSICAL UNITS (SOCKETS)
SD_OPRREG .EQU MK4_SD ; DEDICATED MK4 SDCARD REGISTER
SD_OPRDEF .EQU %00000000 ; QUIESCENT STATE
SD_CS .EQU %00000100 ; SELECT ACTIVE
SD_CNTR .EQU Z180_CNTR
SD_TRDR .EQU Z180_TRDR
#ENDIF
;
; SD CARD COMMANDS
;
SD_CMD_GO_IDLE_STATE .EQU $40 + 0 ; $40, CMD0 -> R1
SD_CMD_SEND_OP_COND .EQU $40 + 1 ; $41, CMD1 -> R1
SD_CMD_SEND_IF_COND .EQU $40 + 8 ; $48, CMD8 -> R7
SD_CMD_SEND_CSD .EQU $40 + 9 ; $49, CMD9 -> R1
SD_CMD_SEND_CID .EQU $40 + 10 ; $4A, CMD10 -> R1
SD_CMD_SET_BLOCKLEN .EQU $40 + 16 ; $50, CMD16 -> R1
SD_CMD_READ_SNGL_BLK .EQU $40 + 17 ; $51, CMD17 -> R1
SD_CMD_WRITE_BLOCK .EQU $40 + 24 ; $58, CMD24 -> R1
SD_CMD_APP_CMD .EQU $40 + 55 ; $77, CMD55 -> R1
SD_CMD_READ_OCR .EQU $40 + 58 ; $7A, CMD58 -> R3
;
; SD CARD APPLICATION COMMANDS (PRECEDED BY APP_CMD COMMAND)
;
SD_ACMD_SEND_OP_COND .EQU $40 + 41 ; $69, ACMD41 -> R1
SD_ACMD_SEND_SCR .EQU $40 + 51 ; $73, ACMD51 -> R1
;
; SD CARD TYPE
;
SD_TYPEUNK .EQU 0 ; CARD TYPE UNKNOWN/UNDETERMINED
SD_TYPEMMC .EQU 1 ; MULTIMEDIA CARD (MMC STANDARD)
SD_TYPESDSC .EQU 2 ; SDSC CARD (V1)
SD_TYPESDHC .EQU 3 ; SDHC CARD (V2)
SD_TYPESDXC .EQU 4 ; SDXC CARD (V3)
;
; SD CARD STATUS (SD_STAT)
;
SD_STOK .EQU 0 ; OK
SD_STINVUNIT .EQU -1 ; INVALID UNIT
SD_STRDYTO .EQU -2 ; TIMEOUT WAITING FOR CARD TO BE READY
SD_STINITTO .EQU -3 ; INITIALIZATOIN TIMEOUT
SD_STCMDTO .EQU -4 ; TIMEOUT WAITING FOR COMMAND RESPONSE
SD_STCMDERR .EQU -5 ; COMMAND ERROR OCCURRED (REF SD_RC)
SD_STDATAERR .EQU -6 ; DATA ERROR OCCURRED (REF SD_TOK)
SD_STDATATO .EQU -7 ; DATA TRANSFER TIMEOUT
SD_STCRCERR .EQU -8 ; CRC ERROR ON RECEIVED DATA PACKET
SD_STNOMEDIA .EQU -9 ; NO MEDIA IN CONNECTOR
SD_STWRTPROT .EQU -10 ; ATTEMPT TO WRITE TO WRITE PROTECTED MEDIA
;
; IDE DEVICE CONFIGURATION
;
SD_CFGSIZ .EQU 12 ; SIZE OF CFG TBL ENTRIES
;
; PER DEVICE DATA OFFSETS
;
SD_DEV .EQU 0 ; OFFSET OF DEVICE NUMBER (BYTE)
SD_STAT .EQU 1 ; LAST STATUS (BYTE)
SD_TYPE .EQU 2 ; DEVICE TYPE (BYTE)
SD_FLAGS .EQU 3 ; FLAG BITS (BYTE)
SD_MEDCAP .EQU 4 ; MEDIA CAPACITY (DWORD)
SD_LBA .EQU 8 ; OFFSET OF LBA (DWORD)
;
SD_CFGTBL:
; DEVICE 0, PRIMARY MASTER
.DB 0 ; DRIVER DEVICE NUMBER
.DB 0 ; DEVICE STATUS
.DB 0 ; DEVICE TYPE
.DB 0 ; FLAGS BYTE
.DW 0,0 ; DEVICE CAPACITY
.DW 0,0 ; CURRENT LBA
#IF (SD_DEVCNT >= 2)
; DEVICE 1, PRIMARY SLAVE
.DB 1 ; DRIVER DEVICE NUMBER
.DB 0 ; DEVICE STATUS
.DB 0 ; DEVICE TYPE
.DB 0 ; FLAGS BYTE
.DW 0,0 ; DEVICE CAPACITY
.DW 0,0 ; CURRENT LBA
#ENDIF
;
#IF ($ - SD_CFGTBL) != (SD_DEVCNT * SD_CFGSIZ)
.ECHO "*** INVALID SD CONFIG TABLE ***\n"
#ENDIF
;
.DB $FF ; END MARKER
;
;=============================================================================
; INITIALIZATION ENTRY POINT
;=============================================================================
;
SD_INIT:
CALL NEWLINE ; FORMATTING
PRTS("SD:$")
;
#IF (SDMODE == SDMODE_JUHA)
PRTS(" MODE=JUHA$")
PRTS(" IO=0x$")
LD A,SD_OPRREG
CALL PRTHEXBYTE
#ENDIF
;
#IF (SDMODE == SDMODE_N8)
PRTS(" MODE=N8$")
PRTS(" IO=0x$")
LD A,SD_OPRREG
CALL PRTHEXBYTE
#ENDIF
;
#IF (SDMODE == SDMODE_CSIO)
PRTS(" MODE=CSIO$")
#IF (SDCSIOFAST)
PRTS(" FAST$")
#ENDIF
PRTS(" OPR=0x$")
LD A,SD_OPRREG
CALL PRTHEXBYTE
PRTS(" CNTR=0x$")
LD A,SD_CNTR
CALL PRTHEXBYTE
PRTS(" TRDR=0x$")
LD A,SD_TRDR
CALL PRTHEXBYTE
#ENDIF
;
#IF (SDMODE == SDMODE_PPI)
PRTS(" MODE=PPI$")
PRTS(" IO=0x$")
LD A,SD_PPIBASE
CALL PRTHEXBYTE
#ENDIF
;
#IF (SDMODE == SDMODE_UART)
PRTS(" MODE=UART$")
PRTS(" MCR=0x$")
LD A,SIO_MCR
CALL PRTHEXBYTE
PRTS(" MSR=0x$")
LD A,SIO_MSR
CALL PRTHEXBYTE
#ENDIF
;
#IF (SDMODE == SDMODE_DSD)
PRTS(" MODE=DSD$")
PRTS(" OPR=0x$")
LD A,SD_OPRREG
CALL PRTHEXBYTE
PRTS(" SEL=0x$")
LD A,SD_SELREG
CALL PRTHEXBYTE
#ENDIF
;
#IF (SDMODE == SDMODE_MK4)
PRTS(" MODE=MK4$")
#IF (SDCSIOFAST)
PRTS(" FAST$")
#ENDIF
PRTS(" OPR=0x$")
LD A,SD_OPRREG
CALL PRTHEXBYTE
PRTS(" CNTR=0x$")
LD A,SD_CNTR
CALL PRTHEXBYTE
PRTS(" TRDR=0x$")
LD A,SD_TRDR
CALL PRTHEXBYTE
#ENDIF
;
CALL SD_PROBE ; CHECK FOR HARDWARE
JR Z,SD_INIT00 ; CONTINUE IF PRESENT
;
; HARDWARE NOT PRESENT
PRTS(" NOT PRESENT$")
OR $FF ; SIGNAL FAILURE
RET
;
SD_INIT00:
;
; SETUP THE DISPATCH TABLE ENTRIES
;
PRTS(" DEVICES=$")
LD A,SD_DEVCNT
CALL PRTDECB
;
; SETUP THE DISPATCH TABLE ENTRIES
;
LD B,SD_DEVCNT ; LOOP CONTROL
LD IY,SD_CFGTBL ; START OF CFG TABLE
SD_INIT0:
PUSH BC ; SAVE LOOP CONTROL
LD BC,SD_FNTBL ; BC := FUNC TABLE ADR
PUSH IY ; CFG ENTRY POINTER
POP DE ; COPY TO DE
CALL DIO_ADDENT ; ADD ENTRY, BC IS NOT DESTROYED
LD BC,SD_CFGSIZ ; SIZE OF CFG ENTRY
ADD IY,BC ; BUMP IY TO NEXT ENTRY
POP BC ; RESTORE BC
DJNZ SD_INIT0 ; LOOP AS NEEDED
;
; INITIALIZE THE SD INTERFACE NOW
CALL SD_SETUP ; DO HARDWARE SETUP/INIT
RET NZ ; ABORT ON ERROR
;
; INITIALIZE INDIVIDUAL UNIT(S) AND DISPLAY DEVICE INVENTORY
LD B,SD_DEVCNT ; INIT LOOP COUNTER TO DEVICE COUNT
LD IY,SD_CFGTBL ; START OF CFG TABLE
SD_INIT1:
PUSH BC ; SAVE LOOP COUNTER/INDEX
CALL SD_INITUNIT ; INITIALIZE IT
#IF (SDTRACE < 2)
CALL NZ,SD_PRTSTAT ; IF ERROR, SHOW IT
#ENDIF
LD BC,SD_CFGSIZ ; SIZE OF CFG ENTRY
ADD IY,BC ; BUMP IY TO NEXT ENTRY
POP BC ; RESTORE LOOP CONTROL
DJNZ SD_INIT1 ; DECREMENT LOOP COUNTER AND LOOP AS NEEDED
;
RET ; DONE
;
; INITIALIZE UNIT DESIGNATED IN ACCUM
;
SD_INITUNIT
CALL SD_SELUNIT ; SELECT UNIT
RET NZ ; ABORT ON ERROR
;
CALL SD_INITCARD ; INIT THE SELECTED CARD
RET NZ ; ABORT ON ERROR
;
CALL SD_PRTPREFIX
;
; PRINT CARD TYPE
LD A,(IY+SD_TYPE) ; GET CARD TYPE VALUE TO A
LD DE,SD_STR_TYPEMMC
CP SD_TYPEMMC
JR Z,SD_INITUNIT1
LD DE,SD_STR_TYPESDSC
CP SD_TYPESDSC
JR Z,SD_INITUNIT1
LD DE,SD_STR_TYPESDHC
CP SD_TYPESDHC
JR Z,SD_INITUNIT1
LD DE,SD_STR_TYPESDXC
CP SD_TYPESDXC
JR Z,SD_INITUNIT1
LD DE,SD_STR_TYPEUNK
SD_INITUNIT1:
CALL WRITESTR
; GET CID (WHICH CONTAINS PRODUCT NAME)
LD A,SD_CMD_SEND_CID ; SEND_CID
CALL SD_INITCMD ; SETUP COMMAND BUFFER
CALL SD_EXECCMD ; RUN COMMAND
RET NZ ; ABORT ON ERROR
LD BC,16 ; 16 BYTES OF CID
LD HL,SD_BUF
CALL SD_GETDATA
CALL SD_DONE
JP NZ,SD_ERRDATA ; DATA XFER ERROR
#IF (SDTRACE >= 3)
CALL SD_PRTPREFIX
LD DE,SD_STR_CID
CALL WRITESTR
LD DE,SD_BUF
LD A,16
CALL PRTHEXBUF
#ENDIF
; PRINT PRODUCT NAME
PRTS(" NAME=$") ; PRINT LABEL
LD B,5 ; PREPARE TO PRINT 5 BYTES
LD HL,SD_BUF + 3 ; AT BYTE OFFSET 3 IN RESULT BUFFER
SD_INITUNIT2:
LD A,(HL) ; GET NEXT BYTE
CALL COUT ; PRINT IT
INC HL ; POINT TO NEXT BYTE
DJNZ SD_INITUNIT2 ; LOOP FOR ALL 5 BYTES
;
; PRINT STORAGE CAPACITY (BLOCK COUNT)
PRTS(" BLOCKS=0x$") ; PRINT FIELD LABEL
LD A,SD_MEDCAP ; OFFSET TO CAPACITY FIELD
CALL LDHLIYA ; HL := IY + A, REG A TRASHED
CALL LD32 ; GET THE CAPACITY VALUE
CALL PRTHEX32 ; PRINT HEX VALUE
;
; PRINT STORAGE SIZE IN MB
PRTS(" SIZE=$") ; PRINT FIELD LABEL
LD B,11 ; 11 BIT SHIFT TO CONVERT BLOCKS --> MB
CALL SRL32 ; RIGHT SHIFT
CALL PRTDEC ; PRINT LOW WORD IN DECIMAL (HIGH WORD DISCARDED)
PRTS("MB$") ; PRINT SUFFIX
;
; CHECK FOR WRITE PROTECT AND NOTIFY USER IF SO
CALL SD_CHKWP ; WRITE PROTECTED?
RET Z ; IF NOT, DONE
PRTS(" WP$") ; NOTIFY USER
;
RET ; DONE
;
;----------------------------------------------------------------------
; PROBE FOR SD HARDWARE
;----------------------------------------------------------------------
;
; ON RETURN, ZF SET INDICATES HARDWARE FOUND
;
SD_PROBE:
;
#IF (SDMODE == SDMODE_DSD)
; ON DSD, SELREG, BIT 0 IS READ BACK AS WRITTEN, BIT 1
; IS ALWAYS READ AS ZERO. TO TEST FOR EXISTENCE, WE
; WRITE 00 AND MAKE SURE IT READS BACK AS 00, THEN WE
; WRITE 11 AND MAKE SURE IT READS BACK AS 01.
LD C,SD_SELREG ; USE C TO ADDRESS PORT
XOR A ; A := 0
OUT (C),A ; SELREG := 0
IN A,(C) ; READ SELREG BACK
AND $03 ; ISOLATE 2 LOWEST BITS
CP $00 ; BOTH BITS SHOULD BE 0
RET NZ ; FAIL IF NOT
LD A,$03 ; SET 2 LOWEST BITS
OUT (C),A ; DO IT
IN A,(C) ; READ SELREG BACK
AND $03 ; ISOLATE 2 LOWEST BITS
CP $01 ; SHOULD READ BACK AS $01
RET ; RETURN W/ ZF SET AS NEEDED
#ENDIF
;
XOR A ; SIGNAL SUCCESS
RET ; AND RETURN
;
;=============================================================================
; DRIVER FUNCTION TABLE
;=============================================================================
;
SD_FNTBL:
.DW SD_STATUS
.DW SD_RESET
.DW SD_SEEK
.DW SD_READ
.DW SD_WRITE
.DW SD_VERIFY
.DW SD_FORMAT
.DW SD_DEVICE
.DW SD_MEDIA
.DW SD_DEFMED
.DW SD_CAP
.DW SD_GEOM
#IF (($ - SD_FNTBL) != (DIO_FNCNT * 2))
.ECHO "*** INVALID IDE FUNCTION TABLE ***\n"
#ENDIF
;
SD_VERIFY:
SD_FORMAT:
SD_DEFMED:
CALL PANIC ; INVALID SUB-FUNCTION
;
;
;
SD_READ:
LD A,SD_CMD_READ_SNGL_BLK ; SETUP FOR SINGLE BLOCK READ CMD
JR SD_IO ; CONTINUE TO GENERIC IO ROUTINE
;
;
;
SD_WRITE:
LD A,SD_CMD_WRITE_BLOCK ; SETUP FOR BLOCK WRITE CMD
JR SD_IO ; CONTINUE TO GENERIC IO ROUTINE
;
;
;
SD_IO:
LD (SD_CMDVAL),A ; SAVE THE SD CARD COMMAND
LD (SD_DSKBUF),HL ; SAVE DISK BUFFER ADDRESS
LD A,E ; GET BLOCK COUNT REQUESTED
LD (SD_BLKCNT),A ; ... AND SAVE IT
OR A ; SET FLAGS
RET Z ; ZERO SECTOR I/O, RETURN W/ E=0 & A=0
#IF (SDTRACE == 1)
LD HL,SD_PRTERR ; SET UP SD_PRTERR
PUSH HL ; ... TO FILTER ALL EXITS
#ENDIF
CALL SD_SELUNIT ; HARDWARE SELECTION OF TARGET UNIT
RET NZ ; ABORT ON ERROR
LD A,(SD_CMDVAL) ; GET COMMAND VALUE
CP SD_CMD_READ_SNGL_BLK ; IS THIS A READ?
CALL NZ,SD_CHKWP ; CHECK FOR WRITE PROTECT IF NOT A READ
JP NZ,SD_WRTPROT ; HANDLE WRITE PROTECT ERR
LD A,(SD_BLKCNT) ; BLOCK COUNT TO A
LD E,A ; ... AND TO E IN CASE OF ZERO ERR BELOW
OR A ; SET FLAGS
RET Z ; ZERO SECTOR I/O, RETURN W/ E=0 & A=0
LD B,A ; INIT SECTOR DOWNCOUNTER
LD C,0 ; INIT SECTOR READ/WRITE COUNT
SD_IO1:
PUSH BC ; SAVE COUNTERS
LD A,(SD_CMDVAL) ; SET COMMAND
LD C,A ; ... AND PUT IN C
CALL SD_SECTIO ; DO SECTOR I/O
JR NZ,SD_IO2 ; IF ERROR, SKIP INCREMENT
; INCREMENT LBA
LD A,SD_LBA ; LBA OFFSET
CALL LDHLIYA ; HL := IY + A, REG A TRASHED
CALL INC32HL ; INCREMENT THE VALUE
; INCREMENT DMA
LD HL,SD_DSKBUF+1 ; POINT TO MSB OF BUFFER ADR
INC (HL) ; BUMP DMA BY
INC (HL) ; ... 512 BYTES
XOR A ; SIGNAL SUCCESS
SD_IO2:
POP BC ; RECOVER COUNTERS
JR NZ,SD_IO3 ; IF ERROR, BAIL OUT
INC C ; BUMP COUNT OF SECTORS READ
DJNZ SD_IO1 ; LOOP AS NEEDED
SD_IO3:
LD E,C ; SECTOR READ COUNT TO E
LD HL,(SD_DSKBUF) ; CURRENT DMA TO HL
OR A ; SET FLAGS BASED ON RETURN CODE
RET ; AND RETURN, A HAS RETURN CODE
;
;
;
SD_STATUS:
; RETURN DEVICE STATUS
LD A,(IY+SD_STAT) ; GET STATUS OF SELECTED DEVICE
OR A ; SET FLAGS
RET ; AND RETURN
;
;
;
SD_RESET:
CALL SD_SELUNIT ; SET CUR UNIT
; RE-INITIALIZE THE SD CARD TO ACCOMMODATE HOT SWAPPING
CALL SD_INITCARD ; RE-INIT SELECTED UNIT
#IF (SDTRACE == 1)
CALL SD_PRTERR ; PRINT ANY ERRORS
#ENDIF
OR A ; SET RESULT FLAGS
RET
;
;
;
SD_DEVICE:
LD D,DIODEV_SD ; D := DEVICE TYPE
LD E,(IY+SD_DEV) ; E := PHYSICAL DEVICE NUMBER
LD C,%01010000 ; C := ATTRIBUTES, REMOVABLE, SD CARD
XOR A ; SIGNAL SUCCESS
RET
;
;
;
SD_MEDIA:
LD A,E ; GET FLAGS
OR A ; SET FLAGS
JR Z,SD_MEDIA2 ; JUST REPORT CURRENT STATUS AND MEDIA
;
; GET CURRENT STATUS
LD A,(IY+SD_STAT) ; GET STATUS
OR A ; SET FLAGS
JR NZ,SD_MEDIA1 ; ERROR ACTIVE, GO RIGHT TO RESET
;
; USE SEND_CSD TO CHECK CARD
CALL SD_SELUNIT ; SET CUR UNIT
LD A,SD_CMD_SEND_CSD ; SEND_CSD
CALL SD_INITCMD ; SETUP COMMAND BUFFER
CALL SD_EXECCMD ; EXECUTE COMMAND
JR NZ,SD_MEDIA1 ; ERROR, NEED RESET
LD BC,16 ; 16 BYTES OF CSD
LD HL,SD_BUF ; PUT IN OUR PRIVATE BUFFER
CALL SD_GETDATA ; GET THE DATA
CALL SD_DONE ; CLOSE THE TRANSACTION
JR Z,SD_MEDIA2 ; IF SUCCESS, BYPASS RESET
;
SD_MEDIA1:
CALL SD_RESET ; RESET CARD
;
SD_MEDIA2:
LD A,(IY+SD_STAT) ; GET STATUS
OR A ; SET FLAGS
LD D,0 ; NO MEDIA CHANGE DETECTED
LD E,MID_HD ; ASSUME WE ARE OK
RET Z ; RETURN IF GOOD INIT
LD E,MID_NONE ; SIGNAL NO MEDIA
RET ; AND RETURN
;
;
;
;
SD_SEEK:
BIT 7,D ; CHECK FOR LBA FLAG
CALL Z,HB_CHS2LBA ; CLEAR MEANS CHS, CONVERT TO LBA
RES 7,D ; CLEAR FLAG REGARDLESS (DOES NO HARM IF ALREADY LBA)
LD (IY+SD_LBA+0),L ; SAVE NEW LBA
LD (IY+SD_LBA+1),H ; ...
LD (IY+SD_LBA+2),E ; ...
LD (IY+SD_LBA+3),D ; ...
XOR A ; SIGNAL SUCCESS
RET ; AND RETURN
;
;
;
SD_CAP:
LD A,(IY+SD_STAT) ; GET STATUS
PUSH AF ; SAVE IT
LD A,SD_MEDCAP ; OFFSET TO CAPACITY FIELD
CALL LDHLIYA ; HL := IY + A, REG A TRASHED
CALL LD32 ; GET THE CURRENT CAPACITY INTO DE:HL
LD BC,512 ; 512 BYTES PER BLOCK
POP AF ; RECOVER STATUS
OR A ; SET FLAGS
RET
;
;
;
SD_GEOM:
; FOR LBA, WE SIMULATE CHS ACCESS USING 16 HEADS AND 16 SECTORS
; RETURN HS:CC -> DE:HL, SET HIGH BIT OF D TO INDICATE LBA CAPABLE
CALL SD_CAP ; GET TOTAL BLOCKS IN DE:HL, BLOCK SIZE TO BC
LD L,H ; DIVIDE BY 256 FOR # TRACKS
LD H,E ; ... HIGH BYTE DISCARDED, RESULT IN HL
LD D,16 | $80 ; HEADS / CYL = 16, SET LBA BIT
LD E,16 ; SECTORS / TRACK = 16
RET ; DONE, A STILL HAS SD_CAP STATUS
;
;=============================================================================
; FUNCTION SUPPORT ROUTINES
;=============================================================================
;
; (RE)INITIALIZE CARD
;
SD_INITCARD:
;
;; CLEAR OUT UNIT SPECIFIC DATA
;SD_DPTR(0) ; SET HL TO START OF UNIT DATA
;LD BC,SD_UNITDATALEN
;XOR A
;CALL FILL
;
CALL SD_CHKCD ; CHECK CARD DETECT
JP Z,SD_NOMEDIA ; Z=NO MEDIA, HANDLE IF SO
;
; WAKE UP THE CARD, KEEP DIN HI (ASSERTED) AND /CS HI (DEASSERTED)
LD B,$10 ; MIN 74 CLOCKS REQUIRED, WE USE 128 ($10 * 8)
SD_INITCARD1:
LD A,$FF ; KEEP DIN HI
PUSH BC ; SAVE LOOP CONTROL
CALL SD_PUT ; SEND 8 CLOCKS
POP BC ; RESTORE LOOP CONTROL
DJNZ SD_INITCARD1 ; LOOP AS NEEDED
;
; PUT CARD IN IDLE STATE
CALL SD_GOIDLE ; GO TO IDLE
RET NZ ; ABORT IF FAILED
;
SD_INITCARD2:
LD (IY+SD_TYPE),SD_TYPESDSC ; ASSUME SDSC CARD TYPE
;
; CMD8 IS REQUIRED FOR V2 CARDS. FAILURE HERE IS OK AND
; JUST MEANS THAT IT IS A V1 CARD
LD A,SD_CMD_SEND_IF_COND ; SEND_IF_COND
CALL SD_INITCMD ; SETUP COMMAND BUFFER
LD HL,SD_CMDP2 ; POINT TO 3RD PARM BYTE
LD (HL),1 ; VHS=1, 2.7-3.6V
INC HL ; POINT TO 4TH PARM BYTE
LD (HL),$AA ; CHECK PATTERN
INC HL ; POINT TO CRC
LD (HL),$87 ; ... AND SET IT TO KNOWN VALUE OF $87
CALL SD_EXECCMDND ; EXEC COMMAND W/ NO DATA RETURNED
;
; GET CARD OUT OF IDLE STATE BY SENDING SD_APP_OP_COND
; REPEATEDLY UNTIL IDLE BIT IS CLEAR
LD A,0
LD (SD_LCNT),A
SD_INITCARD3:
; DELAY A BIT PER SPEC
LD DE,300 ; 16US * 300 = ~5MS
CALL VDELAY ; CPU SPEED NORMALIZED DELAY
; SEND APP CMD INTRODUCER
CALL SD_EXECACMD ; SEND APP COMMAND INTRODUCER
CP SD_STCMDERR ; COMMAND ERROR?
JR Z,SD_INITCARD3A ; IF SO, TRY MMC CARD INIT
OR A ; SET FLAGS
RET NZ ; ABORT IF ANY OTHER ERROR
; SEND APP_OP_COND
LD A,SD_ACMD_SEND_OP_COND ; SD_APP_OP_COND
CALL SD_INITCMD ; SETUP COMMAND BUFFER
LD A,$40 ; P0 = $40 INDICATES WE SUPPORT V2 CARDS
LD (SD_CMDP0),A ; SET COMMAND PARM 0
CALL SD_EXECCMDND ; EXEC COMMAND W/ NO DATA RETURNED
RET NZ ; ABORT ON ERROR
; CHECK FOR IDLE, EXIT LOOP IF IDLE CLEARED
LD A,(SD_RC) ; GET CARD RESULT CODE
OR A ; SET FLAGS
JR Z,SD_INITCARD4 ; IF IDLE BIT CLEAR, EXIT LOOP
; LOOP AS NEEDED
LD HL,SD_LCNT ; POINT TO LOOP COUNTER
DEC (HL) ; DECREMENT LOOP COUNTER
JR NZ,SD_INITCARD3 ; LOOP UNTIL COUNTER EXHAUSTED
JP SD_ERRINITTO ; HANDLE INIT TIMEOUT ERROR
;
SD_INITCARD3A:
; TRY MMC CARD INITIALIZATION
; CALL SEND_OP_COND UNTIL CARD IS READY (NOT IDLE)
LD A,0
LD (SD_LCNT),A
SD_INITCARD3B:
; DELAY A BIT PER SPEC
LD DE,300 ; 16US * 300 = ~5MS
CALL VDELAY ; CPU SPEED NORMALIZED DELAY
; SEND OP_COND COMMAND
LD A,SD_CMD_SEND_OP_COND ; SD_OP_COND
CALL SD_INITCMD ; SETUP COMMAND BUFFER
CALL SD_EXECCMDND ; EXEC COMMAND WITH NO DATA
RET NZ ; ABORT ON ERROR
; CHECK FOR IDLE, EXIT LOOP IF IDLE CLEARED
LD A,(SD_RC) ; GET CARD RESULT CODE
OR A ; SET FLAGS
JR Z,SD_INITCARD3C ; IDLE BIT CLEAR, EXIT LOOP
; LOOP AS NEEDED
LD HL,SD_LCNT ; POINT TO LOOP COUNTER
DEC (HL) ; DECREMENT LOOP COUNTER
JR NZ,SD_INITCARD3B ; LOOP UNTIL COUNTER EXHAUSTED
JP SD_ERRINITTO ; HANDLE INIT TIMEOUT ERROR
;
SD_INITCARD3C:
; SUCCESSFUL MMC CARD INITIALIZATION
LD C,SD_TYPEMMC ; MMC CARD TYPE
JR SD_INITCARD5 ; RESUME FLOW
;
SD_INITCARD4:
; CMD58 RETURNS THE 32 BIT OCR REGISTER (R3), WE WANT TO CHECK
; BIT 30, IF SET THIS IS SDHC/XC CARD
LD A,SD_CMD_READ_OCR ; READ_OCR
CALL SD_INITCMD ; SETUP COMMAND BUFFER
CALL SD_EXECCMD ; EXECUTE COMMAND
RET NZ ; ABORT ON ERROR
; CMD58 WORKED, GET OCR DATA AND SET CARD TYPE
CALL SD_GET ; BITS 31-24
CALL SD_DONE ; FINISH THE TRANSACTION
AND $40 ; ISOLATE BIT 30 (CCS)
LD C,SD_TYPESDSC ; ASSUME V1 CARD
JR Z,SD_INITCARD5 ; IF BIT NOT SET, THIS IS SDSC CARD
;
SD_INITCARD4A:
; ACMD51 RETURNS THE 64 BIT SCR REGISTER (ONLY AVAILABLE ON SDSC AND ABOVE)
; SD_SPEC3 (BIT 47) IS SET IF CARD IS SDXC OR GREATER
CALL SD_EXECACMD ; SEND APP COMMAND INTRODUCER
RET NZ ; ABORT ON ERROR (THIS SHOULD ALWAYS WORK)
LD A,SD_ACMD_SEND_SCR ; APP CMD SEND_SCR
CALL SD_INITCMD ; SETUP COMMAND BUFFER
CALL SD_EXECCMD ; EXECUTE COMMAND
RET NZ ; ABORT ON ERROR (THIS SHOULD ALWAYS WORK)
; ACMD51 SUCCEEDED, NOW GET THE SCR REGISTER CONTENTS
LD BC,8 ; 8 BYTES OF SCR
LD HL,SD_BUF ; PUT IN OUR PRIVATE BUFFER
CALL SD_GETDATA ; GET THE DATA
CALL SD_DONE ; CLOSE THE TRANSACTION
JP NZ,SD_ERRDATA ; DATA XFER ERROR
;
#IF (SDTRACE >= 3)
; IF TRACING, DUMP THE SCR CONTENTS
CALL SD_PRTPREFIX
LD DE,SD_STR_SCR
CALL WRITESTR
LD DE,SD_BUF
LD A,8
CALL PRTHEXBUF
#ENDIF
;
; EXTRACT THE SD_SECURITY FIELD AND SET SDHC/SDXC BASED ON VALUE
LD A,(SD_BUF + 1) ; GET THIRD BYTE (BITS 47-40) (55-48)
AND %01110000 ; ISOLATE SD_SECURITY BITS
CP $40 ; CHECK FOR SDXC VALUE
LD C,SD_TYPESDHC ; ASSUME CARD TYPE = SDHC
JR NZ,SD_INITCARD5 ; IF NOT SDXC, DONE
LD C,SD_TYPESDXC ; OTHERWISE, THIS IS SDXC CARD
;
SD_INITCARD5:
LD (IY+SD_TYPE),C ; SAVE CARD TYPE
#IF (SDTRACE >= 3)
CALL SD_PRTPREFIX
LD DE,SD_STR_SDTYPE
CALL WRITESTR
LD A,C
CALL PRTHEXBYTE
#ENDIF
;
; SET OUR DESIRED BLOCK LENGTH (512 BYTES)
LD A,SD_CMD_SET_BLOCKLEN ; SET_BLOCKLEN
CALL SD_INITCMD ; SETUP COMMAND BUFFER
LD DE,512 ; 512 BYTE BLOCK LENGTH
LD HL,SD_CMDP2 ; PUT VALUE INTO PARMS
LD (HL),D ; ... HIGH WORD (P0, P1) REMAIN ZERO
INC HL ; ... VALUE OF DE GET PUT IN LOW WORD (P2, P3)
LD (HL),E ; ... BUT OBSERVE BIG ENDIAN LAYOUT
CALL SD_EXECCMDND ; EXEC COMMAND W/ NO DATA
RET NZ ; ABORT ON ERROR
#IF ((SDMODE == SDMODE_CSIO) | (SDMODE == SDMODE_MK4))
; PER SPEC, THE CARD SHOULD NOW BE ABLE TO HANDLE FULL SPEED OPERATION
; SO, FOR CSIO OPERATION, WE SET CSIO TO MAXIMUM SPEED
CALL SD_WAITTX ; MAKE SURE WE ARE DONE SENDING
XOR A ; ZERO MEANS MAX SPEED
OUT (Z180_CNTR),A ; NOW SET CSIO PORT
#ENDIF
;
; ISSUE SEND_CSD (TO DERIVE CARD CAPACITY)
LD A,SD_CMD_SEND_CSD ; SEND_CSD
CALL SD_INITCMD ; SETUP COMMAND BUFFER
CALL SD_EXECCMD ; EXECUTE COMMAND
RET NZ ; ABORT ON ERROR
LD BC,16 ; 16 BYTES OF CSD
LD HL,SD_BUF ; PUT IN OUR PRIVATE BUFFER
CALL SD_GETDATA ; GET THE DATA
CALL SD_DONE ; CLOSE THE TRANSACTION
JP NZ,SD_ERRDATA ; DATA XFER ERROR
;
#IF (SDTRACE >= 3)
; IF TRACING, DUMP THE CSD CONTENTS
CALL SD_PRTPREFIX
LD DE,SD_STR_CSD
CALL WRITESTR
LD DE,SD_BUF
LD A,16
CALL PRTHEXBUF
#ENDIF
;
; GET SIZE OF DEVICE IN BLOCKS
LD A,(IY+SD_TYPE) ; GET CARD TYPE
OR A ; SET FLAGS
CALL Z,PANIC ; PANIC IF CARD TYPE UNKNOWN
CP SD_TYPESDHC ; COMPARE TO SDHC (V2)
JP NC,SD_INITCARD8 ; HANDLE SDHC (V2) OR BETTER
JR SD_INITCARD6 ; HANDLE MMC OR SDSC
;
; CAPACITY CALCULATION FOR MMC OR SDSC (V1) CARDS:
; BYTES = (C_SIZE + 1) * 2^(2+C_SIZE_MULT+READ_BL_LEN) = (C_SIZE+1) << (2+C_SIZE_MULT+READ_BL_LEN)
; BLOCKS = BYTES / 512 = BYTES >> 9
;
SD_INITCARD6: ; GET SIZE FOR V1 CARD
PUSH IX ; SAVE IX
LD IX,SD_BUF ; POINT IX TO BUFFER
LD A,(IX+6) ; GET C_SIZE MSB
AND %00000011 ; MASK OFF TOP 6 BITS (NOT PART OF C_SIZE)
LD C,A ; MSB -> C
LD D,(IX+7) ; D
LD E,(IX+8) ; LSB -> E
LD B,6 ; RIGHT SHIFT WHOLE THING BY 6 BITS
SD_INITCARD7:
SRA C ; SHIFT MSB
RR D ; SHIFT NEXT BYTE
RR E ; SHIFT LSB
DJNZ SD_INITCARD7 ; LOOP TILL DONE
PUSH DE ; DE = C_SIZE, SAVE IT
LD A,(IX+9) ; GET C_SIZE_MULT MSB
LD B,(IX+10) ; GET C_SIZE_MULT LSB
SLA B ; SHIFT LEFT MSB
RLA ; SHIFT LEFT LSB
AND %00000111 ; ISOLATE RELEVANT BITS
LD C,A ; C := C_SIZE_MULT
LD A,(IX+5) ; GET READ_BL_LEN
AND %00001111 ; ISLOATE RELEVANT BITS
LD B,A ; B := READ_BL_LEN
; FINAL MULTIPLIER IS 2^(C_SIZE_MULT + READ_BL_LEN + 2)
LD A,B ; READ_BL_LEN
ADD A,C ; AND C_SIZE_MULT
ADD A,2 ; AND 2 MORE BY DEFINITION
; RELOAD C_SIZE AND CONVERT TO 32 BIT VALUE IN DE:HL
POP HL ; RECOVE C_SIZE
INC HL ; ADD 1
LD DE,0 ; HI WORD IS ZERO
; ADJUST TO 512 BYTE BLOCK COUNT
LD B,A ; NORMALIZE TO BYTE COUNT
CALL SLA32 ; BIT SHIFT LEFT ACCORDING TO MULTIPLIERS
LD B,9 ; NORMALIZE TO 512 BYTE BLOCK COUNT
CALL SRL32 ; BIT SHIFT RIGHT 9 BITS
POP IX ; RESTORE IX
JR SD_INITCARD9 ; RECORD VALUE
;
; CAPACITY CALCULATION FOR SDHC/SDXC (V2/V3) CARDS:
; BLOCKS = (C_SIZE + 1) * 1024 = C_SIZE << 10
;
SD_INITCARD8: ; GET SIZE FOR V2 CARD
PUSH IX ; SAVE IX
LD IX,SD_BUF ; POINT IX TO BUFFER
LD A,(IX + 7) ; GET C_SIZE MSB TO A
AND %00111111 ; ISOLATE RELEVANT BITS
LD H,(IX + 8) ; GET NEXT BYTE TO H
LD L,(IX + 9) ; GET C_SIZE LSB TO L
POP IX ; RESTORE IX
; ADD 1 TO C_SIZE IN A:HL
LD DE,1 ; LOAD 1
ADD HL,DE ; ADD TO HL
ADC A,0 ; HANDLE CARRY
; CONVERT TO 32 BIT, A:HL -> DE:HL
LD D,0
LD E,A
; DIVIDE BY 1024 TO NORMALIZE, LEFT SHIFT 10 BITS
LD B,10 ; SHIFT BY 10 BITS
CALL SLA32 ; SHIFT THE 32 BIT VALUE
JR SD_INITCARD9 ; CONTINUE
;
SD_INITCARD9:
; SAVE DERIVED CAPACITY VALUE IN DE:HL
PUSH HL ; SAVE HL
LD A,SD_MEDCAP ; OFFSET TO CAPACITY FIELD
CALL LDHLIYA ; HL := IY + A, REG A TRASHED
PUSH HL ; MOVE ADDRESS
POP BC ; ... TO BC
POP HL ; RECOVER HL
CALL ST32 ; SAVE THE CAPACITY VALUE (DWORD)
;
; RESET CARD STATUS TO 0 (OK)
XOR A ; A := 0 (STATUS = OK)
LD (IY+SD_STAT),A ; SAVE IT
;
RET ; RETURN, A=0, Z SET
; SECTOR I/O
; SD CARD COMMAND BYTE MUST BE PASSED IN C
;
SD_SECTIO:
PUSH BC
CALL SD_CHKCARD ; CHECK / REINIT CARD AS NEEDED
POP BC
RET NZ ; ABORT IF REINIT FAILED
LD A,C ; LOAD SD CARD COMMAND BYTE
CALL SD_INITCMD ; SETUP COMMAND BUFFER
CALL SD_SETADDR ; SETUP LBA ADDRESS
CALL SD_EXECCMD ; EXECUTE COMMAND
RET NZ ; ABORT ON ERROR
LD HL,(SD_DSKBUF)
LD BC,512 ; LENGTH TO READ
LD A,(SD_CMD) ; GET THE COMMAND
CP SD_CMD_READ_SNGL_BLK ; READ_SINGLE_BLOCK?
JR Z,SD_SECTIO1 ; HANDLE READ
CP SD_CMD_WRITE_BLOCK ; WRITE_BLOCK?
JR Z,SD_SECTIO2 ; HANDLE WRITE
CALL PANIC ; PANIC ON ANYTHING ELSE
SD_SECTIO1:
; GET SECTOR DATA
CALL SD_GETDATA ; GET THE BLOCK
JR SD_SECTIO3 ; AND CONTINUE
SD_SECTIO2:
; PUT SECTOR DATA
CALL SD_PUTDATA ; PUT THE BLOCK AND FALL THRU
SD_SECTIO3:
; CONTINUE WITH COMMON CODE
CALL SD_DONE ; CLOSE THE TRANSACTION
RET Z ; RETURN WITH A=0 AND Z SET
JP SD_ERRDATA ; DATA XFER ERROR
;
; CHECK THE SD CARD, ATTEMPT TO REINITIALIZE IF NEEDED
;
SD_CHKCARD:
; FIX: NEED TO CHECK CARD DETECT HERE AND
; HANDLE AS ERROR.
;
LD A,(IY+SD_STAT) ; GET CURRENT STATUS
OR A ; SET FLAGS
RET Z ; RETURN WITH A=0 AND Z SET
JP SD_INITCARD ; OTHERWISE INIT CARD
;
; CONVERT LBA ADDRESS TO CARD SPECIFIC ADDRESS IN CMD PARMS
; V1 CARDS REQUIRE BYTE ADDRESSING, SO A TRANSLATION IS DONE IN THAT CASE
;
SD_SETADDR:
LD A,(IY+SD_TYPE) ; GET CARD TYPE
PUSH AF ; SAVE IT
LD A,SD_LBA ; OFFSET OF LBA VALUE
CALL LDHLIYA ; HL := IY + A, REG A TRASHED
CALL LD32 ; LOAD IT TO DE:HL, AF IS TRASHED
POP AF ; GET CARD TYPE BACK
CP SD_TYPESDHC ; IS IT V2 OR BETTER?
JR NC,SD_SETADDR1 ; IF SO, BYPASS TRANSLATION
;
; TRANSLATE BLOCK ADDRESS TO BYTE ADDRESS FOR V1 CARDS
LD D,E
LD E,H
LD H,L
LD L,0
SLA L
RL H
RL E
RL D
;
SD_SETADDR1:
; STORE RESULTANT ADDRESS INTO PARMS (BIG ENDIAN!)
PUSH HL ; SAVE LOW WORD OF ADDRESS
LD HL,SD_CMDP0 ; POINT TO START OF PARM BYTES
LD (HL),D ; SAVE MSB OF HI WORD
INC HL ; NEXT BYTE
LD (HL),E ; SAVE LSB OF HI WORD
INC HL ; NEXT BYTE
POP DE ; RECOVER LOW WORD OF ADDRESS INTO DE
LD (HL),D ; SAVE MSB OF LO WORD
INC HL ; NEXT BYTE
LD (HL),E ; SAVE LSB OF LO WORD
RET ; DONE
;
;=============================================================================
; COMMAND PROCESSING
;=============================================================================
;
; PUT CARD IN IDLE STATE
;
SD_GOIDLE:
CALL SD_GOIDLE1 ; FIRST ATTEMPT
RET Z ; DONE IF SUCCEEDED
; FALL THRU FOR SECOND ATTEMPT IF NEEDED
;
SD_GOIDLE1:
; SEEMS TO HELP SOME CARDS?
;CALL SD_SELECT ; ASSERT CS
;CALL SD_DONE ; SEND 8 CLOCKS AND DEASSERT CS
; SMALL DELAY HERE HELPS SOME CARDS
;;LD DE,300 ; 16US * 300 = ~5MS
;LD DE,60 ; 16US * 60 = ~1MS
;CALL VDELAY ; CPU SPEED NORMALIZED DELAY
; PUT CARD IN IDLE STATE
LD A,SD_CMD_GO_IDLE_STATE ; CMD0 = ENTER IDLE STATE
CALL SD_INITCMD ; INIT COMMAND BUFFER
LD A,$95 ; CRC FOR GO_IDLE_STATE COMMAND IS $95
LD (SD_CMDCRC),A ; SET CRC
CALL SD_EXECCMDND ; EXECUTE COMMAND W/ NO DATA RETURNED
RET NZ ; ABORT ON ERROR
LD A,(SD_RC) ; GET CARD RESULT
DEC A ; MAP EXPECTED $01 -> $00
RET Z ; ALL IS GOOD, RETURN WITH Z=0 AND Z SET
LD A,SD_STCMDERR ; SET COMMAND ERROR VALUE, NZ ALREADY SET
RET ; AND RETURN
;
; INITIALIZE COMMAND BUFFER
; COMMAND BYTE IN ACCUM
; HL AND AF DESTROYED
;
SD_INITCMD:
LD HL,SD_CMDBUF ; POINT TO START OF BUFFER
LD (HL),A ; SET THE COMMAND BYTE
XOR A ; CLEAR ACCUM
LD B,7 ; PREPARE TO CLEAR NEXT 7 BYTES (PARMS, CRC, RC, TOK)
SD_INITCMD1:
INC HL ; POINT TO NEXT BYTE
LD (HL),A ; CLEAR IT
DJNZ SD_INITCMD1 ; LOOP TILL DONE
RET
;
; EXECUTE APP COMMAND
;
SD_EXECACMD:
LD A,SD_CMD_APP_CMD ; APP_CMD, AN APP CMD IS NEXT
CALL SD_INITCMD ; SETUP COMMAND BUFFER
JR SD_EXECCMDND ; EXEC COMMAND W/ NO DATA RETURNED
;
; EXECUTE COMMAND WITH NO DATA
;
SD_EXECCMDND:
CALL SD_EXECCMD ; RUN THE COMMAND
JP Z,SD_DONE ; RETURN THRU SD_DONE IF NO ERROR
RET ; ERROR STATUS, JUST RETURN, SD_DONE WAS ALREADY RUN
;
; EXECUTE A COMMAND
; WILL FINISH TRANSACTION IF ERROR OCCURS
; RETURNS STATUS IN A WITH ZF SET ACCORDINGLY
;
SD_EXECCMD:
#IF (SDTRACE >= 3)
PUSH AF
CALL SD_PRTPREFIX
LD DE,SD_CMDBUF
PRTS(" CMD$")
LD A,6
CALL PRTHEXBUF
LD DE,SD_STR_ARROW
CALL WRITESTR
POP AF
#ENDIF
; WAIT FOR CARD TO BE READY
CALL SD_WAITRDY ; WAIT FOR CARD TO BE READY FOR A COMMAND
JP NZ,SD_ERRRDYTO ; HANDLE TIMEOUT ERROR
; SEND THE COMMAND
LD HL,SD_CMDBUF ; POINT TO COMMAND BUFFER
LD E,6 ; COMMANDS ARE 6 BYTES
SD_EXECCMD1:
LD A,(HL) ; PREPARE TO SEND NEXT BYTE
CALL SD_PUT ; SEND IT
INC HL ; POINT TO NEXT BYTE
DEC E ; DEC LOOP COUNTER
JR NZ,SD_EXECCMD1 ; LOOP TILL DONE W/ ALL 6 BYTES
;
; GET RESULT
LD E,0 ; INIT TIMEOUT LOOP COUNTER
SD_EXECCMD2:
CALL SD_GET ; GET A BYTE FROM THE CARD
OR A ; SET FLAGS
JP P,SD_EXECCMD3 ; IF HIGH BIT IS 0, WE HAVE RESULT
DEC E ; OTHERWISE DECREMENT LOOP COUNTER
JR NZ,SD_EXECCMD2 ; AND LOOP UNTIL TIMEOUT
JP SD_ERRCMDTO
;
SD_EXECCMD3:
; COMMAND COMPLETE, SAVE RC AND PRINT DIAGNOSTICS AS APPROPRIATE
LD (SD_RC),A ; RECORD THE RESULT
#IF (SDTRACE >= 3)
CALL SD_PRTRC ; IF MAX TRACING, PRINT RC
#ENDIF
#IF (DSKYENABLE)
PUSH AF
CALL SD_DSKY ; IF USING DSKY, SHOW IT THERE
POP AF
#ENDIF
AND ~$01 ; MASK OFF IDLE BIT AND SET FLAGS
RET Z ; IF RC = 0, NO ERROR, RETURN
CALL SD_DONE ; IF ERROR, COMPLETE TRANSACTION
JP SD_ERRCMD ; ... AND HANDLE IT
;
; SD_GETDATA
;
SD_GETDATA:
PUSH HL ; SAVE DESTINATION ADDRESS
PUSH BC ; SAVE LENGTH TO RECEIVE
LD DE,$7FFF ; LOOP MAX (TIMEOUT)
SD_GETDATA1:
CALL SD_GET
CP $FF ; WANT BYTE != $FF
JR NZ,SD_GETDATA2 ; NOT $FF, MOVE ON
DEC DE
BIT 7,D
JR Z,SD_GETDATA1 ; KEEP TRYING UNTIL TIMEOUT
SD_GETDATA2:
LD (SD_TOK),A ; SAVE TOKEN VALUE
#IF (SDTRACE >= 3)
PUSH AF
CALL SD_PRTTOK
POP AF
#ENDIF
POP DE ; RESTORE LENGTH TO RECEIVE
POP HL ; RECOVER DEST ADDRESS
CP $FE ; PACKET START?
JR NZ,SD_GETDATA4 ; NOPE, ABORT, A HAS ERROR CODE
SD_GETDATA3:
CALL SD_GET ; GET NEXT BYTE
LD (HL),A ; SAVE IT
INC HL
DEC DE
LD A,D
OR E
JR NZ,SD_GETDATA3 ; LOOP FOR ALL BYTES
CALL SD_GET ; DISCARD CRC BYTE 1
CALL SD_GET ; DISCARD CRC BYTE 2
XOR A ; RESULT IS ZERO
SD_GETDATA4:
RET
;
; SD_PUTDATA
;
SD_PUTDATA:
PUSH HL ; SAVE SOURCE ADDRESS
PUSH BC ; SAVE LENGTH TO SEND
LD A,$FE ; PACKET START
CALL SD_PUT ; SEND IT
POP DE ; RECOVER LENGTH TO SEND
POP HL ; RECOVER SOURCE ADDRESS
SD_PUTDATA1:
LD A,(HL) ; GET NEXT BYTE TO SEND
CALL SD_PUT ; SEND IF
INC HL
DEC DE
LD A,D
OR E
JR NZ,SD_PUTDATA1 ; LOOP FOR ALL BYTES
LD A,$FF ; DUMMY CRC BYTE
CALL SD_PUT
LD A,$FF ; DUMMY CRC BYTE
CALL SD_PUT
LD DE,$7FFF ; LOOP MAX (TIMEOUT)
SD_PUTDATA2:
CALL SD_GET
CP $FF ; WANT BYTE != $FF
JR NZ,SD_PUTDATA3 ; NOT $FF, MOVE ON
DEC DE
BIT 7,D
JR Z,SD_PUTDATA2 ; KEEP TRYING UNTIL TIMEOUT
SD_PUTDATA3:
LD (SD_TOK),A
#IF (SDTRACE >= 3)
PUSH AF
CALL SD_PRTTOK
POP AF
#ENDIF
AND $1F
CP $05
RET NZ
XOR A
RET
;
; SELECT CARD AND WAIT FOR IT TO BE READY ($FF)
;
SD_WAITRDY:
CALL SD_SELECT ; SELECT CARD
LD DE,$FFFF ; LOOP MAX (TIMEOUT)
SD_WAITRDY1:
CALL SD_GET
INC A ; $FF -> $00
RET Z ; IF READY, RETURN
DEC DE
LD A,D
OR E
JR NZ,SD_WAITRDY1 ; KEEP TRYING UNTIL TIMEOUT
XOR A ; ZERO ACCUM
DEC A ; ACCUM := $FF TO SIGNAL ERROR
RET ; TIMEOUT
;
; FINISH A TRANSACTION - PRESERVE AF
;
; PER SPEC: AFTER THE LAST SPI BUS TRANSACTION, THE HOST IS REQUIRED, TO PROVIDE
; 8 (EIGHT) CLOCK CYCLES FOR THE CARD TO COMPLETE THE OPERATION BEFORE SHUTTING
; DOWN THE CLOCK. THROUGHOUT THIS 8 CLOCKS PERIOD THE STATE OF THE CS SIGNAL IS
; IRRELEVANT. IT CAN BE ASSERTED OR DE-ASSERTED.
;
; NOTE THAT I HAVE FOUND AT LEAST ONE MMC CARD THAT FAILS UNLESS THE CS SIGNAL
; REMAINS ACTIVE DURING THE 8 CLOCKS, SO THE CLOCKS ARE SENT BEFORE DESLECTING THE CARD.
;
SD_DONE:
PUSH AF
LD A,$FF
CALL SD_PUT
CALL SD_DESELECT
POP AF
RET
;
;=============================================================================
; HARDWARE INTERFACE ROUTINES
;=============================================================================
;
; PERFORM HARDWARE SPECIFIC INITIALIZATION
;
SD_SETUP:
;
#IF ((SDMODE == SDMODE_JUHA) | (SDMODE == SDMODE_N8) | (SDMODE == SDMODE_DSD))
LD A,SD_OPRDEF
LD (SD_OPRVAL),A
OUT (SD_OPRREG),A
#ENDIF
;
#IF ((SDMODE == SDMODE_CSIO) | (SDMODE == SDMODE_MK4))
; CSIO SETUP
; LD A,2 ; 18MHz/20 <= 400kHz
LD A,6 ; ???
OUT0 (SD_CNTR),A
LD A,SD_OPRDEF
LD (SD_OPRVAL),A
OUT (SD_OPRREG),A
#ENDIF
;
#IF (SDMODE == SDMODE_PPI)
LD A,82H ; PPI PORT A=OUT, B=IN, C=OUT
OUT (SD_PPIX),A
LD A,SD_OPRDEF
LD (SD_OPRVAL),A
OUT (SD_OPRREG),A
#ENDIF
;
#IF (SDMODE == SDMODE_UART)
SD_OPRMSK .EQU (SD_CS | SD_CLK | SD_DI)
IN A,(SD_OPRREG) ; OPRREG == SIO_MCR
AND ~SD_OPRMSK ; MASK OFF SD CONTROL BITS
OR SD_OPRDEF ; SET DEFAULT BITS
LD (SD_OPRVAL),A ; RECORD THE WORKING VALLUE
OUT (SD_OPRREG),A ; OPRREG == SIO_MCR
#ENDIF
;
XOR A
RET
;
; TAKE ANY ACTIONS REQUIRED TO SELECT DESIRED PHYSICAL UNIT
; UNIT IS SPECIFIED IN A
;
SD_SELUNIT:
LD A,(IY+SD_DEV) ; GET CURRENT DEVICE
;
#IF (SDMODE == SDMODE_DSD)
; SELECT REQUESTED UNIT
OUT (SD_SELREG),A ; ACTUALLY SELECT THE CARD
#ENDIF
XOR A ; SIGNAL SUCCESS
RET ; DONE
;
; CHECK FOR CARD DETECT (NZ = MEDIA PRESENT)
;
SD_CHKCD:
#IF ((SDMODE == SDMODE_DSD) | (SDMODE == SDMODE_MK4))
IN A,(SD_OPRREG) ; GET OPERATIONS REGISTER
BIT 5,A ; TEST CARD DETECT BIT
#ELSE
OR $FF ; ASSUME CARD PRESENT
#ENDIF
RET ; DONE
;
; CHECK FOR WRITE PROTECT (NZ = WRITE PROTECTED)
;
SD_CHKWP:
#IF ((SDMODE == SDMODE_DSD) | (SDMODE == SDMODE_MK4))
IN A,(SD_OPRREG) ; GET OPERATIONS REGISTER
BIT 4,A ; TEST WP BIT
#ELSE
XOR A ; WP NOT SUPPORTED BY HARDWARE, ASSUME WP OFF
#ENDIF
RET ; AND RETURN
;
; SELECT CARD
;
SD_SELECT:
LD A,(SD_OPRVAL)
#IF ((SDMODE == SDMODE_PPI) | (SDMODE == SDMODE_UART))
AND ~SD_CS ; SET SD_CS (CHIP SELECT)
#ELSE
OR SD_CS ; SET SD_CS (CHIP SELECT)
#ENDIF
LD (SD_OPRVAL),A
OUT (SD_OPRREG),A
RET
;
; DESELECT CARD
;
SD_DESELECT:
LD A,(SD_OPRVAL)
#IF ((SDMODE == SDMODE_PPI) | (SDMODE == SDMODE_UART))
OR SD_CS ; RESET SD_CS (CHIP SELECT)
#ELSE
AND ~SD_CS ; RESET SD_CS (CHIP SELECT)
#ENDIF
LD (SD_OPRVAL),A
OUT (SD_OPRREG),A
RET
;
#IF ((SDMODE == SDMODE_CSIO) | (SDMODE == SDMODE_MK4))
;
; CSIO WAIT FOR TRANSMIT READY (TX REGSITER EMPTY)
;
SD_WAITTX: ; WAIT FOR TX EMPTY
IN0 A,(SD_CNTR) ; GET CSIO STATUS
BIT 4,A ; TX EMPTY?
JR NZ,SD_WAITTX
RET
;
; CSIO WAIT FOR RECEIVER READY (BYTE AVAILABLE)
;
SD_WAITRX:
IN0 A,(SD_CNTR) ; WAIT FOR RECEIVER TO FINISH
BIT 5,A
JR NZ,SD_WAITRX
RET
;
#ENDIF
;
; SEND ONE BYTE
;
SD_PUT:
#IF ((SDMODE == SDMODE_CSIO) | (SDMODE == SDMODE_MK4))
CALL MIRROR ; MSB<-->LSB MIRROR BITS, RESULT IN C
CALL SD_WAITTX ; MAKE SURE WE ARE DONE SENDING
OUT0 (SD_TRDR),C ; PUT BYTE IN BUFFER
IN0 A,(SD_CNTR)
SET 4,A ; SET TRANSMIT ENABLE
OUT0 (SD_CNTR),A
#ELSE
#IF (SDMODE == SDMODE_UART)
XOR $FF ; DI IS INVERTED ON UART
#ENDIF
LD C,A ; C=BYTE TO SEND
LD B,8 ; SEND 8 BITS (LOOP 8 TIMES)
LD A,(SD_OPRVAL) ; LOAD CURRENT OPR VALUE
SD_PUT1:
RRA ; PREPARE TO GET DATA BIT FROM CF
RL C ; ROTATE NEXT BIT FROM C INTO CF
RLA ; ROTATE CF INTO A:0, SD_DO is OPR:0
OUT (SD_OPRREG),A ; ASSERT DATA BIT
XOR SD_CLK ; TOGGLE CLOCK
OUT (SD_OPRREG),A ; UPDATE CLOCK AND ASSERT DATA BIT
XOR SD_CLK ; TOGGLE CLOCK
OUT (SD_OPRREG),A ; UPDATE CLOCK
DJNZ SD_PUT1 ; REPEAT FOR ALL 8 BITS
LD A,(SD_OPRVAL) ; LOAD CURRENT OPR VALUE
OUT (SD_OPRREG),A ; LEAVE WITH CLOCK LOW
#ENDIF
RET ; DONE
;
; RECEIVE ONE BYTE
;
SD_GET:
#IF ((SDMODE == SDMODE_CSIO) | (SDMODE == SDMODE_MK4))
CALL SD_WAITTX ; MAKE SURE WE ARE DONE SENDING
IN0 A,(Z180_CNTR) ; GET CSIO STATUS
SET 5,A ; START RECEIVER
OUT0 (Z180_CNTR),A
CALL SD_WAITRX
IN0 A,(Z180_TRDR) ; GET RECEIVED BYTE
CALL MIRROR ; MSB<-->LSB MIRROR BITS
LD A,C ; KEEP RESULT
#ELSE
LD B,8 ; RECEIVE 8 BITS (LOOP 8 TIMES)
LD A,(SD_OPRVAL) ; LOAD CURRENT OPR VALUE
SD_GET1:
XOR SD_CLK ; TOGGLE CLOCK
OUT (SD_OPRREG),A ; UPDATE CLOCK
IN A,(SD_INPREG) ; READ THE DATA WHILE CLOCK IS ACTIVE
#IF ((SDMODE == SDMODE_JUHA) | (SDMODE == SDMODE_PPI))
RLA ; ROTATE INP:7 INTO CF
#ENDIF
#IF (SDMODE == SDMODE_N8)
RLA ; ROTATE INP:6 INTO CF
RLA ; "
#ENDIF
#IF (SDMODE == SDMODE_UART)
RLA ; ROTATE INP:5 INTO CF
RLA ; "
RLA ; "
#ENDIF
#IF (SDMODE == SDMODE_DSD)
RRA ; ROTATE INP:0 INTO CF
#ENDIF
RL C ; ROTATE CF INTO C:0
LD A,(SD_OPRVAL) ; BACK TO INITIAL VALUES (TOGGLE CLOCK)
OUT (SD_OPRREG),A ; DO IT
DJNZ SD_GET1 ; REPEAT FOR ALL 8 BITS
LD A,C ; GET BYTE RECEIVED INTO A
#IF (SDMODE == SDMODE_UART)
XOR $FF ; DO IS INVERTED ON UART
#ENDIF
#ENDIF
RET
;
;=============================================================================
; ERROR HANDLING AND DIAGNOSTICS
;=============================================================================
;
; ERROR HANDLERS
;
SD_INVUNIT:
LD A,SD_STINVUNIT
JR SD_ERR2 ; SPECIAL CASE FOR INVALID UNIT
;
SD_ERRRDYTO:
LD A,SD_STRDYTO
JR SD_ERR
;
SD_ERRINITTO:
LD A,SD_STINITTO
JR SD_ERR
;
SD_ERRCMDTO:
LD A,SD_STCMDTO
JR SD_ERR
;
SD_ERRCMD:
LD A,SD_STCMDERR
JR SD_ERR
;
SD_ERRDATA:
LD A,SD_STDATAERR
JR SD_ERR
;
SD_ERRDATATO:
LD A,SD_STDATATO
JR SD_ERR
;
SD_ERRCRC:
LD A,SD_STCRCERR
JR SD_ERR
;
SD_NOMEDIA:
LD A,SD_STNOMEDIA
JR SD_ERR
;
SD_WRTPROT:
LD A,SD_STWRTPROT
JR SD_ERR2 ; DO NOT UPDATE UNIT STATUS!
;
SD_ERR:
LD (IY+SD_STAT),A ; SAVE NEW STATUS
SD_ERR2:
#IF (SDTRACE >= 2)
CALL SD_PRTSTAT
CALL SD_REGDUMP
#ENDIF
OR A ; SET FLAGS
RET
;
;
;
SD_PRTERR:
RET Z ; DONE IF NO ERRORS
; FALL THRU TO SD_PRTSTAT
;
; PRINT STATUS STRING
;
SD_PRTSTAT:
PUSH AF
PUSH DE
PUSH HL
OR A
LD DE,SD_STR_STOK
JR Z,SD_PRTSTAT1
INC A
LD DE,SD_STR_STINVUNIT
JR Z,SD_PRTSTAT2 ; INVALID UNIT IS SPECIAL CASE
INC A
LD DE,SD_STR_STRDYTO
JR Z,SD_PRTSTAT1
INC A
LD DE,SD_STR_STINITTO
JR Z,SD_PRTSTAT1
INC A
LD DE,SD_STR_STCMDTO
JR Z,SD_PRTSTAT1
INC A
LD DE,SD_STR_STCMDERR
JR Z,SD_PRTSTAT1
INC A
LD DE,SD_STR_STDATAERR
JR Z,SD_PRTSTAT1
INC A
LD DE,SD_STR_STDATATO
JR Z,SD_PRTSTAT1
INC A
LD DE,SD_STR_STCRCERR
JR Z,SD_PRTSTAT1
INC A
LD DE,SD_STR_STNOMEDIA
JR Z,SD_PRTSTAT1
INC A
LD DE,SD_STR_STWRTPROT
JR Z,SD_PRTSTAT1
LD DE,SD_STR_STUNK
SD_PRTSTAT1:
CALL SD_PRTPREFIX ; PRINT UNIT PREFIX
JR SD_PRTSTAT3
SD_PRTSTAT2:
CALL NEWLINE
PRTS("SD:$") ; NO UNIT NUM IN PREFIX FOR INVALID UNIT
SD_PRTSTAT3:
CALL PC_SPACE ; FORMATTING
CALL WRITESTR
POP HL
POP DE
POP AF
RET
;
SD_PRTRC:
PUSH AF
PUSH DE
LD DE,SD_STR_RC
CALL WRITESTR
LD A,(SD_RC)
CALL PRTHEXBYTE
POP DE
POP AF
RET
;
SD_PRTTOK:
PUSH AF
PUSH DE
LD DE,SD_STR_TOK
CALL WRITESTR
LD A,(SD_TOK)
CALL PRTHEXBYTE
POP DE
POP AF
RET
;
;
;
SD_REGDUMP:
PUSH AF
PUSH BC
PUSH HL
CALL PC_SPACE
CALL PC_LBKT
LD HL,SD_CMDBUF
LD B,8
SD_REGDUMP1:
LD A,(HL)
INC HL
CALL PRTHEXBYTE
DJNZ SD_REGDUMP1
CALL PC_RBKT
POP HL
POP BC
POP AF
RET
;
; PRINT DIAGNONSTIC PREFIX
;
SD_PRTPREFIX:
PUSH AF
CALL NEWLINE
PRTS("SD$")
LD A,(IY+SD_DEV) ; GET CURRENT DEVICE NUM
ADD A,'0'
CALL COUT
CALL PC_COLON
POP AF
RET
;
; DISPLAY COMMAND, LOW ORDER WORD OF PARMS, AND RC
;
#IF (DSKYENABLE)
SD_DSKY:
PUSH AF
PUSH HL
LD HL,DSKY_HEXBUF
LD A,(SD_CMD)
LD (HL),A
INC HL
LD A,(SD_CMDP2)
LD (HL),A
INC HL
LD A,(SD_CMDP3)
LD (HL),A
INC HL
LD A,(SD_RC)
CALL DSKY_HEXOUT
POP HL
POP AF
RET
#ENDIF
;
;=============================================================================
; STRING DATA
;=============================================================================
;
SD_STR_ARROW .TEXT " -->$"
SD_STR_RC .TEXT " RC=$"
SD_STR_TOK .TEXT " TOK=$"
SD_STR_CSD .TEXT " CSD =$"
SD_STR_CID .TEXT " CID =$"
SD_STR_SCR .TEXT " SCR =$"
SD_STR_SDTYPE .TEXT " SD CARD TYPE ID=$"
;
SD_STR_STOK .TEXT "OK$"
SD_STR_STINVUNIT .TEXT "INVALID UNIT$"
SD_STR_STRDYTO .TEXT "READY TIMEOUT$"
SD_STR_STINITTO .TEXT "INITIALIZATION TIMEOUT$"
SD_STR_STCMDTO .TEXT "COMMAND TIMEOUT$"
SD_STR_STCMDERR .TEXT "COMMAND ERROR$"
SD_STR_STDATAERR .TEXT "DATA ERROR$"
SD_STR_STDATATO .TEXT "DATA TIMEOUT$"
SD_STR_STCRCERR .TEXT "CRC ERROR$"
SD_STR_STNOMEDIA .TEXT "NO MEDIA$"
SD_STR_STWRTPROT .TEXT "WRITE PROTECTED$"
SD_STR_STUNK .TEXT "UNKNOWN$"
SD_STR_TYPEUNK .TEXT "UNK$"
SD_STR_TYPEMMC .TEXT "MMC$"
SD_STR_TYPESDSC .TEXT "SDSC$"
SD_STR_TYPESDHC .TEXT "SDHC$"
SD_STR_TYPESDXC .TEXT "SDXC$"
;
;=============================================================================
; DATA STORAGE
;=============================================================================
;
SD_OPRVAL .DB 0 ; CURRENT OPR REG VALUE
SD_LCNT .DB 0 ; LOOP COUNTER
SD_CMDVAL .DB 0 ; PENDING COMMAND FOR IO FUCNTIONS
SD_BLKCNT .DB 0 ; BLOCK COUNT REQUESTED FOR IO FUNCTIONS
;
SD_BUF .FILL 16,0 ; WORK BUFFER
;
SD_CMDBUF: ; START OF STD CMD BUF
SD_CMD .DB 0 ; COMMAND BYTE
SD_CMDP0 .DB 0 ; FIRST PARM BYTE (MSB)
SD_CMDP1 .DB 0
SD_CMDP2 .DB 0
SD_CMDP3 .DB 0 ; LAST PARM BYTE (LSB)
SD_CMDCRC .DB 0 ; CRC
;
SD_RC .DB 0 ; RETURN CODE FROM CMD
SD_TOK .DB 0 ; TOKEN FROM DATA XFR
;
SD_DSKBUF .DW 0 ; ADR OF ACTIVE DISK BUFFER
;
;=============================================================================
; HELPER ROUTINES
;=============================================================================
;
; MSB<-->LSB MIRROR BITS IN A, RESULT IN C
;
MIRROR:
#IF (((SDMODE == SDMODE_CSIO) | (SDMODE == SDMODE_MK4)) & SDCSIOFAST)
LD BC,MIRTAB ; 256 BYTE MIRROR TABLE
ADD A,C ; ADD OFFSET
LD C,A
JR NC,MIRROR2
INC B
MIRROR2:
LD A,(BC) ; GET RESULT
LD C,A ; RETURN RESULT IN C
RET
#ELSE ; FASTEST BUT USES MOST CODE SPACE
LD B,8 ; BIT COUNTER
MIRROR1:
RLA ; ROTATE BIT 7 INTO CARRY
RR C ; ROTATE CARRY INTO RESULT
DJNZ MIRROR1 ; DO ALL 8 BITS
RET
#ENDIF
;
; LOOKUP TABLE TO MIRROR BITS IN A BYTE
;
#IF (((SDMODE == SDMODE_CSIO) | (SDMODE == SDMODE_MK4)) & SDCSIOFAST)
MIRTAB .DB 00H, 80H, 40H, 0C0H, 20H, 0A0H, 60H, 0E0H, 10H, 90H, 50H, 0D0H, 30H, 0B0H, 70H, 0F0H
.DB 08H, 88H, 48H, 0C8H, 28H, 0A8H, 68H, 0E8H, 18H, 98H, 58H, 0D8H, 38H, 0B8H, 78H, 0F8H
.DB 04H, 84H, 44H, 0C4H, 24H, 0A4H, 64H, 0E4H, 14H, 94H, 54H, 0D4H, 34H, 0B4H, 74H, 0F4H
.DB 0CH, 8CH, 4CH, 0CCH, 2CH, 0ACH, 6CH, 0ECH, 1CH, 9CH, 5CH, 0DCH, 3CH, 0BCH, 7CH, 0FCH
.DB 02H, 82H, 42H, 0C2H, 22H, 0A2H, 62H, 0E2H, 12H, 92H, 52H, 0D2H, 32H, 0B2H, 72H, 0F2H
.DB 0AH, 8AH, 4AH, 0CAH, 2AH, 0AAH, 6AH, 0EAH, 1AH, 9AH, 5AH, 0DAH, 3AH, 0BAH, 7AH, 0FAH
.DB 06H, 86H, 46H, 0C6H, 26H, 0A6H, 66H, 0E6H, 16H, 96H, 56H, 0D6H, 36H, 0B6H, 76H, 0F6H
.DB 0EH, 8EH, 4EH, 0CEH, 2EH, 0AEH, 6EH, 0EEH, 1EH, 9EH, 5EH, 0DEH, 3EH, 0BEH, 7EH, 0FEH
.DB 01H, 81H, 41H, 0C1H, 21H, 0A1H, 61H, 0E1H, 11H, 91H, 51H, 0D1H, 31H, 0B1H, 71H, 0F1H
.DB 09H, 89H, 49H, 0C9H, 29H, 0A9H, 69H, 0E9H, 19H, 99H, 59H, 0D9H, 39H, 0B9H, 79H, 0F9H
.DB 05H, 85H, 45H, 0C5H, 25H, 0A5H, 65H, 0E5H, 15H, 95H, 55H, 0D5H, 35H, 0B5H, 75H, 0F5H
.DB 0DH, 8DH, 4DH, 0CDH, 2DH, 0ADH, 6DH, 0EDH, 1DH, 9DH, 5DH, 0DDH, 3DH, 0BDH, 7DH, 0FDH
.DB 03H, 83H, 43H, 0C3H, 23H, 0A3H, 63H, 0E3H, 13H, 93H, 53H, 0D3H, 33H, 0B3H, 73H, 0F3H
.DB 0BH, 8BH, 4BH, 0CBH, 2BH, 0ABH, 6BH, 0EBH, 1BH, 9BH, 5BH, 0DBH, 3BH, 0BBH, 7BH, 0FBH
.DB 07H, 87H, 47H, 0C7H, 27H, 0A7H, 67H, 0E7H, 17H, 97H, 57H, 0D7H, 37H, 0B7H, 77H, 0F7H
.DB 0FH, 8FH, 4FH, 0CFH, 2FH, 0AFH, 6FH, 0EFH, 1FH, 9FH, 5FH, 0DFH, 3FH, 0BFH, 7FH, 0FFH
;
#ENDIF
|
; A141449: A005439 mod 9.
; 1,2,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8,2,5,8
mul $0,2
mov $2,$0
trn $0,4
trn $2,1
add $0,$2
lpb $0,1
mov $3,$0
sub $0,1
add $3,$0
add $3,$0
trn $0,2
lpe
mov $1,1
add $1,$3
|
_echo: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 56 push %esi
e: 53 push %ebx
f: 51 push %ecx
10: 83 ec 0c sub $0xc,%esp
13: 8b 01 mov (%ecx),%eax
15: 8b 51 04 mov 0x4(%ecx),%edx
int i;
for(i = 1; i < argc; i++)
18: 83 f8 01 cmp $0x1,%eax
1b: 7e 3f jle 5c <main+0x5c>
1d: 8d 5a 04 lea 0x4(%edx),%ebx
20: 8d 34 82 lea (%edx,%eax,4),%esi
23: eb 18 jmp 3d <main+0x3d>
25: 8d 76 00 lea 0x0(%esi),%esi
printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n");
28: 68 88 07 00 00 push $0x788
2d: 50 push %eax
2e: 68 8a 07 00 00 push $0x78a
33: 6a 01 push $0x1
35: e8 f6 03 00 00 call 430 <printf>
3a: 83 c4 10 add $0x10,%esp
3d: 83 c3 04 add $0x4,%ebx
40: 8b 43 fc mov -0x4(%ebx),%eax
43: 39 f3 cmp %esi,%ebx
45: 75 e1 jne 28 <main+0x28>
47: 68 8f 07 00 00 push $0x78f
4c: 50 push %eax
4d: 68 8a 07 00 00 push $0x78a
52: 6a 01 push $0x1
54: e8 d7 03 00 00 call 430 <printf>
59: 83 c4 10 add $0x10,%esp
exit();
5c: e8 61 02 00 00 call 2c2 <exit>
61: 66 90 xchg %ax,%ax
63: 66 90 xchg %ax,%ax
65: 66 90 xchg %ax,%ax
67: 66 90 xchg %ax,%ax
69: 66 90 xchg %ax,%ax
6b: 66 90 xchg %ax,%ax
6d: 66 90 xchg %ax,%ax
6f: 90 nop
00000070 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
70: 55 push %ebp
71: 89 e5 mov %esp,%ebp
73: 53 push %ebx
74: 8b 45 08 mov 0x8(%ebp),%eax
77: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
7a: 89 c2 mov %eax,%edx
7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
80: 83 c1 01 add $0x1,%ecx
83: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
87: 83 c2 01 add $0x1,%edx
8a: 84 db test %bl,%bl
8c: 88 5a ff mov %bl,-0x1(%edx)
8f: 75 ef jne 80 <strcpy+0x10>
;
return os;
}
91: 5b pop %ebx
92: 5d pop %ebp
93: c3 ret
94: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
9a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
000000a0 <strcmp>:
int
strcmp(const char *p, const char *q)
{
a0: 55 push %ebp
a1: 89 e5 mov %esp,%ebp
a3: 53 push %ebx
a4: 8b 55 08 mov 0x8(%ebp),%edx
a7: 8b 4d 0c mov 0xc(%ebp),%ecx
while(*p && *p == *q)
aa: 0f b6 02 movzbl (%edx),%eax
ad: 0f b6 19 movzbl (%ecx),%ebx
b0: 84 c0 test %al,%al
b2: 75 1c jne d0 <strcmp+0x30>
b4: eb 2a jmp e0 <strcmp+0x40>
b6: 8d 76 00 lea 0x0(%esi),%esi
b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
p++, q++;
c0: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
c3: 0f b6 02 movzbl (%edx),%eax
p++, q++;
c6: 83 c1 01 add $0x1,%ecx
c9: 0f b6 19 movzbl (%ecx),%ebx
while(*p && *p == *q)
cc: 84 c0 test %al,%al
ce: 74 10 je e0 <strcmp+0x40>
d0: 38 d8 cmp %bl,%al
d2: 74 ec je c0 <strcmp+0x20>
return (uchar)*p - (uchar)*q;
d4: 29 d8 sub %ebx,%eax
}
d6: 5b pop %ebx
d7: 5d pop %ebp
d8: c3 ret
d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
e0: 31 c0 xor %eax,%eax
return (uchar)*p - (uchar)*q;
e2: 29 d8 sub %ebx,%eax
}
e4: 5b pop %ebx
e5: 5d pop %ebp
e6: c3 ret
e7: 89 f6 mov %esi,%esi
e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000000f0 <strlen>:
uint
strlen(const char *s)
{
f0: 55 push %ebp
f1: 89 e5 mov %esp,%ebp
f3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
f6: 80 39 00 cmpb $0x0,(%ecx)
f9: 74 15 je 110 <strlen+0x20>
fb: 31 d2 xor %edx,%edx
fd: 8d 76 00 lea 0x0(%esi),%esi
100: 83 c2 01 add $0x1,%edx
103: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
107: 89 d0 mov %edx,%eax
109: 75 f5 jne 100 <strlen+0x10>
;
return n;
}
10b: 5d pop %ebp
10c: c3 ret
10d: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
110: 31 c0 xor %eax,%eax
}
112: 5d pop %ebp
113: c3 ret
114: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
11a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000120 <memset>:
void*
memset(void *dst, int c, uint n)
{
120: 55 push %ebp
121: 89 e5 mov %esp,%ebp
123: 57 push %edi
124: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
127: 8b 4d 10 mov 0x10(%ebp),%ecx
12a: 8b 45 0c mov 0xc(%ebp),%eax
12d: 89 d7 mov %edx,%edi
12f: fc cld
130: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
132: 89 d0 mov %edx,%eax
134: 5f pop %edi
135: 5d pop %ebp
136: c3 ret
137: 89 f6 mov %esi,%esi
139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000140 <strchr>:
char*
strchr(const char *s, char c)
{
140: 55 push %ebp
141: 89 e5 mov %esp,%ebp
143: 53 push %ebx
144: 8b 45 08 mov 0x8(%ebp),%eax
147: 8b 5d 0c mov 0xc(%ebp),%ebx
for(; *s; s++)
14a: 0f b6 10 movzbl (%eax),%edx
14d: 84 d2 test %dl,%dl
14f: 74 1d je 16e <strchr+0x2e>
if(*s == c)
151: 38 d3 cmp %dl,%bl
153: 89 d9 mov %ebx,%ecx
155: 75 0d jne 164 <strchr+0x24>
157: eb 17 jmp 170 <strchr+0x30>
159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
160: 38 ca cmp %cl,%dl
162: 74 0c je 170 <strchr+0x30>
for(; *s; s++)
164: 83 c0 01 add $0x1,%eax
167: 0f b6 10 movzbl (%eax),%edx
16a: 84 d2 test %dl,%dl
16c: 75 f2 jne 160 <strchr+0x20>
return (char*)s;
return 0;
16e: 31 c0 xor %eax,%eax
}
170: 5b pop %ebx
171: 5d pop %ebp
172: c3 ret
173: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
179: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000180 <gets>:
char*
gets(char *buf, int max)
{
180: 55 push %ebp
181: 89 e5 mov %esp,%ebp
183: 57 push %edi
184: 56 push %esi
185: 53 push %ebx
int i, cc;
char c;
for(i=0; i+1 < max; ){
186: 31 f6 xor %esi,%esi
188: 89 f3 mov %esi,%ebx
{
18a: 83 ec 1c sub $0x1c,%esp
18d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
190: eb 2f jmp 1c1 <gets+0x41>
192: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
198: 8d 45 e7 lea -0x19(%ebp),%eax
19b: 83 ec 04 sub $0x4,%esp
19e: 6a 01 push $0x1
1a0: 50 push %eax
1a1: 6a 00 push $0x0
1a3: e8 32 01 00 00 call 2da <read>
if(cc < 1)
1a8: 83 c4 10 add $0x10,%esp
1ab: 85 c0 test %eax,%eax
1ad: 7e 1c jle 1cb <gets+0x4b>
break;
buf[i++] = c;
1af: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1b3: 83 c7 01 add $0x1,%edi
1b6: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
1b9: 3c 0a cmp $0xa,%al
1bb: 74 23 je 1e0 <gets+0x60>
1bd: 3c 0d cmp $0xd,%al
1bf: 74 1f je 1e0 <gets+0x60>
for(i=0; i+1 < max; ){
1c1: 83 c3 01 add $0x1,%ebx
1c4: 3b 5d 0c cmp 0xc(%ebp),%ebx
1c7: 89 fe mov %edi,%esi
1c9: 7c cd jl 198 <gets+0x18>
1cb: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
1cd: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
1d0: c6 03 00 movb $0x0,(%ebx)
}
1d3: 8d 65 f4 lea -0xc(%ebp),%esp
1d6: 5b pop %ebx
1d7: 5e pop %esi
1d8: 5f pop %edi
1d9: 5d pop %ebp
1da: c3 ret
1db: 90 nop
1dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1e0: 8b 75 08 mov 0x8(%ebp),%esi
1e3: 8b 45 08 mov 0x8(%ebp),%eax
1e6: 01 de add %ebx,%esi
1e8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
1ea: c6 03 00 movb $0x0,(%ebx)
}
1ed: 8d 65 f4 lea -0xc(%ebp),%esp
1f0: 5b pop %ebx
1f1: 5e pop %esi
1f2: 5f pop %edi
1f3: 5d pop %ebp
1f4: c3 ret
1f5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000200 <stat>:
int
stat(const char *n, struct stat *st)
{
200: 55 push %ebp
201: 89 e5 mov %esp,%ebp
203: 56 push %esi
204: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
205: 83 ec 08 sub $0x8,%esp
208: 6a 00 push $0x0
20a: ff 75 08 pushl 0x8(%ebp)
20d: e8 f0 00 00 00 call 302 <open>
if(fd < 0)
212: 83 c4 10 add $0x10,%esp
215: 85 c0 test %eax,%eax
217: 78 27 js 240 <stat+0x40>
return -1;
r = fstat(fd, st);
219: 83 ec 08 sub $0x8,%esp
21c: ff 75 0c pushl 0xc(%ebp)
21f: 89 c3 mov %eax,%ebx
221: 50 push %eax
222: e8 f3 00 00 00 call 31a <fstat>
close(fd);
227: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
22a: 89 c6 mov %eax,%esi
close(fd);
22c: e8 b9 00 00 00 call 2ea <close>
return r;
231: 83 c4 10 add $0x10,%esp
}
234: 8d 65 f8 lea -0x8(%ebp),%esp
237: 89 f0 mov %esi,%eax
239: 5b pop %ebx
23a: 5e pop %esi
23b: 5d pop %ebp
23c: c3 ret
23d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
240: be ff ff ff ff mov $0xffffffff,%esi
245: eb ed jmp 234 <stat+0x34>
247: 89 f6 mov %esi,%esi
249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000250 <atoi>:
int
atoi(const char *s)
{
250: 55 push %ebp
251: 89 e5 mov %esp,%ebp
253: 53 push %ebx
254: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
257: 0f be 11 movsbl (%ecx),%edx
25a: 8d 42 d0 lea -0x30(%edx),%eax
25d: 3c 09 cmp $0x9,%al
n = 0;
25f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
264: 77 1f ja 285 <atoi+0x35>
266: 8d 76 00 lea 0x0(%esi),%esi
269: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
270: 8d 04 80 lea (%eax,%eax,4),%eax
273: 83 c1 01 add $0x1,%ecx
276: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
27a: 0f be 11 movsbl (%ecx),%edx
27d: 8d 5a d0 lea -0x30(%edx),%ebx
280: 80 fb 09 cmp $0x9,%bl
283: 76 eb jbe 270 <atoi+0x20>
return n;
}
285: 5b pop %ebx
286: 5d pop %ebp
287: c3 ret
288: 90 nop
289: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000290 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
290: 55 push %ebp
291: 89 e5 mov %esp,%ebp
293: 56 push %esi
294: 53 push %ebx
295: 8b 5d 10 mov 0x10(%ebp),%ebx
298: 8b 45 08 mov 0x8(%ebp),%eax
29b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst;
const char *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
29e: 85 db test %ebx,%ebx
2a0: 7e 14 jle 2b6 <memmove+0x26>
2a2: 31 d2 xor %edx,%edx
2a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
*dst++ = *src++;
2a8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx
2ac: 88 0c 10 mov %cl,(%eax,%edx,1)
2af: 83 c2 01 add $0x1,%edx
while(n-- > 0)
2b2: 39 d3 cmp %edx,%ebx
2b4: 75 f2 jne 2a8 <memmove+0x18>
return vdst;
}
2b6: 5b pop %ebx
2b7: 5e pop %esi
2b8: 5d pop %ebp
2b9: c3 ret
000002ba <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2ba: b8 01 00 00 00 mov $0x1,%eax
2bf: cd 40 int $0x40
2c1: c3 ret
000002c2 <exit>:
SYSCALL(exit)
2c2: b8 02 00 00 00 mov $0x2,%eax
2c7: cd 40 int $0x40
2c9: c3 ret
000002ca <wait>:
SYSCALL(wait)
2ca: b8 03 00 00 00 mov $0x3,%eax
2cf: cd 40 int $0x40
2d1: c3 ret
000002d2 <pipe>:
SYSCALL(pipe)
2d2: b8 04 00 00 00 mov $0x4,%eax
2d7: cd 40 int $0x40
2d9: c3 ret
000002da <read>:
SYSCALL(read)
2da: b8 05 00 00 00 mov $0x5,%eax
2df: cd 40 int $0x40
2e1: c3 ret
000002e2 <write>:
SYSCALL(write)
2e2: b8 10 00 00 00 mov $0x10,%eax
2e7: cd 40 int $0x40
2e9: c3 ret
000002ea <close>:
SYSCALL(close)
2ea: b8 15 00 00 00 mov $0x15,%eax
2ef: cd 40 int $0x40
2f1: c3 ret
000002f2 <kill>:
SYSCALL(kill)
2f2: b8 06 00 00 00 mov $0x6,%eax
2f7: cd 40 int $0x40
2f9: c3 ret
000002fa <exec>:
SYSCALL(exec)
2fa: b8 07 00 00 00 mov $0x7,%eax
2ff: cd 40 int $0x40
301: c3 ret
00000302 <open>:
SYSCALL(open)
302: b8 0f 00 00 00 mov $0xf,%eax
307: cd 40 int $0x40
309: c3 ret
0000030a <mknod>:
SYSCALL(mknod)
30a: b8 11 00 00 00 mov $0x11,%eax
30f: cd 40 int $0x40
311: c3 ret
00000312 <unlink>:
SYSCALL(unlink)
312: b8 12 00 00 00 mov $0x12,%eax
317: cd 40 int $0x40
319: c3 ret
0000031a <fstat>:
SYSCALL(fstat)
31a: b8 08 00 00 00 mov $0x8,%eax
31f: cd 40 int $0x40
321: c3 ret
00000322 <link>:
SYSCALL(link)
322: b8 13 00 00 00 mov $0x13,%eax
327: cd 40 int $0x40
329: c3 ret
0000032a <mkdir>:
SYSCALL(mkdir)
32a: b8 14 00 00 00 mov $0x14,%eax
32f: cd 40 int $0x40
331: c3 ret
00000332 <chdir>:
SYSCALL(chdir)
332: b8 09 00 00 00 mov $0x9,%eax
337: cd 40 int $0x40
339: c3 ret
0000033a <dup>:
SYSCALL(dup)
33a: b8 0a 00 00 00 mov $0xa,%eax
33f: cd 40 int $0x40
341: c3 ret
00000342 <getpid>:
SYSCALL(getpid)
342: b8 0b 00 00 00 mov $0xb,%eax
347: cd 40 int $0x40
349: c3 ret
0000034a <sbrk>:
SYSCALL(sbrk)
34a: b8 0c 00 00 00 mov $0xc,%eax
34f: cd 40 int $0x40
351: c3 ret
00000352 <sleep>:
SYSCALL(sleep)
352: b8 0d 00 00 00 mov $0xd,%eax
357: cd 40 int $0x40
359: c3 ret
0000035a <uptime>:
SYSCALL(uptime)
35a: b8 0e 00 00 00 mov $0xe,%eax
35f: cd 40 int $0x40
361: c3 ret
00000362 <sigset>:
SYSCALL(sigset)
362: b8 16 00 00 00 mov $0x16,%eax
367: cd 40 int $0x40
369: c3 ret
0000036a <sigsend>:
SYSCALL(sigsend)
36a: b8 17 00 00 00 mov $0x17,%eax
36f: cd 40 int $0x40
371: c3 ret
00000372 <sigret>:
SYSCALL(sigret)
372: b8 18 00 00 00 mov $0x18,%eax
377: cd 40 int $0x40
379: c3 ret
0000037a <testing>:
37a: b8 19 00 00 00 mov $0x19,%eax
37f: cd 40 int $0x40
381: c3 ret
382: 66 90 xchg %ax,%ax
384: 66 90 xchg %ax,%ax
386: 66 90 xchg %ax,%ax
388: 66 90 xchg %ax,%ax
38a: 66 90 xchg %ax,%ax
38c: 66 90 xchg %ax,%ax
38e: 66 90 xchg %ax,%ax
00000390 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
390: 55 push %ebp
391: 89 e5 mov %esp,%ebp
393: 57 push %edi
394: 56 push %esi
395: 53 push %ebx
396: 83 ec 3c sub $0x3c,%esp
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
399: 85 d2 test %edx,%edx
{
39b: 89 45 c0 mov %eax,-0x40(%ebp)
neg = 1;
x = -xx;
39e: 89 d0 mov %edx,%eax
if(sgn && xx < 0){
3a0: 79 76 jns 418 <printint+0x88>
3a2: f6 45 08 01 testb $0x1,0x8(%ebp)
3a6: 74 70 je 418 <printint+0x88>
x = -xx;
3a8: f7 d8 neg %eax
neg = 1;
3aa: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp)
} else {
x = xx;
}
i = 0;
3b1: 31 f6 xor %esi,%esi
3b3: 8d 5d d7 lea -0x29(%ebp),%ebx
3b6: eb 0a jmp 3c2 <printint+0x32>
3b8: 90 nop
3b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
do{
buf[i++] = digits[x % base];
3c0: 89 fe mov %edi,%esi
3c2: 31 d2 xor %edx,%edx
3c4: 8d 7e 01 lea 0x1(%esi),%edi
3c7: f7 f1 div %ecx
3c9: 0f b6 92 98 07 00 00 movzbl 0x798(%edx),%edx
}while((x /= base) != 0);
3d0: 85 c0 test %eax,%eax
buf[i++] = digits[x % base];
3d2: 88 14 3b mov %dl,(%ebx,%edi,1)
}while((x /= base) != 0);
3d5: 75 e9 jne 3c0 <printint+0x30>
if(neg)
3d7: 8b 45 c4 mov -0x3c(%ebp),%eax
3da: 85 c0 test %eax,%eax
3dc: 74 08 je 3e6 <printint+0x56>
buf[i++] = '-';
3de: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
3e3: 8d 7e 02 lea 0x2(%esi),%edi
3e6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi
3ea: 8b 7d c0 mov -0x40(%ebp),%edi
3ed: 8d 76 00 lea 0x0(%esi),%esi
3f0: 0f b6 06 movzbl (%esi),%eax
write(fd, &c, 1);
3f3: 83 ec 04 sub $0x4,%esp
3f6: 83 ee 01 sub $0x1,%esi
3f9: 6a 01 push $0x1
3fb: 53 push %ebx
3fc: 57 push %edi
3fd: 88 45 d7 mov %al,-0x29(%ebp)
400: e8 dd fe ff ff call 2e2 <write>
while(--i >= 0)
405: 83 c4 10 add $0x10,%esp
408: 39 de cmp %ebx,%esi
40a: 75 e4 jne 3f0 <printint+0x60>
putc(fd, buf[i]);
}
40c: 8d 65 f4 lea -0xc(%ebp),%esp
40f: 5b pop %ebx
410: 5e pop %esi
411: 5f pop %edi
412: 5d pop %ebp
413: c3 ret
414: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
418: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
41f: eb 90 jmp 3b1 <printint+0x21>
421: eb 0d jmp 430 <printf>
423: 90 nop
424: 90 nop
425: 90 nop
426: 90 nop
427: 90 nop
428: 90 nop
429: 90 nop
42a: 90 nop
42b: 90 nop
42c: 90 nop
42d: 90 nop
42e: 90 nop
42f: 90 nop
00000430 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
430: 55 push %ebp
431: 89 e5 mov %esp,%ebp
433: 57 push %edi
434: 56 push %esi
435: 53 push %ebx
436: 83 ec 2c sub $0x2c,%esp
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
439: 8b 75 0c mov 0xc(%ebp),%esi
43c: 0f b6 1e movzbl (%esi),%ebx
43f: 84 db test %bl,%bl
441: 0f 84 b3 00 00 00 je 4fa <printf+0xca>
ap = (uint*)(void*)&fmt + 1;
447: 8d 45 10 lea 0x10(%ebp),%eax
44a: 83 c6 01 add $0x1,%esi
state = 0;
44d: 31 ff xor %edi,%edi
ap = (uint*)(void*)&fmt + 1;
44f: 89 45 d4 mov %eax,-0x2c(%ebp)
452: eb 2f jmp 483 <printf+0x53>
454: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
458: 83 f8 25 cmp $0x25,%eax
45b: 0f 84 a7 00 00 00 je 508 <printf+0xd8>
write(fd, &c, 1);
461: 8d 45 e2 lea -0x1e(%ebp),%eax
464: 83 ec 04 sub $0x4,%esp
467: 88 5d e2 mov %bl,-0x1e(%ebp)
46a: 6a 01 push $0x1
46c: 50 push %eax
46d: ff 75 08 pushl 0x8(%ebp)
470: e8 6d fe ff ff call 2e2 <write>
475: 83 c4 10 add $0x10,%esp
478: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
47b: 0f b6 5e ff movzbl -0x1(%esi),%ebx
47f: 84 db test %bl,%bl
481: 74 77 je 4fa <printf+0xca>
if(state == 0){
483: 85 ff test %edi,%edi
c = fmt[i] & 0xff;
485: 0f be cb movsbl %bl,%ecx
488: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
48b: 74 cb je 458 <printf+0x28>
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
48d: 83 ff 25 cmp $0x25,%edi
490: 75 e6 jne 478 <printf+0x48>
if(c == 'd'){
492: 83 f8 64 cmp $0x64,%eax
495: 0f 84 05 01 00 00 je 5a0 <printf+0x170>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
49b: 81 e1 f7 00 00 00 and $0xf7,%ecx
4a1: 83 f9 70 cmp $0x70,%ecx
4a4: 74 72 je 518 <printf+0xe8>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
4a6: 83 f8 73 cmp $0x73,%eax
4a9: 0f 84 99 00 00 00 je 548 <printf+0x118>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
4af: 83 f8 63 cmp $0x63,%eax
4b2: 0f 84 08 01 00 00 je 5c0 <printf+0x190>
putc(fd, *ap);
ap++;
} else if(c == '%'){
4b8: 83 f8 25 cmp $0x25,%eax
4bb: 0f 84 ef 00 00 00 je 5b0 <printf+0x180>
write(fd, &c, 1);
4c1: 8d 45 e7 lea -0x19(%ebp),%eax
4c4: 83 ec 04 sub $0x4,%esp
4c7: c6 45 e7 25 movb $0x25,-0x19(%ebp)
4cb: 6a 01 push $0x1
4cd: 50 push %eax
4ce: ff 75 08 pushl 0x8(%ebp)
4d1: e8 0c fe ff ff call 2e2 <write>
4d6: 83 c4 0c add $0xc,%esp
4d9: 8d 45 e6 lea -0x1a(%ebp),%eax
4dc: 88 5d e6 mov %bl,-0x1a(%ebp)
4df: 6a 01 push $0x1
4e1: 50 push %eax
4e2: ff 75 08 pushl 0x8(%ebp)
4e5: 83 c6 01 add $0x1,%esi
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
}
state = 0;
4e8: 31 ff xor %edi,%edi
write(fd, &c, 1);
4ea: e8 f3 fd ff ff call 2e2 <write>
for(i = 0; fmt[i]; i++){
4ef: 0f b6 5e ff movzbl -0x1(%esi),%ebx
write(fd, &c, 1);
4f3: 83 c4 10 add $0x10,%esp
for(i = 0; fmt[i]; i++){
4f6: 84 db test %bl,%bl
4f8: 75 89 jne 483 <printf+0x53>
}
}
}
4fa: 8d 65 f4 lea -0xc(%ebp),%esp
4fd: 5b pop %ebx
4fe: 5e pop %esi
4ff: 5f pop %edi
500: 5d pop %ebp
501: c3 ret
502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
state = '%';
508: bf 25 00 00 00 mov $0x25,%edi
50d: e9 66 ff ff ff jmp 478 <printf+0x48>
512: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
printint(fd, *ap, 16, 0);
518: 83 ec 0c sub $0xc,%esp
51b: b9 10 00 00 00 mov $0x10,%ecx
520: 6a 00 push $0x0
522: 8b 7d d4 mov -0x2c(%ebp),%edi
525: 8b 45 08 mov 0x8(%ebp),%eax
528: 8b 17 mov (%edi),%edx
52a: e8 61 fe ff ff call 390 <printint>
ap++;
52f: 89 f8 mov %edi,%eax
531: 83 c4 10 add $0x10,%esp
state = 0;
534: 31 ff xor %edi,%edi
ap++;
536: 83 c0 04 add $0x4,%eax
539: 89 45 d4 mov %eax,-0x2c(%ebp)
53c: e9 37 ff ff ff jmp 478 <printf+0x48>
541: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
548: 8b 45 d4 mov -0x2c(%ebp),%eax
54b: 8b 08 mov (%eax),%ecx
ap++;
54d: 83 c0 04 add $0x4,%eax
550: 89 45 d4 mov %eax,-0x2c(%ebp)
if(s == 0)
553: 85 c9 test %ecx,%ecx
555: 0f 84 8e 00 00 00 je 5e9 <printf+0x1b9>
while(*s != 0){
55b: 0f b6 01 movzbl (%ecx),%eax
state = 0;
55e: 31 ff xor %edi,%edi
s = (char*)*ap;
560: 89 cb mov %ecx,%ebx
while(*s != 0){
562: 84 c0 test %al,%al
564: 0f 84 0e ff ff ff je 478 <printf+0x48>
56a: 89 75 d0 mov %esi,-0x30(%ebp)
56d: 89 de mov %ebx,%esi
56f: 8b 5d 08 mov 0x8(%ebp),%ebx
572: 8d 7d e3 lea -0x1d(%ebp),%edi
575: 8d 76 00 lea 0x0(%esi),%esi
write(fd, &c, 1);
578: 83 ec 04 sub $0x4,%esp
s++;
57b: 83 c6 01 add $0x1,%esi
57e: 88 45 e3 mov %al,-0x1d(%ebp)
write(fd, &c, 1);
581: 6a 01 push $0x1
583: 57 push %edi
584: 53 push %ebx
585: e8 58 fd ff ff call 2e2 <write>
while(*s != 0){
58a: 0f b6 06 movzbl (%esi),%eax
58d: 83 c4 10 add $0x10,%esp
590: 84 c0 test %al,%al
592: 75 e4 jne 578 <printf+0x148>
594: 8b 75 d0 mov -0x30(%ebp),%esi
state = 0;
597: 31 ff xor %edi,%edi
599: e9 da fe ff ff jmp 478 <printf+0x48>
59e: 66 90 xchg %ax,%ax
printint(fd, *ap, 10, 1);
5a0: 83 ec 0c sub $0xc,%esp
5a3: b9 0a 00 00 00 mov $0xa,%ecx
5a8: 6a 01 push $0x1
5aa: e9 73 ff ff ff jmp 522 <printf+0xf2>
5af: 90 nop
write(fd, &c, 1);
5b0: 83 ec 04 sub $0x4,%esp
5b3: 88 5d e5 mov %bl,-0x1b(%ebp)
5b6: 8d 45 e5 lea -0x1b(%ebp),%eax
5b9: 6a 01 push $0x1
5bb: e9 21 ff ff ff jmp 4e1 <printf+0xb1>
putc(fd, *ap);
5c0: 8b 7d d4 mov -0x2c(%ebp),%edi
write(fd, &c, 1);
5c3: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
5c6: 8b 07 mov (%edi),%eax
write(fd, &c, 1);
5c8: 6a 01 push $0x1
ap++;
5ca: 83 c7 04 add $0x4,%edi
putc(fd, *ap);
5cd: 88 45 e4 mov %al,-0x1c(%ebp)
write(fd, &c, 1);
5d0: 8d 45 e4 lea -0x1c(%ebp),%eax
5d3: 50 push %eax
5d4: ff 75 08 pushl 0x8(%ebp)
5d7: e8 06 fd ff ff call 2e2 <write>
ap++;
5dc: 89 7d d4 mov %edi,-0x2c(%ebp)
5df: 83 c4 10 add $0x10,%esp
state = 0;
5e2: 31 ff xor %edi,%edi
5e4: e9 8f fe ff ff jmp 478 <printf+0x48>
s = "(null)";
5e9: bb 91 07 00 00 mov $0x791,%ebx
while(*s != 0){
5ee: b8 28 00 00 00 mov $0x28,%eax
5f3: e9 72 ff ff ff jmp 56a <printf+0x13a>
5f8: 66 90 xchg %ax,%ax
5fa: 66 90 xchg %ax,%ax
5fc: 66 90 xchg %ax,%ax
5fe: 66 90 xchg %ax,%ax
00000600 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
600: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
601: a1 44 0a 00 00 mov 0xa44,%eax
{
606: 89 e5 mov %esp,%ebp
608: 57 push %edi
609: 56 push %esi
60a: 53 push %ebx
60b: 8b 5d 08 mov 0x8(%ebp),%ebx
bp = (Header*)ap - 1;
60e: 8d 4b f8 lea -0x8(%ebx),%ecx
611: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
618: 39 c8 cmp %ecx,%eax
61a: 8b 10 mov (%eax),%edx
61c: 73 32 jae 650 <free+0x50>
61e: 39 d1 cmp %edx,%ecx
620: 72 04 jb 626 <free+0x26>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
622: 39 d0 cmp %edx,%eax
624: 72 32 jb 658 <free+0x58>
break;
if(bp + bp->s.size == p->s.ptr){
626: 8b 73 fc mov -0x4(%ebx),%esi
629: 8d 3c f1 lea (%ecx,%esi,8),%edi
62c: 39 fa cmp %edi,%edx
62e: 74 30 je 660 <free+0x60>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
630: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
633: 8b 50 04 mov 0x4(%eax),%edx
636: 8d 34 d0 lea (%eax,%edx,8),%esi
639: 39 f1 cmp %esi,%ecx
63b: 74 3a je 677 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
63d: 89 08 mov %ecx,(%eax)
freep = p;
63f: a3 44 0a 00 00 mov %eax,0xa44
}
644: 5b pop %ebx
645: 5e pop %esi
646: 5f pop %edi
647: 5d pop %ebp
648: c3 ret
649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
650: 39 d0 cmp %edx,%eax
652: 72 04 jb 658 <free+0x58>
654: 39 d1 cmp %edx,%ecx
656: 72 ce jb 626 <free+0x26>
{
658: 89 d0 mov %edx,%eax
65a: eb bc jmp 618 <free+0x18>
65c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
660: 03 72 04 add 0x4(%edx),%esi
663: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
666: 8b 10 mov (%eax),%edx
668: 8b 12 mov (%edx),%edx
66a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
66d: 8b 50 04 mov 0x4(%eax),%edx
670: 8d 34 d0 lea (%eax,%edx,8),%esi
673: 39 f1 cmp %esi,%ecx
675: 75 c6 jne 63d <free+0x3d>
p->s.size += bp->s.size;
677: 03 53 fc add -0x4(%ebx),%edx
freep = p;
67a: a3 44 0a 00 00 mov %eax,0xa44
p->s.size += bp->s.size;
67f: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
682: 8b 53 f8 mov -0x8(%ebx),%edx
685: 89 10 mov %edx,(%eax)
}
687: 5b pop %ebx
688: 5e pop %esi
689: 5f pop %edi
68a: 5d pop %ebp
68b: c3 ret
68c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
00000690 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
690: 55 push %ebp
691: 89 e5 mov %esp,%ebp
693: 57 push %edi
694: 56 push %esi
695: 53 push %ebx
696: 83 ec 0c sub $0xc,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
699: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
69c: 8b 15 44 0a 00 00 mov 0xa44,%edx
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6a2: 8d 78 07 lea 0x7(%eax),%edi
6a5: c1 ef 03 shr $0x3,%edi
6a8: 83 c7 01 add $0x1,%edi
if((prevp = freep) == 0){
6ab: 85 d2 test %edx,%edx
6ad: 0f 84 9d 00 00 00 je 750 <malloc+0xc0>
6b3: 8b 02 mov (%edx),%eax
6b5: 8b 48 04 mov 0x4(%eax),%ecx
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
if(p->s.size >= nunits){
6b8: 39 cf cmp %ecx,%edi
6ba: 76 6c jbe 728 <malloc+0x98>
6bc: 81 ff 00 10 00 00 cmp $0x1000,%edi
6c2: bb 00 10 00 00 mov $0x1000,%ebx
6c7: 0f 43 df cmovae %edi,%ebx
p = sbrk(nu * sizeof(Header));
6ca: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi
6d1: eb 0e jmp 6e1 <malloc+0x51>
6d3: 90 nop
6d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6d8: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
6da: 8b 48 04 mov 0x4(%eax),%ecx
6dd: 39 f9 cmp %edi,%ecx
6df: 73 47 jae 728 <malloc+0x98>
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
6e1: 39 05 44 0a 00 00 cmp %eax,0xa44
6e7: 89 c2 mov %eax,%edx
6e9: 75 ed jne 6d8 <malloc+0x48>
p = sbrk(nu * sizeof(Header));
6eb: 83 ec 0c sub $0xc,%esp
6ee: 56 push %esi
6ef: e8 56 fc ff ff call 34a <sbrk>
if(p == (char*)-1)
6f4: 83 c4 10 add $0x10,%esp
6f7: 83 f8 ff cmp $0xffffffff,%eax
6fa: 74 1c je 718 <malloc+0x88>
hp->s.size = nu;
6fc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
6ff: 83 ec 0c sub $0xc,%esp
702: 83 c0 08 add $0x8,%eax
705: 50 push %eax
706: e8 f5 fe ff ff call 600 <free>
return freep;
70b: 8b 15 44 0a 00 00 mov 0xa44,%edx
if((p = morecore(nunits)) == 0)
711: 83 c4 10 add $0x10,%esp
714: 85 d2 test %edx,%edx
716: 75 c0 jne 6d8 <malloc+0x48>
return 0;
}
}
718: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
71b: 31 c0 xor %eax,%eax
}
71d: 5b pop %ebx
71e: 5e pop %esi
71f: 5f pop %edi
720: 5d pop %ebp
721: c3 ret
722: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
728: 39 cf cmp %ecx,%edi
72a: 74 54 je 780 <malloc+0xf0>
p->s.size -= nunits;
72c: 29 f9 sub %edi,%ecx
72e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
731: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
734: 89 78 04 mov %edi,0x4(%eax)
freep = prevp;
737: 89 15 44 0a 00 00 mov %edx,0xa44
}
73d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
740: 83 c0 08 add $0x8,%eax
}
743: 5b pop %ebx
744: 5e pop %esi
745: 5f pop %edi
746: 5d pop %ebp
747: c3 ret
748: 90 nop
749: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
750: c7 05 44 0a 00 00 48 movl $0xa48,0xa44
757: 0a 00 00
75a: c7 05 48 0a 00 00 48 movl $0xa48,0xa48
761: 0a 00 00
base.s.size = 0;
764: b8 48 0a 00 00 mov $0xa48,%eax
769: c7 05 4c 0a 00 00 00 movl $0x0,0xa4c
770: 00 00 00
773: e9 44 ff ff ff jmp 6bc <malloc+0x2c>
778: 90 nop
779: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
prevp->s.ptr = p->s.ptr;
780: 8b 08 mov (%eax),%ecx
782: 89 0a mov %ecx,(%edx)
784: eb b1 jmp 737 <malloc+0xa7>
|
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
//
// Temperature Menu
//
#include "../../inc/MarlinConfigPre.h"
#if HAS_LCD_MENU
#include "menu.h"
#include "../../module/temperature.h"
#if FAN_COUNT > 1 || ENABLED(SINGLENOZZLE)
#include "../../module/motion.h"
#endif
#if ENABLED(SINGLENOZZLE)
#include "../../module/tool_change.h"
#endif
// Initialized by settings.load()
int16_t MarlinUI::preheat_hotend_temp[2], MarlinUI::preheat_bed_temp[2];
uint8_t MarlinUI::preheat_fan_speed[2];
//
// "Temperature" submenu items
//
void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const uint8_t fan) {
if (temph > 0) thermalManager.setTargetHotend(MIN(heater_maxtemp[endnum] - 15, temph), endnum);
#if HAS_HEATED_BED
if (tempb >= 0) thermalManager.setTargetBed(tempb);
#else
UNUSED(tempb);
#endif
#if FAN_COUNT > 0
#if FAN_COUNT > 1
thermalManager.set_fan_speed(active_extruder < FAN_COUNT ? active_extruder : 0, fan);
#else
thermalManager.set_fan_speed(0, fan);
#endif
#else
UNUSED(fan);
#endif
ui.return_to_status();
}
#if HOTENDS > 1
void lcd_preheat_m1_e1_only() { _lcd_preheat(1, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e1_only() { _lcd_preheat(1, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e1() { _lcd_preheat(1, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e1() { _lcd_preheat(1, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#if HOTENDS > 2
void lcd_preheat_m1_e2_only() { _lcd_preheat(2, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e2_only() { _lcd_preheat(2, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e2() { _lcd_preheat(2, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e2() { _lcd_preheat(2, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#if HOTENDS > 3
void lcd_preheat_m1_e3_only() { _lcd_preheat(3, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e3_only() { _lcd_preheat(3, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e3() { _lcd_preheat(3, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e3() { _lcd_preheat(3, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#if HOTENDS > 4
void lcd_preheat_m1_e4_only() { _lcd_preheat(4, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e4_only() { _lcd_preheat(4, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e4() { _lcd_preheat(4, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e4() { _lcd_preheat(4, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#if HOTENDS > 5
void lcd_preheat_m1_e5_only() { _lcd_preheat(5, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e5_only() { _lcd_preheat(5, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e5() { _lcd_preheat(5, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e5() { _lcd_preheat(5, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#if HAS_HEATED_BED
void lcd_preheat_m1_e0();
void lcd_preheat_m2_e0();
#else
void lcd_preheat_m1_e0_only();
void lcd_preheat_m2_e0_only();
#endif
void lcd_preheat_m1_all() {
#if HOTENDS > 1
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 1);
#if HOTENDS > 2
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 2);
#if HOTENDS > 3
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 3);
#if HOTENDS > 4
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 4);
#if HOTENDS > 5
thermalManager.setTargetHotend(ui.preheat_hotend_temp[0], 5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#if HAS_HEATED_BED
lcd_preheat_m1_e0();
#else
lcd_preheat_m1_e0_only();
#endif
}
void lcd_preheat_m2_all() {
#if HOTENDS > 1
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 1);
#if HOTENDS > 2
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 2);
#if HOTENDS > 3
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 3);
#if HOTENDS > 4
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 4);
#if HOTENDS > 5
thermalManager.setTargetHotend(ui.preheat_hotend_temp[1], 5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#if HAS_HEATED_BED
lcd_preheat_m2_e0();
#else
lcd_preheat_m2_e0_only();
#endif
}
#endif // HOTENDS > 1
#if HAS_TEMP_HOTEND || HAS_HEATED_BED
void lcd_preheat_m1_e0_only() { _lcd_preheat(0, ui.preheat_hotend_temp[0], -1, ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e0_only() { _lcd_preheat(0, ui.preheat_hotend_temp[1], -1, ui.preheat_fan_speed[1]); }
#if HAS_HEATED_BED
void lcd_preheat_m1_e0() { _lcd_preheat(0, ui.preheat_hotend_temp[0], ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_e0() { _lcd_preheat(0, ui.preheat_hotend_temp[1], ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
void lcd_preheat_m1_bedonly() { _lcd_preheat(0, 0, ui.preheat_bed_temp[0], ui.preheat_fan_speed[0]); }
void lcd_preheat_m2_bedonly() { _lcd_preheat(0, 0, ui.preheat_bed_temp[1], ui.preheat_fan_speed[1]); }
#endif
void menu_preheat_m1() {
START_MENU();
MENU_BACK(MSG_TEMPERATURE);
#if HOTENDS == 1
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0);
MENU_ITEM(function, MSG_PREHEAT_1_END, lcd_preheat_m1_e0_only);
#else
MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only);
#endif
#elif HOTENDS > 1
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E1, lcd_preheat_m1_e0_only);
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E2, lcd_preheat_m1_e1_only);
#else
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H1, lcd_preheat_m1_e0_only);
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H2, lcd_preheat_m1_e1_only);
#endif
#if HOTENDS > 2
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E3, lcd_preheat_m1_e2_only);
#else
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H3, lcd_preheat_m1_e2_only);
#endif
#if HOTENDS > 3
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E4, lcd_preheat_m1_e3_only);
#else
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H4, lcd_preheat_m1_e3_only);
#endif
#if HOTENDS > 4
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E5, lcd_preheat_m1_e4_only);
#else
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H5, lcd_preheat_m1_e4_only);
#endif
#if HOTENDS > 5
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H6, lcd_preheat_m1_e5);
MENU_ITEM(function, MSG_PREHEAT_1_END " " MSG_E6, lcd_preheat_m1_e5_only);
#else
MENU_ITEM(function, MSG_PREHEAT_1_N MSG_H6, lcd_preheat_m1_e5_only);
#endif
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
MENU_ITEM(function, MSG_PREHEAT_1_ALL, lcd_preheat_m1_all);
#endif // HOTENDS > 1
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_1_BEDONLY, lcd_preheat_m1_bedonly);
#endif
END_MENU();
}
void menu_preheat_m2() {
START_MENU();
MENU_BACK(MSG_TEMPERATURE);
#if HOTENDS == 1
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0);
MENU_ITEM(function, MSG_PREHEAT_2_END, lcd_preheat_m2_e0_only);
#else
MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
#endif
#elif HOTENDS > 1
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E1, lcd_preheat_m2_e0_only);
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E2, lcd_preheat_m2_e1_only);
#else
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H1, lcd_preheat_m2_e0_only);
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H2, lcd_preheat_m2_e1_only);
#endif
#if HOTENDS > 2
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E3, lcd_preheat_m2_e2_only);
#else
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H3, lcd_preheat_m2_e2_only);
#endif
#if HOTENDS > 3
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E4, lcd_preheat_m2_e3_only);
#else
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H4, lcd_preheat_m2_e3_only);
#endif
#if HOTENDS > 4
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E5, lcd_preheat_m2_e4_only);
#else
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H5, lcd_preheat_m2_e4_only);
#endif
#if HOTENDS > 5
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H6, lcd_preheat_m2_e5);
MENU_ITEM(function, MSG_PREHEAT_2_END " " MSG_E6, lcd_preheat_m2_e5_only);
#else
MENU_ITEM(function, MSG_PREHEAT_2_N MSG_H6, lcd_preheat_m2_e5_only);
#endif
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
MENU_ITEM(function, MSG_PREHEAT_2_ALL, lcd_preheat_m2_all);
#endif // HOTENDS > 1
#if HAS_HEATED_BED
MENU_ITEM(function, MSG_PREHEAT_2_BEDONLY, lcd_preheat_m2_bedonly);
#endif
END_MENU();
}
void lcd_cooldown() {
thermalManager.zero_fan_speeds();
thermalManager.disable_all_heaters();
ui.return_to_status();
}
#endif // HAS_TEMP_HOTEND || HAS_HEATED_BED
#if ENABLED(SPINDLE_LASER_ENABLE)
extern uint8_t spindle_laser_power;
bool spindle_laser_enabled();
void set_spindle_laser_enabled(const bool enabled);
#if ENABLED(SPINDLE_LASER_PWM)
void update_spindle_laser_power();
#endif
inline void _lcd_spindle_laser_off() { set_spindle_laser_enabled(false); }
inline void _lcd_spindle_laser_on(const bool is_M4) {
#if SPINDLE_DIR_CHANGE
set_spindle_direction(is_M4);
#endif
set_spindle_laser_enabled(true);
}
inline void _lcd_spindle_laser_on() { _lcd_spindle_laser_on(false); }
#if SPINDLE_DIR_CHANGE
inline void _lcd_spindle_on_reverse() { _lcd_spindle_laser_on(true); }
#endif
void menu_spindle_laser() {
START_MENU();
MENU_BACK(MSG_MAIN);
if (spindle_laser_enabled()) {
#if ENABLED(SPINDLE_LASER_PWM)
MENU_ITEM_EDIT_CALLBACK(int3, MSG_LASER_POWER, &spindle_laser_power, SPEED_POWER_MIN, SPEED_POWER_MAX, update_spindle_laser_power);
#endif
MENU_ITEM(function, MSG_LASER_OFF, _lcd_spindle_laser_off);
}
else {
MENU_ITEM(function, MSG_LASER_ON, _lcd_spindle_laser_on);
#if SPINDLE_DIR_CHANGE
MENU_ITEM(function, MSG_SPINDLE_REVERSE, _lcd_spindle_on_reverse);
#endif
}
END_MENU();
}
#endif // SPINDLE_LASER_ENABLE
void menu_temperature() {
START_MENU();
MENU_BACK(MSG_MAIN);
//
// Nozzle:
// Nozzle [1-5]:
//
#if HOTENDS == 1
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE, &thermalManager.temp_hotend[0].target, 0, HEATER_0_MAXTEMP - 15, thermalManager.start_watching_E0);
#else // HOTENDS > 1
#define EDIT_TARGET(N) MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE MSG_LCD_N##N, &thermalManager.temp_hotend[N].target, 0, HEATER_##N##_MAXTEMP - 15, thermalManager.start_watching_E##N)
EDIT_TARGET(0);
EDIT_TARGET(1);
#if HOTENDS > 2
EDIT_TARGET(2);
#if HOTENDS > 3
EDIT_TARGET(3);
#if HOTENDS > 4
EDIT_TARGET(4);
#if HOTENDS > 5
EDIT_TARGET(5);
#endif // HOTENDS > 5
#endif // HOTENDS > 4
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#if ENABLED(SINGLENOZZLE)
MENU_MULTIPLIER_ITEM_EDIT(uint16_3, MSG_NOZZLE_STANDBY, &singlenozzle_temp[active_extruder ? 0 : 1], 0, HEATER_0_MAXTEMP - 15);
#endif
//
// Bed:
//
#if HAS_HEATED_BED
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &thermalManager.temp_bed.target, 0, BED_MAXTEMP - 10, thermalManager.start_watching_bed);
#endif
//
// Chamber:
//
#if HAS_HEATED_CHAMBER
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_CHAMBER, &thermalManager.temp_chamber.target, 0, CHAMBER_MAXTEMP - 5, thermalManager.start_watching_chamber);
#endif
//
// Fan Speed:
//
#if FAN_COUNT > 0
#if HAS_FAN0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(percent, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &thermalManager.lcd_tmpfan_speed[0], 0, 255, thermalManager.lcd_setFanSpeed0);
#if ENABLED(EXTRA_FAN_SPEED)
MENU_MULTIPLIER_ITEM_EDIT(percent, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &thermalManager.new_fan_speed[0], 3, 255);
#endif
#endif
#if HAS_FAN1 || (ENABLED(SINGLENOZZLE) && EXTRUDERS > 1)
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(percent, MSG_FAN_SPEED " 2", &thermalManager.lcd_tmpfan_speed[1], 0, 255, thermalManager.lcd_setFanSpeed1);
#if ENABLED(EXTRA_FAN_SPEED)
MENU_MULTIPLIER_ITEM_EDIT(percent, MSG_EXTRA_FAN_SPEED " 2", &thermalManager.new_fan_speed[1], 3, 255);
#endif
#endif
#if HAS_FAN2 || (ENABLED(SINGLENOZZLE) && EXTRUDERS > 2)
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(percent, MSG_FAN_SPEED " 3", &thermalManager.lcd_tmpfan_speed[2], 0, 255, thermalManager.lcd_setFanSpeed2);
#if ENABLED(EXTRA_FAN_SPEED)
MENU_MULTIPLIER_ITEM_EDIT(percent, MSG_EXTRA_FAN_SPEED " 3", &thermalManager.new_fan_speed[2], 3, 255);
#endif
#endif
#endif // FAN_COUNT > 0
#if ENABLED(SPINDLE_LASER_ENABLE)
MENU_ITEM(submenu, MSG_LASER_MENU, menu_spindle_laser);
#endif
#if HAS_TEMP_HOTEND
//
// Preheat for Material 1 and 2
//
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_4 != 0 || TEMP_SENSOR_5 != 0 || HAS_HEATED_BED
MENU_ITEM(submenu, MSG_PREHEAT_1, menu_preheat_m1);
MENU_ITEM(submenu, MSG_PREHEAT_2, menu_preheat_m2);
#else
MENU_ITEM(function, MSG_PREHEAT_1, lcd_preheat_m1_e0_only);
MENU_ITEM(function, MSG_PREHEAT_2, lcd_preheat_m2_e0_only);
#endif
//
// Cooldown
//
bool has_heat = false;
HOTEND_LOOP() if (thermalManager.temp_hotend[HOTEND_INDEX].target) { has_heat = true; break; }
#if HAS_TEMP_BED
if (thermalManager.temp_bed.target) has_heat = true;
#endif
if (has_heat) MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
#endif // HAS_TEMP_HOTEND
END_MENU();
}
#endif // HAS_LCD_MENU
|
//Problem link - https://www.hackerrank.com/challenges/rectangle-area
//Code author - Parin Vachhani - https://github.com/parinvachhani
#include <iostream>
using namespace std;
class Rectangle {
protected:
int width,height;
public:
virtual void display() const {
cout << width << ' ' << height << endl;
}
};
class RectangleArea : public Rectangle {
public:
void read_input(){
cin >> width >> height;
}
void display() const override{
cout << width*height << endl;
}
};
int main(){
RectangleArea r_area;
r_area.read_input();
r_area.Rectangle::display();
r_area.display();
return 0;
} |
#pragma once
class Tickable {
public:
Tickable() {}
virtual ~Tickable() {}
virtual void onTick(float dt) = 0;
private:
};
|
/*
Copyright 2009-2021 Nicolas Colombe
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 <engine/gfx/tileset.hpp>
#include <core/resource/resourceloader.hpp>
#include <core/resource/resourcemanager.hpp>
#include <core/image/imagestreamer.hpp>
#include <ogl/renderer/ogltextureloader.hpp>
#include <core/log.hpp>
#include <core/type/typemanager.hpp>
#include <core/type/enumtype.hpp>
#include <core/type/arraytype.hpp>
#include <core/type/tupletypestruct.hpp>
#include <core/stream/jsonstreamer.hpp>
#include <fstream>
#include "../dummysprites.hpp"
#define BUFFERSIZE 256
#include <b64/encode.h>
#include <b64/decode.h>
#undef BUFFERSIZE
namespace eXl
{
IMPLEMENT_RTTI(Tileset)
Err Tile::Stream(Streamer& iStreamer) const
{
return GetType()->Stream(this, &iStreamer);
}
Err Tile::Unstream(Unstreamer& iStreamer)
{
void* readBuffer = this;
return GetType()->Unstream(readBuffer, &iStreamer);
}
class TilesetLoader : public ResourceLoader
{
public:
static TilesetLoader& Get()
{
static TilesetLoader s_This;
return s_This;
}
TilesetLoader()
: ResourceLoader(Tileset::StaticLoaderName(), 1)
{
}
static Type const* GetTileType()
{
static TupleType const* s_Type = []
{
return TypeManager::BeginNativeTypeRegistration<Tile>("Tile")
.AddField("ImageName", &Tile::m_ImageName)
.AddField("FrameDuration", &Tile::m_FrameDuration)
.AddField("Size", &Tile::m_Size)
.AddField("AnimationType", &Tile::m_AnimType)
.AddCustomField("Frames", &Tile::m_Frames, TypeManager::GetArrayType<Vector2i>())
.AddField("Offset", &Tile::m_Offset)
.AddField("Scale", &Tile::m_Scale)
.EndRegistration();
}();
return s_Type;
}
#ifndef EXL_IS_BAKED_PLATFORM
Tileset* Create(Path const& iDir, String const& iName) const
{
ResourceMetaData* metaData = CreateNewMetaData(iName);
Path rscPath = iDir / Path(iName.c_str());
rscPath.replace_extension(ResourceManager::GetAssetExtension().c_str());
Tileset* newTileset = eXl_NEW Tileset(*metaData);
newTileset->SetFlags(Resource::LockPathDirectory);
if (ResourceManager::SetPath(newTileset, rscPath))
{
return newTileset;
}
return nullptr;
}
#endif
Tileset* Create_Impl(ResourceMetaData* iMetaData) const override
{
Tileset* tileset = eXl_NEW Tileset(*iMetaData);
return tileset;
}
bool NeedsBaking(Resource* iRsc) const override
{
return true;
}
Tileset* CreateBakedResource(Resource* iRsc) const override
{
Tileset* tilesetToBake = Tileset::DynamicCast(iRsc);
Tileset* bakedTileset = eXl_NEW Tileset(*CreateBakedMetaData(iRsc->GetMetaData()));
bakedTileset->m_Tiles = tilesetToBake->m_Tiles;
bakedTileset->PostLoad();
return bakedTileset;
}
private:
Type const* m_TileType;
};
void Tileset::Init()
{
ResourceManager::AddLoader(&TilesetLoader::Get(), Tileset::StaticRtti());
}
Type const* Tile::GetType()
{
return TilesetLoader::GetTileType();
}
void Tileset::PostLoad()
{
#ifndef EXL_IS_BAKED_PLATFORM
Path rscPath = ResourceManager::GetPath(GetHeader().m_ResourceId);
Path rscDir = rscPath.parent_path();
for (auto const& tile : m_Tiles)
{
ImageName imgName = tile.second.m_ImageName;
if (imgName != Tile::EmptyName())
{
if (m_ImagePathCache.count(tile.second.m_ImageName) == 0)
{
Path imagePath = rscDir / Path(imgName.get().c_str());
m_ImagePathCache.insert(std::make_pair(imgName, imagePath));
}
}
}
#endif
}
#ifndef EXL_IS_BAKED_PLATFORM
Path Tileset::GetSrcImagePath(ImageName iImage) const
{
auto iterPath = m_ImagePathCache.find(iImage);
if (iterPath == m_ImagePathCache.end())
{
return Path();
}
return iterPath->second;
}
boost::optional<ImageName> Tileset::ImageNameFromImagePath(Path const& iImagePath)
{
Path resourcePath = ResourceManager::GetPath(GetHeader().m_ResourceId);
if (iImagePath.string() == Tile::EmptyName().get())
{
return {};
}
if (Filesystem::exists(iImagePath) && !Filesystem::is_directory(iImagePath))
{
Path containingDir = Filesystem::absolute(Filesystem::canonical(iImagePath.parent_path()));
Path remainingPath = iImagePath.filename();
Path resourceDir = resourcePath.parent_path();
while (containingDir != resourceDir && containingDir.has_parent_path())
{
remainingPath = containingDir.filename() / remainingPath;
containingDir = containingDir.parent_path();
}
if (containingDir == resourceDir)
{
return ImageName(remainingPath.string().c_str());
}
}
return {};
}
Tileset* Tileset::Create(Path const& iDir, String const& iName)
{
return TilesetLoader::Get().Create(iDir, iName);
}
#endif
ResourceLoaderName Tileset::StaticLoaderName()
{
return ResourceLoaderName("Tileset");
}
Tileset::Tileset(ResourceMetaData& iMetaData)
: Resource(iMetaData)
{
}
Err Tileset::AddTile(TileName iName, Tile const& iTile)
{
if (iTile.m_ImageName != Tile::EmptyName())
{
#ifndef EXL_IS_BAKED_PLATFORM
if (m_ImagePathCache.count(iTile.m_ImageName) == 0)
{
Path rscPath = ResourceManager::GetPath(GetHeader().m_ResourceId);
Path rscDir = rscPath.parent_path();
Path imagePath = rscDir / Path(iTile.m_ImageName.get().c_str());
if (!Filesystem::exists(imagePath) || Filesystem::is_directory(imagePath))
{
LOG_ERROR << "Could not find an image at " << imagePath.string() << "\n";
return Err::Error;
}
m_ImagePathCache.insert(std::make_pair(iTile.m_ImageName, imagePath));
}
#else
if (m_Images.count(iTile.m_ImageName) == 0)
{
return Err::Error;
}
#endif
}
m_Tiles.insert_or_assign(iName, iTile);
return Err::Success;
}
void Tileset::RemoveTile(TileName iName)
{
m_Tiles.erase(iName);
}
Image const* Tileset::GetImage(ImageName iImage) const
{
if (iImage == Tile::EmptyName())
{
return nullptr;
}
auto iter = const_cast<Tileset*>(this)->m_Images.find(iImage);
if(iter == m_Images.end() || iter->second == nullptr)
{
#ifndef EXL_IS_BAKED_PLATFORM
auto iterPath = m_ImagePathCache.find(iImage);
if (iterPath == m_ImagePathCache.end())
{
LOG_WARNING << "Tried to use unknown image " << iImage.get() << " with tileset " << GetName() << "\n";
return nullptr;
}
#ifdef EXL_IMAGESTREAMER_ENABLED
if (Image* newImg = ImageStreamer::Load(iterPath->second.string().c_str()))
{
iter = const_cast<Tileset*>(this)->m_Images.emplace(std::make_pair(iImage, std::unique_ptr<Image>())).first;
iter->second.reset(newImg);
}
else
#endif
{
LOG_ERROR << "Could not load image at path " << iterPath->second.string() << "\n";
}
#endif
}
if (iter == m_Images.end())
{
return nullptr;
}
return iter->second.get();
}
Vector2i Tileset::GetImageSize(ImageName iImage) const
{
if(Image const* image = GetImage(iImage))
{
return Vector2i(image->GetSize().X(), image->GetSize().Y());
}
return Vector2i::ZERO;
}
IntrusivePtr<OGLTexture> Tileset::GetTexture(ImageName iImage) const
{
#ifdef EXL_WITH_OGL
auto iter = m_Textures.find(iImage);
if (iter == m_Textures.end())
{
Image const* img = GetImage(iImage);
if (img == nullptr)
{
return IntrusivePtr<OGLTexture>();
}
//Image dummy = DummySprites::BitmapToImage(DummySprites::dummyChar, img->GetSize());
//img = &dummy;
if (OGLTexture* newTex = OGLTextureLoader::CreateFromImage(img, true))
{
LOG_INFO << "Created texture for image " << img << " of size (" << img->GetSize().X() << ", " << img->GetSize().Y() << ")\n";
iter = const_cast<Tileset*>(this)->m_Textures.insert(std::make_pair(iImage, newTex)).first;
}
else
{
LOG_ERROR << "Could not create texture for image " << iImage.get() << "\n";
}
}
if (iter == m_Textures.end())
{
return iter->second;
}
return iter->second;
#else
return nullptr;
#endif
}
Err Tileset::Stream_Data(Streamer& iStreamer) const
{
return const_cast<Tileset*>(this)->Serialize(Serializer(iStreamer));
}
Err Tileset::Unstream_Data(Unstreamer& iStreamer)
{
return Serialize(Serializer(iStreamer));
}
namespace
{
uint32_t NextPOT(uint32_t iValue)
{
uint32_t val = 1;
while (val < iValue)
{
val *= 2;
}
return val;
}
}
Err Tileset::Serialize(Serializer iStreamer)
{
iStreamer.BeginStruct();
iStreamer.PushKey("Tiles");
iStreamer.HandleMapSorted(m_Tiles);
//iStreamer.HandleSequence(m_Tiles,
// [](UnorderedMap<TileName, Tile>& oMap, Unstreamer& iStreamer)
//{
// String tempStr;
// Tile tempTile;
// iStreamer.BeginStruct();
// iStreamer.PushKey("Name");
// iStreamer.Read(&tempStr);
// iStreamer.PopKey();
// iStreamer.PushKey("TileData");
// iStreamer.Read(&tempTile);
// iStreamer.PopKey();
// iStreamer.EndStruct();
//
// oMap.insert(std::make_pair(TileName(tempStr), std::move(tempTile)));
//},
// [](UnorderedMap<TileName, Tile>::value_type const& iEntry, Streamer& iStreamer)
//{
// iStreamer.BeginStruct();
// iStreamer.PushKey("Name");
// iStreamer.Write(&iEntry.first);
// iStreamer.PopKey();
// iStreamer.PushKey("TileData");
// iStreamer.Write(&iEntry.second);
// iStreamer.PopKey();
// iStreamer.EndStruct();
//});
iStreamer.PopKey();
if (GetHeader().m_Flags & BakedResource)
{
#ifndef EXL_IS_BAKED_PLATFORM
if (iStreamer.IsWriting())
{
for (auto& entry : m_ImagePathCache)
{
m_Images.insert(std::make_pair(entry.first, nullptr));
}
}
#endif
iStreamer.PushKey("Images");
iStreamer.HandleSequence(m_Images,
[this](UnorderedMap<ImageName, std::unique_ptr<Image>>& oMap, Unstreamer& iStreamer)
{
String tempStr;
iStreamer.BeginStruct();
iStreamer.PushKey("Name");
iStreamer.Read(&tempStr);
iStreamer.PopKey();
iStreamer.PushKey("Data");
#ifdef RAW_IMAGE
iStreamer.BeginStruct();
iStreamer.PushKey("Size");
Vector2i size;
iStreamer.Read(&size);
iStreamer.PopKey();
int components;
iStreamer.PushKey("Components");
iStreamer.ReadInt(&components);
iStreamer.PopKey();
int format;
iStreamer.PushKey("Format");
iStreamer.ReadInt(&format);
iStreamer.PopKey();
iStreamer.PushKey("Pixels");
String base64String;
iStreamer.ReadString(&base64String);
LOG_INFO << "Image : " << tempStr << "Data : " << base64String;
Vector<char> imageData;
imageData.reserve(base64String.size());
base64::base64_decodestate state;
base64::base64_init_decodestate(&state);
size_t const decodeBufferSize = 256;
char decodeBuffer[decodeBufferSize];
char const* dataIter = base64String.data();
char const* endIter = dataIter + base64String.size();
size_t const inputSize = 128;
do
{
size_t readSize = dataIter + inputSize < endIter ? inputSize : endIter - dataIter;
size_t outSize = base64::base64_decode_block(dataIter, readSize, decodeBuffer, &state);
imageData.insert(imageData.end(), decodeBuffer, decodeBuffer + outSize);
dataIter += readSize;
} while (dataIter != endIter);
Image::Size imageSize(size.X(), size.Y());
std::unique_ptr<Image> imagePtr;
{
imagePtr = std::make_unique<Image>(imageData.data(), imageSize, (Image::Components)components, (Image::Format)format, 4);
}
//std::unique_ptr<Image> imagePtr(ImageStreamer::Load((uint8_t*)imageData.data(), imageData.size()));
//Image::Size imageSize = imagePtr ? imagePtr->GetSize() : Image::Size(0, 0);
//if (imageSize.X() == 0 || imageSize.Y() == 0)
//{
// LOG_ERROR << "Image " << tempStr << " zero size!!";
//}
oMap.insert(std::make_pair(ImageName(tempStr), std::move(imagePtr)));
iStreamer.PopKey();
iStreamer.EndStruct();
#else
String base64String;
iStreamer.ReadString(&base64String);
Vector<char> imageData;
imageData.reserve(base64String.size());
base64::base64_decodestate state;
base64::base64_init_decodestate(&state);
size_t const decodeBufferSize = 256;
char decodeBuffer[decodeBufferSize];
char const* dataIter = base64String.data();
char const* endIter = dataIter + base64String.size();
size_t const inputSize = 128;
do
{
size_t readSize = dataIter + inputSize < endIter ? inputSize : endIter - dataIter;
size_t outSize = base64::base64_decode_block(dataIter, readSize, decodeBuffer, &state);
imageData.insert(imageData.end(), decodeBuffer, decodeBuffer + outSize);
dataIter += readSize;
} while (dataIter != endIter);
#ifdef EXL_IMAGESTREAMER_ENABLED
std::unique_ptr<Image> imagePtr(ImageStreamer::Load((uint8_t*)imageData.data(), imageData.size()));
Image::Size imageSize = imagePtr ? imagePtr->GetSize() : Image::Size(0, 0);
if (imageSize.X() == 0 || imageSize.Y() == 0)
{
LOG_ERROR << "Image " << tempStr << " zero size!!";
}
oMap.insert(std::make_pair(ImageName(tempStr), std::move(imagePtr)));
#endif
#endif
iStreamer.PopKey();
iStreamer.EndStruct();
},
[this](UnorderedMap<ImageName, std::unique_ptr<Image>>::value_type const& iEntry, Streamer& iStreamer)
{
#ifndef EXL_IS_BAKED_PLATFORM
iStreamer.BeginStruct();
iStreamer.PushKey("Name");
iStreamer.Write(&iEntry.first);
iStreamer.PopKey();
iStreamer.PushKey("Data");
#ifdef RAW_IMAGE
iStreamer.BeginStruct();
Image const* image = GetImage(iEntry.first);
iStreamer.PushKey("Size");
Vector2i size(image->GetSize().X(), image->GetSize().Y());
iStreamer.Write(&size);
iStreamer.PopKey();
int components = image->GetComponents();
iStreamer.PushKey("Components");
iStreamer.WriteInt(&components);
iStreamer.PopKey();
int format = image->GetFormat();
iStreamer.PushKey("Format");
iStreamer.WriteInt(&format);
iStreamer.PopKey();
iStreamer.PushKey("Pixels");
base64::base64_encodestate state;
base64::base64_init_encodestate(&state);
Vector<char> tempStr;
char const* pixelsData = (char const*)image->GetImageData();
size_t const inputBufferSize = 128;
size_t const encodeBufferSize = 256;
char encodeBuffer[encodeBufferSize];
for (int i = 0; i < size.Y(); ++i)
{
char const* pixelRow = pixelsData + i * image->GetRowStride();
size_t rowSizeInBytes = size.X() * image->GetPixelSize();
uint32_t numWrites = rowSizeInBytes / inputBufferSize;
numWrites += rowSizeInBytes % inputBufferSize == 0 ? 0 : 1;
for(uint32_t block = 0; block < numWrites; ++block)
{
uint32_t readSize = block == numWrites - 1 && rowSizeInBytes % inputBufferSize != 0
? rowSizeInBytes % inputBufferSize
: inputBufferSize;
size_t encodeSize = base64::base64_encode_block(pixelRow + block * inputBufferSize, readSize, encodeBuffer, &state);
tempStr.insert(tempStr.end(), encodeBuffer, encodeBuffer + encodeSize);
}
}
size_t encodeSize = base64::base64_encode_blockend(encodeBuffer, &state);
tempStr.insert(tempStr.end(), encodeBuffer, encodeBuffer + encodeSize);
tempStr.push_back(0);
iStreamer.WriteString(tempStr.data());
iStreamer.PopKey();
iStreamer.EndStruct();
#endif
Path imgPath = GetSrcImagePath(iEntry.first);
std::ifstream fileStream(imgPath.c_str(), std::ios::binary);
if (fileStream.is_open())
{
size_t const inputBufferSize = 128;
char inputBuffer[inputBufferSize];
size_t const encodeBufferSize = 256;
char encodeBuffer[encodeBufferSize];
base64::base64_encodestate state;
base64::base64_init_encodestate(&state);
Vector<char> tempStr;
fileStream.read(inputBuffer, inputBufferSize);
size_t readSize = fileStream.gcount();
while (readSize > 0)
{
size_t encodeSize = base64::base64_encode_block(inputBuffer, readSize, encodeBuffer, &state);
tempStr.insert(tempStr.end(), encodeBuffer, encodeBuffer + encodeSize);
fileStream.read(inputBuffer, inputBufferSize);
readSize = fileStream.gcount();
}
size_t encodeSize = base64::base64_encode_blockend(encodeBuffer, &state);
tempStr.insert(tempStr.end(), encodeBuffer, encodeBuffer + encodeSize);
tempStr.push_back(0);
iStreamer.WriteString(tempStr.data());
}
iStreamer.PopKey();
iStreamer.EndStruct();
#endif
});
iStreamer.PopKey();
}
iStreamer.EndStruct();
return Err::Success;
}
//Err Tileset::Unstream_Data(Unstreamer& iStreamer)
//{
// String tempStr;
// iStreamer.BeginStruct();
//
// auto tileType = TilesetLoader::Get().GetTileType();
//
// iStreamer.PushKey("Tiles");
// if (iStreamer.BeginSequence())
// {
// do
// {
//
//
// } while (iStreamer.NextSequenceElement());
// }
// iStreamer.PopKey();
//
// iStreamer.EndStruct();
//
// return Err::Success;
//}
uint32_t Tileset::ComputeHash()
{
return 0;
}
} |
#include "db_impl.h"
#include "blob_file_iterator.h"
#include "blob_gc_job.h"
#include "blob_gc_picker.h"
namespace rocksdb {
namespace titandb {
void TitanDBImpl::MaybeScheduleGC() {
mutex_.AssertHeld();
if (db_options_.disable_background_gc) return;
if (shuting_down_.load(std::memory_order_acquire)) return;
if (bg_gc_scheduled_.load(std::memory_order_acquire) >=
db_options_.max_background_gc)
return;
bg_gc_scheduled_.fetch_add(1, std::memory_order_release);
env_->Schedule(&TitanDBImpl::BGWorkGC, this, Env::Priority::LOW, this);
}
void TitanDBImpl::BGWorkGC(void* db) {
reinterpret_cast<TitanDBImpl*>(db)->BackgroundCallGC();
}
void TitanDBImpl::BackgroundCallGC() {
LogBuffer log_buffer(InfoLogLevel::INFO_LEVEL, db_options_.info_log.get());
{
MutexLock l(&mutex_);
assert(bg_gc_scheduled_ > 0);
BackgroundGC(&log_buffer);
{
mutex_.Unlock();
log_buffer.FlushBufferToLog();
LogFlush(db_options_.info_log.get());
mutex_.Lock();
}
bg_gc_scheduled_--;
if (bg_gc_scheduled_ == 0) {
// signal if
// * bg_gc_scheduled_ == 0 -- need to wakeup ~TitanDBImpl
// If none of this is true, there is no need to signal since nobody is
// waiting for it
bg_cv_.SignalAll();
}
// IMPORTANT: there should be no code after calling SignalAll. This call may
// signal the DB destructor that it's OK to proceed with destruction. In
// that case, all DB variables will be dealloacated and referencing them
// will cause trouble.
}
}
Status TitanDBImpl::BackgroundGC(LogBuffer* log_buffer) {
mutex_.AssertHeld();
std::unique_ptr<BlobGC> blob_gc;
std::unique_ptr<ColumnFamilyHandle> cfh;
Status s;
if (!gc_queue_.empty()) {
uint32_t column_family_id = PopFirstFromGCQueue();
auto bs = vset_->GetBlobStorage(column_family_id).lock().get();
const auto& titan_cf_options = bs->titan_cf_options();
std::shared_ptr<BlobGCPicker> blob_gc_picker =
std::make_shared<BasicBlobGCPicker>(db_options_, titan_cf_options);
blob_gc = blob_gc_picker->PickBlobGC(bs);
if (blob_gc) {
cfh = db_impl_->GetColumnFamilyHandleUnlocked(column_family_id);
assert(column_family_id == cfh->GetID());
blob_gc->SetColumnFamily(cfh.get());
}
}
// TODO(@DorianZheng) Make sure enough room for GC
if (UNLIKELY(!blob_gc)) {
// Nothing to do
ROCKS_LOG_BUFFER(log_buffer, "Titan GC nothing to do");
} else {
BlobGCJob blob_gc_job(blob_gc.get(), db_, &mutex_, db_options_, env_,
env_options_, blob_manager_.get(), vset_.get(),
log_buffer, &shuting_down_);
s = blob_gc_job.Prepare();
if (s.ok()) {
mutex_.Unlock();
s = blob_gc_job.Run();
mutex_.Lock();
}
if (s.ok()) {
s = blob_gc_job.Finish();
}
blob_gc->ReleaseGcFiles();
}
if (s.ok()) {
// Done
} else {
ROCKS_LOG_WARN(db_options_.info_log, "Titan GC error: %s",
s.ToString().c_str());
}
return s;
}
} // namespace titandb
} // namespace rocksdb
|
; A188935: Decimal expansion of (1+sqrt(37))/6.
; Submitted by Jon Maiga
; 1,1,8,0,4,6,0,4,2,1,7,1,6,3,6,9,9,4,8,1,6,6,6,1,4,0,4,0,8,6,7,0,1,1,1,7,7,0,1,4,1,6,1,6,8,2,4,6,4,4,0,1,8,6,4,4,0,3,1,9,2,1,7,4,4,1,4,3,8,8,7,8,7,5,5,3,1,5,1,7,0,6,6,3,3,8,4,4,4,0,4,6,5,9,6,4,1,4,4,3
mov $1,1
mov $3,$0
mul $3,3
lpb $3
add $1,$2
add $2,$1
mul $2,3
sub $3,1
lpe
mov $4,10
pow $4,$0
div $2,$4
cmp $5,0
add $2,$5
div $1,$2
mov $0,$1
mod $0,10
|
; A152995: Twice 11-gonal numbers: a(n) = n*(9*n-7).
; 0,2,22,60,116,190,282,392,520,666,830,1012,1212,1430,1666,1920,2192,2482,2790,3116,3460,3822,4202,4600,5016,5450,5902,6372,6860,7366,7890,8432,8992,9570,10166,10780,11412,12062,12730,13416,14120,14842,15582,16340,17116,17910,18722,19552,20400,21266,22150,23052,23972,24910,25866,26840,27832,28842,29870,30916,31980,33062,34162,35280,36416,37570,38742,39932,41140,42366,43610,44872,46152,47450,48766,50100,51452,52822,54210,55616,57040,58482,59942,61420,62916,64430,65962,67512,69080,70666,72270,73892,75532,77190,78866,80560,82272,84002,85750,87516,89300,91102,92922,94760,96616,98490,100382,102292,104220,106166,108130,110112,112112,114130,116166,118220,120292,122382,124490,126616,128760,130922,133102,135300,137516,139750,142002,144272,146560,148866,151190,153532,155892,158270,160666,163080,165512,167962,170430,172916,175420,177942,180482,183040,185616,188210,190822,193452,196100,198766,201450,204152,206872,209610,212366,215140,217932,220742,223570,226416,229280,232162,235062,237980,240916,243870,246842,249832,252840,255866,258910,261972,265052,268150,271266,274400,277552,280722,283910,287116,290340,293582,296842,300120,303416,306730,310062,313412,316780,320166,323570,326992,330432,333890,337366,340860,344372,347902,351450,355016,358600,362202,365822,369460,373116,376790,380482,384192,387920,391666,395430,399212,403012,406830,410666,414520,418392,422282,426190,430116,434060,438022,442002,446000,450016,454050,458102,462172,466260,470366,474490,478632,482792,486970,491166,495380,499612,503862,508130,512416,516720,521042,525382,529740,534116,538510,542922,547352,551800,556266
mov $1,9
mul $1,$0
sub $1,7
mul $1,$0
|
// Copyright (c) 2012-2017 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <addrman.h>
#include <test/test_PALLY1.h>
#include <string>
#include <boost/test/unit_test.hpp>
#include <hash.h>
#include <serialize.h>
#include <streams.h>
#include <net.h>
#include <netbase.h>
#include <chainparams.h>
#include <util.h>
#include <memory>
class CAddrManSerializationMock : public CAddrMan
{
public:
virtual void Serialize(CDataStream& s) const = 0;
//! Ensure that bucket placement is always the same for testing purposes.
void MakeDeterministic()
{
nKey.SetNull();
insecure_rand = FastRandomContext(true);
}
};
class CAddrManUncorrupted : public CAddrManSerializationMock
{
public:
void Serialize(CDataStream& s) const override
{
CAddrMan::Serialize(s);
}
};
class CAddrManCorrupted : public CAddrManSerializationMock
{
public:
void Serialize(CDataStream& s) const override
{
// Produces corrupt output that claims addrman has 20 addrs when it only has one addr.
unsigned char nVersion = 1;
s << nVersion;
s << ((unsigned char)32);
s << nKey;
s << 10; // nNew
s << 10; // nTried
int nUBuckets = ADDRMAN_NEW_BUCKET_COUNT ^ (1 << 30);
s << nUBuckets;
CService serv;
Lookup("252.1.1.1", serv, 7777, false);
CAddress addr = CAddress(serv, NODE_NONE);
CNetAddr resolved;
LookupHost("252.2.2.2", resolved, false);
CAddrInfo info = CAddrInfo(addr, resolved);
s << info;
}
};
static CDataStream AddrmanToStream(CAddrManSerializationMock& _addrman)
{
CDataStream ssPeersIn(SER_DISK, CLIENT_VERSION);
ssPeersIn << Params().MessageStart();
ssPeersIn << _addrman;
std::string str = ssPeersIn.str();
std::vector<unsigned char> vchData(str.begin(), str.end());
return CDataStream(vchData, SER_DISK, CLIENT_VERSION);
}
BOOST_FIXTURE_TEST_SUITE(net_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(cnode_listen_port)
{
// test default
unsigned short port = GetListenPort();
BOOST_CHECK(port == Params().GetDefaultPort());
// test set port
unsigned short altPort = 12345;
gArgs.SoftSetArg("-port", std::to_string(altPort));
port = GetListenPort();
BOOST_CHECK(port == altPort);
}
BOOST_AUTO_TEST_CASE(caddrdb_read)
{
CAddrManUncorrupted addrmanUncorrupted;
addrmanUncorrupted.MakeDeterministic();
CService addr1, addr2, addr3;
Lookup("250.7.1.1", addr1, 6883, false);
Lookup("250.7.2.2", addr2, 9999, false);
Lookup("250.7.3.3", addr3, 9999, false);
// Add three addresses to new table.
CService source;
Lookup("252.5.1.1", source, 6883, false);
addrmanUncorrupted.Add(CAddress(addr1, NODE_NONE), source);
addrmanUncorrupted.Add(CAddress(addr2, NODE_NONE), source);
addrmanUncorrupted.Add(CAddress(addr3, NODE_NONE), source);
// Test that the de-serialization does not throw an exception.
CDataStream ssPeers1 = AddrmanToStream(addrmanUncorrupted);
bool exceptionThrown = false;
CAddrMan addrman1;
BOOST_CHECK(addrman1.size() == 0);
try {
unsigned char pchMsgTmp[4];
ssPeers1 >> pchMsgTmp;
ssPeers1 >> addrman1;
} catch (const std::exception& e) {
exceptionThrown = true;
}
BOOST_CHECK(addrman1.size() == 3);
BOOST_CHECK(exceptionThrown == false);
// Test that CAddrDB::Read creates an addrman with the correct number of addrs.
CDataStream ssPeers2 = AddrmanToStream(addrmanUncorrupted);
CAddrMan addrman2;
CAddrDB adb;
BOOST_CHECK(addrman2.size() == 0);
adb.Read(addrman2, ssPeers2);
BOOST_CHECK(addrman2.size() == 3);
}
BOOST_AUTO_TEST_CASE(caddrdb_read_corrupted)
{
CAddrManCorrupted addrmanCorrupted;
addrmanCorrupted.MakeDeterministic();
// Test that the de-serialization of corrupted addrman throws an exception.
CDataStream ssPeers1 = AddrmanToStream(addrmanCorrupted);
bool exceptionThrown = false;
CAddrMan addrman1;
BOOST_CHECK(addrman1.size() == 0);
try {
unsigned char pchMsgTmp[4];
ssPeers1 >> pchMsgTmp;
ssPeers1 >> addrman1;
} catch (const std::exception& e) {
exceptionThrown = true;
}
// Even through de-serialization failed addrman is not left in a clean state.
BOOST_CHECK(addrman1.size() == 1);
BOOST_CHECK(exceptionThrown);
// Test that CAddrDB::Read leaves addrman in a clean state if de-serialization fails.
CDataStream ssPeers2 = AddrmanToStream(addrmanCorrupted);
CAddrMan addrman2;
CAddrDB adb;
BOOST_CHECK(addrman2.size() == 0);
adb.Read(addrman2, ssPeers2);
BOOST_CHECK(addrman2.size() == 0);
}
BOOST_AUTO_TEST_CASE(cnode_simple_test)
{
SOCKET hSocket = INVALID_SOCKET;
NodeId id = 0;
int height = 0;
in_addr ipv4Addr;
ipv4Addr.s_addr = 0xa0b0c001;
CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK);
std::string pszDest;
bool fInboundIn = false;
// Test that fFeeler is false by default.
std::unique_ptr<CNode> pnode1(new CNode(id++, NODE_NETWORK, height, hSocket, addr, 0, 0, CAddress(), pszDest, fInboundIn));
BOOST_CHECK(pnode1->fInbound == false);
BOOST_CHECK(pnode1->fFeeler == false);
fInboundIn = true;
std::unique_ptr<CNode> pnode2(new CNode(id++, NODE_NETWORK, height, hSocket, addr, 1, 1, CAddress(), pszDest, fInboundIn));
BOOST_CHECK(pnode2->fInbound == true);
BOOST_CHECK(pnode2->fFeeler == false);
}
BOOST_AUTO_TEST_SUITE_END()
|
; A134736: a(1) = 5; for n >1, a(n) = a(n-1) + gcd(n, a(n-1)).
; Submitted by Jon Maiga
; 5,6,9,10,15,18,19,20,21,22,33,36,37,38,39,40,41,42,43,44,45,46,69,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,141,144,145,150,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202
mov $1,5
mov $2,1
lpb $0
sub $0,1
add $2,1
mov $3,$2
gcd $3,$1
add $1,$3
lpe
mov $0,$1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r14
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0x1b392, %rsi
lea addresses_normal_ht+0xf392, %rdi
nop
nop
nop
xor $40233, %r13
mov $102, %rcx
rep movsl
sub %r14, %r14
lea addresses_WT_ht+0x1e192, %r12
nop
nop
nop
xor $65309, %rbp
movb $0x61, (%r12)
nop
nop
nop
nop
nop
add $2844, %rcx
lea addresses_WC_ht+0x8592, %rsi
lea addresses_A_ht+0xe962, %rdi
nop
nop
nop
nop
nop
add %r8, %r8
mov $87, %rcx
rep movsw
nop
nop
nop
nop
add %rdi, %rdi
lea addresses_D_ht+0x2e12, %r8
clflush (%r8)
nop
nop
nop
nop
dec %r12
mov $0x6162636465666768, %rdi
movq %rdi, (%r8)
nop
nop
nop
nop
nop
cmp $3720, %r12
lea addresses_A_ht+0x17452, %rsi
lea addresses_normal_ht+0x1e792, %rdi
clflush (%rsi)
cmp $41198, %r12
mov $16, %rcx
rep movsl
nop
nop
nop
cmp $1863, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r14
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r15
push %r8
push %rbp
push %rbx
// Store
lea addresses_WT+0x11892, %r15
nop
nop
add $16363, %rbp
mov $0x5152535455565758, %r8
movq %r8, %xmm3
vmovups %ymm3, (%r15)
sub $29018, %r8
// Store
lea addresses_WT+0x96f6, %r12
nop
nop
nop
nop
nop
dec %r11
movw $0x5152, (%r12)
nop
nop
nop
nop
inc %r8
// Faulty Load
lea addresses_PSE+0x1bf92, %r11
nop
nop
dec %rbx
mov (%r11), %r15w
lea oracles, %r8
and $0xff, %r15
shlq $12, %r15
mov (%r8,%r15,1), %r15
pop %rbx
pop %rbp
pop %r8
pop %r15
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_PSE', 'same': True, 'AVXalign': False, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 8}}
{'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 2}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_PSE', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 10}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 9}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 4}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 6}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 4}, 'dst': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 11}}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: Config Library
MODULE: PrefContainerClass
FILE: prefContainer.asm
AUTHOR: Adam de Boor, Dec 3, 1992
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Adam 12/ 3/92 Initial revision
DESCRIPTION:
Implementation of the PrefContainerClass, an interaction that
manages a tree of Generic UI stored in a VM file or in a
Preferences submodule.
$Id: prefContainer.asm,v 1.1 97/04/04 17:50:44 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
EC<include Internal/heapInt.def>
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PC_DerefDI
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Point ds:di to the PrefContainerInstance for the object.
CALLED BY: (INTERNAL)
PASS: *ds:si = PrefContainer object
RETURN: ds:di = PrefContainerInstance
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 4/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PC_DerefDI proc near
class PrefContainerClass
mov di, ds:[si]
add di, ds:[di].PrefContainer_offset
ret
PC_DerefDI endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerReloc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Required relocation/unrelocation stuff for supporting
GenPath mechanism.
CALLED BY: MSG_META_RELOCATE, MSG_META_UNRELOCATE
PASS: *ds:si = instance
ds:di = PrefContainerInstance
dx = VMRelocType
bp = frame to pass to ObjRelocOrUnRelocSuper
RETURN: carry set if error
bp = preserved
DESTROYED: ax, cx, dx
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 3/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerReloc method dynamic PrefContainerClass, reloc
uses dx, bp
.enter
cmp ax, MSG_META_UNRELOCATE
jne done
mov ds:[di].PCI_handle, 0 ; so we don't get
; confused on restore
mov ax, ATTR_GEN_PATH_DATA
mov dx, TEMP_GEN_PATH_SAVED_DISK_HANDLE
call GenPathUnrelocObjectPath
done:
.leave
mov di, offset PrefContainerClass
call ObjRelocOrUnRelocSuper
ret
PrefContainerReloc endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerCloseActiveFile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Close the active file, if such there be.
CALLED BY: (INTERNAL) PrefContainerGenPathSet,
PrefContainerNotifyDialogChange
PASS: *ds:si = PrefContainer object
RETURN: nothing
DESTROYED: ax, es, bx, di, cx, dx
SIDE EFFECTS: PCI_handle is set to 0 and tree is detached
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 3/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerCloseActiveFile proc near
class PrefContainerClass
uses si, bp
.enter
call PC_DerefDI
clr bx
xchg bx, ds:[di].PCI_handle
tst bx
LONG jz done
movdw cxdx, ds:[di].PCI_dupRoot
jcxz unhookVM
mov ds:[di].PCI_dupRoot.handle, 0 ; so we don't think
; the next thing loaded
; is a library unless
; it is...
push bx, si
movdw bxsi, cxdx
mov ax, MSG_GEN_REMOVE
mov dl, VUM_NOW
clr bp
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
mov ax, MSG_META_BLOCK_FREE
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
mov dx, bx ; flag handle as library
pop cx, si
jmp closeHandle
unhookVM:
;
; Locate the root of the tree in the current file.
;
push si
call VMGetMapBlock
call VMLock
mov es, ax
movdw axsi, es:[PVMMB_root]
call VMUnlock
call VMVMBlockToMemBlock ; ax <- handle
;
; Remove the root from our own generic tree.
;
push bx
mov_tr bx, ax
mov ax, MSG_GEN_REMOVE
mov dl, VUM_NOW
clr bp ; don't mark dirty
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
;
; Close the file it's in.
;
pop cx
pop si ; *ds:si <- us
clr dx ; flag VM file
closeHandle:
;
; Now flush all the queues before sending ourselves a message to close
; the handle in whatever way is appropriate. Note that even if the
; block in which we sit is going away, the META_BLOCK_FREE sent to
; the dialog in which we sit will also be routing things through the
; same event queues, so we are guaranteed to receive the message to
; close the file/unload the library before we bite the big one.
;
mov ax, MSG_PC_CLOSE_HANDLE
mov bx, ds:[LMBH_handle]
mov di, mask MF_RECORD
call ObjMessage ; record message to send back
mov dx, bx ; dx <- block for which flush
; is to occur
mov cx, di ; cx <- event
clr bp ; bp <- start at the beginning
mov ax, MSG_META_OBJ_FLUSH_INPUT_QUEUE
call ObjCallInstanceNoLock
done:
.leave
ret
PrefContainerCloseActiveFile endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerCloseHandle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Close a handle we opened, as appropriate to its type.
CALLED BY: MSG_PC_CLOSE_HANDLE
PASS: *ds:si = PrefContainer object
cx = affected handle
dx = non-zero if it's a library handle. 0 if it's a
VM file
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 6/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerCloseHandle method dynamic PrefContainerClass, MSG_PC_CLOSE_HANDLE
.enter
mov bx, cx
tst dx
jnz isLibrary
mov al, FILE_NO_ERRORS
call VMClose
done:
.leave
ret
isLibrary:
call GeodeFreeLibrary
jmp done
PrefContainerCloseHandle endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerGenPathSet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Field a command to open another file.
CALLED BY: MSG_GEN_PATH_SET
PASS: *ds:si = PrefContainer object
cx:dx = null-terminated pathname
bp = disk handle of path
RETURN: carry set if path couldn't be set
ax = FileError
carry clear if path successfully set
ax = destroyed
DESTROYED: cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 4/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerGenPathSet method dynamic PrefContainerClass, MSG_GEN_PATH_SET
diskHandle local word push bp
pathBuf local PathName
fileName local fptr
ForceRef fileName ; manipulated by subroutines
.enter
;
; Split the path into leading components and final component.
;
call PrefContainerSplitAndComparePath
cmp al, PCT_EQUAL
je done ; => no need to do anything, as file
; is already open (carry clear)
;
; Change to the directory holding the file.
;
push bp
mov cx, ss
lea dx, ss:[pathBuf]
mov bp, ss:[diskHandle]
mov ax, MSG_GEN_PATH_SET
mov di, offset PrefContainerClass
call ObjCallSuperNoLock
pop bp
jc done
;
; Close the old file, if any, as we're pretty much committed.
;
call PrefContainerCloseActiveFile
;
; Now open the new one.
;
call PrefContainerOpenNewFile
jc done
;
; Set our moniker, if appropriate.
;
call PrefContainerBuildMoniker
;
; Hook the tree in as our only generic child.
;
call PrefContainerLoadTree
done:
.leave
ret
PrefContainerGenPathSet endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerSplitAndComparePath
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Split the passed path into leading components and filename
and see if it's the same as what we've already got open, as
we'd rather avoid excessive flashing.
CALLED BY: (INTERNAL) PrefContainerGenPathSet
PASS: *ds:si = PrefContainer object
ss:bp = inherited stack frame
cx:dx = path being set
RETURN: al = PCT_EQUAL if same path being set
= PCT_UNRELATED if different path being set
ss:[pathBuf] = leading components
ss:[fileName] = points to final component of path
DESTROYED: bx, cx, dx, di
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 4/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerSplitAndComparePath proc near
class PrefContainerClass
uses es
.enter inherit PrefContainerGenPathSet
;
; First split the thing into two pieces.
;
push ds, si
movdw dssi, cxdx ; ds:si <- source path
segmov es, ss
lea di, ss:[pathBuf]; es:di <- dest buffer
saveCompStart:
mov bx, si ; ds:bx <- start of this component
getChar:
LocalGetChar ax, dssi
LocalPutChar esdi, ax
LocalCmpChar ax, '\\' ; end of component?
je saveCompStart ; yes -- record start of next
LocalIsNull ax ; end of path?
jnz getChar ; no -- keep looping
;
; Record the start of the final component in ss:[fileName] for
; later use.
;
movdw ss:[fileName], dsbx
;
; Terminate the leading components before the final component, being
; careful about name being in root directory.
;
dec bx ; point to presumed backslash
DBCS < dec bx >
sbb bx, si ; bx <- negative distance to final
; separator
pop ds, si ; *ds:si <- object
lea bx, es:[di][bx] ; bx <- corresponding place in pathBuf
lea di, ss:[pathBuf]; di <- start again, so...
cmp bx, di ; ...we can compare the two
jb compareFileNames ; => no backslash
ja nullTermAndComparePaths ; => not root
inc bx ; leave leading backslash, please
DBCS < inc bx >
nullTermAndComparePaths:
SBCS < mov {char}es:[bx], 0 >
DBCS < mov {wchar}es:[bx], 0 >
;
; Now the path is split, make sure we've actually got a file open,
; which is the only thing that makes this comparison worthwhile (this
; also ensures we've actually got a path set.
;
mov bx, ds:[si]
add bx, ds:[bx].PrefContainer_offset
tst ds:[bx].PCI_handle
jz setNew
;
; Now fetch path currently bound to the object.
;
mov ax, ATTR_GEN_PATH_DATA
mov dx, TEMP_GEN_PATH_SAVED_DISK_HANDLE
call GenPathFetchDiskHandleAndDerefPath
tst ax
jz setNew
;
; Compare that path with the one we've now got in pathBuf
; (es:di = pathBuf).
;
push si
lea si, ds:[bx].GFP_path ; ds:si <- path
mov_tr cx, ax ; cx <- disk handle
mov dx, ss:[diskHandle] ; dx <- disk for es:di
call FileComparePaths
pop si
cmp al, PCT_EQUAL
jne setNew
compareFileNames:
;
; Paths match. Check up on the filename.
;
push si
call PC_DerefDI
lea si, ds:[di].PCI_fileName ; ds:si <- src string
les di, ss:[fileName] ; es:di <- dst string
compareNameLoop:
LocalGetChar ax, dssi
SBCS < scasb >
DBCS < scasw >
jne popSISetNew
LocalIsNull ax ; end of string?
jnz compareNameLoop ; nope.
CheckHack <PCT_EQUAL eq 0>
pop si
done:
.leave
ret
popSISetNew:
pop si
setNew:
mov al, PCT_UNRELATED
jmp done
PrefContainerSplitAndComparePath endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerOpenNewFile
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Copy the name into our instance data and open the beast.
CALLED BY: (INTERNAL) PrefContainerGenPathSet
PASS: *ds:si = PrefContainer object
ss:bp = inherited stack frame
RETURN: carry set on error:
ax = FileError
bx = destroyed
carry clear on success:
bx = VM file handle
ax = destroyed
DESTROYED: cx, dx, di
SIDE EFFECTS: PCI_handle set on success
PCI_fileName set on success or failure
object added to the PDGCNLT_DIALOG_CHANGE list
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 4/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerOpenNewFile proc near
class PrefContainerClass
.enter inherit PrefContainerGenPathSet
;
; Copy the new name in. Even if the open fails, PCI_handle is
; 0, so we'll overwrite the data the next time someone tells us to
; open the thing.
;
push si, ds
segmov es, ds
call PC_DerefDI
add di, offset PCI_fileName
mov dx, di ; save for open
lds si, ss:[fileName]
mov cx, length PCI_fileName
nameCopyLoop:
LocalGetChar ax, dssi
LocalPutChar esdi, ax
LocalIsNull ax
loopnz nameCopyLoop
pop si, ds
jnz badName ; => name too long
;
; Push to the directory we set, please.
;
call FilePushDir
push dx
mov ax, ATTR_GEN_PATH_DATA
mov dx, TEMP_GEN_PATH_SAVED_DISK_HANDLE
call GenPathSetCurrentPathFromObjectPath
pop dx
;
; Now open the file read-only.
;
mov ax, (VMO_OPEN shl 8) or mask VMAF_FORCE_READ_ONLY or \
mask VMAF_FORCE_DENY_WRITE
call VMOpen
jc checkLibrary
;
; Make sure the protocol is ok.
;
mov cx, size ProtocolNumber
sub sp, cx
segmov es, ss
mov di, sp
mov ax, FEA_PROTOCOL
call FileGetHandleExtAttributes
pop ax, cx
CheckHack <PN_major eq 0 and PN_minor eq 2 and \
ProtocolNumber eq 4>
cmp cx, PREFVM_DOC_PROTO_MAJOR
jne closeFail
cmp ax, PREFVM_DOC_PROTO_MINOR
ja closeFail
;
; Everything peachy. Save the handle away and add ourselves to the
; dialog's GCN list.
;
call PC_DerefDI
fileOpen:
mov ds:[di].PCI_handle, bx
mov ax, MSG_META_GCN_LIST_ADD
call PrefContainerManipGCNList
clc
done:
call FilePopDir
.leave
ret
closeFail:
mov al, FILE_NO_ERRORS
call VMClose
mov ax, ERROR_FILE_FORMAT_MISMATCH
error:
stc
jmp done
badName:
mov ax, ERROR_INVALID_NAME
jmp error
checkLibrary:
cmp ax, VM_OPEN_INVALID_VM_FILE
je tryLibraryLoad
mov_tr bx, ax
mov ax, ERROR_SHARING_VIOLATION
cmp bx, VM_SHARING_DENIED
je error
mov ax, ERROR_FILE_NOT_FOUND
cmp bx, VM_FILE_NOT_FOUND
je error
mov ax, ERROR_FILE_FORMAT_MISMATCH
cmp bx, VM_FILE_FORMAT_MISMATCH
je error
mov ax, ERROR_GENERAL_FAILURE
jmp error
tryLibraryLoad:
;
; Kernel didn't think much of that supposed VM file, so see if it'll
; load the beastie as a library.
;
push si
mov si, dx ; ds:si <- lib name
mov ax, PREF_MODULE_PROTO_MAJOR
mov bx, PREF_MODULE_PROTO_MINOR
call GeodeUseLibrary ; bx <- geode handle, if ok
pop si
mov ax, ERROR_GENERAL_FAILURE
jc error ; nope.
;
; Note that we've got a library, by setting the handle portion of the
; dupRoot variable non-zero, so we know to query the beast for its
; UI tree, rather than looking at the map block.
;
call PC_DerefDI
mov ds:[di].PCI_dupRoot.handle, 1
jmp fileOpen
PrefContainerOpenNewFile endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerBuildMoniker
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Build a moniker for ourselves from the template provided.
CALLED BY: (INTERNAL) PrefContainerGenPathSet
PASS: *ds:si = PrefContainer
RETURN: nothing
DESTROYED: ax, cx, dx, di
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 4/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerBuildMoniker proc near
class PrefContainerClass
uses bx
.enter
call PC_DerefDI
mov bx, ds:[di].PCI_templateMon
tst bx
LONG jz done
;
; Duplicate the template moniker.
;
push si
ChunkSizeHandle ds, bx, cx
mov al, mask OCF_DIRTY
call LMemAlloc
segmov es, ds
mov si, ds:[bx]
mov_tr bx, ax
mov di, ds:[bx]
rep movsb
pop si
;
; Find the length of the text in the filename.
;
call PC_DerefDI
add di, offset PCI_fileName
call LocalStringSize ; cx = length w/o null
push cx
;
; Locate the \1 in the template moniker.
;
mov di, ds:[bx]
test ds:[di].VM_type, mask VMT_GSTRING
jnz popHaveNewMoniker
mov ax, 1 ; ax <- 1
mov ds:[di].VM_width, 0 ; nuke cached width while we've
; got the pointer
ChunkSizePtr ds, di, cx
add di, offset VM_data + offset VMT_text
sub cx, offset VM_data + offset VMT_text
DBCS < shr cx, 1 >
LocalFindChar
popHaveNewMoniker:
pop cx ; cx <- length of file name
jne haveNewMoniker ; => no \1, so nothing to insert
; (also jumps if moniker is gstring,
; not text)
;
; Insert enough room there in the moniker for the file name
;
LocalPrevChar esdi ; point to \1
sub di, ds:[bx] ; figure offset from base of chunk
; for insertion
mov_tr ax, di ; ax <- offset
xchg ax, bx ; ax <- chunk, bx <- offset
dec cx ; reduce by 1 to account for
; overwriting \1
DBCS < dec cx >
call LMemInsertAt
;
; Now copy the text from the file name into the new moniker
;
mov di, bx
mov_tr bx, ax
add di, ds:[bx] ; es:di <- insertion point
push si
mov si, ds:[si]
add si, ds:[si].PrefContainer_offset
add si, offset PCI_fileName
DBCS < shr cx, 1 >
inc cx ; account for previous reduction
LocalCopyNString
pop si
haveNewMoniker:
;
; Fetch the current moniker so we can free it once we've set
; the new one.
;
mov di, ds:[si]
add di, ds:[di].Gen_offset
push ds:[di].GI_visMoniker
;
; And set the new one as the vis moniker for the beast.
;
mov cx, bx
mov dl, VUM_NOW
mov ax, MSG_GEN_USE_VIS_MONIKER
push bp
call ObjCallInstanceNoLockES
pop bp
;
; Now free the old moniker.
;
pop ax
tst ax
jz oldMonikerFreed
call LMemFree
oldMonikerFreed:
done:
.leave
ret
PrefContainerBuildMoniker endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerLoadTree
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Load the tree as our only generic child.
CALLED BY: (INTERNAL) PrefContainerGenPathSet
PASS: *ds:si = PrefContainer object
bx = VM file handle of open file
RETURN: nothing
DESTROYED: ax, es, dx, cx, bx, di
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 4/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerLoadTree proc near
class PrefContainerClass
uses bp, si
.enter
call PC_DerefDI
tst ds:[di].PCI_dupRoot.handle
jnz askLibrary
;
; Get the optr of the root object of the tree.
;
call VMGetMapBlock
call VMLock
mov es, ax
movdw axdx, es:[PVMMB_root]
call VMUnlock
call VMVMBlockToMemBlock
;
; Add the root as our first child.
;
mov_tr cx, ax
addChild:
mov bp, CCO_FIRST
mov ax, MSG_GEN_ADD_CHILD
call ObjCallInstanceNoLock
movdw bxsi, cxdx
;
; Tell it to initialize itself and load its options.
;
mov ax, MSG_PREF_INIT
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
;
; Release20X EC dies because es never gets set to NULL_SEGMENT. Do it
; here to make things work.
;
EC < segmov es, NULL_SEGMENT, ax >
mov ax, MSG_META_LOAD_OPTIONS
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
;
; Set the root usable, finally. (done after init/load_options so
; the child has a chance to add any hairy controllers to various
; GCN lists in the application object before they get set usable.)
;
mov ax, MSG_GEN_SET_USABLE
mov dl, VUM_NOW
mov di, mask MF_CALL or mask MF_FIXUP_DS
call ObjMessage
.leave
ret
askLibrary:
;
; Call the library to get its tree of UI.
;
mov ax, PMET_FETCH_UI
call ProcGetLibraryEntry
call ProcCallFixedOrMovable ; ^ldx:ax <- root
;
; Now duplicate the resource it returned.
;
push ax ; save chunk handle
call GeodeGetProcessHandle
mov_tr ax, bx ; ax <- owner
mov bx, dx ; bx <- block to duplicate
clr cx ; run by this thread
call ObjDuplicateResource ; bx <- new block
mov cx, bx
pop dx ; ^lcx:dx <- root of tree
;
; Save the thing so we know we need to destroy it when we go away.
;
call PC_DerefDI
movdw ds:[di].PCI_dupRoot, cxdx
jmp addChild
PrefContainerLoadTree endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerManipGCNList
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Manipulate our containing PrefDialog object's notification
list, so we know to close the VM file before the box
gets destroyed.
CALLED BY: (INTERNAL) PrefContainerOpenNewFile,
PrefContainerCloseActiveFile
PASS: *ds:si = PrefContainer object
ax = message to send (MSG_META_GCN_LIST_ADD or
MSG_META_GCN_LIST_REMOVE)
RETURN: nothing
DESTROYED: ax, di
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 4/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerManipGCNList proc near
class PrefContainerClass
uses bx, cx, dx, bp
.enter
;
; Record message for the PrefDialog object.
;
mov dx, size GCNListParams
sub sp, dx
mov bp, sp
mov bx, ds:[LMBH_handle]
movdw ss:[bp].GCNLP_optr, bxsi
mov ss:[bp].GCNLP_ID.GCNLT_manuf, MANUFACTURER_ID_GEOWORKS
mov ss:[bp].GCNLP_ID.GCNLT_type, PDGCNLT_DIALOG_CHANGE
mov bx, segment PrefDialogClass
push si
mov si, offset PrefDialogClass
mov di, mask MF_RECORD or mask MF_STACK
call ObjMessage
pop si
add sp, size GCNListParams
;
; Now ship the thing up the tree.
;
mov cx, di
mov ax, MSG_GEN_GUP_CALL_OBJECT_OF_CLASS
call GenCallParent
.leave
ret
PrefContainerManipGCNList endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerNotifyDialogChange
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Take note that the dialog in which we're located is
changing state
CALLED BY: MSG_PREF_NOTIFY_DIALOG_CHANGE
PASS: *ds:si = PrefContainer object
cx = PrefDialogChangeType
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
if change type is PDCT_DESTROY, PDCT_SHUTDOWN or PDCT_RESTART,
we need to close the VM file and uproot its tree.
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 4/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerNotifyDialogChange method dynamic PrefContainerClass,
MSG_PREF_NOTIFY_DIALOG_CHANGE
.enter
cmp cx, PDCT_DESTROY
jb done
CheckHack <PDCT_SHUTDOWN gt PDCT_DESTROY and \
PDCT_RESTART gt PDCT_DESTROY and \
PrefDialogChangeType eq PDCT_SHUTDOWN+1>
call PrefContainerCloseActiveFile
done:
.leave
ret
PrefContainerNotifyDialogChange endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PrefContainerMakeApplyable
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: If dialog box is sitting inside another dialog, forcibly
continue the travel of a MSG_GEN_MAKE_APPLYABLE message
to the parent object.
CALLED BY: MSG_GEN_MAKE_APPLYABLE
PASS: *ds:si = PrefContainer object
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/ 8/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
PrefContainerMakeApplyable method dynamic PrefContainerClass, MSG_GEN_MAKE_APPLYABLE
.enter
mov di, offset PrefContainerClass
call ObjCallSuperNoLock
;
; If we're a dialog, we need to forcibly pass the thing to our parent,
; as our superclass won't...
;
mov di, ds:[si]
add di, ds:[di].Gen_offset
cmp ds:[di].GII_visibility, GIV_DIALOG
jne done
mov ax, MSG_GEN_MAKE_APPLYABLE
call GenCallParent
done:
.leave
ret
PrefContainerMakeApplyable endm
|
; A279521: Maximum number of single-direction edges in leveled binary trees with n nodes.
; 0,1,1,2,3,3,3,4,5,6,7,7,7,7,7,8,9,10,11,12,13,14,15,15,15,15,15,15,15,15,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,63,63,63,63,63
lpb $0
sub $0,1
trn $1,$0
add $2,1
sub $2,$1
trn $0,$2
mov $1,$2
mul $2,2
lpe
mov $0,$1
|
; A158746: Numbers n such that 30*n + 13 is prime.
; 0,1,2,3,5,6,7,9,10,12,14,15,17,20,21,22,24,27,28,29,34,35,36,37,38,40,43,47,48,49,51,55,56,57,58,59,62,64,66,68,69,70,71,73,76,79,82,83,86,89,90,93,94,98,105,108,110,111,112,114,115,119,120,121,122,124,126,127
seq $0,132233 ; Primes congruent to 13 (mod 30).
div $0,30
|
###############################################################################
# Copyright 2018 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.section .note.GNU-stack,"",%progbits
.text
.p2align 6, 0x90
.globl DecryptCBC_RIJ128pipe_AES_NI
.type DecryptCBC_RIJ128pipe_AES_NI, @function
DecryptCBC_RIJ128pipe_AES_NI:
push %rbx
sub $(144), %rsp
movdqu (%r9), %xmm15
movslq %r8d, %r8
lea (,%rdx,4), %rax
cmp $(64), %r8
jl .Lshort123_inputgas_1
cmp $(256), %r8
jle .Lblock4xgas_1
mov %rsp, %rbx
sub $(64), %rsp
movdqa %xmm6, (%rsp)
movdqa %xmm7, (16)(%rsp)
movdqa %xmm8, (32)(%rsp)
movdqa %xmm9, (48)(%rsp)
sub $(128), %r8
.p2align 6, 0x90
.Lblk8_loopgas_1:
lea (-16)(%rcx,%rax,4), %r9
movdqu (%rdi), %xmm0
movdqu (16)(%rdi), %xmm1
movdqu (32)(%rdi), %xmm2
movdqu (48)(%rdi), %xmm3
movdqu (64)(%rdi), %xmm6
movdqu (80)(%rdi), %xmm7
movdqu (96)(%rdi), %xmm8
movdqu (112)(%rdi), %xmm9
movdqa (16)(%r9), %xmm5
movdqa (%r9), %xmm4
movdqa %xmm0, (16)(%rbx)
pxor %xmm5, %xmm0
movdqa %xmm1, (32)(%rbx)
pxor %xmm5, %xmm1
movdqa %xmm2, (48)(%rbx)
pxor %xmm5, %xmm2
movdqa %xmm3, (64)(%rbx)
pxor %xmm5, %xmm3
movdqa %xmm6, (80)(%rbx)
pxor %xmm5, %xmm6
movdqa %xmm7, (96)(%rbx)
pxor %xmm5, %xmm7
movdqa %xmm8, (112)(%rbx)
pxor %xmm5, %xmm8
movdqa %xmm9, (128)(%rbx)
pxor %xmm5, %xmm9
movdqa (-16)(%r9), %xmm5
sub $(32), %r9
lea (-2)(%rdx), %r10
.p2align 6, 0x90
.Lcipher_loop8gas_1:
aesdec %xmm4, %xmm0
aesdec %xmm4, %xmm1
aesdec %xmm4, %xmm2
aesdec %xmm4, %xmm3
aesdec %xmm4, %xmm6
aesdec %xmm4, %xmm7
aesdec %xmm4, %xmm8
aesdec %xmm4, %xmm9
movdqa (%r9), %xmm4
aesdec %xmm5, %xmm0
aesdec %xmm5, %xmm1
aesdec %xmm5, %xmm2
aesdec %xmm5, %xmm3
aesdec %xmm5, %xmm6
aesdec %xmm5, %xmm7
aesdec %xmm5, %xmm8
aesdec %xmm5, %xmm9
movdqa (-16)(%r9), %xmm5
sub $(32), %r9
sub $(2), %r10
jnz .Lcipher_loop8gas_1
aesdec %xmm4, %xmm0
aesdec %xmm4, %xmm1
aesdec %xmm4, %xmm2
aesdec %xmm4, %xmm3
aesdec %xmm4, %xmm6
aesdec %xmm4, %xmm7
aesdec %xmm4, %xmm8
aesdec %xmm4, %xmm9
aesdeclast %xmm5, %xmm0
pxor %xmm15, %xmm0
movdqu %xmm0, (%rsi)
aesdeclast %xmm5, %xmm1
pxor (16)(%rbx), %xmm1
movdqu %xmm1, (16)(%rsi)
aesdeclast %xmm5, %xmm2
pxor (32)(%rbx), %xmm2
movdqu %xmm2, (32)(%rsi)
aesdeclast %xmm5, %xmm3
pxor (48)(%rbx), %xmm3
movdqu %xmm3, (48)(%rsi)
aesdeclast %xmm5, %xmm6
pxor (64)(%rbx), %xmm6
movdqu %xmm6, (64)(%rsi)
aesdeclast %xmm5, %xmm7
pxor (80)(%rbx), %xmm7
movdqu %xmm7, (80)(%rsi)
aesdeclast %xmm5, %xmm8
pxor (96)(%rbx), %xmm8
movdqu %xmm8, (96)(%rsi)
aesdeclast %xmm5, %xmm9
pxor (112)(%rbx), %xmm9
movdqu %xmm9, (112)(%rsi)
movdqa (128)(%rbx), %xmm15
add $(128), %rsi
add $(128), %rdi
sub $(128), %r8
jge .Lblk8_loopgas_1
movdqa (%rsp), %xmm6
movdqa (16)(%rsp), %xmm7
movdqa (32)(%rsp), %xmm8
movdqa (48)(%rsp), %xmm9
add $(64), %rsp
add $(128), %r8
jz .Lquitgas_1
.Lblock4xgas_1:
cmp $(64), %r8
jl .Lshort123_inputgas_1
sub $(64), %r8
.p2align 6, 0x90
.Lblk4_loopgas_1:
lea (-16)(%rcx,%rax,4), %r9
movdqu (%rdi), %xmm0
movdqu (16)(%rdi), %xmm1
movdqu (32)(%rdi), %xmm2
movdqu (48)(%rdi), %xmm3
movdqa (16)(%r9), %xmm5
movdqa (%r9), %xmm4
movdqa %xmm0, (16)(%rsp)
pxor %xmm5, %xmm0
movdqa %xmm1, (32)(%rsp)
pxor %xmm5, %xmm1
movdqa %xmm2, (48)(%rsp)
pxor %xmm5, %xmm2
movdqa %xmm3, (64)(%rsp)
pxor %xmm5, %xmm3
movdqa (-16)(%r9), %xmm5
sub $(32), %r9
lea (-2)(%rdx), %r10
.p2align 6, 0x90
.Lcipher_loop4gas_1:
aesdec %xmm4, %xmm0
aesdec %xmm4, %xmm1
aesdec %xmm4, %xmm2
aesdec %xmm4, %xmm3
movdqa (%r9), %xmm4
aesdec %xmm5, %xmm0
aesdec %xmm5, %xmm1
aesdec %xmm5, %xmm2
aesdec %xmm5, %xmm3
movdqa (-16)(%r9), %xmm5
sub $(32), %r9
sub $(2), %r10
jnz .Lcipher_loop4gas_1
aesdec %xmm4, %xmm0
aesdec %xmm4, %xmm1
aesdec %xmm4, %xmm2
aesdec %xmm4, %xmm3
aesdeclast %xmm5, %xmm0
pxor %xmm15, %xmm0
movdqu %xmm0, (%rsi)
aesdeclast %xmm5, %xmm1
pxor (16)(%rsp), %xmm1
movdqu %xmm1, (16)(%rsi)
aesdeclast %xmm5, %xmm2
pxor (32)(%rsp), %xmm2
movdqu %xmm2, (32)(%rsi)
aesdeclast %xmm5, %xmm3
pxor (48)(%rsp), %xmm3
movdqu %xmm3, (48)(%rsi)
movdqa (64)(%rsp), %xmm15
add $(64), %rsi
add $(64), %rdi
sub $(64), %r8
jge .Lblk4_loopgas_1
add $(64), %r8
jz .Lquitgas_1
.Lshort123_inputgas_1:
lea (%rcx,%rax,4), %r9
.p2align 6, 0x90
.Lsingle_blk_loopgas_1:
movdqu (%rdi), %xmm0
add $(16), %rdi
movdqa %xmm0, %xmm1
pxor (%r9), %xmm0
cmp $(12), %rdx
jl .Lkey_128_sgas_1
jz .Lkey_192_sgas_1
.Lkey_256_sgas_1:
aesdec (208)(%rcx), %xmm0
aesdec (192)(%rcx), %xmm0
.Lkey_192_sgas_1:
aesdec (176)(%rcx), %xmm0
aesdec (160)(%rcx), %xmm0
.Lkey_128_sgas_1:
aesdec (144)(%rcx), %xmm0
aesdec (128)(%rcx), %xmm0
aesdec (112)(%rcx), %xmm0
aesdec (96)(%rcx), %xmm0
aesdec (80)(%rcx), %xmm0
aesdec (64)(%rcx), %xmm0
aesdec (48)(%rcx), %xmm0
aesdec (32)(%rcx), %xmm0
aesdec (16)(%rcx), %xmm0
aesdeclast (%rcx), %xmm0
pxor %xmm15, %xmm0
movdqu %xmm0, (%rsi)
add $(16), %rsi
sub $(16), %r8
movdqa %xmm1, %xmm15
jnz .Lsingle_blk_loopgas_1
.Lquitgas_1:
pxor %xmm4, %xmm4
pxor %xmm5, %xmm5
add $(144), %rsp
vzeroupper
pop %rbx
ret
.Lfe1:
.size DecryptCBC_RIJ128pipe_AES_NI, .Lfe1-(DecryptCBC_RIJ128pipe_AES_NI)
|
// Copyright 2018 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
#include "tink/json_keyset_writer.h"
#include <ostream>
#include <sstream>
#include "absl/strings/escaping.h"
#include "include/rapidjson/document.h"
#include "include/rapidjson/error/en.h"
#include "tink/json_keyset_reader.h"
#include "tink/util/protobuf_helper.h"
#include "tink/util/test_util.h"
#include "gtest/gtest.h"
#include "proto/aes_eax.pb.h"
#include "proto/aes_gcm.pb.h"
#include "proto/tink.pb.h"
namespace crypto {
namespace tink {
using crypto::tink::test::AddRawKey;
using crypto::tink::test::AddTinkKey;
using google::crypto::tink::AesEaxKey;
using google::crypto::tink::AesGcmKey;
using google::crypto::tink::EncryptedKeyset;
using google::crypto::tink::KeyData;
using google::crypto::tink::Keyset;
using google::crypto::tink::KeyStatusType;
using google::crypto::tink::OutputPrefixType;
namespace {
class JsonKeysetWriterTest : public ::testing::Test {
protected:
void SetUp() {
AesGcmKey gcm_key;
gcm_key.set_key_value("some gcm key value");
gcm_key.set_version(0);
std::string gcm_key_base64;
absl::Base64Escape(gcm_key.SerializeAsString(), &gcm_key_base64);
AesEaxKey eax_key;
eax_key.set_key_value("some eax key value");
eax_key.set_version(0);
eax_key.mutable_params()->set_iv_size(16);
std::string eax_key_base64;
absl::Base64Escape(eax_key.SerializeAsString(), &eax_key_base64);
AddTinkKey("type.googleapis.com/google.crypto.tink.AesGcmKey",
42, gcm_key, KeyStatusType::ENABLED,
KeyData::SYMMETRIC, &keyset_);
AddRawKey("type.googleapis.com/google.crypto.tink.AesEaxKey",
711, eax_key, KeyStatusType::ENABLED,
KeyData::SYMMETRIC, &keyset_);
keyset_.set_primary_key_id(42);
std::string json_string = "{"
"\"primaryKeyId\": 42,"
"\"key\": ["
" {"
" \"keyData\": {"
" \"typeUrl\":"
" \"type.googleapis.com/google.crypto.tink.AesGcmKey\","
" \"keyMaterialType\": \"SYMMETRIC\","
" \"value\": \"" + gcm_key_base64 + "\""
" },"
" \"outputPrefixType\": \"TINK\","
" \"keyId\": 42,"
" \"status\": \"ENABLED\""
" },"
" {"
" \"keyData\": {"
" \"typeUrl\":"
" \"type.googleapis.com/google.crypto.tink.AesEaxKey\","
" \"keyMaterialType\": \"SYMMETRIC\","
" \"value\": \"" + eax_key_base64 + "\""
" },"
" \"outputPrefixType\": \"RAW\","
" \"keyId\": 711,"
" \"status\": \"ENABLED\""
" }"
"]}";
ASSERT_FALSE(good_json_keyset_.Parse(json_string.c_str()).HasParseError());
std::string enc_keyset = "some ciphertext with keyset";
encrypted_keyset_.set_encrypted_keyset(enc_keyset);
std::string enc_keyset_base64;
absl::Base64Escape(enc_keyset, &enc_keyset_base64);
auto keyset_info = encrypted_keyset_.mutable_keyset_info();
keyset_info->set_primary_key_id(42);
auto key_info = keyset_info->add_key_info();
key_info->set_type_url("type.googleapis.com/google.crypto.tink.AesGcmKey");
key_info->set_key_id(42);
key_info->set_output_prefix_type(OutputPrefixType::TINK);
key_info->set_status(KeyStatusType::ENABLED);
good_json_encrypted_keyset_string_ = "{"
"\"encryptedKeyset\": \"" + enc_keyset_base64 + "\", "
"\"keysetInfo\": {"
" \"primaryKeyId\": 42,"
" \"keyInfo\": ["
" {"
" \"typeUrl\":"
" \"type.googleapis.com/google.crypto.tink.AesGcmKey\","
" \"outputPrefixType\": \"TINK\","
" \"keyId\": 42,"
" \"status\": \"ENABLED\""
" }"
" ]"
"}}";
ASSERT_FALSE(good_json_encrypted_keyset_.Parse(
good_json_encrypted_keyset_string_.c_str()).HasParseError());
}
EncryptedKeyset encrypted_keyset_;
Keyset keyset_;
rapidjson::Document good_json_keyset_;
rapidjson::Document good_json_encrypted_keyset_;
std::string good_json_encrypted_keyset_string_;
};
TEST_F(JsonKeysetWriterTest, testWriterCreation) {
{ // Input stream is null.
std::unique_ptr<std::ostream> null_stream(nullptr);
auto writer_result = JsonKeysetWriter::New(std::move(null_stream));
EXPECT_FALSE(writer_result.ok());
EXPECT_EQ(util::error::INVALID_ARGUMENT,
writer_result.status().error_code());
}
{ // Stream with good keyset.
std::unique_ptr<std::ostream> destination_stream(new std::stringstream());
auto writer_result = JsonKeysetWriter::New(std::move(destination_stream));
EXPECT_TRUE(writer_result.ok()) << writer_result.status();
}
}
TEST_F(JsonKeysetWriterTest, testWriteKeyset) {
std::stringbuf buffer;
std::unique_ptr<std::ostream> destination_stream(new std::ostream(&buffer));
auto writer_result = JsonKeysetWriter::New(std::move(destination_stream));
ASSERT_TRUE(writer_result.ok()) << writer_result.status();
auto writer = std::move(writer_result.ValueOrDie());
auto status = writer->Write(keyset_);
EXPECT_TRUE(status.ok()) << status;
rapidjson::Document json_keyset(rapidjson::kObjectType);
EXPECT_FALSE(json_keyset.Parse(buffer.str().c_str()).HasParseError());
EXPECT_TRUE(good_json_keyset_ == json_keyset);
}
TEST_F(JsonKeysetWriterTest, testWriteAndReadKeyset) {
std::stringbuf buffer;
std::unique_ptr<std::ostream> destination_stream(new std::ostream(&buffer));
auto writer_result = JsonKeysetWriter::New(std::move(destination_stream));
ASSERT_TRUE(writer_result.ok()) << writer_result.status();
auto writer = std::move(writer_result.ValueOrDie());
auto status = writer->Write(keyset_);
EXPECT_TRUE(status.ok()) << status;
auto reader_result = JsonKeysetReader::New(buffer.str());
EXPECT_TRUE(reader_result.ok()) << reader_result.status();
auto reader = std::move(reader_result.ValueOrDie());
auto read_result = reader->Read();
EXPECT_TRUE(read_result.ok()) << read_result.status();
auto keyset = std::move(read_result.ValueOrDie());
EXPECT_EQ(keyset_.SerializeAsString(), keyset->SerializeAsString());
}
TEST_F(JsonKeysetWriterTest, testWriteEncryptedKeyset) {
std::stringbuf buffer;
std::unique_ptr<std::ostream> destination_stream(new std::ostream(&buffer));
auto writer_result = JsonKeysetWriter::New(std::move(destination_stream));
ASSERT_TRUE(writer_result.ok()) << writer_result.status();
auto writer = std::move(writer_result.ValueOrDie());
auto status = writer->Write(encrypted_keyset_);
EXPECT_TRUE(status.ok()) << status;
rapidjson::Document json_encrypted_keyset(rapidjson::kObjectType);
EXPECT_FALSE(
json_encrypted_keyset.Parse(buffer.str().c_str()).HasParseError())
<< "Parsing error at position "
<< (unsigned)json_encrypted_keyset.GetErrorOffset()
<< " of JSON string\n"
<< buffer.str() << "\n"
<< rapidjson::GetParseError_En(json_encrypted_keyset.GetParseError());
EXPECT_TRUE(good_json_encrypted_keyset_ == json_encrypted_keyset)
<< "Expected JSON:\n" << good_json_encrypted_keyset_string_ << "\n"
<< "Got JSON:\n" << buffer.str();
}
TEST_F(JsonKeysetWriterTest, testWriteAndReadEncryptedKeyset) {
std::stringbuf buffer;
std::unique_ptr<std::ostream> destination_stream(new std::ostream(&buffer));
auto writer_result = JsonKeysetWriter::New(std::move(destination_stream));
ASSERT_TRUE(writer_result.ok()) << writer_result.status();
auto writer = std::move(writer_result.ValueOrDie());
auto status = writer->Write(encrypted_keyset_);
EXPECT_TRUE(status.ok()) << status;
auto reader_result = JsonKeysetReader::New(buffer.str());
EXPECT_TRUE(reader_result.ok()) << reader_result.status();
auto reader = std::move(reader_result.ValueOrDie());
auto read_result = reader->ReadEncrypted();
EXPECT_TRUE(read_result.ok()) << read_result.status();
auto encrypted_keyset = std::move(read_result.ValueOrDie());
EXPECT_EQ(encrypted_keyset_.SerializeAsString(),
encrypted_keyset->SerializeAsString());
}
TEST_F(JsonKeysetWriterTest, testDestinationStreamErrors) {
std::stringbuf buffer;
std::unique_ptr<std::ostream> destination_stream(new std::ostream(&buffer));
destination_stream->setstate(std::ostream::badbit);
auto writer_result = JsonKeysetWriter::New(std::move(destination_stream));
ASSERT_TRUE(writer_result.ok()) << writer_result.status();
auto writer = std::move(writer_result.ValueOrDie());
{ // Write keyset.
auto status = writer->Write(keyset_);
EXPECT_FALSE(status.ok()) << status;
EXPECT_EQ(util::error::UNKNOWN, status.error_code());
}
{ // Write encrypted keyset.
auto status = writer->Write(encrypted_keyset_);
EXPECT_FALSE(status.ok()) << status;
EXPECT_EQ(util::error::UNKNOWN, status.error_code());
}
}
} // namespace
} // namespace tink
} // namespace crypto
int main(int ac, char* av[]) {
testing::InitGoogleTest(&ac, av);
return RUN_ALL_TESTS();
}
|
*PROCESS DUPALIAS
*
* Compiled by DCC Version 2.25.07 Mar 6 2021 08:51:07
* on Fri Apr 30 15:36:23 2021
*
WXTRN @@ZARCH#
*
*
*
* Code Section
*
@CODE ALIAS C'@RDVARINT'
@CODE CSECT
@CODE AMODE ANY
@CODE RMODE ANY
@DATA ALIAS C'@rdvarint'
fprintf ALIAS C'fprintf'
EXTRN fprintf
rd_unittest_assert_on_failure ALIAS X'99846DA49589A3A385A2A36D81A2A2859*
9A36D96956D86818993A49985'
rd_unittest_assert_on_failure DXD 0F
rd_buf_push0 ALIAS X'99846D82A4866D97A4A288F0'
EXTRN rd_buf_push0
rd_buf_init ALIAS X'99846D82A4866D899589A3'
EXTRN rd_buf_init
rd_buf_destroy ALIAS X'99846D82A4866D8485A2A39996A8'
EXTRN rd_buf_destroy
__assert ALIAS C'@@ASSERT'
EXTRN __assert
rd_slice_init_full ALIAS X'99846DA2938983856D899589A36D86A49393'
EXTRN rd_slice_init_full
rd_slice_read_uvarint ALIAS X'99846DA2938983856D998581846DA4A581998995A*
3'
EXTRN rd_slice_read_uvarint
rd_slice_narrow_copy ALIAS X'99846DA2938983856D9581999996A66D839697A8'
EXTRN rd_slice_narrow_copy
__stderrp ALIAS C'@@STDERP'
__stderrp DXD 0F
*
*
*
* ....... start of rd_slice_offset
@LNAME805 DS 0H
DC X'0000000F'
DC C'rd_slice_offset'
DC X'00'
rd_slice_offset DCCPRLG CINDEX=805,BASER=12,FRAME=168,SAVEAREA=NO,ENTRY*
=NO,ARCH=ZARCH,LNAMEADDR=@LNAME805
* ******* End of Prologue
* *
* *** if (((!slice->seg)))
LG 15,0(0,1) ; slice
LTG 1,8(0,15) ; offset of seg in rd_slice_s
BNZ @L49
* *** return ((slice)->end - (slice)->start);
LG 1,32(0,15) ; offset of end in rd_slice_s
SLG 1,24(0,15)
LGR 15,1
B @ret_lab_805
@L49 DS 0H
* ***
* *** return (slice->seg->seg_absof + slice->rof) - slice->s\
* tart;
LG 1,8(0,15) ; offset of seg in rd_slice_s
LG 1,40(0,1) ; offset of seg_absof in rd_segment_s
ALG 1,16(0,15)
SLG 1,24(0,15)
LGR 15,1
* *** }
@ret_lab_805 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_slice_offset"
* (FUNCTION #805)
*
@AUTO#rd_slice_offset DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_slice_read_varint
@LNAME814 DS 0H
DC X'00000014'
DC C'rd_slice_read_varint'
DC X'00'
rd_slice_read_varint DCCPRLG CINDEX=814,BASER=12,FRAME=192,ENTRY=NO,ARC*
H=ZARCH,LNAMEADDR=@LNAME814
LGR 2,1 ; ptr to parm area
* ******* End of Prologue
* *
* *** size_t r;
* *** uint64_t unum;
* ***
* *** r = rd_slice_read_uvarint(slice, &unum);
LG 15,0(0,2) ; slice
STG 15,176(0,13)
LA 15,168(0,13)
STG 15,184(0,13)
LA 1,176(0,13)
LG 15,@lit_814_0 ; rd_slice_read_uvarint
@@gen_label1 DS 0H
BALR 14,15
@@gen_label2 DS 0H
* *** if (((r > 0))) {
CLGFI 15,X'00000000'
BNH @L50
* ***
* *** *nump = (int64_t)((unum >> 1) ^
* *** -(int64_t)(unum & 1));
LG 1,8(0,2) ; nump
LG 2,168(0,13) ; unum
SRLG 3,2,1(0)
NG 2,@lit_814_1
LCGR 2,2
XGR 3,2
STG 3,0(0,1) ; nump
* *** }
@L50 DS 0H
* ***
* *** return r;
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_814 DC F'192'
@lit_814_0 DC AD(rd_slice_read_uvarint)
@lit_814_1 DC FD'1' 0x0000000000000001
DROP 12
*
* DSECT for automatic variables in "rd_slice_read_varint"
* (FUNCTION #814)
*
@AUTO#rd_slice_read_varint DSECT
DS XL168
rd_slice_read_varint#unum#0 DS 8XL1 ; unum
ORG @AUTO#rd_slice_read_varint+168
rd_slice_read_varint#r#0 DS 8XL1 ; r
*
@CODE CSECT
*
*
*
* ....... start of rd_uvarint_enc_u64
@LNAME826 DS 0H
DC X'00000012'
DC C'rd_uvarint_enc_u64'
DC X'00'
rd_uvarint_enc_u64 DCCPRLG CINDEX=826,BASER=12,FRAME=176,SAVEAREA=NO,EN*
TRY=NO,ARCH=ZARCH,LNAMEADDR=@LNAME826
LGR 2,1 ; ptr to parm area
* ******* End of Prologue
* *
* *** size_t of = 0;
LG 15,16(0,2) ; num
LGHI 1,0 ; 0
* ***
* *** do {
@L51 DS 0H
* *** if (((of >= dstsize)))
CLG 1,8(0,2)
BL @L54
* *** return 0;
LGHI 15,0 ; 0
B @ret_lab_826
DS 0D
@lit_826_5 DC FD'127' 0x000000000000007f
@L54 DS 0H
* ***
* *** dst[of++] = (num & 0x7f) | (num > 0x7f ? 0x80 \
* : 0);
LG 3,0(0,2) ; dst
LGR 4,1
AGHI 1,1
LGR 5,15
NG 5,@lit_826_5
CLGFI 15,X'0000007F'
BNH @L55
LHI 6,128 ; 128
B @L56
@L55 DS 0H
LHI 6,0 ; 0
@L56 DS 0H
LGFR 6,6
OGR 5,6
STC 5,0(4,3)
* *** num >>= 7;
SRLG 15,15,7(0)
* *** } while (num);
LTGR 3,15
BNZ @L51
* ***
* *** return of;
LGR 15,1
* *** }
@ret_lab_826 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_uvarint_enc_u64"
* (FUNCTION #826)
*
@AUTO#rd_uvarint_enc_u64 DSECT
DS XL168
rd_uvarint_enc_u64#of#0 DS 8XL1 ; of
*
@CODE CSECT
*
*
*
* ....... start of rd_uvarint_enc_i64
@LNAME827 DS 0H
DC X'00000012'
DC C'rd_uvarint_enc_i64'
DC X'00'
rd_uvarint_enc_i64 DCCPRLG CINDEX=827,BASER=12,FRAME=192,ENTRY=NO,ARCH=*
ZARCH,LNAMEADDR=@LNAME827
* ******* End of Prologue
* *
* *** return rd_uvarint_enc_u64(dst, dstsize, (num << 1) ^ (\
* num >> 63));
LG 15,0(0,1) ; dst
STG 15,168(0,13)
LG 15,8(0,1) ; dstsize
STG 15,176(0,13)
LG 15,16(0,1) ; num
SLLG 1,15,1(0)
SRAG 15,15,63(0)
XGR 1,15
STG 1,184(0,13)
LA 1,168(0,13)
LG 15,@lit_827_8 ; rd_uvarint_enc_u64
@@gen_label7 DS 0H
BALR 14,15
@@gen_label8 DS 0H
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_827 DC F'192'
@lit_827_8 DC AD(rd_uvarint_enc_u64)
DROP 12
*
* DSECT for automatic variables in "rd_uvarint_enc_i64"
* (FUNCTION #827)
*
@AUTO#rd_uvarint_enc_i64 DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_uvarint_dec
@LNAME829 DS 0H
DC X'0000000E'
DC C'rd_uvarint_dec'
DC X'00'
rd_uvarint_dec DCCPRLG CINDEX=829,BASER=12,FRAME=176,SAVEAREA=NO,ENTRY=*
NO,ARCH=ZARCH,LNAMEADDR=@LNAME829
LGR 3,1 ; ptr to parm area
* ******* End of Prologue
* *
* *** size_t of = 0;
LGHI 15,0 ; 0
* *** uint64_t num = 0;
LGR 1,15 ; num
* *** int shift = 0;
LHI 2,0 ; 0
* ***
* *** do {
@L57 DS 0H
* *** if (((srcsize-- == 0)))
LG 4,8(0,3) ; srcsize
LGR 5,4
AGHI 5,-1
STG 5,8(0,3) ; srcsize
LTGR 4,4
BNE @L60
* *** return 0;
LGHI 15,0 ; 0
B @ret_lab_829
@L60 DS 0H
* *** num |= (uint64_t)(src[(int)of] & 0x7f) << shif\
* t;
LG 4,0(0,3) ; src
LGFR 5,15
IC 5,0(5,4)
NILF 5,X'0000007F'
LGFR 5,5
SLLG 5,5,0(2)
OGR 1,5
* *** shift += 7;
AHI 2,7
* *** } while (src[(int)of++] & 0x80);
LGR 5,15
AGHI 15,1
LGFR 5,5
LA 4,0(5,4)
TM 0(4),128
BNZ @L57
* ***
* *** *nump = num;
LG 2,16(0,3) ; nump
STG 1,0(0,2) ; nump
* *** return of;
* *** }
@ret_lab_829 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_uvarint_dec"
* (FUNCTION #829)
*
@AUTO#rd_uvarint_dec DSECT
DS XL168
rd_uvarint_dec#shift#0 DS 1F ; shift
ORG @AUTO#rd_uvarint_dec+168
rd_uvarint_dec#num#0 DS 8XL1 ; num
ORG @AUTO#rd_uvarint_dec+168
rd_uvarint_dec#of#0 DS 8XL1 ; of
*
@CODE CSECT
*
*
*
* ....... start of rd_varint_dec_i64
@LNAME830 DS 0H
DC X'00000011'
DC C'rd_varint_dec_i64'
DC X'00'
rd_varint_dec_i64 DCCPRLG CINDEX=830,BASER=12,FRAME=200,ENTRY=NO,ARCH=Z*
ARCH,LNAMEADDR=@LNAME830
LGR 2,1 ; ptr to parm area
* ******* End of Prologue
* *
* *** uint64_t n;
* *** size_t r;
* ***
* *** r = rd_uvarint_dec(src, srcsize, &n);
LG 15,0(0,2) ; src
STG 15,176(0,13)
LG 15,8(0,2) ; srcsize
STG 15,184(0,13)
LA 15,168(0,13)
STG 15,192(0,13)
LA 1,176(0,13)
LG 15,@lit_830_14 ; rd_uvarint_dec
@@gen_label11 DS 0H
BALR 14,15
@@gen_label12 DS 0H
* *** if (((!((r == 0) || (r > 0xffffffffffffffffULL)))))
LTGR 1,15
BE @L61
CLG 15,@lit_830_15
BH @L61
@L62 DS 0H
* *** *nump = (int64_t)(n >> 1) ^ -(int64_t)(n & 1);
LG 1,16(0,2) ; nump
LG 2,168(0,13) ; n
SRLG 3,2,1(0)
NG 2,@lit_830_16
LCGR 2,2
XGR 3,2
STG 3,0(0,1) ; nump
@L61 DS 0H
* ***
* *** return r;
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_830 DC F'200'
@lit_830_14 DC AD(rd_uvarint_dec)
@lit_830_15 DC FD'-1' 0xffffffffffffffff
@lit_830_16 DC FD'1' 0x0000000000000001
DROP 12
*
* DSECT for automatic variables in "rd_varint_dec_i64"
* (FUNCTION #830)
*
@AUTO#rd_varint_dec_i64 DSECT
DS XL168
rd_varint_dec_i64#r#0 DS 8XL1 ; r
ORG @AUTO#rd_varint_dec_i64+168
rd_varint_dec_i64#n#0 DS 8XL1 ; n
*
@CODE CSECT
*
*
*
* ....... start of do_test_rd_uvarint_enc_i64
@LNAME833 DS 0H
DC X'0000001A'
DC C'do_test_rd_uvarint_enc_i64'
DC X'00'
do_test_rd_uvarint_enc_i64 DCCPRLG CINDEX=833,BASER=12,FRAME=392,ENTRY=*
NO,ARCH=ZARCH,LNAMEADDR=@LNAME833
DCCPRV REG=5 ; Get PRV from DVT
LGR 6,1 ; ptr to parm area
* ******* End of Prologue
* *
* *** char buf[16] = { 0xff, 0xff, 0xff, 0xff,
LG 3,16(0,6) ; num
LG 2,32(0,6) ; exp_size
MVI 336(13),255
MVI 337(13),255
MVI 338(13),255
MVI 339(13),255
* *** 0xff, 0xff, 0xff, 0xff,
MVI 340(13),255
MVI 341(13),255
MVI 342(13),255
MVI 343(13),255
* *** 0xff, 0xff, 0xff, 0xff,
MVI 344(13),255
MVI 345(13),255
MVI 346(13),255
MVI 347(13),255
* *** 0xff, 0xff, 0xff, 0xff };
MVI 348(13),255
MVI 349(13),255
MVI 350(13),255
MVI 351(13),255
* *** size_t sz = rd_uvarint_enc_i64(buf, sizeof(buf), num);
LA 15,336(0,13)
STG 15,352(0,13)
MVGHI 360(13),16
STG 3,368(0,13)
LA 1,352(0,13)
LG 15,@lit_833_18 ; rd_uvarint_enc_i64
@@gen_label15 DS 0H
BALR 14,15
@@gen_label16 DS 0H
LGR 4,15
* *** size_t r;
* *** int ir;
* *** rd_buf_t b;
* *** rd_slice_t slice, bad_slice;
* *** int64_t ret_num;
* ***
* *** if (sz != exp_size || __memcmp(buf,exp,exp_size))
CLGR 4,2
BNE @L65
LA 15,336(0,13)
LG 1,24(0,6)
LGHI 7,0
LTGR 6,2
BZ @@gen_label18
@@gen_label20 DS 0H
CLC 0(1,15),0(1)
BNZ @@gen_label19
LA 15,1(0,15)
LA 1,1(0,1)
BCTG 6,@@gen_label20
B @@gen_label18
DS 0D
@FRAMESIZE_833 DC F'392'
@lit_833_18 DC AD(rd_uvarint_enc_i64)
@lit_833_22 DC AD(fprintf)
@lit_833_21 DC AD(@DATA)
@lit_833_20 DC AD(@strings@)
@lit_833_19 DC Q(__stderrp)
@lit_833_27 DC Q(rd_unittest_assert_on_failure)
@lit_833_28 DC AD(__assert)
@lit_region_diff_833_1_2 DC A(@REGION_833_2-@REGION_833_1)
@lit_833_30 DC AD(rd_varint_dec_i64)
@lit_833_31 DC FD'-1' 0xffffffffffffffff
@lit_833_55 DC AD(rd_buf_init)
@lit_833_56 DC AD(rd_buf_push0)
@lit_833_57 DC AD(rd_slice_init_full)
@lit_833_58 DC AD(rd_slice_narrow_copy)
@lit_833_70 DC AD(rd_slice_read_varint)
@lit_833_84 DC AD(rd_slice_offset)
@@gen_label19 DS 0H
IC 7,0(0,15)
LGHI 15,0
IC 15,0(0,1)
SLGR 7,15
@@gen_label18 DS 0H
LTR 7,7
BZ @L63
@L64 DS 0H
* *** do { fprintf(__stderrp, "\033[31mRDUT: FAIL: %\
* s:%d: %s: ", "C:\\asgkafka\\librdkafka\\src\\rdvarint.c", 49, __FUNC\
* TION__); fprintf(__stderrp, "i64 encode of %" "lld" ": " "expected s\
* ize %" "zu" " (got %" "zu" ")\n", num, exp_size, sz); fprintf(__stde\
* rrp, "\033[0m\n"); if (rd_unittest_assert_on_failure) ((!*"unittest \
* failure") ? (void)0 : __assert(__func__, "C:\\asgkafka\\librdkafka\\\
* src\\rdvarint.c", 49, "!*\"unittest failure\"")); return 1; } while \
* (0);
@L65 DS 0H
LLGF 6,@lit_833_19 ; __stderrp
LG 15,0(6,5) ; __stderrp
STG 15,352(0,13)
LG 7,@lit_833_20
STG 7,360(0,13)
LA 15,30(0,7)
STG 15,368(0,13)
MVGHI 376(13),49
LG 8,@lit_833_21
LA 15,70(0,8)
STG 15,384(0,13)
LA 1,352(0,13)
LG 9,@lit_833_22 ; fprintf
LGR 15,9
@@gen_label22 DS 0H
BALR 14,15
@@gen_label23 DS 0H
LG 15,0(6,5) ; __stderrp
STG 15,352(0,13)
LA 15,68(0,7)
STG 15,360(0,13)
STG 3,368(0,13)
STG 2,376(0,13)
STG 4,384(0,13)
LA 1,352(0,13)
LGR 15,9
@@gen_label24 DS 0H
BALR 14,15
@@gen_label25 DS 0H
LG 15,0(6,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,7)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,9
@@gen_label26 DS 0H
BALR 14,15
@@gen_label27 DS 0H
LLGF 15,@lit_833_27 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L68
LA 15,124(0,7)
CLI 0(15),0
BE @L68
@L69 DS 0H
LA 15,70(0,8)
STG 15,352(0,13)
LA 15,30(0,7)
STG 15,360(0,13)
MVGHI 368(13),49
LA 15,142(0,7)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_28 ; __assert
@@gen_label30 DS 0H
BALR 14,15
@@gen_label31 DS 0H
@L70 DS 0H
@L68 DS 0H
LGHI 15,1 ; 1
ALGF 12,@lit_region_diff_833_1_2
DROP 12
USING @REGION_833_2,12
B @ret_lab_833
DROP 12
USING @REGION_833_1,12
* ***
* ***
* ***
* ***
* *** r = rd_varint_dec_i64(buf, sz, &ret_num);
@L63 DS 0H
LA 15,336(0,13)
STG 15,352(0,13)
STG 4,360(0,13)
LA 15,168(0,13)
STG 15,368(0,13)
LA 1,352(0,13)
LG 15,@lit_833_30 ; rd_varint_dec_i64
@@gen_label32 DS 0H
BALR 14,15
@@gen_label33 DS 0H
LGR 2,15 ; r
* *** do { if (!(!((r == 0) || (r > 0xffffffffffffffffULL)))\
* ) { fprintf(__stderrp, "\033[31mRDUT: FAIL: %s:%d: %s: " "assert fai\
* led: " "!RD_UVARINT_DEC_FAILED(r)" ": ", "C:\\asgkafka\\librdkafka\\\
* src\\rdvarint.c", 55, __FUNCTION__); fprintf(__stderrp, "varint deco\
* de failed: %" "zu", r); fprintf(__stderrp, "\033[0m\n"); if (rd_unit\
* test_assert_on_failure) ((!((r == 0) || (r > 0xffffffffffffffffULL))\
* ) ? (void)0 : __assert(__func__, "C:\\asgkafka\\librdkafka\\src\\rdv\
* arint.c", 55, "!((r == 0) || (r > 0xffffffffffffffffULL))")); return\
* 1; } } while (0);
@L71 DS 0H
LTGR 15,2
BE @L75
CLG 2,@lit_833_31
BNH @L74
@L75 DS 0H
LLGF 3,@lit_833_19 ; __stderrp
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LG 4,@lit_833_20
LA 15,164(0,4)
STG 15,360(0,13)
LA 15,30(0,4)
STG 15,368(0,13)
MVGHI 376(13),55
LG 6,@lit_833_21
LA 15,70(0,6)
STG 15,384(0,13)
LA 1,352(0,13)
LG 7,@lit_833_22 ; fprintf
LGR 15,7
@@gen_label36 DS 0H
BALR 14,15
@@gen_label37 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,236(0,4)
STG 15,360(0,13)
STG 2,368(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label38 DS 0H
BALR 14,15
@@gen_label39 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,4)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label40 DS 0H
BALR 14,15
@@gen_label41 DS 0H
LLGF 15,@lit_833_27 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L76
LTGR 15,2
BE @L77
CLG 2,@lit_833_31
BNH @L76
@L77 DS 0H
LA 15,70(0,6)
STG 15,352(0,13)
LA 15,30(0,4)
STG 15,360(0,13)
MVGHI 368(13),55
LA 15,262(0,4)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_28 ; __assert
@@gen_label45 DS 0H
BALR 14,15
@@gen_label46 DS 0H
@L79 DS 0H
@L76 DS 0H
LGHI 15,1 ; 1
ALGF 12,@lit_region_diff_833_1_2
DROP 12
USING @REGION_833_2,12
B @ret_lab_833
DROP 12
USING @REGION_833_1,12
@L74 DS 0H
* ***
* *** do { if (!(ret_num == num)) { fprintf(__stderrp, "\033\
* [31mRDUT: FAIL: %s:%d: %s: " "assert failed: " "ret_num == num" ": "\
* , "C:\\asgkafka\\librdkafka\\src\\rdvarint.c", 57, __FUNCTION__); fp\
* rintf(__stderrp, "varint decode returned wrong number: " "%" "lld" "\
* != %" "lld", ret_num, num); fprintf(__stderrp, "\033[0m\n"); if (rd\
* _unittest_assert_on_failure) ((ret_num == num) ? (void)0 : __assert(\
* __func__, "C:\\asgkafka\\librdkafka\\src\\rdvarint.c", 57, "ret_num \
* == num")); return 1; } } while (0);
@L80 DS 0H
CG 3,168(0,13)
BE @L83
LLGF 2,@lit_833_19 ; __stderrp
LG 15,0(2,5) ; __stderrp
STG 15,352(0,13)
LG 4,@lit_833_20
LA 15,306(0,4)
STG 15,360(0,13)
LA 15,30(0,4)
STG 15,368(0,13)
MVGHI 376(13),57
LG 6,@lit_833_21
LA 15,70(0,6)
STG 15,384(0,13)
LA 1,352(0,13)
LG 7,@lit_833_22 ; fprintf
LGR 15,7
@@gen_label48 DS 0H
BALR 14,15
@@gen_label49 DS 0H
LG 15,0(2,5) ; __stderrp
STG 15,352(0,13)
LA 15,366(0,4)
STG 15,360(0,13)
LG 15,168(0,13) ; ret_num
STG 15,368(0,13)
STG 3,376(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label50 DS 0H
BALR 14,15
@@gen_label51 DS 0H
LG 15,0(2,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,4)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label52 DS 0H
BALR 14,15
@@gen_label53 DS 0H
LLGF 15,@lit_833_27 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L84
CG 3,168(0,13)
BE @L84
@L85 DS 0H
LA 15,70(0,6)
STG 15,352(0,13)
LA 15,30(0,4)
STG 15,360(0,13)
MVGHI 368(13),57
LA 15,416(0,4)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_28 ; __assert
@@gen_label56 DS 0H
BALR 14,15
@@gen_label57 DS 0H
@L86 DS 0H
@L84 DS 0H
LGHI 15,1 ; 1
ALGF 12,@lit_region_diff_833_1_2
DROP 12
USING @REGION_833_2,12
B @ret_lab_833
DROP 12
USING @REGION_833_1,12
@L83 DS 0H
* ***
* ***
* ***
* ***
* *** rd_buf_init(&b, 1, 0);
LA 15,256(0,13)
STG 15,352(0,13)
MVGHI 360(13),1
XC 368(8,13),368(13)
LA 1,352(0,13)
LG 15,@lit_833_55 ; rd_buf_init
@@gen_label58 DS 0H
BALR 14,15
@@gen_label59 DS 0H
* *** rd_buf_push0(&b,buf,sizeof(buf),((void *)0),0 );
LA 15,256(0,13)
STG 15,352(0,13)
LA 15,336(0,13)
STG 15,360(0,13)
MVGHI 368(13),16
XC 376(16,13),376(13)
LA 1,352(0,13)
LG 15,@lit_833_56 ; rd_buf_push0
@@gen_label60 DS 0H
BALR 14,15
@@gen_label61 DS 0H
* ***
* ***
* *** rd_slice_init_full(&slice, &b);
LA 15,216(0,13)
STG 15,352(0,13)
LA 15,256(0,13)
STG 15,360(0,13)
LA 1,352(0,13)
LG 15,@lit_833_57 ; rd_slice_init_full
@@gen_label62 DS 0H
BALR 14,15
@@gen_label63 DS 0H
* ***
* ***
* *** ir = rd_slice_narrow_copy(&slice, &bad_slice, sz-1);
LA 15,216(0,13)
STG 15,352(0,13)
LA 15,176(0,13)
STG 15,360(0,13)
LGR 15,4
AGHI 15,-1
STG 15,368(0,13)
LA 1,352(0,13)
LG 15,@lit_833_58 ; rd_slice_narrow_copy
@@gen_label64 DS 0H
BALR 14,15
@@gen_label65 DS 0H
LR 2,15
* *** do { if (!(ir)) { fprintf(__stderrp, "\033[31mRDUT: FA\
* IL: %s:%d: %s: " "assert failed: " "ir" ": ", "C:\\asgkafka\\librdka\
* fka\\src\\rdvarint.c", 70, __FUNCTION__); fprintf(__stderrp, "narrow\
* _copy failed"); fprintf(__stderrp, "\033[0m\n"); if (rd_unittest_ass\
* ert_on_failure) ((ir) ? (void)0 : __assert(__func__, "C:\\asgkafka\\\
* librdkafka\\src\\rdvarint.c", 70, "ir")); return 1; } } while (0);
@L87 DS 0H
LTR 2,2
BNZ @L90
LLGF 3,@lit_833_19 ; __stderrp
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LG 4,@lit_833_20
LA 15,432(0,4)
STG 15,360(0,13)
LA 15,30(0,4)
STG 15,368(0,13)
MVGHI 376(13),70
LG 6,@lit_833_21
LA 15,70(0,6)
STG 15,384(0,13)
LA 1,352(0,13)
LG 7,@lit_833_22 ; fprintf
LGR 15,7
@@gen_label67 DS 0H
BALR 14,15
@@gen_label68 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,480(0,4)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label69 DS 0H
BALR 14,15
@@gen_label70 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,4)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label71 DS 0H
BALR 14,15
@@gen_label72 DS 0H
LLGF 15,@lit_833_27 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L91
LTR 2,2
BNZ @L91
@L92 DS 0H
LA 15,70(0,6)
STG 15,352(0,13)
LA 15,30(0,4)
STG 15,360(0,13)
MVGHI 368(13),70
LA 15,500(0,4)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_28 ; __assert
@@gen_label75 DS 0H
BALR 14,15
@@gen_label76 DS 0H
@L93 DS 0H
@L91 DS 0H
LGHI 15,1 ; 1
ALGF 12,@lit_region_diff_833_1_2
DROP 12
USING @REGION_833_2,12
B @ret_lab_833
DROP 12
USING @REGION_833_1,12
@L90 DS 0H
* *** ret_num = -1;
MVGHI 168(13),-1 ; ret_num
* *** r = rd_slice_read_varint(&bad_slice, &ret_num);
LA 15,176(0,13)
STG 15,352(0,13)
LA 15,168(0,13)
STG 15,360(0,13)
LA 1,352(0,13)
LG 15,@lit_833_70 ; rd_slice_read_varint
@@gen_label77 DS 0H
BALR 14,15
@@gen_label78 DS 0H
LGR 2,15 ; r
* *** do { if (!(((r == 0) || (r > 0xffffffffffffffffULL))))\
* { fprintf(__stderrp, "\033[31mRDUT: FAIL: %s:%d: %s: " "assert fail\
* ed: " "RD_UVARINT_DEC_FAILED(r)" ": ", "C:\\asgkafka\\librdkafka\\sr\
* c\\rdvarint.c", 73, __FUNCTION__); fprintf(__stderrp, "varint decode\
* failed should have failed, " "returned %" "zu", r); fprintf(__stder\
* rp, "\033[0m\n"); if (rd_unittest_assert_on_failure) ((((r == 0) || \
* (r > 0xffffffffffffffffULL))) ? (void)0 : __assert(__func__, "C:\\as\
* gkafka\\librdkafka\\src\\rdvarint.c", 73, "((r == 0) || (r > 0xfffff\
* fffffffffffULL))")); return 1; } } while (0);
@L94 DS 0H
LTGR 15,2
BE @L97
CLG 2,@lit_833_31
BH @L97
@L98 DS 0H
LLGF 3,@lit_833_19 ; __stderrp
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LG 4,@lit_833_20
LA 15,504(0,4)
STG 15,360(0,13)
LA 15,30(0,4)
STG 15,368(0,13)
MVGHI 376(13),73
LG 6,@lit_833_21
LA 15,70(0,6)
STG 15,384(0,13)
LA 1,352(0,13)
LG 7,@lit_833_22 ; fprintf
LGR 15,7
@@gen_label81 DS 0H
BALR 14,15
@@gen_label82 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,574(0,4)
STG 15,360(0,13)
STG 2,368(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label83 DS 0H
BALR 14,15
@@gen_label84 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,4)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label85 DS 0H
BALR 14,15
@@gen_label86 DS 0H
LLGF 15,@lit_833_27 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L99
LTGR 15,2
BE @L99
CLG 2,@lit_833_31
BNH @L100
@L101 DS 0H
B @L99
@L100 DS 0H
LA 15,70(0,6)
STG 15,352(0,13)
LA 15,30(0,4)
STG 15,360(0,13)
MVGHI 368(13),73
LA 15,628(0,4)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_28 ; __assert
@@gen_label90 DS 0H
BALR 14,15
@@gen_label91 DS 0H
@L102 DS 0H
@L99 DS 0H
LGHI 15,1 ; 1
ALGF 12,@lit_region_diff_833_1_2
DROP 12
USING @REGION_833_2,12
B @ret_lab_833
DROP 12
USING @REGION_833_1,12
@L97 DS 0H
* ***
* ***
* ***
* *** r = rd_slice_offset(&bad_slice);
LA 15,176(0,13)
STG 15,352(0,13)
LA 1,352(0,13)
LG 15,@lit_833_84 ; rd_slice_offset
@@gen_label92 DS 0H
BALR 14,15
@@gen_label93 DS 0H
LGR 2,15 ; r
* *** do { if (!(r == 0)) { fprintf(__stderrp, "\033[31mRDUT\
* : FAIL: %s:%d: %s: " "assert failed: " "r == 0" ": ", "C:\\asgkafka\\
* \librdkafka\\src\\rdvarint.c", 78, __FUNCTION__); fprintf(__stderrp,\
* "expected slice position to not change, but got %" "zu", r); fprint\
* f(__stderrp, "\033[0m\n"); if (rd_unittest_assert_on_failure) ((r ==\
* 0) ? (void)0 : __assert(__func__, "C:\\asgkafka\\librdkafka\\src\\r\
* dvarint.c", 78, "r == 0")); return 1; } } while (0);
@L103 DS 0H
LTGR 15,2
BNE *+14 Around region break
ALGF 12,@lit_region_diff_833_1_2
DROP 12
USING @REGION_833_2,12
B @L106
DROP 12
USING @REGION_833_1,12
LLGF 3,@lit_833_19 ; __stderrp
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LG 4,@lit_833_20
LA 15,670(0,4)
STG 15,360(0,13)
LA 15,30(0,4)
STG 15,368(0,13)
MVGHI 376(13),78
LG 6,@lit_833_21
LA 15,70(0,6)
STG 15,384(0,13)
LA 1,352(0,13)
LG 7,@lit_833_22 ; fprintf
LGR 15,7
@@gen_label95 DS 0H
BALR 14,15
@@gen_label96 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,722(0,4)
STG 15,360(0,13)
STG 2,368(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label97 DS 0H
BALR 14,15
@@gen_label98 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,4)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label99 DS 0H
BALR 14,15
@@gen_label100 DS 0H
LLGF 15,@lit_833_27 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L107
LTGR 15,2
BE @L107
@L108 DS 0H
LA 15,70(0,6)
STG 15,352(0,13)
LA 15,30(0,4)
STG 15,360(0,13)
MVGHI 368(13),78
LA 15,774(0,4)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_28 ; __assert
@@gen_label103 DS 0H
BALR 14,15
@@gen_label104 DS 0H
@L109 DS 0H
@L107 DS 0H
LGHI 15,1 ; 1
ALGF 12,@lit_region_diff_833_1_2
DROP 12
USING @REGION_833_2,12
B @ret_lab_833
DROP 12
USING @REGION_833_1,12
@REGION_833_2 DS 0H
DROP 12
USING @REGION_833_2,12
@L106 DS 0H
* ***
* ***
* ***
* ***
* *** ret_num = -1;
MVGHI 168(13),-1 ; ret_num
* *** r = rd_slice_read_varint(&slice, &ret_num);
LA 15,216(0,13)
STG 15,352(0,13)
LA 15,168(0,13)
STG 15,360(0,13)
LA 1,352(0,13)
LG 15,@lit_833_96 ; rd_slice_read_varint
@@gen_label105 DS 0H
BALR 14,15
@@gen_label106 DS 0H
LGR 2,15 ; r
* *** do { if (!(!((r == 0) || (r > 0xffffffffffffffffULL)))\
* ) { fprintf(__stderrp, "\033[31mRDUT: FAIL: %s:%d: %s: " "assert fai\
* led: " "!RD_UVARINT_DEC_FAILED(r)" ": ", "C:\\asgkafka\\librdkafka\\\
* src\\rdvarint.c", 85, __FUNCTION__); fprintf(__stderrp, "varint deco\
* de failed: %" "zu", r); fprintf(__stderrp, "\033[0m\n"); if (rd_unit\
* test_assert_on_failure) ((!((r == 0) || (r > 0xffffffffffffffffULL))\
* ) ? (void)0 : __assert(__func__, "C:\\asgkafka\\librdkafka\\src\\rdv\
* arint.c", 85, "!((r == 0) || (r > 0xffffffffffffffffULL))")); return\
* 1; } } while (0);
@L110 DS 0H
LTGR 15,2
BE @L114
CLG 2,@lit_833_97
BNH @L113
@L114 DS 0H
LLGF 3,@lit_833_98 ; __stderrp
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LG 4,@lit_833_99
LA 15,164(0,4)
STG 15,360(0,13)
LA 15,30(0,4)
STG 15,368(0,13)
MVGHI 376(13),85
LG 6,@lit_833_100
LA 15,70(0,6)
STG 15,384(0,13)
LA 1,352(0,13)
LG 7,@lit_833_101 ; fprintf
LGR 15,7
@@gen_label109 DS 0H
BALR 14,15
@@gen_label110 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,236(0,4)
STG 15,360(0,13)
STG 2,368(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label111 DS 0H
BALR 14,15
@@gen_label112 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,4)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label113 DS 0H
BALR 14,15
@@gen_label114 DS 0H
LLGF 15,@lit_833_106 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L115
LTGR 15,2
BE @L116
CLG 2,@lit_833_97
BNH @L115
@L116 DS 0H
LA 15,70(0,6)
STG 15,352(0,13)
LA 15,30(0,4)
STG 15,360(0,13)
MVGHI 368(13),85
LA 15,262(0,4)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_108 ; __assert
@@gen_label118 DS 0H
BALR 14,15
@@gen_label119 DS 0H
@L118 DS 0H
@L115 DS 0H
LGHI 15,1 ; 1
B @ret_lab_833
DS 0D
@lit_833_96 DC AD(rd_slice_read_varint)
@lit_833_97 DC FD'-1' 0xffffffffffffffff
@lit_833_101 DC AD(fprintf)
@lit_833_100 DC AD(@DATA)
@lit_833_99 DC AD(@strings@)
@lit_833_98 DC Q(__stderrp)
@lit_833_106 DC Q(rd_unittest_assert_on_failure)
@lit_833_108 DC AD(__assert)
@lit_833_132 DC AD(rd_slice_offset)
@lit_833_144 DC AD(rd_buf_destroy)
@L113 DS 0H
* ***
* *** do { if (!(ret_num == num)) { fprintf(__stderrp, "\033\
* [31mRDUT: FAIL: %s:%d: %s: " "assert failed: " "ret_num == num" ": "\
* , "C:\\asgkafka\\librdkafka\\src\\rdvarint.c", 87, __FUNCTION__); fp\
* rintf(__stderrp, "varint decode returned wrong number: " "%" "lld" "\
* != %" "lld", ret_num, num); fprintf(__stderrp, "\033[0m\n"); if (rd\
* _unittest_assert_on_failure) ((ret_num == num) ? (void)0 : __assert(\
* __func__, "C:\\asgkafka\\librdkafka\\src\\rdvarint.c", 87, "ret_num \
* == num")); return 1; } } while (0);
@L119 DS 0H
CG 3,168(0,13)
BE @L122
LLGF 2,@lit_833_98 ; __stderrp
LG 15,0(2,5) ; __stderrp
STG 15,352(0,13)
LG 4,@lit_833_99
LA 15,306(0,4)
STG 15,360(0,13)
LA 15,30(0,4)
STG 15,368(0,13)
MVGHI 376(13),87
LG 6,@lit_833_100
LA 15,70(0,6)
STG 15,384(0,13)
LA 1,352(0,13)
LG 7,@lit_833_101 ; fprintf
LGR 15,7
@@gen_label121 DS 0H
BALR 14,15
@@gen_label122 DS 0H
LG 15,0(2,5) ; __stderrp
STG 15,352(0,13)
LA 15,366(0,4)
STG 15,360(0,13)
LG 15,168(0,13) ; ret_num
STG 15,368(0,13)
STG 3,376(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label123 DS 0H
BALR 14,15
@@gen_label124 DS 0H
LG 15,0(2,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,4)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,7
@@gen_label125 DS 0H
BALR 14,15
@@gen_label126 DS 0H
LLGF 15,@lit_833_106 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L123
CG 3,168(0,13)
BE @L123
@L124 DS 0H
LA 15,70(0,6)
STG 15,352(0,13)
LA 15,30(0,4)
STG 15,360(0,13)
MVGHI 368(13),87
LA 15,416(0,4)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_108 ; __assert
@@gen_label129 DS 0H
BALR 14,15
@@gen_label130 DS 0H
@L125 DS 0H
@L123 DS 0H
LGHI 15,1 ; 1
B @ret_lab_833
@L122 DS 0H
* ***
* ***
* *** do { if (!(r == sz)) { fprintf(__stderrp, "\033[31mRDU\
* T: FAIL: %s:%d: %s: " "assert failed: " "r == sz" ": ", "C:\\asgkafk\
* a\\librdkafka\\src\\rdvarint.c", 90, __FUNCTION__); fprintf(__stderr\
* p, "expected varint decoder to read %" "zu" " bytes, " "not %" "zu",\
* sz, r); fprintf(__stderrp, "\033[0m\n"); if (rd_unittest_assert_on_\
* failure) ((r == sz) ? (void)0 : __assert(__func__, "C:\\asgkafka\\li\
* brdkafka\\src\\rdvarint.c", 90, "r == sz")); return 1; } } while (0)\
* ;
@L126 DS 0H
CLGR 2,4
BE @L129
LLGF 3,@lit_833_98 ; __stderrp
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LG 6,@lit_833_99
LA 15,782(0,6)
STG 15,360(0,13)
LA 15,30(0,6)
STG 15,368(0,13)
MVGHI 376(13),90
LG 7,@lit_833_100
LA 15,70(0,7)
STG 15,384(0,13)
LA 1,352(0,13)
LG 8,@lit_833_101 ; fprintf
LGR 15,8
@@gen_label132 DS 0H
BALR 14,15
@@gen_label133 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,836(0,6)
STG 15,360(0,13)
STG 4,368(0,13)
STG 2,376(0,13)
LA 1,352(0,13)
LGR 15,8
@@gen_label134 DS 0H
BALR 14,15
@@gen_label135 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,6)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,8
@@gen_label136 DS 0H
BALR 14,15
@@gen_label137 DS 0H
LLGF 15,@lit_833_106 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L130
CLGR 2,4
BE @L130
@L131 DS 0H
LA 15,70(0,7)
STG 15,352(0,13)
LA 15,30(0,6)
STG 15,360(0,13)
MVGHI 368(13),90
LA 15,888(0,6)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_108 ; __assert
@@gen_label140 DS 0H
BALR 14,15
@@gen_label141 DS 0H
@L132 DS 0H
@L130 DS 0H
LGHI 15,1 ; 1
B @ret_lab_833
@L129 DS 0H
* ***
* ***
* ***
* *** r = rd_slice_offset(&slice);
LA 15,216(0,13)
STG 15,352(0,13)
LA 1,352(0,13)
LG 15,@lit_833_132 ; rd_slice_offset
@@gen_label142 DS 0H
BALR 14,15
@@gen_label143 DS 0H
LGR 2,15 ; r
* *** do { if (!(r == sz)) { fprintf(__stderrp, "\033[31mRDU\
* T: FAIL: %s:%d: %s: " "assert failed: " "r == sz" ": ", "C:\\asgkafk\
* a\\librdkafka\\src\\rdvarint.c", 95, __FUNCTION__); fprintf(__stderr\
* p, "expected slice position to change to %" "zu" ", but got %" "zu",\
* sz, r); fprintf(__stderrp, "\033[0m\n"); if (rd_unittest_assert_on_\
* failure) ((r == sz) ? (void)0 : __assert(__func__, "C:\\asgkafka\\li\
* brdkafka\\src\\rdvarint.c", 95, "r == sz")); return 1; } } while (0)\
* ;
@L133 DS 0H
CLGR 2,4
BE @L136
LLGF 3,@lit_833_98 ; __stderrp
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LG 6,@lit_833_99
LA 15,782(0,6)
STG 15,360(0,13)
LA 15,30(0,6)
STG 15,368(0,13)
MVGHI 376(13),95
LG 7,@lit_833_100
LA 15,70(0,7)
STG 15,384(0,13)
LA 1,352(0,13)
LG 8,@lit_833_101 ; fprintf
LGR 15,8
@@gen_label145 DS 0H
BALR 14,15
@@gen_label146 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,896(0,6)
STG 15,360(0,13)
STG 4,368(0,13)
STG 2,376(0,13)
LA 1,352(0,13)
LGR 15,8
@@gen_label147 DS 0H
BALR 14,15
@@gen_label148 DS 0H
LG 15,0(3,5) ; __stderrp
STG 15,352(0,13)
LA 15,118(0,6)
STG 15,360(0,13)
LA 1,352(0,13)
LGR 15,8
@@gen_label149 DS 0H
BALR 14,15
@@gen_label150 DS 0H
LLGF 15,@lit_833_106 ; rd_unittest_assert_on_failure
LA 15,0(15,5)
CLI 0(15),0
BE @L137
CLGR 2,4
BE @L137
@L138 DS 0H
LA 15,70(0,7)
STG 15,352(0,13)
LA 15,30(0,6)
STG 15,360(0,13)
MVGHI 368(13),95
LA 15,888(0,6)
STG 15,376(0,13)
LA 1,352(0,13)
LG 15,@lit_833_108 ; __assert
@@gen_label153 DS 0H
BALR 14,15
@@gen_label154 DS 0H
@L139 DS 0H
@L137 DS 0H
LGHI 15,1 ; 1
B @ret_lab_833
@L136 DS 0H
* ***
* ***
* ***
* ***
* ***
* *** rd_buf_destroy(&b);
LA 15,256(0,13)
STG 15,352(0,13)
LA 1,352(0,13)
LG 15,@lit_833_144 ; rd_buf_destroy
@@gen_label155 DS 0H
BALR 14,15
@@gen_label156 DS 0H
* ***
* *** do { fprintf(__stderrp, "\033[32mRDUT: PASS: %s:%d: %s\
* \033[0m\n", "C:\\asgkafka\\librdkafka\\src\\rdvarint.c", 103, __FUNC\
* TION__); return 0; } while (0);
@L140 DS 0H
LLGF 15,@lit_833_98 ; __stderrp
LG 15,0(15,5) ; __stderrp
STG 15,352(0,13)
LG 15,@lit_833_99
LA 1,950(0,15)
STG 1,360(0,13)
LA 15,30(0,15)
STG 15,368(0,13)
MVGHI 376(13),103
LG 15,@lit_833_100
LA 15,70(0,15)
STG 15,384(0,13)
LA 1,352(0,13)
LG 15,@lit_833_101 ; fprintf
@@gen_label157 DS 0H
BALR 14,15
@@gen_label158 DS 0H
LGHI 15,0 ; 0
* *** }
@ret_lab_833 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "do_test_rd_uvarint_enc_i64"
* (FUNCTION #833)
*
@AUTO#do_test_rd_uvarint_enc_i64 DSECT
DS XL168
do_test_rd_uvarint_enc_i64#ret_num#0 DS 8XL1 ; ret_num
ORG @AUTO#do_test_rd_uvarint_enc_i64+168
do_test_rd_uvarint_enc_i64#ir#0 DS 1F ; ir
ORG @AUTO#do_test_rd_uvarint_enc_i64+168
do_test_rd_uvarint_enc_i64#r#0 DS 8XL1 ; r
ORG @AUTO#do_test_rd_uvarint_enc_i64+168
do_test_rd_uvarint_enc_i64#sz#0 DS 8XL1 ; sz
ORG @AUTO#do_test_rd_uvarint_enc_i64+176
do_test_rd_uvarint_enc_i64#bad_slice#0 DS 40XL1 ; bad_slice
ORG @AUTO#do_test_rd_uvarint_enc_i64+216
do_test_rd_uvarint_enc_i64#slice#0 DS 40XL1 ; slice
ORG @AUTO#do_test_rd_uvarint_enc_i64+256
do_test_rd_uvarint_enc_i64#b#0 DS 80XL1 ; b
ORG @AUTO#do_test_rd_uvarint_enc_i64+336
do_test_rd_uvarint_enc_i64#buf#0 DS 16XL1 ; buf
*
@CODE CSECT
*
*
*
* ....... start of unittest_rdvarint
unittest_rdvarint ALIAS X'A49589A3A385A2A36D9984A581998995A3'
@LNAME831 DS 0H
DC X'00000011'
DC C'unittest_rdvarint'
DC X'00'
unittest_rdvarint DCCPRLG CINDEX=831,BASER=12,FRAME=232,ENTRY=YES,ARCH=*
ZARCH,LNAMEADDR=@LNAME831
* ******* End of Prologue
* *
* *** int fails = 0;
LHI 2,0 ; 0
* ***
* *** fails += do_test_rd_uvarint_enc_i64("C:\\asgkafka\\lib\
* rdkafka\\src\\rdvarint.c", 110, 0,
* *** (const char[]){ 0 \
* }, 1);
* setting 1 bytes to 0x00
XC 190(1,13),190(13)
LG 3,@lit_831_159
LA 15,30(0,3)
STG 15,192(0,13)
MVGHI 200(13),110
XC 208(8,13),208(13)
LA 15,190(0,13)
STG 15,216(0,13)
MVGHI 224(13),1
LA 1,192(0,13)
LG 4,@lit_831_160 ; do_test_rd_uvarint_enc_i64
LGR 15,4
@@gen_label159 DS 0H
BALR 14,15
@@gen_label160 DS 0H
AR 2,15
* *** fails += do_test_rd_uvarint_enc_i64("C:\\asgkafka\\lib\
* rdkafka\\src\\rdvarint.c", 112, 1,
* *** (const char[]){ 0x\
* 2 }, 1);
MVI 189(13),2
LA 15,30(0,3)
STG 15,192(0,13)
MVGHI 200(13),112
MVGHI 208(13),1
LA 15,189(0,13)
STG 15,216(0,13)
MVGHI 224(13),1
LA 1,192(0,13)
LGR 15,4
@@gen_label161 DS 0H
BALR 14,15
@@gen_label162 DS 0H
AR 2,15
* *** fails += do_test_rd_uvarint_enc_i64("C:\\asgkafka\\lib\
* rdkafka\\src\\rdvarint.c", 114, -1,
* *** (const char[]){ 0x\
* 1 }, 1);
MVI 188(13),1
LA 15,30(0,3)
STG 15,192(0,13)
MVGHI 200(13),114
MVGHI 208(13),-1
LA 15,188(0,13)
STG 15,216(0,13)
MVGHI 224(13),1
LA 1,192(0,13)
LGR 15,4
@@gen_label163 DS 0H
BALR 14,15
@@gen_label164 DS 0H
AR 2,15
* *** fails += do_test_rd_uvarint_enc_i64("C:\\asgkafka\\lib\
* rdkafka\\src\\rdvarint.c", 116, 23,
* *** (const char[]){ 0x\
* 2e }, 1);
MVI 187(13),46
LA 15,30(0,3)
STG 15,192(0,13)
MVGHI 200(13),116
MVGHI 208(13),23
LA 15,187(0,13)
STG 15,216(0,13)
MVGHI 224(13),1
LA 1,192(0,13)
LGR 15,4
@@gen_label165 DS 0H
BALR 14,15
@@gen_label166 DS 0H
AR 2,15
* *** fails += do_test_rd_uvarint_enc_i64("C:\\asgkafka\\lib\
* rdkafka\\src\\rdvarint.c", 118, -23,
* *** (const char[]){ 0x\
* 2d }, 1);
MVI 186(13),45
LA 15,30(0,3)
STG 15,192(0,13)
MVGHI 200(13),118
MVGHI 208(13),-23
LA 15,186(0,13)
STG 15,216(0,13)
MVGHI 224(13),1
LA 1,192(0,13)
LGR 15,4
@@gen_label167 DS 0H
BALR 14,15
@@gen_label168 DS 0H
AR 2,15
* *** fails += do_test_rd_uvarint_enc_i64("C:\\asgkafka\\lib\
* rdkafka\\src\\rdvarint.c", 120, 253,
* *** (const char[]){ 0x\
* fa, 3 }, 2);
MVI 184(13),250
MVI 185(13),3
LA 15,30(0,3)
STG 15,192(0,13)
MVGHI 200(13),120
MVGHI 208(13),253
LA 15,184(0,13)
STG 15,216(0,13)
MVGHI 224(13),2
LA 1,192(0,13)
LGR 15,4
@@gen_label169 DS 0H
BALR 14,15
@@gen_label170 DS 0H
AR 2,15
* *** fails += do_test_rd_uvarint_enc_i64("C:\\asgkafka\\lib\
* rdkafka\\src\\rdvarint.c", 122,
* *** 1234567890101112,
* *** (const char[]){ 0x\
* f0,
MVI 176(13),240
* *** 0x\
* 8d,
MVI 177(13),141
* *** 0x\
* d3,
MVI 178(13),211
* *** 0x\
* c8,
MVI 179(13),200
* *** 0x\
* a7,
MVI 180(13),167
* *** 0x\
* b5,
MVI 181(13),181
* *** 0x\
* b1,
MVI 182(13),177
* *** 0x\
* 04 }, 8);
MVI 183(13),4
LA 15,30(0,3)
STG 15,192(0,13)
MVGHI 200(13),122
LG 15,@lit_831_167 ; 1234567890101112
STG 15,208(0,13)
LA 15,176(0,13)
STG 15,216(0,13)
MVGHI 224(13),8
LA 1,192(0,13)
LGR 15,4
@@gen_label171 DS 0H
BALR 14,15
@@gen_label172 DS 0H
AR 2,15
* *** fails += do_test_rd_uvarint_enc_i64("C:\\asgkafka\\lib\
* rdkafka\\src\\rdvarint.c", 132,
* *** -1234567890101112,
* *** (const char[]){ 0x\
* ef,
MVI 168(13),239
* *** 0x\
* 8d,
MVI 169(13),141
* *** 0x\
* d3,
MVI 170(13),211
* *** 0x\
* c8,
MVI 171(13),200
* *** 0x\
* a7,
MVI 172(13),167
* *** 0x\
* b5,
MVI 173(13),181
* *** 0x\
* b1,
MVI 174(13),177
* *** 0x\
* 04 }, 8);
MVI 175(13),4
LA 15,30(0,3)
STG 15,192(0,13)
MVGHI 200(13),132
LG 15,@lit_831_170 ; -1234567890101112
STG 15,208(0,13)
LA 15,168(0,13)
STG 15,216(0,13)
MVGHI 224(13),8
LA 1,192(0,13)
LGR 15,4
@@gen_label173 DS 0H
BALR 14,15
@@gen_label174 DS 0H
AR 2,15
* ***
* *** return fails;
LGFR 15,2
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_831 DC F'232'
@lit_831_160 DC AD(do_test_rd_uvarint_enc_i64)
@lit_831_159 DC AD(@strings@)
@lit_831_167 DC FD'1234567890101112' 0x000462d53c8a6378
@lit_831_170 DC FD'-1234567890101112' 0xfffb9d2ac3759c88
DROP 12
*
* DSECT for automatic variables in "unittest_rdvarint"
* (FUNCTION #831)
*
@AUTO#unittest_rdvarint DSECT
DS XL168
unittest_rdvarint#__cl7#0 DS 8XL1 ; __cl7
ORG @AUTO#unittest_rdvarint+168
unittest_rdvarint#fails#0 DS 1F ; fails
ORG @AUTO#unittest_rdvarint+176
unittest_rdvarint#__cl6#0 DS 8XL1 ; __cl6
ORG @AUTO#unittest_rdvarint+184
unittest_rdvarint#__cl5#0 DS 2XL1 ; __cl5
ORG @AUTO#unittest_rdvarint+186
unittest_rdvarint#__cl4#0 DS 1XL1 ; __cl4
ORG @AUTO#unittest_rdvarint+187
unittest_rdvarint#__cl3#0 DS 1XL1 ; __cl3
ORG @AUTO#unittest_rdvarint+188
unittest_rdvarint#__cl2#0 DS 1XL1 ; __cl2
ORG @AUTO#unittest_rdvarint+189
unittest_rdvarint#__cl1#0 DS 1XL1 ; __cl1
ORG @AUTO#unittest_rdvarint+190
unittest_rdvarint#__cl0#0 DS 1XL1 ; __cl0
*
@CODE CSECT
@@STATIC ALIAS X'7C9984A581998995A350'
@@STATIC DXD 64D
*
* Non-Re-Entrant Data Section
*
@DATA CSECT
@DATA RMODE ANY
@DATA AMODE ANY
@@T349 DC X'99846D838193939683' rd.calloc
DC 1X'00'
@@T34D DC X'99846D948193939683' rd.malloc
DC 1X'00'
@@T352 DC X'99846D99858193939683' rd.realloc
DC 2X'00'
@@T358 DC X'99846DA2A39984A497' rd.strdup
DC 1X'00'
@@T35D DC X'99846DA2A3999584A497' rd.strndup
DC 2X'00'
@@T365 DC X'99846D9985868395A36DA2A482F0' rd.refcnt.sub0
DC 2X'00'
@@T3E6 DC X'84966DA385A2A36D99846DA4A5819989' do.test.rd.uvari
DC X'95A36D8595836D89F6F4' nt.enc.i64
DC 1X'00'
@strings@ DS 0H
DC X'1BADF3F194D9C4E4E37A40C6C1C9D37A' ..31mRDUT..FAIL.
DC X'406CA27A6C847A406CA27A400000C37A' ..s..d...s....C.
DC X'E081A2879281869281E0938982998492' .asgkafka.librdk
DC X'81869281E0A29983E09984A581998995' afka.src.rdvarin
DC X'A34B830089F6F4408595839684854096' t.c.i64.encode.o
DC X'86406C9393847A4085A7978583A38584' f..lld..expected
DC X'40A289A985406CA9A4404D8796A3406C' .size..zu..got..
DC X'A9A45D1500001BADF0941500A49589A3' zu......0m..unit
DC X'A385A2A34086818993A4998500005A5C' test.failure....
DC X'7FA49589A3A385A2A34086818993A499' .unittest.failur
DC X'857F00001BADF3F194D9C4E4E37A40C6' e.....31mRDUT..F
DC X'C1C9D37A406CA27A6C847A406CA27A40' AIL...s..d...s..
DC X'81A2A28599A3408681899385847A405A' assert.failed...
DC X'D9C46DE4E5C1D9C9D5E36DC4C5C36DC6' RD.UVARINT.DEC.F
DC X'C1C9D3C5C44D995D7A400000A5819989' AILED.r.....vari
DC X'95A34084858396848540868189938584' nt.decode.failed
DC X'7A406CA9A4005A4D4D99407E7E40F05D' ...zu....r....0.
DC X'404F4F404D99406E40F0A78686868686' .....r...0xfffff
DC X'8686868686868686868686E4D3D35D5D' fffffffffffULL..
DC X'00001BADF3F194D9C4E4E37A40C6C1C9' ....31mRDUT..FAI
DC X'D37A406CA27A6C847A406CA27A4081A2' L...s..d...s..as
DC X'A28599A3408681899385847A409985A3' sert.failed..ret
DC X'6D95A494407E7E4095A4947A4000A581' .num....num...va
DC X'998995A340848583968485409985A3A4' rint.decode.retu
DC X'9995858440A6999695874095A4948285' rned.wrong.numbe
DC X'997A406C939384405A7E406C93938400' r...lld.....lld.
DC X'9985A36D95A494407E7E4095A4940000' ret.num....num..
DC X'1BADF3F194D9C4E4E37A40C6C1C9D37A' ..31mRDUT..FAIL.
DC X'406CA27A6C847A406CA27A4081A2A285' ..s..d...s..asse
DC X'99A3408681899385847A4089997A4000' rt.failed..ir...
DC X'9581999996A66D839697A84086818993' narrow.copy.fail
DC X'85840000899900001BADF3F194D9C4E4' ed..ir....31mRDU
DC X'E37A40C6C1C9D37A406CA27A6C847A40' T..FAIL...s..d..
DC X'6CA27A4081A2A28599A3408681899385' .s..assert.faile
DC X'847A40D9C46DE4E5C1D9C9D5E36DC4C5' d..RD.UVARINT.DE
DC X'C36DC6C1C9D3C5C44D995D7A4000A581' C.FAILED.r....va
DC X'998995A3408485839684854086818993' rint.decode.fail
DC X'858440A28896A49384408881A5854086' ed.should.have.f
DC X'81899385846B409985A3A49995858440' ailed..returned.
DC X'6CA9A4004D4D99407E7E40F05D404F4F' .zu...r....0....
DC X'404D99406E40F0A78686868686868686' ..r...0xffffffff
DC X'8686868686868686E4D3D35D5D001BAD' ffffffffULL.....
DC X'F3F194D9C4E4E37A40C6C1C9D37A406C' 31mRDUT..FAIL...
DC X'A27A6C847A406CA27A4081A2A28599A3' s..d...s..assert
DC X'408681899385847A4099407E7E40F07A' .failed..r....0.
DC X'400085A7978583A3858440A293898385' ..expected.slice
DC X'409796A289A389969540A396409596A3' .position.to.not
DC X'408388819587856B4082A4A3408796A3' .change..but.got
DC X'406CA9A4000099407E7E40F000001BAD' ..zu..r....0....
DC X'F3F194D9C4E4E37A40C6C1C9D37A406C' 31mRDUT..FAIL...
DC X'A27A6C847A406CA27A4081A2A28599A3' s..d...s..assert
DC X'408681899385847A4099407E7E40A2A9' .failed..r....sz
DC X'7A40000085A7978583A3858440A58199' ....expected.var
DC X'8995A3408485839684859940A3964099' int.decoder.to.r
DC X'858184406CA9A44082A8A385A26B4095' ead..zu.bytes..n
DC X'96A3406CA9A4000099407E7E40A2A900' ot..zu..r....sz.
DC X'85A7978583A3858440A2938983854097' expected.slice.p
DC X'96A289A389969540A396408388819587' osition.to.chang
DC X'8540A396406CA9A46B4082A4A3408796' e.to..zu..but.go
DC X'A3406CA9A4001BADF3F294D9C4E4E37A' t..zu...32mRDUT.
DC X'40D7C1E2E27A406CA27A6C847A406CA2' .PASS...s..d...s
DC X'1BADF0941500' ..0m..
@E__stderrp ALIAS C'@@STDERP'
EXTRN @E__stderrp
@Erd_unittest_assert_on_failure ALIAS X'99846DA49589A3A385A2A36D81A2A28*
599A36D96956D86818993A49985'
EXTRN @Erd_unittest_assert_on_failure
*
*
* Re-entrant Data Initialization Section
*
@@INIT@ ALIAS C'rdvarint:'
@@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(0)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000001E0'
DC X'00000000'
DC X'00000001'
DC X'8B40404040404040' ........
*
END
|
; A122690: a(n) = 5*a(n-1) + 4*a(n-2) with a(0)=1, a(1)=4.
; Submitted by Jamie Morken(s2)
; 1,4,24,136,776,4424,25224,143816,819976,4675144,26655624,151978696,866515976,4940494664,28168537224,160604664776,915697472776,5220906022984,29767320006024,169720224122056,967670400634376,5517232899660104,31456846100838024,179353162102830536,1022593194917504776,5830378622998846024,33242265894664249224,189532843965316630216,1080633283405240147976,6161297792887467260744,35129022098058296895624,200290301661841353521096,1141967596701439955187976,6510999190154565190024264,37122866337578585770873224
mov $1,1
lpb $0
sub $0,1
mov $2,$1
add $1,$3
add $2,$1
mul $1,4
mov $3,$2
lpe
mov $0,$1
|
; Assembly code emitted by HLA compiler
; Version 2.16 build 4413 (prototype)
; HLA compiler written by Randall Hyde
; NASM compatible output
bits 32
%define ExceptionPtr__hla_ [dword fs:0]
global QuitMain__hla_
global DfltExHndlr__hla_
global _HLAMain
global HWexcept__hla_
global start
section .text code align=16
extern STDIN_FLUSHINPUT
extern STDOUT_PUTI16
extern STDIN_GETI8
extern STDOUT_NEWLN
extern DefaultExceptionHandler__hla_
extern abstract__hla_
extern STDOUT_PUTI8
extern HardwareException__hla_
extern BuildExcepts__hla_
extern STDOUT_PUTS
extern STDIN_GETI16
extern Raise__hla_
extern shortDfltExcept__hla_
section .text
;/* HWexcept__hla_ gets called when Windows raises the exception. */
; procedure HWexcept__hla_
HWexcept__hla_:
jmp HardwareException__hla_
;HWexcept__hla_ endp
; procedure DfltExHndlr__hla_
DfltExHndlr__hla_:
jmp DefaultExceptionHandler__hla_
;DfltExHndlr__hla_ endp
; procedure _HLAMain
_HLAMain:
nop
; procedure start
start:
;start endp
call BuildExcepts__hla_
; push dword 0
db 06ah ;
db 00h ;
; push ebp
db 055h ;
; push ebp
db 055h ;
; lea ebp, [esp+4]
db 08dh ;
db 06ch ;
db 024h ;
db 04h ;
; push strict dword str__hla_1890
db 068h ;
dd str__hla_1890
call STDOUT_PUTS
call STDIN_GETI8
; mov [a__hla_1885], al
db 0a2h ;
dd (a__hla_1885+0)
call STDOUT_NEWLN
; push strict dword str__hla_1891
db 068h ;
dd str__hla_1891
call STDOUT_PUTS
; push dword 0
db 06ah ;
db 00h ;
; push eax
db 050h ;
; mov al, [a__hla_1885]
db 0a0h ;
dd (a__hla_1885+0)
; mov [esp+4], al
db 088h ;
db 044h ;
db 024h ;
db 04h ;
; pop eax
db 058h ;
call STDOUT_PUTI8
call STDIN_FLUSHINPUT
call STDOUT_NEWLN
; push strict dword str__hla_1892
db 068h ;
dd str__hla_1892
call STDOUT_PUTS
call STDIN_GETI16
; mov [b__hla_1886], ax
dw 0a366h
dd (b__hla_1886+0)
call STDOUT_NEWLN
; push strict dword str__hla_1891
db 068h ;
dd str__hla_1891
call STDOUT_PUTS
; push word 0
dw 06a66h
db 00h ;
; push word [b__hla_1886]
db 066h ; size prefix
db 0ffh ;
db 035h ;
dd b__hla_1886
call STDOUT_PUTI16
QuitMain__hla_:
; push dword 0
db 06ah ;
db 00h ;
; call [__imp__ExitProcess@4]
db 0ffh ;
db 015h ;
dd __imp__ExitProcess@4
;_HLAMain endp
section .text
align (4)
len__hla_1890 dd 017h
dd 017h
str__hla_1890:
db "int 8 bit (-128..127): "
db 0
align (4)
len__hla_1891 dd 08h
dd 08h
str__hla_1891:
db "result: "
db 0
db 0
db 0
db 0
align (4)
len__hla_1892 dd 01eh
dd 01eh
str__hla_1892:
db "int 16 bit (-32 768..32 767): "
db 0
db 0
section .data data align=16
extern MainPgmCoroutine__hla_
extern __imp__MessageBoxA@16
extern __imp__ExitProcess@4
align (4)
a__hla_1885 times 1 db 0
b__hla_1886 times 2 db 0
|
#include <nlohmann/json.hpp>
int main() {
return 0;
} |
db 0 ; species ID placeholder
db 95, 95, 85, 55, 125, 65
; hp atk def spd sat sdf
db GRASS, PSYCHIC ; type
db 45 ; catch rate
db 212 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F0 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/exeggutor/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_SLOW ; growth rate
dn EGG_PLANT, EGG_PLANT ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, ROLLOUT, TOXIC, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, GIGA_DRAIN, ENDURE, FRUSTRATION, SOLARBEAM, RETURN, PSYCHIC_M, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, DREAM_EATER, REST, ATTRACT, THIEF, NIGHTMARE, STRENGTH, FLASH
; end
|
; Q40/Q60 Caches management v. 1.00 copyright (c) Mark Swift
; 2003-10-17 1.01 adapted for SMSQ/E (FD)
; 2005-01-21 1.02 rationalised, reset sr as was on entry (wl)
section exten
xdef copyback
xdef serialized
xdef writethrough
include 'dev8_sbsext_ext_keys'
include 'dev8_keys_sys'
;
rprt_ni
moveq #err.ni,d0
rts
copyback
lea hw_copyback,a2
bra.s common
writethrough
lea hw_writethrough,a2
bra.s common
serialized
lea hw_serialized,a2
common
cmp.l a3,a5 ; are htere parameters?
bne.s rprt_bp ; yes : error
moveq #0,d0 ; mt.inf
trap #1
move.b sys_ptyp(a0),d0 ; what type of processor is this?
cmp.b #$40,d0
bcs.s rprt_ni ; not at least a '40
move.w sr,d0
trap #0 ; supervisor mode
ori.w #$700,sr ; don't interrupt
move.w d0,-(sp) ; keep old status
jsr (a2) ; do routine
b_ttracux
move.w (a7)+,sr ; get old mode back
moveq #0,d0
rts
rprt_bp
moveq #err.bp,d0
rts
; routine to disable the instruction & data caches
; exit: d0 = previous cacr value
cachoff
moveq #0,d0
; routine to set the cacr
; entry: d0 = value to write to cacr
; exit: d0 = previous cacr value
setcach
move.l d1,-(a7)
moveq #-1,d1
bsr.s docach
move.l (a7)+,d1
rts
; routine to alter the state of the cacr
; callable from user or supervisor modes
; entry: d0 = bits to set
; d1 = bits to clear/alter
; exit: d0 = previous cacr value
docach
movem.l d2/a0/a6,-(a7)
movea.l a7,a0
trap #0
move.w sr,-(a7)
ori.w #$0700,sr ; interrupts off
subq.l #2,a0
cmpa.l a0,a7
beq.s docachsv ; entered routine as supervisor
bclr #5,0(a7) ; otherwise sr on exit = user mode
docachsv
move.l a7,d2 ; calculate start of
andi.w #-$8000,d2 ; system variables
move.l d2,a6
and.l d1,d0
not.l d1
cmpi.b #$10,sys_ptyp(a6)
bls.s docachx ; exit if 010 or less
dc.w $4e7a,$2002 ; movec cacr,d2
and.l d2,d1 ; mask off changed bits
or.l d0,d1 ; or in set bits
move.l d2,d0 ; store old cacr value
ori.w #$0808,d1 ; always clear caches on 020/030
cmpi.b #$30,sys_ptyp(a6)
bls.s docachset
tst.w d0 ; check 040 bits
bpl.s docachdchk ; branch if instruction cache off
dc.w $f4b8 ; cpusha ic
; otherwise update memory from cache
docachdchk
tst.l d0 ; check 040 bits
bpl.s docachdinv ; branch if data cache off
dc.w $f478 ; cpusha dc
; otherwise update memory from cache
tst.l d1 ; check 040 bits
bmi.s docachiinv ; branch if leaving data cache on
docachdinv
dc.w $f458 ; cinva dc
; invalidate cache
docachiinv
dc.w $f498 ; cinva ic
; invalidate cache
docachset
dc.w $4e7b,$1002 ; movec d1,cacr
; set the cache
docachx
move.w (a7)+,sr
movem.l (a7)+,d2/a0/a6
rts
; ttr/acu options : set cache options for memory map
hw_copyback
movem.l d0-d2/d7,-(a7)
move.l #$007fc020,d1 ; 0-32mb 0 = cachable, copyback (q40)
bra.s ttracu
hw_writethrough
movem.l d0-d2/d7,-(a7)
move.l #$007fc000,d1 ; 0-32mb = cachable, writethrough (*q40)
bra.s ttracu
hw_serialized
movem.l d0-d2/d7,-(a7)
move.l #$007fc040,d1 ; 0-32mb = non-cachable, serialized (q40)
ttracu
bsr cachoff ; disable caches
move.l d0,d7 ; save cacr value
dc.w $4e7b,$1006 ; movec d1,dtt0
dc.w $4e7b,$1004 ; movec d1,itt0
move.l #$fe01c040,d1 ; base fe000000 = non-cachable, serialized (*q40)
dc.w $4e7b,$1007 ; movec d1,dtt1
dc.w $4e7b,$1005 ; movec d1,itt1
move.l d7,d0
bsr setcach
movem.l (a7)+,d0-d2/d7
rts
end
|
#include <vector>
#include <fstream>
#include <iostream>
using namespace std;
class Point
{
public:
void fromfile(ifstream& file)
{
file >> x;
file >> y;
}
int x;
int y;
};
class Line
{
public:
Line(ifstream& file)
{
a.fromfile(file);
b.fromfile(file);
}
Line()
{
}
Point a;
Point b;
};
class Character
{
public:
Character()
{
heading=0.0f;
speed=0.0f;
ang_vel=0.0f;
}
Point location;
float heading;
float speed;
float ang_vel;
};
class Environment
{
public:
Environment(const char* filename)
{
ifstream inpfile(filename);
hero.location.fromfile(inpfile);
end.fromfile(inpfile);
while(!inpfile.eof())
{
Line* x=new Line(inpfile);
lines.push_back(x);
}
}
~Environment()
{
//clean up lines!
}
vector<Line*> lines;
Character hero;
Point end;
};
|
/*
* Test for custom 'not_empty' notificator for mchain.
*/
#include <so_5/all.hpp>
#include <various_helpers_1/time_limited_execution.hpp>
#include <utest_helper_1/h/helper.hpp>
#include "../mchain_params.hpp"
using namespace std;
class event
{
std::mutex m;
std::condition_variable cv;
bool signaled = { false };
public :
void notify_one()
{
std::lock_guard< std::mutex > l{ m };
signaled = true;
cv.notify_one();
}
void wait()
{
std::unique_lock< std::mutex > l{ m };
if( !signaled )
cv.wait( l, [this]{ return signaled; } );
signaled = false;
}
};
void
do_check(
so_5::environment_t & env,
so_5::mchain_params_t params )
{
event child_started;
event chain_not_empty;
params.not_empty_notificator(
[&chain_not_empty] { chain_not_empty.notify_one(); } );
auto ch = env.create_mchain( params );
std::thread child{ [&] {
child_started.notify_one();
chain_not_empty.wait();
receive( ch, so_5::infinite_wait,
[]( int i ) {
UT_CHECK_CONDITION( i != 0 );
} );
} };
std::cout << "child starting." << std::flush;
child_started.wait();
std::cout << "sending." << std::flush;
so_5::send< int >( ch, 1 );
std::cout << "joining." << std::flush;
child.join();
std::cout << "OK" << std::endl;
}
int
main()
{
try
{
auto params = build_mchain_params();
for( const auto & p : params )
{
cout << "=== " << p.first << " ===" << endl;
run_with_time_limit(
[&p]()
{
so_5::wrapped_env_t env;
do_check( env.environment(), p.second );
},
20,
p.first );
}
}
catch( const exception & ex )
{
cerr << "Error: " << ex.what() << endl;
return 1;
}
return 0;
}
|
;
; Copyright (c) 2016, Alliance for Open Media. All rights reserved
;
; This source code is subject to the terms of the BSD 2 Clause License and
; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
; was not distributed with this source code in the LICENSE file, you can
; obtain it at www.aomedia.org/license/software. If the Alliance for Open
; Media Patent License 1.0 was not distributed with this source code in the
; PATENTS file, you can obtain it at www.aomedia.org/license/patent.
;
%include "aom_ports/x86_abi_support.asm"
section .text
%if LIBAOM_YASM_WIN64
globalsym(aom_winx64_fldcw)
sym(aom_winx64_fldcw):
sub rsp, 8
mov [rsp], rcx ; win x64 specific
fldcw [rsp]
add rsp, 8
ret
globalsym(aom_winx64_fstcw)
sym(aom_winx64_fstcw):
sub rsp, 8
fstcw [rsp]
mov rax, [rsp]
add rsp, 8
ret
%endif
|
.thumb
.syntax unified
.org 0x00
.equ CopyDataWithPossibleUncomp, 0x8012F50+1
.macro blh to, reg=r3
ldr \reg, =\to
mov lr, \reg
.short 0xf800
.endm
Load6CFACEGraphics: @ 0x08005594
push {lr}
ldr r1, [r0, #0x2c]
ldr r2, [r1]
ldr r1, =0x0202A68C
adds r0, #0x40
ldrb r0, [r0]
cmp r0, #1
bne Continue
adds r0, #1
Continue:
lsls r0, r0, #3
adds r0, r0, r1
ldr r1, [r0]
ldr r0, =0x06010000
adds r1, r1, r0
adds r0, r2, #0
blh CopyDataWithPossibleUncomp
pop {r0}
bx r0
.align 2, 0
.pool
|
; A030192: Scaled Chebyshev U-polynomial evaluated at sqrt(6)/2.
; 1,6,30,144,684,3240,15336,72576,343440,1625184,7690464,36391680,172207296,814893696,3856118400,18247348224,86347378944,408600184320,1933516832256,9149499887616,43295898332160,204878390667264,969494954010624,4587699380060160,21709226556297216,102729163057422336,486119619006750720,2300342735695970304,10885338700135317504,51509975786636083200,243747822519004594176,1153427080394211065856,5458075547251238830080,25827890801142166585344,122218891523345566531584,578346004333220399677440,2736762676859248998875136,12950500035156171595186176,61282424149781535577866240,289991544687752183896080384,1372254723227823889909284864,6493579071240430236079226880,30727946088075638077019652096,145406202101011247045642551296,688069536077613653811737395200,3255980003859614440596569063424,15407462806692004720708990009344,72908896816994341680674525675520,345008604061814021759793213997056,1632598243468918080474712129929216,7725537836442624352289513495592960,36557637557842237630888808193982464,172992598328397679671595768190337024,818609764623332652244241759978127360
mul $0,2
mov $1,1
lpb $0
sub $0,2
sub $1,$2
add $2,$1
mul $1,6
lpe
mov $0,$1
|
; A242082: Nim sequence of game on n counters whose legal moves are removing some number of counters in A027941.
; 0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,2,0,1,0,1,2,0,1,0,1,2,0
lpb $0
mov $2,$0
seq $2,114986 ; Characteristic function of (A000201 prefixed with 0).
sub $0,$2
add $1,$2
lpe
mov $0,$1
|
/// \file
/// Test for using third-party verilog-parse
#include <ilang/verilog-in/verilog_parse.h>
extern "C" {
#include <verilogparser/verilog_parser.h>
}
namespace ilang {
// we need to use this, so vlg parser will record memory usage and free later
static void* VlgParserAllocCstr(const std::string& str) {
char* ret = (char*)ast_calloc(str.size() + 1, sizeof(char));
strcpy(ret, str.c_str());
return (void*)ret;
}
// void TestParseVerilog() { verilog_parser_init(); }
int TestParseVerilogFrom(const std::string& fn) {
std::FILE* fp = std::fopen(fn.c_str(), "r");
if (fp == NULL)
return 1;
verilog_parser_init();
verilog_preprocessor_set_file(yy_preproc, (char*)VlgParserAllocCstr(fn));
auto ret = verilog_parse_file(fp);
std::fclose(fp);
ast_free_all();
yy_preproc = NULL;
yy_verilog_source_tree = NULL;
return ret;
}
}; // namespace ilang
|
/*=========================================================================
*
* Copyright David Doria 2011 daviddoria@gmail.com
*
* 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.txt
*
* 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 "Derivatives.h"
#include "Mask.h"
#include "Testing/Testing.h"
// static void CreateMask(Mask* const mask);
// static void CreateImage(UnsignedCharScalarImageType* const image);
static void TestComputeColorIsophotesInRegion();
static void TestComputeMaskedIsophotesInRegion();
int main(int argc, char*argv[])
{
TestComputeColorIsophotesInRegion();
TestComputeMaskedIsophotesInRegion();
return EXIT_SUCCESS;
}
void TestComputeColorIsophotesInRegion()
{
//void ComputeColorIsophotesInRegion(const FloatVectorImageType* image, const Mask* mask,
// const itk::ImageRegion<2>& region , FloatVector2ImageType* isophotes);
throw std::runtime_error("TestComputeColorIsophotesInRegion not yet written!");
}
void TestComputeMaskedIsophotesInRegion()
{
//void ComputeMaskedIsophotesInRegion(const FloatScalarImageType* const image, const Mask* const mask, const itk::ImageRegion<2>& region,
// FloatVector2ImageType* const outputIsophotes);
throw std::runtime_error("TestComputeMaskedIsophotesInRegion not yet written!");
}
/*
void CreateMask(Mask* const mask)
{
itk::Index<2> maskCorner;
maskCorner.Fill(0);
itk::Size<2> maskSize;
maskSize.Fill(100);
itk::ImageRegion<2> maskRegion(maskCorner, maskSize);
mask->SetRegions(maskRegion);
mask->Allocate();
unsigned int indeterminateValue = (static_cast<unsigned int>(mask->GetHoleValue()) + static_cast<unsigned int>(mask->GetValidValue()))/2;
// Make the left half of the mask the hole, the center indeterminate, and the right half valid.
for(unsigned int column = 0; column < maskSize[0]; ++column)
{
for(unsigned int row = 0; row < maskSize[1]; ++row)
{
itk::Index<2> currentIndex;
currentIndex[0] = column;
currentIndex[1] = row;
if(column < maskSize[0] / 3)
{
mask->SetPixel(currentIndex, mask->GetHoleValue());
}
else if(column < 2*maskSize[0]/3)
{
mask->SetPixel(currentIndex, indeterminateValue);
}
else
{
mask->SetPixel(currentIndex, mask->GetValidValue());
}
}
}
}
void CreateImage(UnsignedCharScalarImageType* const image)
{
itk::Index<2> corner;
corner.Fill(0);
itk::Size<2> size;
size.Fill(100);
itk::ImageRegion<2> region(corner, size);
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
// Make a white square on a black background
for(unsigned int column = 25; column < 75; ++column)
{
for(unsigned int row = 25; row < 75; ++row)
{
itk::Index<2> currentIndex;
currentIndex[0] = column;
currentIndex[1] = row;
image->SetPixel(currentIndex, 255);
}
}
}*/
|
;
; Sequencer Pattern Compress/Decompress (RLE)
;
compress:
lda #WRAM_PATTERNS
jsr setMMC1r1
lda #<patterns
sta tmp0
lda #>patterns
sta tmp1
lda #<$7000
sta tmp2
lda #>$7000
sta tmp3
ldy #$00
lda #$FF
: sta (tmp2),y
iny
bne :-
ldx #$60 ;96 blocks
lda #$00
sta tmp4
: ldy #$00
lda (tmp0),y ;0?
bne :++
lda tmp4 ;yes, doing RLE?
bne :+ ;yes
sta (tmp2),y ;no, store 0 token
inc tmp2 ;update dest address
bne :+
inc tmp3
: inc tmp4 ;update RLE count
bne :+++ ;should never go over 255 (pattern would be 255 * 5)
: pha ;save byte
lda tmp4 ;any RLE?
beq :+ ;no
sta (tmp2),y ;yes, write count
lda #$00 ;clear count
sta tmp4
inc tmp2 ;update dest address
bne :+
inc tmp3
: pla ;retrieve byte
sta (tmp2),y
iny
lda (tmp0),y
sta (tmp2),y
iny
lda (tmp0),y
sta (tmp2),y
iny
lda (tmp0),y
sta (tmp2),y
iny
lda (tmp0),y
sta (tmp2),y
lda tmp2
clc
adc #$05
sta tmp2
bcc :+
inc tmp3
: lda tmp0
clc
adc #$05
sta tmp0
bcc :+
inc tmp1
: dex
bne :------
ldy #$00
lda tmp4
beq :+
sta (tmp2),y
iny
: lda #$00
sta (tmp2),y
iny
sta (tmp2),y
rts
decompress: lda #<$7000
sta tmp0
lda #>$7000
sta tmp1
lda #<$7200
sta tmp2
lda #>$7200
sta tmp3
: ldy #$00
lda (tmp0),y ;token?
bne :++ ;no
iny ;yes, get count
lda (tmp0),y
beq :+++++ ;00 00 so done
tax ;otherwise load count in X
: ldy #$00 ;clear 5 bytes
tya
sta (tmp2),y
iny
sta (tmp2),y
iny
sta (tmp2),y
iny
sta (tmp2),y
iny
sta (tmp2),y
lda tmp2 ;update dest pointer
clc
adc #$05
sta tmp2
lda tmp3
adc #$00
sta tmp3
dex ;dec count
bne :- ;done?
lda tmp0 ;yes update source pointer
clc
adc #$02
sta tmp0
lda tmp2
clc
adc #$00
sta tmp2
jmp :-- ;get more
: sta (tmp2),y ;copy 5 bytes
iny
lda (tmp0),y
sta (tmp2),y
iny
lda (tmp0),y
sta (tmp2),y
iny
lda (tmp0),y
sta (tmp2),y
iny
lda (tmp0),y
sta (tmp2),y
lda tmp0 ;update source
clc
adc #$05
sta tmp0
bne :+
inc tmp1
: lda tmp2 ;update dest
clc
adc #$05
sta tmp2
bne :+
inc tmp3
:
jmp :----- ;get more
: rts
|
; Copyright Oliver Kowalke 2009.
; Distributed under the Boost Software License, Version 1.0.
; (See accompanying file LICENSE_1_0.txt or copy at
; http://www.boost.org/LICENSE_1_0.txt)
; ----------------------------------------------------------------------------------
; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
; ----------------------------------------------------------------------------------
; | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c |
; ----------------------------------------------------------------------------------
; | fbr_strg | fc_dealloc | limit | base |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
; ----------------------------------------------------------------------------------
; | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c |
; ----------------------------------------------------------------------------------
; | R12 | R13 | R14 | R15 |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
; ----------------------------------------------------------------------------------
; | 0xe40 | 0x44 | 0x48 | 0x4c | 0x50 | 0x54 | 0x58 | 0x5c |
; ----------------------------------------------------------------------------------
; | RDI | RSI | RBX | RBP |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
; ----------------------------------------------------------------------------------
; | 0x60 | 0x64 | 0x68 | 0x6c | 0x70 | 0x74 | 0x78 | 0x7c |
; ----------------------------------------------------------------------------------
; | hidden | RIP | EXIT | parameter area |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 32 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
; ----------------------------------------------------------------------------------
; | 0x80 | 0x84 | 0x88 | 0x8c | 0x90 | 0x94 | 0x98 | 0x9c |
; ----------------------------------------------------------------------------------
; | parameter area | FCTX |
; ----------------------------------------------------------------------------------
; ----------------------------------------------------------------------------------
; | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
; ----------------------------------------------------------------------------------
; | 0xa0 | 0xa4 | 0xa8 | 0xac | 0xb0 | 0xb4 | 0xb8 | 0xbc |
; ----------------------------------------------------------------------------------
; | DATA | | | |
; ----------------------------------------------------------------------------------
.code
jump_fcontext PROC BOOST_CONTEXT_EXPORT FRAME
.endprolog
push rcx ; save hidden address of transport_t
push rbp ; save RBP
push rbx ; save RBX
push rsi ; save RSI
push rdi ; save RDI
push r15 ; save R15
push r14 ; save R14
push r13 ; save R13
push r12 ; save R12
; load NT_TIB
mov r10, gs:[030h]
; save current stack base
mov rax, [r10+08h]
push rax
; save current stack limit
mov rax, [r10+010h]
push rax
; save current deallocation stack
mov rax, [r10+01478h]
push rax
; save fiber local storage
mov rax, [r10+018h]
push rax
; preserve RSP (pointing to context-data) in R9
mov r9, rsp
; restore RSP (pointing to context-data) from RDX
mov rsp, rdx
; load NT_TIB
mov r10, gs:[030h]
; restore fiber local storage
pop rax
mov [r10+018h], rax
; restore deallocation stack
pop rax
mov [r10+01478h], rax
; restore stack limit
pop rax
mov [r10+010h], rax
; restore stack base
pop rax
mov [r10+08h], rax
pop r12 ; restore R12
pop r13 ; restore R13
pop r14 ; restore R14
pop r15 ; restore R15
pop rdi ; restore RDI
pop rsi ; restore RSI
pop rbx ; restore RBX
pop rbp ; restore RBP
pop rax ; restore hidden address of transport_t
; restore return-address
pop r10
; transport_t returned in RAX
; return parent fcontext_t
mov [rax], r9
; return data
mov [rax+08h], r8
; transport_t as 1.arg of context-function
mov rcx, rax
; indirect jump to context
jmp r10
jump_fcontext ENDP
END
|
; A002549: Numerators of coefficients of log(1+x)/sqrt(1+x).
; Submitted by Jon Maiga
; 1,1,23,11,563,1627,88069,1423,1593269,7759469,31730711,46522243,3788707301,2888008157,340028535787,41743955887,10823198495797,2738032559863,409741429887649,25876414060339,17141894231615609
seq $0,74599 ; Numerator of 2 * H(n,2,1), a generalized harmonic number. See A075135. Also 2 * A025550.
lpb $0
dif $0,4
lpe
div $0,2
|
/*
Copyright (c) 2005-2019, University of Oxford.
All rights reserved.
University of Oxford means the Chancellor, Masters and Scholars of the
University of Oxford, having an administrative office at Wellington
Square, Oxford OX1 2JD, UK.
This file is part of Chaste.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the University of Oxford nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ODEPDECONVERGENCETESTER_HPP_
#define ODEPDECONVERGENCETESTER_HPP_
#include "AbstractConvergenceTester.hpp"
/**
* Drop the PDE and ODE time-steps (in synch) until a convergence criterion is met
*/
template<class CELL, class CARDIAC_PROBLEM, unsigned DIM, unsigned PROBLEM_DIM>
class OdePdeConvergenceTester : public AbstractConvergenceTester<CELL, CARDIAC_PROBLEM, DIM, PROBLEM_DIM>
{
public:
/**
* Set the ODE and PDE time-steps to be the same (coarse).
*/
void SetInitialConvergenceParameters()
{
this->OdeTimeStep = 1e-2;
this->PdeTimeStep = this->OdeTimeStep;
}
/*
* Each new run has the #PdeTimeStep and #OdeTimeStep halved.
* (There is always one ODE step per PDE step.)
*/
void UpdateConvergenceParameters()
{
this->OdeTimeStep *= 0.5;
this->PdeTimeStep = this->OdeTimeStep;
}
/**
* @return true to give up when the time-steps become unreasonably small
*/
bool GiveUpConvergence()
{
assert( this->PdeTimeStep == this->OdeTimeStep);
return this->OdeTimeStep<=1e-5;
}
/**
* @return the ODE/PDE time-step as abcissa
*/
double Abscissa()
{
return this->OdeTimeStep;
}
};
#endif /*ODECONVERGENCETESTER_HPP_*/
|
#include "option.h"
|
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2017, Alliance for Sustainable Energy, 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.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote
* products derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative
* works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without
* specific prior written permission from Alliance for Sustainable Energy, LLC.
*
* 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, THE UNITED STATES GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
#ifndef UTILITIES_IDF_URLSEARCHPATH_HPP
#define UTILITIES_IDF_URLSEARCHPATH_HPP
#include "../core/Path.hpp"
#include "../idd/IddEnums.hpp"
#include <boost/optional.hpp>
#include <QUrl>
namespace openstudio
{
class URLSearchPath
{
public:
enum Relative
{
ToInputFile,
ToCurrentWorkingDir
};
/// Create a new URLSearchPath.
/// \param[in] t_url Url to search (local or remote, remote not yet implemented)
/// \param[in] t_relativity If t_url is a relative path, it is evaluated relative to t_relativity.
URLSearchPath(const QUrl &t_url, Relative t_relativity = ToInputFile)
: m_url(t_url), m_relativity(t_relativity)
{
}
/// Create a new URLSearchPath.
/// \param[in] t_url Url to search (local or remote, remote not yet implemented)
/// \param[in] t_relativity If t_url is a relative path, it is evaluated relative to t_relativity.
/// \param[in] t_object_type Object type to apply this search to
URLSearchPath(const QUrl &t_url, Relative t_relativity, IddObjectType t_object_type)
: m_url(t_url), m_relativity(t_relativity), m_object_type(t_object_type)
{
}
/// Create a new URLSearchPath.
/// \param[in] t_path local path to search
/// \param[in] t_relativity If t_url is a relative path, it is evaluated relative to t_relativity.
URLSearchPath(const openstudio::path &t_path, Relative t_relativity = ToInputFile)
: m_url(QUrl::fromLocalFile(toQString(t_path))), m_relativity(t_relativity)
{
}
/// Create a new URLSearchPath.
/// \param[in] t_path local path to search
/// \param[in] t_relativity If t_url is a relative path, it is evaluated relative to t_relativity.
/// \param[in] t_object_type Object type to apply this search to
URLSearchPath(const openstudio::path &t_path, Relative t_relativity, IddObjectType t_object_type)
: m_url(QUrl::fromLocalFile(toQString(t_path))), m_relativity(t_relativity), m_object_type(t_object_type)
{
}
QUrl getUrl() const
{
return m_url;
}
Relative getRelativity() const
{
return m_relativity;
}
boost::optional<IddObjectType> getIddObjectType() const
{
return m_object_type;
}
private:
QUrl m_url;
Relative m_relativity;
boost::optional<IddObjectType> m_object_type;
};
}
#endif // UTILITIES_IDF_URLSEARCHPATH_HPP
|
;
; Amstrad CPC library
; (CALLER linkage for function pointers)
;
; set color palette, flashing is useless so we forget the second color
;
; void __LIB__ __CALLEE__ cpc_Uncrunch(int src, int dst);
;
; $Id: cpc_Uncrunch.asm $
;
SECTION code_clib
PUBLIC cpc_Uncrunch
PUBLIC _cpc_Uncrunch
EXTERN asm_cpc_Uncrunch
.cpc_Uncrunch
._cpc_Uncrunch
pop bc
pop hl
pop de
push de
push hl
push bc
jp asm_cpc_Uncrunch
|
//Test that constant pointers are detected correctly
// Commodore 64 PRG executable file
.file [name="const-pointer.prg", type="prg", segments="Program"]
.segmentdef Program [segments="Basic, Code, Data"]
.segmentdef Basic [start=$0801]
.segmentdef Code [start=$80d]
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
.segment Code
main: {
.label screen = $400
// screen[0] = '*'
lda #'*'
sta screen
// }
rts
}
|
SECTION code_fp_am9511
PUBLIC cam32_sdcc___fseq
EXTERN cam32_sdcc_readr
EXTERN asm_am9511_compare
; Entry: stack: float right, float left, ret
.cam32_sdcc___fseq
call asm_am9511_compare
scf
ret Z
ccf
dec hl
ret
|
; A046030: Digits are squares.
; Submitted by Simon Strandgaard
; 0,1,4,9,10,11,14,19,40,41,44,49,90,91,94,99,100,101,104,109,110,111,114,119,140,141,144,149,190,191,194,199,400,401,404,409,410,411,414,419,440,441,444,449,490,491,494,499,900,901,904,909,910,911,914,919,940,941,944,949,990,991,994,999,1000,1001,1004,1009,1010,1011,1014,1019,1040,1041,1044,1049,1090,1091,1094,1099,1100,1101,1104,1109,1110,1111,1114,1119,1140,1141,1144,1149,1190,1191,1194,1199,1400,1401,1404,1409
mov $3,1
lpb $0
mov $2,$0
div $0,4
mod $2,4
pow $2,2
mul $2,$3
add $1,$2
mul $3,10
lpe
mov $0,$1
|
; A141054: Binomial(n+8,8)*8^n and 8-idempotent numbers. example: A059300 Triangle of idempotent numbers binomial(n,k)*k^(n-k), version 4. A059300 formatted as a triangular array: 1 72 ...........
; 1,72,2880,84480,2027520,42172416,787218432,13495173120,215922769920,3262832967680,46984794734592,649244436332544,8656592484433920,111869810568069120,1406363332855726080,17251390216363573248,207016682596362878976,2435490383486622105600,28143444431400966553600,319946526167505725030400,3583401093076064120340480,39588050171126041710428160,431869638230465909568307200,4656681316571980242301747200,49671267376767789251218636800,524528583498667854492868804608,5487375950447602170079242878976,56906120967604763245266222448640,585320101381077564808452573757440,5974301724441343420113860752834560,60539590807672279990487122295390208,609301688128830688936515553424572416
mov $1,8
pow $1,$0
mov $2,8
add $2,$0
bin $2,$0
mul $1,$2
mov $0,$1
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 (c) 2017, Open AI Lab
* Author: haitao@openailab.com
*/
#include <iostream>
#include <functional>
#include <cmath>
#include <unistd.h>
#include<omp.h>
#include "share_lib_parser.hpp"
#include "executor.hpp"
#include "tensor_mem.hpp"
#include "graph_executor.hpp"
#include "graph.hpp"
#include "operator/convolution.hpp"
#include "operator/pooling.hpp"
#include "prof_utils.hpp"
#include "debug_utils.hpp"
#include<sys/time.h>
using namespace TEngine;
float op_fops;
void init_tensor_data(float * addr, int number, int fixed_val)
{
for(int i=0;i<number;i++)
{
if(fixed_val>=0)
addr[i]=fixed_val;
else
addr[i]=i%64;
}
}
Node * create_pooling_node(
int input_n,int input_c,int input_h,int input_w,
int ksize,int stride,PoolArg type=kPoolMax,
int pad=0,
int global=0)
{
Operator * op=OpManager::CreateOp("Pooling");
Pooling * pool_op=dynamic_cast<Pooling *>(op);
// param, padding use default value 0
PoolParam* param=pool_op->GetParam();
param->pads.resize(4);
param->pads[0]=pad;
param->pads[1]=pad;
param->pads[2]=pad;
param->pads[3]=pad;
param->kernel_shape.resize(2);
param->kernel_shape[0]=ksize;
param->kernel_shape[1]=ksize;
//param->kernel_shape[1]=3;
param->strides.resize(2);
param->strides[0]=stride;
param->strides[1]=stride;
param->caffe_flavor=1;
param->global=global;
param->alg=type;
//param->alg=kPoolAvg;
/* calculate shapes */
std::vector<int> input_dims={input_n,input_c,input_h,input_w};
Node * node=new Node("test_pool");
node->SetOp(pool_op);
//prepare tensor: input/output
Tensor * tensor;
int mem_size;
void * addr;
tensor=new Tensor("input");
tensor->SetDataType("float32");
tensor->SetType(kVarTensor);
TShape& shape=tensor->GetShape();
shape.SetDataLayout("NCHW");
shape.SetDim(input_dims);
node->SetInputPort(0,tensor);
mem_size=tensor->GetTotalSize();
addr=std::malloc(mem_size);
init_tensor_data((float *)addr,mem_size/sizeof(float),-1);
set_tensor_mem(tensor,addr,mem_size,std::free);
tensor=new Tensor("output");
tensor->SetDataType("float32");
tensor->SetType(kVarTensor);
TShape& oshape=tensor->GetShape();
oshape.SetDataLayout("NCHW");
std::vector<TShape> input_shape;
input_shape.push_back(shape);
std::vector<TShape> output_shape;
output_shape.resize(1);
pool_op->InferShape(input_shape,output_shape);
oshape=output_shape[0];
node->SetOutputPort(0,tensor);
mem_size=tensor->GetTotalSize();
addr=std::malloc(mem_size);
init_tensor_data((float *)addr,mem_size/sizeof(float),0);
set_tensor_mem(tensor,addr,mem_size,std::free);
std::cout<<"\n----------------------------------------------\n";
std::cout<<"Pooling Settings:\n";
std::cout<<"kernel_h : "<<param->kernel_shape[0]<<" kernel_w: "<<param->kernel_shape[1]<<"\n";
std::cout<<" stride: "<<param->strides[0]<<" pad: "<<param->pads[0];
std::cout<<" global: "<<param->global<<" alg: "<<param->alg<<" caffe_style: "<<param->caffe_flavor<<"\n";
std::cout<<"input n: "<<input_n<<" c: "<<input_c<<" h: "<<input_h<<" w: "<<input_w<<"\n";
std::cout<<"output n: "<<oshape.GetN()<<" c: "<<oshape.GetC()<<" h: "<<oshape.GetH()<<" w: "<<oshape.GetW()<<"\n";
op_fops=1.0*input_n*oshape.GetH()*oshape.GetW()*input_c*(param->kernel_shape[0]*param->kernel_shape[1]);
return node;
}
namespace TEngine {
extern bool caffe_run_pooling(Node *node, ExecEngine * engine);
extern bool PoolingRun(Node* node, ExecEngine * engine);
void RegisterPoolingNodeExec(void);
}
void test_new_operator(int rep,int input_n,int input_c,int input_h,int input_w,
int ksize,int stride,PoolArg type=kPoolMax,int pad=0,int global=0)
{
// caffe
Node * node0=create_pooling_node(input_n,input_c,input_h,input_w,ksize,stride,type,pad,global);
caffe_run_pooling(node0,nullptr);
if(!PrerunNode(node0,nullptr))
{
std::cout<<"Prerun failed\n";
}
Tensor * tensor=node0->GetOutputTensor(0);
TShape * shape=&tensor->GetShape();
float * data0=(float *)get_tensor_mem(tensor);
std::cout<<"caffe output [";
for(int i=0;i<9;i++)std::cout<< data0[i]<<",";
std::cout<<"]\n";
// pooling_run
Node * node1=create_pooling_node(input_n,input_c,input_h,input_w,ksize,stride,type,pad,global);
PoolingRun(node1,nullptr);
if(!RunNode(node1,nullptr))
{
std::cout<<"Run failed\n";
}
Tensor * otensor=node1->GetOutputTensor(0);
float * data_out=(float *)get_tensor_mem(otensor);
std::cout<<"\nmy output [";
for(int i=0;i<9;i++)std::cout<< data_out[i]<<",";
std::cout<<"]\n";
/* compare date */
CalcMaxError(data_out,data0,shape->GetSize());
/* performance benchmark ... */
struct timeval t0, t1;
float sum=0.f;
for(int i=0;i<30;i++)
{
gettimeofday(&t0, NULL);
PoolingRun(node1,nullptr);
gettimeofday(&t1, NULL);
float mytime=(float)((t1.tv_sec * 1000000 + t1.tv_usec) - (t0.tv_sec * 1000000 + t0.tv_usec)) / 1000;
// std::cout<<"time is "<<mytime<<"\n";
if(i>=10) sum+=mytime;
}
std::cout<<"avg time is "<<sum/20.<<std::endl;
if(!PostrunNode(node1,nullptr))
{
std::cout<<"Postrun failed\n";
}
}
void sys_init(void)
{
ShareLibParser p0("./build/operator/liboperator.so");
p0.ExcecuteFunc<int()>("tengine_plugin_init");
ShareLibParser p1("./build/serializer/libserializer.so");
p1.ExcecuteFunc<int()>("tengine_plugin_init");
ShareLibParser p2("./build/executor/libexecutor.so");
p2.ExcecuteFunc<int()>("tengine_plugin_init");
}
int main(int argc, char * argv[])
{
int rep=80;
int res;
while((res=getopt(argc,argv,"r:"))!=-1)
{
switch(res)
{
case 'r':
rep=strtoul(optarg,NULL,10);
break;
default:
break;
}
}
sys_init();
RegisterPoolingNodeExec();
// "divide exactly" means (input_h - ksize_h )= n * stride_h
// ------------------------------------------------------------
test_new_operator(rep,1,64,113,113,3,2);
// global
// test_new_operator(rep,1,1000,16,16,3,2,kPoolMax,0,1);
// test_new_operator(rep,1,2048,7,7,3,2,kPoolMax,0,1);
// test_new_operator(rep,1,1000,16,16,3,2,kPoolAvg,0,1);
// test_new_operator(rep,1,2048,7,7,3,2,kPoolAvg,0,1);
return 0;
}
|
Name: Debug-d.asm
Type: file
Size: 19892
Last-Modified: '1992-07-14T15:00:00Z'
SHA-1: 8C99C6417280432BD349F9E79DAC5C425E65E1EA
Description: null
|
; A229127: Number of n-digit numbers containing the digit '0'.
; Submitted by Jamie Morken(s1)
; 1,9,171,2439,30951,368559,4217031,46953279,512579511,5513215599,58618940391,617570463519,6458134171671,67123207545039,694108867905351,7146979811148159,73322818300333431,749905364703000879,7649148282327007911,77842334540943071199
mul $0,2
seq $0,50720 ; Number of nonzero palindromes of length n containing the digit '0'.
trn $0,1
add $0,1
|
//
// Created by Gegel85 on 23/09/2019
//
#include <fstream>
#include <iostream>
#include "Entity.hpp"
#include "Exceptions.hpp"
#include "json.hpp"
#include "../Game.hpp"
namespace DungeonIntern::Rendering
{
Entity::Config::Config(Resources &resources, const std::string &path)
{
this->loadFile(resources, path);
}
void Entity::Config::loadFile(Resources &resources, const std::string &path)
{
std::ifstream stream{path};
nlohmann::json value;
if (stream.fail())
throw InvalidAnimationConfigException("Cannot open file " + path);
try {
unsigned counter = 0;
stream >> value;
this->texture = value["texture"];
this->tileSize = {value["tileSize"]["x"], value["tileSize"]["y"]};
for (auto &val : value["animations"]) {
if (val == 0)
throw InvalidAnimationConfigException("Animation count can't be 0");
this->animations.push_back(val);
}
for (auto &val : value["delays"])
this->delays.push_back(val);
for (int i = 0; i < DEAD; i++)
for (int j = 0; j < NB_DIRS; j++) {
this->animationStart.emplace_back(counter);
counter += this->animations[i];
}
this->animationStart.emplace_back(counter);
this->textureSize = resources.textures.at(this->texture).getSize();
if (this->textureSize.x % this->tileSize.x || this->textureSize.y % this->tileSize.y)
throw InvalidAnimationConfigException(
"The texture chosen (" + this->texture +
") size isn't a perfect grid of " +
std::to_string(this->tileSize.x) + "x" + std::to_string(this->tileSize.y) +
" tiles"
);
} catch (std::out_of_range &) {
throw InvalidAnimationConfigException("The texture given is not loaded: " + this->texture);
} catch (nlohmann::detail::parse_error &e) {
throw InvalidAnimationConfigException("The JSON file has an invalid format: " + std::string(e.what()));
} catch (nlohmann::detail::type_error &e) {
throw InvalidAnimationConfigException("The JSON values are invalid: " + std::string(e.what()));
}
if (this->animations.size() != DEAD + 1)
throw InvalidAnimationConfigException(
"Expected " + std::to_string(DEAD + 1) + " animations but found " + std::to_string(this->animations.size())
);
if (this->delays.size() != DEAD + 1)
throw InvalidAnimationConfigException(
"Expected " + std::to_string(DEAD + 1) + " delays but found " + std::to_string(this->delays.size())
);
}
sf::Vector2u Entity::Config::getPositionFromAnimationIndex(unsigned index)
{
return {
(this->tileSize.x * index) % this->textureSize.x,
(this->tileSize.x * index) / this->textureSize.x * this->tileSize.y,
};
}
Entity::Entity(Resources &resources, const std::string &configPath) :
_resources(resources),
_configs(resources, configPath)
{
}
void Entity::setConfigs(Resources &resources, const std::string &path)
{
this->_configs.loadFile(resources, path);
}
void Entity::setAnimation(Animation newAnimation, bool forceReset)
{
if (this->_animation == newAnimation && !forceReset)
return;
this->_animation = newAnimation;
this->_animationState = 0;
this->_delay = this->_configs.delays[newAnimation];
}
void Entity::setSize(sf::Vector2u newSize)
{
this->_size = newSize;
}
void Entity::setPosition(sf::Vector2f newPos)
{
this->_pos = newPos;
}
void Entity::setDirection(DungeonIntern::Rendering::Direction newDir)
{
this->_dir = newDir;
}
void Entity::render(Rendering::Screen &screen)
{
unsigned char dir = (this->_animation != DEAD) * this->_dir;
unsigned char animation = this->_animation * NB_DIRS + dir;
sf::Vector2u pos = this->_configs.getPositionFromAnimationIndex(this->_configs.animationStart[animation] + this->_animationState);
this->_sprite.setTexture(this->_resources.textures.at(this->_configs.texture));
this->_sprite.setScale({
this->_size.x / static_cast<float>(this->_configs.tileSize.x),
this->_size.y / static_cast<float>(this->_configs.tileSize.y)
});
this->_sprite.setTextureRect({
static_cast<int>(pos.x),
static_cast<int>(pos.y),
static_cast<int>(this->_configs.tileSize.x),
static_cast<int>(this->_configs.tileSize.y)
});
this->_sprite.setOrigin({
this->_configs.tileSize.x / 2.f,
this->_configs.tileSize.y / 2.f,
});
this->_sprite.setRotation(this->_angle);
screen.fillColor();
screen.draw(
this->_sprite,
{
this->_pos.x + this->_size.x / 2.f,
this->_pos.y + this->_size.y / 2.f,
}
);
#ifdef _DEBUG
screen.fillColor({0, 255, 0, 40});
screen.draw({
static_cast<int>(this->_pos.x),
static_cast<int>(this->_pos.y),
static_cast<int>(this->_size.x),
static_cast<int>(this->_size.y),
});
#endif
screen.fillColor();
this->_sprite.setOrigin({0, 0});
}
void Entity::setSpriteAngle(float newAngle)
{
this->_angle = newAngle * 180 / M_PI;
}
void Entity::update()
{
if (!this->_delay) {
this->_delay = this->_configs.delays[this->_animation];
switch (this->_animation) {
case DEAD:
case HIT:
if (this->_animationState + 2 == this->_configs.animations[this->_animation])
this->_delay = -1;
break;
default:
break;
}
this->_animationState = (this->_animationState + 1) % this->_configs.animations[this->_animation];
} else
this->_delay--;
}
} |
SECT_TEXT(suarithm)
;-------------------------------------------------------------------------------
; POP opcode: remove (discard) the topmost signal from the stack
;-------------------------------------------------------------------------------
; Mono: a -> (empty)
; Stereo: a b -> (empty)
;-------------------------------------------------------------------------------
%if POP_ID > -1
EXPORT MANGLE_FUNC(su_op_pop,0)
%ifdef INCLUDE_STEREO_POP
jnc su_op_pop_mono
fstp st0
su_op_pop_mono:
%endif
fstp st0
ret
%endif
;-------------------------------------------------------------------------------
; ADD opcode: add the two top most signals on the stack
;-------------------------------------------------------------------------------
; Mono: a b -> a+b b
; Stereo: a b c d -> a+c b+d c d
;-------------------------------------------------------------------------------
%if ADD_ID > -1
EXPORT MANGLE_FUNC(su_op_add,0)
%ifdef INCLUDE_STEREO_ADD
jnc su_op_add_mono
fadd st0, st2
fxch
fadd st0, st3
fxch
ret
su_op_add_mono:
%endif
fadd st1
ret
%endif
;-------------------------------------------------------------------------------
; ADDP opcode: add the two top most signals on the stack and pop
;-------------------------------------------------------------------------------
; Mono: a b -> a+b
; Stereo: a b c d -> a+c b+d
;-------------------------------------------------------------------------------
%if ADDP_ID > -1
EXPORT MANGLE_FUNC(su_op_addp,0)
%ifdef INCLUDE_STEREO_ADDP
jnc su_op_addp_mono
faddp st2, st0
faddp st2, st0
ret
su_op_addp_mono:
%endif
faddp st1, st0
ret
%endif
;-------------------------------------------------------------------------------
; LOADNOTE opcode: load the current note, scaled to [-1,1]
;-------------------------------------------------------------------------------
; Mono: (empty) -> n, where n is the note
; Stereo: (empty) -> n n
;-------------------------------------------------------------------------------
%if LOADNOTE_ID > -1
EXPORT MANGLE_FUNC(su_op_loadnote,0)
%ifdef INCLUDE_STEREO_LOADNOTE
jnc su_op_loadnote_mono
call su_op_loadnote_mono
su_op_loadnote_mono:
%endif
fild dword [INP-su_voice.inputs+su_voice.note]
do fmul dword [,c_i128,]
do fsub dword [,c_0_5,] ; s-.5
fadd st0, st0 ; 2*s-1
ret
%endif
;-------------------------------------------------------------------------------
; MUL opcode: multiply the two top most signals on the stack
;-------------------------------------------------------------------------------
; Mono: a b -> a*b a
; Stereo: a b c d -> a*c b*d c d
;-------------------------------------------------------------------------------
%if MUL_ID > -1
EXPORT MANGLE_FUNC(su_op_mul,0)
%ifdef INCLUDE_STEREO_MUL
jnc su_op_mul_mono
fmul st0, st2
fxch
fadd st0, st3
fxch
ret
su_op_mul_mono:
%endif
fmul st1
ret
%endif
;-------------------------------------------------------------------------------
; MULP opcode: multiply the two top most signals on the stack and pop
;-------------------------------------------------------------------------------
; Mono: a b -> a*b
; Stereo: a b c d -> a*c b*d
;-------------------------------------------------------------------------------
%if MULP_ID > -1
EXPORT MANGLE_FUNC(su_op_mulp,0)
%ifdef INCLUDE_STEREO_MULP
jnc su_op_mulp_mono
fmulp st2, st0
fmulp st2, st0
ret
su_op_mulp_mono:
%endif
fmulp st1
ret
%endif
;-------------------------------------------------------------------------------
; PUSH opcode: push the topmost signal on the stack
;-------------------------------------------------------------------------------
; Mono: a -> a a
; Stereo: a b -> a b a b
;-------------------------------------------------------------------------------
%if PUSH_ID > -1
EXPORT MANGLE_FUNC(su_op_push,0)
%ifdef INCLUDE_STEREO_PUSH
jnc su_op_push_mono
fld st1
fld st1
ret
su_op_push_mono:
%endif
fld st0
ret
%endif
;-------------------------------------------------------------------------------
; XCH opcode: exchange the signals on the stack
;-------------------------------------------------------------------------------
; Mono: a b -> b a
; stereo: a b c d -> c d a b
;-------------------------------------------------------------------------------
%if XCH_ID > -1
EXPORT MANGLE_FUNC(su_op_xch,0)
%ifdef INCLUDE_STEREO_XCH
jnc su_op_xch_mono
fxch st0, st2 ; c b a d
fxch st0, st1 ; b c a d
fxch st0, st3 ; d c a b
su_op_xch_mono:
%endif
fxch st0, st1
ret
%endif
|
/* Copyright 2019, Gurobi Optimization, LLC
This example considers the following nonconvex nonlinear problem
maximize 2 x + y
subject to exp(x) + 4 sqrt(y) <= 9
x, y >= 0
We show you two approaches to solve this:
1) Use a piecewise-linear approach to handle general function
constraints (such as exp and sqrt).
a) Add two variables
u = exp(x)
v = sqrt(y)
b) Compute points (x, u) of u = exp(x) for some step length (e.g., x
= 0, 1e-3, 2e-3, ..., xmax) and points (y, v) of v = sqrt(y) for
some step length (e.g., y = 0, 1e-3, 2e-3, ..., ymax). We need to
compute xmax and ymax (which is easy for this example, but this
does not hold in general).
c) Use the points to add two general constraints of type
piecewise-linear.
2) Use the Gurobis built-in general function constraints directly (EXP
and POW). Here, we do not need to compute the points and the maximal
possible values, which will be done internally by Gurobi. In this
approach, we show how to "zoom in" on the optimal solution and
tighten tolerances to improve the solution quality.
*/
#if defined (WIN32) || defined (WIN64)
#include <Windows.h>
#endif
#include "gurobi_c++.h"
#include <cmath>
using namespace std;
static double f(double u) { return exp(u); }
static double g(double u) { return sqrt(u); }
static void
printsol(GRBModel& m, GRBVar& x, GRBVar& y, GRBVar& u, GRBVar& v)
{
cout << "x = " << x.get(GRB_DoubleAttr_X) << ", u = " << u.get(GRB_DoubleAttr_X) << endl;
cout << "y = " << y.get(GRB_DoubleAttr_X) << ", v = " << v.get(GRB_DoubleAttr_X) << endl;
cout << "Obj = " << m.get(GRB_DoubleAttr_ObjVal) << endl;
// Calculate violation of exp(x) + 4 sqrt(y) <= 9
double vio = f(x.get(GRB_DoubleAttr_X)) + 4 * g(y.get(GRB_DoubleAttr_X)) - 9;
if (vio < 0.0) vio = 0.0;
cout << "Vio = " << vio << endl;
}
int
main(int argc, char* argv[])
{
double* xpts = NULL;
double* ypts = NULL;
double* vpts = NULL;
double* upts = NULL;
try {
// Create environment
GRBEnv env = GRBEnv();
// Create a new model
GRBModel m = GRBModel(env);
// Create variables
double lb = 0.0, ub = GRB_INFINITY;
GRBVar x = m.addVar(lb, ub, 0.0, GRB_CONTINUOUS, "x");
GRBVar y = m.addVar(lb, ub, 0.0, GRB_CONTINUOUS, "y");
GRBVar u = m.addVar(lb, ub, 0.0, GRB_CONTINUOUS, "u");
GRBVar v = m.addVar(lb, ub, 0.0, GRB_CONTINUOUS, "v");
// Set objective
m.setObjective(2*x + y, GRB_MAXIMIZE);
// Add linear constraint
m.addConstr(u + 4*v <= 9, "l1");
// Approach 1) PWL constraint approach
double intv = 1e-3;
double xmax = log(9.0);
int len = (int) ceil(xmax/intv) + 1;
xpts = new double[len];
upts = new double[len];
for (int i = 0; i < len; i++) {
xpts[i] = i*intv;
upts[i] = f(i*intv);
}
GRBGenConstr gc1 = m.addGenConstrPWL(x, u, len, xpts, upts, "gc1");
double ymax = (9.0/4.0)*(9.0/4.0);
len = (int) ceil(ymax/intv) + 1;
ypts = new double[len];
vpts = new double[len];
for (int i = 0; i < len; i++) {
ypts[i] = i*intv;
vpts[i] = g(i*intv);
}
GRBGenConstr gc2 = m.addGenConstrPWL(y, v, len, ypts, vpts, "gc2");
// Optimize the model and print solution
m.optimize();
printsol(m, x, y, u, v);
// Approach 2) General function constraint approach with auto PWL
// translation by Gurobi
// restore unsolved state and get rid of PWL constraints
m.reset();
m.remove(gc1);
m.remove(gc2);
m.update();
GRBGenConstr gcf1 = m.addGenConstrExp(x, u, "gcf1");
GRBGenConstr gcf2 = m.addGenConstrPow(y, v, 0.5, "gcf2");
m.set(GRB_DoubleParam_FuncPieceLength, 1e-3);
// Optimize the model and print solution
m.optimize();
printsol(m, x, y, u, v);
// Zoom in, use optimal solution to reduce the ranges and use a smaller
// pclen=1e-5 to solve it
double xval = x.get(GRB_DoubleAttr_X);
double yval = y.get(GRB_DoubleAttr_X);
x.set(GRB_DoubleAttr_LB, max(x.get(GRB_DoubleAttr_LB), xval-0.01));
x.set(GRB_DoubleAttr_UB, min(x.get(GRB_DoubleAttr_UB), xval+0.01));
y.set(GRB_DoubleAttr_LB, max(y.get(GRB_DoubleAttr_LB), yval-0.01));
y.set(GRB_DoubleAttr_UB, min(y.get(GRB_DoubleAttr_UB), yval+0.01));
m.update();
m.reset();
m.set(GRB_DoubleParam_FuncPieceLength, 1e-5);
// Optimize the model and print solution
m.optimize();
printsol(m, x, y, u, v);
} catch(GRBException e) {
cout << "Error code = " << e.getErrorCode() << endl;
cout << e.getMessage() << endl;
} catch(...) {
cout << "Exception during optimization" << endl;
}
if (xpts) delete[] xpts;
if (ypts) delete[] ypts;
if (upts) delete[] upts;
if (vpts) delete[] vpts;
return 0;
}
|
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.00.23506.0
include listing.inc
INCLUDELIB MSVCRT
INCLUDELIB OLDNAMES
_DATA SEGMENT
$SG5303 DB '%d', 00H
_DATA ENDS
PUBLIC __local_stdio_printf_options
PUBLIC __local_stdio_scanf_options
PUBLIC _vfprintf_l
PUBLIC printf
PUBLIC _vfscanf_l
PUBLIC scanf
PUBLIC func
PUBLIC main
EXTRN __imp___acrt_iob_func:PROC
EXTRN __imp___stdio_common_vfprintf:PROC
EXTRN __imp___stdio_common_vfscanf:PROC
EXTRN gets:PROC
EXTRN __chkstk:PROC
_DATA SEGMENT
COMM ?_OptionsStorage@?1??__local_stdio_printf_options@@9@9:QWORD ; `__local_stdio_printf_options'::`2'::_OptionsStorage
COMM ?_OptionsStorage@?1??__local_stdio_scanf_options@@9@9:QWORD ; `__local_stdio_scanf_options'::`2'::_OptionsStorage
_DATA ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$_vfprintf_l DD imagerel $LN3
DD imagerel $LN3+68
DD imagerel $unwind$_vfprintf_l
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$printf DD imagerel $LN3
DD imagerel $LN3+88
DD imagerel $unwind$printf
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$_vfscanf_l DD imagerel $LN3
DD imagerel $LN3+68
DD imagerel $unwind$_vfscanf_l
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$scanf DD imagerel $LN3
DD imagerel $LN3+85
DD imagerel $unwind$scanf
pdata ENDS
pdata SEGMENT
$pdata$func DD imagerel $LN4
DD imagerel $LN4+101
DD imagerel $unwind$func
$pdata$main DD imagerel $LN3
DD imagerel $LN3+16
DD imagerel $unwind$main
pdata ENDS
xdata SEGMENT
$unwind$func DD 025030b01H
DD 05206230bH
DD 05002H
$unwind$main DD 010401H
DD 04204H
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$scanf DD 011801H
DD 06218H
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$_vfscanf_l DD 011801H
DD 06218H
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$printf DD 011801H
DD 06218H
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$_vfprintf_l DD 011801H
DD 06218H
xdata ENDS
; Function compile flags: /Odtpy
; File d:\projects\taintanalysis\antitaint\epilog\src\func-alloca.c
_TEXT SEGMENT
main PROC
; 20 : {
$LN3:
sub rsp, 40 ; 00000028H
; 21 : func();
call func
; 22 : return 0;
xor eax, eax
; 23 : }
add rsp, 40 ; 00000028H
ret 0
main ENDP
_TEXT ENDS
; Function compile flags: /Odtpy
; File d:\projects\taintanalysis\antitaint\epilog\src\func-alloca.c
_TEXT SEGMENT
sz$ = 0
buf$ = 8
func PROC
; 10 : {
$LN4:
push rbp
sub rsp, 48 ; 00000030H
lea rbp, QWORD PTR [rsp+32]
; 11 : int sz;
; 12 : char *buf;
; 13 : scanf("%d", &sz);
lea rdx, QWORD PTR sz$[rbp]
lea rcx, OFFSET FLAT:$SG5303
call scanf
; 14 : buf = (char*)alloca(sz);
movsxd rax, DWORD PTR sz$[rbp]
mov rcx, rax
add rcx, 15
cmp rcx, rax
ja SHORT $LN3@func
mov rcx, 1152921504606846960 ; 0ffffffffffffff0H
$LN3@func:
and rcx, -16
mov rax, rcx
call __chkstk
sub rsp, rax
lea rax, QWORD PTR [rsp+32]
mov QWORD PTR buf$[rbp], rax
; 15 : gets(buf);
mov rcx, QWORD PTR buf$[rbp]
call gets
; 16 : printf(buf);
mov rcx, QWORD PTR buf$[rbp]
call printf
; 17 : }
lea rsp, QWORD PTR [rbp+16]
pop rbp
ret 0
func ENDP
_TEXT ENDS
; Function compile flags: /Odtpy
; File c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\stdio.h
; COMDAT scanf
_TEXT SEGMENT
_Result$ = 32
_ArgList$ = 40
_Format$ = 64
scanf PROC ; COMDAT
; 1276 : {
$LN3:
mov QWORD PTR [rsp+8], rcx
mov QWORD PTR [rsp+16], rdx
mov QWORD PTR [rsp+24], r8
mov QWORD PTR [rsp+32], r9
sub rsp, 56 ; 00000038H
; 1277 : int _Result;
; 1278 : va_list _ArgList;
; 1279 : __crt_va_start(_ArgList, _Format);
lea rax, QWORD PTR _Format$[rsp+8]
mov QWORD PTR _ArgList$[rsp], rax
; 1280 : _Result = _vfscanf_l(stdin, _Format, NULL, _ArgList);
xor ecx, ecx
call QWORD PTR __imp___acrt_iob_func
mov r9, QWORD PTR _ArgList$[rsp]
xor r8d, r8d
mov rdx, QWORD PTR _Format$[rsp]
mov rcx, rax
call _vfscanf_l
mov DWORD PTR _Result$[rsp], eax
; 1281 : __crt_va_end(_ArgList);
mov QWORD PTR _ArgList$[rsp], 0
; 1282 : return _Result;
mov eax, DWORD PTR _Result$[rsp]
; 1283 : }
add rsp, 56 ; 00000038H
ret 0
scanf ENDP
_TEXT ENDS
; Function compile flags: /Odtpy
; File c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\stdio.h
; COMDAT _vfscanf_l
_TEXT SEGMENT
_Stream$ = 64
_Format$ = 72
_Locale$ = 80
_ArgList$ = 88
_vfscanf_l PROC ; COMDAT
; 1058 : {
$LN3:
mov QWORD PTR [rsp+32], r9
mov QWORD PTR [rsp+24], r8
mov QWORD PTR [rsp+16], rdx
mov QWORD PTR [rsp+8], rcx
sub rsp, 56 ; 00000038H
; 1059 : return __stdio_common_vfscanf(
call __local_stdio_scanf_options
mov rcx, QWORD PTR _ArgList$[rsp]
mov QWORD PTR [rsp+32], rcx
mov r9, QWORD PTR _Locale$[rsp]
mov r8, QWORD PTR _Format$[rsp]
mov rdx, QWORD PTR _Stream$[rsp]
mov rcx, QWORD PTR [rax]
call QWORD PTR __imp___stdio_common_vfscanf
; 1060 : _CRT_INTERNAL_LOCAL_SCANF_OPTIONS,
; 1061 : _Stream, _Format, _Locale, _ArgList);
; 1062 : }
add rsp, 56 ; 00000038H
ret 0
_vfscanf_l ENDP
_TEXT ENDS
; Function compile flags: /Odtpy
; File c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\stdio.h
; COMDAT printf
_TEXT SEGMENT
_Result$ = 32
_ArgList$ = 40
_Format$ = 64
printf PROC ; COMDAT
; 950 : {
$LN3:
mov QWORD PTR [rsp+8], rcx
mov QWORD PTR [rsp+16], rdx
mov QWORD PTR [rsp+24], r8
mov QWORD PTR [rsp+32], r9
sub rsp, 56 ; 00000038H
; 951 : int _Result;
; 952 : va_list _ArgList;
; 953 : __crt_va_start(_ArgList, _Format);
lea rax, QWORD PTR _Format$[rsp+8]
mov QWORD PTR _ArgList$[rsp], rax
; 954 : _Result = _vfprintf_l(stdout, _Format, NULL, _ArgList);
mov ecx, 1
call QWORD PTR __imp___acrt_iob_func
mov r9, QWORD PTR _ArgList$[rsp]
xor r8d, r8d
mov rdx, QWORD PTR _Format$[rsp]
mov rcx, rax
call _vfprintf_l
mov DWORD PTR _Result$[rsp], eax
; 955 : __crt_va_end(_ArgList);
mov QWORD PTR _ArgList$[rsp], 0
; 956 : return _Result;
mov eax, DWORD PTR _Result$[rsp]
; 957 : }
add rsp, 56 ; 00000038H
ret 0
printf ENDP
_TEXT ENDS
; Function compile flags: /Odtpy
; File c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\stdio.h
; COMDAT _vfprintf_l
_TEXT SEGMENT
_Stream$ = 64
_Format$ = 72
_Locale$ = 80
_ArgList$ = 88
_vfprintf_l PROC ; COMDAT
; 638 : {
$LN3:
mov QWORD PTR [rsp+32], r9
mov QWORD PTR [rsp+24], r8
mov QWORD PTR [rsp+16], rdx
mov QWORD PTR [rsp+8], rcx
sub rsp, 56 ; 00000038H
; 639 : return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Stream, _Format, _Locale, _ArgList);
call __local_stdio_printf_options
mov rcx, QWORD PTR _ArgList$[rsp]
mov QWORD PTR [rsp+32], rcx
mov r9, QWORD PTR _Locale$[rsp]
mov r8, QWORD PTR _Format$[rsp]
mov rdx, QWORD PTR _Stream$[rsp]
mov rcx, QWORD PTR [rax]
call QWORD PTR __imp___stdio_common_vfprintf
; 640 : }
add rsp, 56 ; 00000038H
ret 0
_vfprintf_l ENDP
_TEXT ENDS
; Function compile flags: /Odtpy
; File c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\corecrt_stdio_config.h
; COMDAT __local_stdio_scanf_options
_TEXT SEGMENT
__local_stdio_scanf_options PROC ; COMDAT
; 83 : static unsigned __int64 _OptionsStorage;
; 84 : return &_OptionsStorage;
lea rax, OFFSET FLAT:?_OptionsStorage@?1??__local_stdio_scanf_options@@9@9 ; `__local_stdio_scanf_options'::`2'::_OptionsStorage
; 85 : }
ret 0
__local_stdio_scanf_options ENDP
_TEXT ENDS
; Function compile flags: /Odtpy
; File c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\corecrt_stdio_config.h
; COMDAT __local_stdio_printf_options
_TEXT SEGMENT
__local_stdio_printf_options PROC ; COMDAT
; 74 : static unsigned __int64 _OptionsStorage;
; 75 : return &_OptionsStorage;
lea rax, OFFSET FLAT:?_OptionsStorage@?1??__local_stdio_printf_options@@9@9 ; `__local_stdio_printf_options'::`2'::_OptionsStorage
; 76 : }
ret 0
__local_stdio_printf_options ENDP
_TEXT ENDS
END
|
; A144143: a(n) = Hermite(n,4).
; Submitted by Jon Maiga
; 1,8,62,464,3340,23008,150664,929216,5324432,27728000,125984224,453313792,854857408,-4040671744,-54551666560,-323274523648,-949646192384,2747615217664,54268892282368,335236990423040,619678016654336,-8452055483686912,-93642920568977408,-377252923269595136,1289550960016199680,28424547997070163968,162918835975751327744,-174725808041637904384,-10195423607023674933248,-71778743605857676820480,17104620360511731564544,4443561579235554461745152,34488006171532708336959488,-8483891698813818856013824
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
mul $2,8
mul $3,-1
mul $3,$0
mul $3,2
lpe
mov $0,$1
|
CNZ_Header:
smpsHeaderStartSong 2, 1
smpsHeaderVoice CNZ_Voices
smpsHeaderChan $06, $03
smpsHeaderTempo $01, $48
smpsHeaderDAC CNZ_DAC
smpsHeaderFM CNZ_FM1, $0C, $08
smpsHeaderFM CNZ_FM2, $F4, $0A
smpsHeaderFM CNZ_FM3, $F4, $12
smpsHeaderFM CNZ_FM4, $F4, $12
smpsHeaderFM CNZ_FM5, $F4, $0F
smpsHeaderPSG CNZ_PSG1, $DC, $05, $00, $00
smpsHeaderPSG CNZ_PSG2, $DC, $05, $00, $00
smpsHeaderPSG CNZ_PSG3, $00, $04, $00, $00
; FM1 Data
CNZ_FM1:
smpsSetvoice $00
dc.b nRst, $18
CNZ_Jump04:
dc.b nC3, $06, nC2, nC3, nC2, nC3, nC2, nC3, nC2, nRst, nG1, $04
dc.b nRst, $02, nBb1, $04, nAb1, $06, nG1, $04, nRst, $02, nG2, $02
dc.b nG1, $06, nA1, nB1, nC2, $06, nB1, nA1, nG1, nC2, nG1, nC2
dc.b nD2, nE2, nD2, nC2, nB1, nE1, nFs1, nAb1, nE1, nA1, nA1, nE2
dc.b nE2, nA1, nB1, nC2, nA1, nAb1, nBb1, nC2, nD2, nEb2, $04, $02
dc.b nAb1, $06, nC2, nAb1, nC2, nC2, nD2, nEb2, nE2, $04, $02, nE1
dc.b $06, nFs1, nAb1, nA1, nA1, nG1, nG1, nF1, nC2, nF1, nA1, nRst
dc.b nC2, nRst, nC2, nRst, nF2, nRst, nF2, nAb1, $0C, $06, nRst, $04
dc.b nG1, $04, nRst, $02, nG2, nF2, $06, nE2, nD2, nC2, $04, $02
dc.b nE1, $06, nF1, nFs1, nG1, nB1, nC2, nD2, nE2, nB1, nAb1, nFs1
dc.b nE1, nB1, nE2, nE1, nA1, nB1, nC2, nB1, nA1, nC2, nE2, nA1
dc.b nAb1, nBb1, nC2, nBb1, nAb1, nA1, nBb1, nB1, nC2, nB1, nC2, nD2
dc.b nE2, $04, $02, nB1, $06, nE1, nAb1, nA1, nB1, nC2, nE2, nF2
dc.b $04, nA1, $08, nBb1, $06, nB1, nRst, nC2, nRst, nC2, nRst, nF2
dc.b nRst, nF2
smpsAlterVol $04
dc.b nRst, nC2, nRst, nC2, nRst, nF2, nRst, nF2
smpsAlterVol $FC
dc.b nRst, nC2, nRst, nC2, nRst, nF2, nRst, nF2, $04, nC2, $02, nRst
dc.b $18, nC2, $02, nRst, nC2, nB1, $06, nA1, nG1
smpsJump CNZ_Jump04
; FM3 Data
CNZ_FM3:
smpsSetvoice $02
smpsPan panLeft, $00
dc.b nRst, $18
CNZ_Jump03:
smpsSetvoice $02
dc.b nRst, $06, nG5, nRst, nG5, nRst, nG5, nRst, nG5, nRst, nF5, $02
dc.b nRst, $04, nF5, $04, $02, nRst, $04, nF5, $02, nRst, $18
smpsCall CNZ_Call02
smpsSetvoice $01
smpsAlterPitch $F4
smpsAlterVol $FC
smpsCall CNZ_Call03
dc.b nE6, $18, nD6, $0C, nE6, $06, nD6, nC6, $18, nF6, nRst, $06
dc.b nG5, nRst, nG5, nRst, nA5, nRst, nA5
smpsAlterVol $04
dc.b nRst, nG5, nRst, nG5, nRst, nA5, nRst, nA5
smpsAlterVol $FC
dc.b nRst, nG5, nRst, nG5, nRst, nA5, $0C, $04, nG5, $02, nRst, $30
smpsAlterPitch $0C
smpsAlterVol $04
smpsJump CNZ_Jump03
CNZ_Call02:
dc.b nRst, $06, nG4, $02, nRst, $08, nG4, $02, nRst, $06, nG4, $08
dc.b nRst, $02, nG4, $06, nRst, $02, nG4, $04, $02, nRst, $06, nAb4
dc.b $02, nRst, $08, nAb4, $02, nRst, $06, nAb4, $08, nRst, $02, nAb4
dc.b $06, nRst, $02, nAb4, $04, $02, nRst, $06, nA4, $02, nRst, $08
dc.b nA4, $02, nRst, $06, nA4, $08, nRst, $02, nA4, $06, nRst, $02
dc.b nA4, $04, $02, nRst, $06, nAb4, $02, nRst, $08, nAb4, $02, nRst
dc.b $06, nAb4, $08, nRst, $02, nAb4, $06, nRst, $02, nAb4, $04, $02
dc.b nRst, $06, nG4, $02, nRst, $08, nG4, $02, nRst, $06, nAb4, $08
dc.b nRst, $02, nAb4, $06, nRst, $02, nAb4, $04, $02, nRst, $06, nA4
dc.b $02, nRst, $08, nA4, $02, nRst, $06, nA4, $08, nRst, $02, nA4
dc.b $06, nRst, $02, nA4, $04, $02, nRst, $06, nG4, nRst, nG4, nRst
dc.b nA4, nRst, nA4, nC5, $0C, $06, $04, nB4, $02, nRst, $18
smpsReturn
CNZ_Call03:
dc.b nRst, $06, nE6, $02, nRst, $08, nE6, $02, nRst, $06, nE6, $06
dc.b nF6, $04, nE6, $02, nRst, $0C, nRst, $06, nD6, $02, nRst, $08
dc.b nD6, $02, nRst, $06, nD6, $06, nE6, $04, nD6, $02, nRst, $0C
dc.b nRst, $06, nC6, $02, nRst, $08, nC6, $02, nRst, $06, nC6, $06
dc.b nD6, $04, nC6, $02, nRst, $0C, nRst, $06, nC6, $02, nRst, $08
dc.b nC6, $02, nRst, $06, nC6, $06, nD6, $04, nC6, $02, nRst, $0C
smpsReturn
; FM4 Data
CNZ_FM4:
smpsSetvoice $02
smpsPan panRight, $00
dc.b nRst, $18
CNZ_Jump02:
smpsSetvoice $02
dc.b nRst, $06, nEb5, nRst, nEb5, nRst, nEb5, nRst, nEb5, nRst, nD5, $02
dc.b nRst, $04, nD5, $04, $02, nRst, $04, nD5, $02, nRst, $18
smpsCall CNZ_Call00
smpsSetvoice $01
smpsAlterPitch $F4
smpsAlterVol $FC
smpsCall CNZ_Call01
dc.b nC6, $18, nB5, $0C, nC6, $06, nB5, nA5, $18, nC6, nRst, $06
dc.b nE5, nRst, nE5, nRst, nF5, nRst, nF5
smpsAlterVol $04
dc.b nRst, nE5, nRst, nE5, nRst, nF5, nRst, nF5
smpsAlterVol $FC
dc.b nRst, nE5, nRst, nE5, nRst, nF5, $0C, $04, nE5, $02, nRst, $30
smpsAlterPitch $0C
smpsAlterVol $04
smpsJump CNZ_Jump02
CNZ_Call00:
dc.b nRst, $06, nE4, $02, nRst, $08, nE4, $02, nRst, $06, nE4, $08
dc.b nRst, $02, nE4, $06, nRst, $02, nE4, $04, $02
smpsLoop $00, $03, CNZ_Call00
dc.b nRst, $06, nEb4, $02, nRst, $08, nEb4, $02, nRst, $06, nEb4, $08
dc.b nRst, $02, nEb4, $06, nRst, $02, nEb4, $04, $02, nRst, $06, nE4
dc.b $02, nRst, $08, nE4, $02, nRst, $06, nE4, $08, nRst, $02, nE4
dc.b $06, nRst, $02, nE4, $04, $02, nRst, $06, nE4, $02, nRst, $08
dc.b nE4, $02, nRst, $06, nF4, $08, nRst, $02, nF4, $06, nRst, $02
dc.b nF4, $04, $02, nRst, $06, nE4, nRst, nE4, nRst, nF4, nRst, nF4
dc.b nAb4, $0C, $06, $04, nG4, $02, nRst, $18
smpsReturn
CNZ_Call01:
dc.b nRst, $06, nC6, $02, nRst, $08, nC6, $02, nRst, $06, nC6, $06
dc.b nD6, $04, nC6, $02, nRst, $0C, nRst, $06, nB5, $02, nRst, $08
dc.b nB5, $02, nRst, $06, nB5, $06, nC6, $04, nB5, $02, nRst, $0C
dc.b nRst, $06, nA5, $02, nRst, $08, nA5, $02, nRst, $06, nA5, $06
dc.b nB5, $04, nA5, $02, nRst, $0C, nRst, $06, nAb5, $02, nRst, $08
dc.b nAb5, $02, nRst, $06, nAb5, $06, nBb5, $04, nAb5, $02, nRst, $0C
smpsReturn
; FM2 Data
CNZ_FM2:
smpsSetvoice $01
smpsModSet $1C, $01, $06, $04
dc.b nRst, $18
CNZ_Jump01:
smpsSetvoice $01
dc.b nRst, $06, nEb5, $0C, nC5, $02, nRst, $04, nFs5, nF5, $02, nRst
dc.b $04, nEb5, $02, nRst, $04, nC5, $08, nRst, $06, nG4, $02, nRst
dc.b $04, nBb4, nAb4, $02, nRst, $04, nG4, $02, nRst, $0C, nE4, $04
dc.b nRst, $02, nE4, $04, nRst, $02, nE4, $18, nRst, $06, nE4, $04
dc.b nRst, $02, nF4, $04, nE4, $08, nAb4, $04, $02, nRst, $04, nE4
dc.b $1A, nRst, $06, nE4, nA4, $04, $02, nRst, $04, nE4, $02, nC4
dc.b $12, nRst, $06, nC4, $04, nRst, $02, nD4, $04, nC4, $02, nEb4
dc.b $06, nD4, $04, nC4, $26, nRst, $06, nE4, $04, nRst, $02, nF4
dc.b $04, nRst, $02, nE4, $04, nRst, $02, nAb4, $04, $02, nRst, $04
dc.b nE4, $0E, nRst, $06, nA4, $0C, nB4, $04, nA4, $02, nC5, $0C
dc.b nRst, $06, nA4, $02, nRst, $04, nG4, $0C, nE4, nC4, nD4, nEb4
dc.b nF4, $04, nEb4, $02, nF4, $04, nG4, $02, nRst, $10, nG3, $02
dc.b nA3, $04, nC4, $02, nE4, $18, nRst, $06, nE4, $04, nRst, $02
dc.b nF4, $04, nE4, $08, nAb4, $04, $02, nRst, $04, nE4, $1A, nRst
dc.b $06, nE4, nA4, $04, $02, nRst, $04, nE4, $02, nC4, $12, nRst
dc.b $06, nC4, $04, nRst, $02, nD4, $04, nC4, $02, nEb4, $06, nD4
dc.b $04, nC4, $26, nRst, $06, nE4, $04, nRst, $02, nF4, $04, nRst
dc.b $02, nE4, $04, nRst, $02, nAb4, $04, $02, nRst, $04, nE4, $0E
dc.b nRst, $06, nA4, $0C, nB4, $04, nA4, $02, nC5, $0C, nRst, $06
dc.b nA4, $02, nRst, $04, nG4, $0C, nE4, nC4, nD4, $06
smpsAlterVol $04
dc.b nA4, $02, nRst, $04, nG4, $0C, nE4, nC4, nD4, $06
smpsAlterVol $FC
dc.b nA4, $02, nRst, $04, nG4, $0C, nE4, nC4, nD4, $0A, nC4, $02
dc.b nRst, $30
smpsJump CNZ_Jump01
; FM5 Data
CNZ_FM5:
smpsSetvoice $01
dc.b nRst, $18
smpsModSet $1C, $01, $06, $04
CNZ_Jump00:
smpsSetvoice $01
dc.b nRst, $06, nC5, $0C, nG4, $02, nRst, $04, nEb5, nD5, $02, nRst
dc.b $04, nC5, $02, nRst, $04, nG4, $08, nRst, $06, nD4, $02, nRst
dc.b $04, nF4, nEb4, $02, nRst, $04, nD4, $02, nRst, $0C, nA3, $04
dc.b nRst, $02, nB3, $04, nRst, $02, nC4, $18, nRst, $06, nC4, $04
dc.b nRst, $02, nD4, $04, nC4, $08, nE4, $04, nE4, $02, nRst, $04
dc.b nB3, $1A, nRst, $06, nB3, nE4, $04, $02, nRst, $04, nC4, $02
dc.b nA3, $12, nRst, $06, nA3, $04, nRst, $02, nB3, $04, nA3, $02
dc.b nC4, $06, nBb3, $04, nAb3, $26, nRst, $06, nC4, $04, nRst, $02
dc.b nD4, $04, nRst, $02, nC4, $04, nRst, $02, nE4, $04, nE4, $02
dc.b nRst, $04, nB3, $0E, nRst, $06, nE4, $0C, nG4, $04, nE4, $02
dc.b nA4, $0C, nRst, $06, nF4, $02, nRst, $04, nE4, $0C, nC4, nA3
dc.b nB3, nC4, nD4, $04, nC4, $02, nD4, $04, nD4, $02, nRst, $10
dc.b nD3, $02, nE3, $04, nG3, $02, nC4, $18, nRst, $06, nC4, $04
dc.b nRst, $02, nD4, $04, nC4, $08, nE4, $04, nE4, $02, nRst, $04
dc.b nB3, $1A, nRst, $06, nB3, nE4, $04, $02, nRst, $04, nC4, $02
dc.b nA3, $12, nRst, $06, nA3, $04, nRst, $02, nB3, $04, nA3, $02
dc.b nC4, $06, nBb3, $04, nAb3, $26, nRst, $06, nC4, $04, nRst, $02
dc.b nD4, $04, nRst, $02, nC4, $04, nRst, $02, nE4, $04, nE4, $02
dc.b nRst, $04, nB3, $0E, nRst, $06, nE4, $0C, nG4, $04, nE4, $02
dc.b nA4, $0C, nRst, $06, nF4, $02, nRst, $04, nE4, $0C, nC4, nA3
dc.b nB3, $06
smpsAlterVol $04
dc.b nF4, $02, nRst, $04, nE4, $0C, nC4, nA3, nB3, $06
smpsAlterVol $F8
dc.b nF4, $02, nRst, $04, nE4, $0C, nC4, nA3, nF3, $0A, nE3, $02
dc.b nRst, $30
smpsAlterVol $04
smpsJump CNZ_Jump00
; PSG1 Data
CNZ_PSG1:
dc.b nRst, $18
CNZ_Jump06:
dc.b nRst, $06, nG4, $0C, nEb4, $02, nRst, $04, nA4, nAb4, $02, nRst
dc.b $04, nG4, $02, nRst, $04, nEb4, $08, nRst, $06, nB3, $02, nRst
dc.b $04, nD4, nC4, $02, nRst, $04, nB3, $02, nRst, $18
smpsPSGvoice fTone_01
smpsPSGAlterVol $FF
smpsCall CNZ_Call02
smpsPSGAlterVol $01
smpsPSGvoice $00
smpsAlterPitch $E8
smpsCall CNZ_Call03
smpsAlterPitch $18
smpsPSGAlterVol $02
dc.b nE4, $18, nD4, $0C, nE4, $06, nD4, nC4, $18, nF4
smpsPSGAlterVol $FE
dc.b nRst, $06, nG4, nRst, nG4, nRst, nA4, nRst, nA4
smpsPSGAlterVol $03
dc.b nG5, $0C, nE5, nC5, nD5, $06, nRst
smpsPSGAlterVol $FC
dc.b nRst, nG4, nRst, nG4, nRst, nA4, $0C, $04, nG4, $02, nRst, $30
smpsPSGAlterVol $01
smpsJump CNZ_Jump06
; PSG2 Data
CNZ_PSG2:
dc.b nRst, $18
CNZ_Jump05:
dc.b nRst, $06, nEb5, $0C, nC5, $02, nRst, $04, nFs5, nF5, $02, nRst
dc.b $04, nEb5, $02, nRst, $04, nC5, $08, nRst, $06, nG4, $02, nRst
dc.b $04, nBb4, nAb4, $02, nRst, $04, nG4, $02, nRst, $18
smpsPSGvoice fTone_01
smpsPSGAlterVol $FF
smpsCall CNZ_Call00
smpsPSGAlterVol $01
smpsPSGvoice $00
smpsAlterPitch $E8
smpsCall CNZ_Call01
smpsAlterPitch $18
smpsPSGAlterVol $02
dc.b nC4, $18, nB3, $0C, nC4, $06, nB3, nA3, $18, nC4
smpsPSGAlterVol $FE
dc.b nRst, $06, nE4, nRst, nE4, nRst, nF4, nRst, nF4
smpsPSGAlterVol $03
dc.b nRst, nC4, nRst, nC4, nRst, nC4, nRst, nC4
smpsPSGAlterVol $FC
dc.b nRst, nC4, nRst, nC4, nRst, nC4, $0C, $04, nC4, $02
smpsPSGAlterVol $01
dc.b nRst, $30
smpsJump CNZ_Jump05
; Unreachable
smpsStop
; PSG3 Data
CNZ_PSG3:
smpsPSGform $E7
dc.b nRst, $18
CNZ_Loop03:
smpsCall CNZ_Call04
smpsLoop $01, $07, CNZ_Loop03
dc.b $04, $02, $04, $02
CNZ_Loop04:
smpsCall CNZ_Call04
smpsLoop $01, $1F, CNZ_Loop04
dc.b $04, $02, $04, $02
CNZ_Loop05:
smpsCall CNZ_Call04
smpsLoop $01, $24, CNZ_Loop05
dc.b nRst, $30
smpsJump CNZ_Loop03
CNZ_Call04:
smpsPSGvoice fTone_01
dc.b nMaxPSG, $06
smpsPSGvoice fTone_02
smpsPSGAlterVol $FF
dc.b $04
smpsPSGvoice fTone_01
smpsPSGAlterVol $01
dc.b $02
smpsReturn
; DAC Data
CNZ_DAC:
dc.b dKick, $06, dKick, dKick, $04, dSnare, $02, $06
CNZ_Loop00:
dc.b dKick, $06, dSnare
smpsLoop $00, $04, CNZ_Loop00
dc.b dKick, $06, dSnare, dSnare, $04, $06, $06, dKick, $02, $06, $06, dSnare
CNZ_Loop01:
dc.b dKick, dSnare
smpsLoop $00, $1C, CNZ_Loop01
dc.b dKick, dSnare, dSnare, $04, $06, $06, dKick, $02, $06, $06, dSnare
CNZ_Loop02:
dc.b dKick, dSnare
smpsLoop $00, $20, CNZ_Loop02
dc.b dKick, dSnare, dKick, dSnare, dKick, dSnare, dSnare, $04, $06, $02, nRst, $28
dc.b dSnare, $02, $06
smpsJump CNZ_Loop00
CNZ_Voices:
; Voice $00
; $3A
; $20, $23, $60, $01, $1E, $1F, $1F, $1F, $0A, $0A, $0B, $0A
; $05, $07, $0A, $08, $A4, $85, $96, $78, $21, $25, $28, $00
smpsVcAlgorithm $02
smpsVcFeedback $07
smpsVcUnusedBits $00
smpsVcDetune $00, $06, $02, $02
smpsVcCoarseFreq $01, $00, $03, $00
smpsVcRateScale $00, $00, $00, $00
smpsVcAttackRate $1F, $1F, $1F, $1E
smpsVcAmpMod $00, $00, $00, $00
smpsVcDecayRate1 $0A, $0B, $0A, $0A
smpsVcDecayRate2 $08, $0A, $07, $05
smpsVcDecayLevel $07, $09, $08, $0A
smpsVcReleaseRate $08, $06, $05, $04
smpsVcTotalLevel $00, $28, $25, $21
; Voice $01
; $3A
; $32, $56, $32, $42, $8D, $4F, $15, $52, $06, $08, $07, $04
; $02, $00, $00, $00, $18, $18, $28, $28, $19, $20, $2A, $00
smpsVcAlgorithm $02
smpsVcFeedback $07
smpsVcUnusedBits $00
smpsVcDetune $04, $03, $05, $03
smpsVcCoarseFreq $02, $02, $06, $02
smpsVcRateScale $01, $00, $01, $02
smpsVcAttackRate $12, $15, $0F, $0D
smpsVcAmpMod $00, $00, $00, $00
smpsVcDecayRate1 $04, $07, $08, $06
smpsVcDecayRate2 $00, $00, $00, $02
smpsVcDecayLevel $02, $02, $01, $01
smpsVcReleaseRate $08, $08, $08, $08
smpsVcTotalLevel $00, $2A, $20, $19
; Voice $02
; $2C
; $61, $03, $01, $33, $5F, $94, $5F, $94, $05, $05, $05, $07
; $02, $02, $02, $02, $1F, $6F, $1F, $AF, $1E, $80, $1E, $80
smpsVcAlgorithm $04
smpsVcFeedback $05
smpsVcUnusedBits $00
smpsVcDetune $03, $00, $00, $06
smpsVcCoarseFreq $03, $01, $03, $01
smpsVcRateScale $02, $01, $02, $01
smpsVcAttackRate $14, $1F, $14, $1F
smpsVcAmpMod $00, $00, $00, $00
smpsVcDecayRate1 $07, $05, $05, $05
smpsVcDecayRate2 $02, $02, $02, $02
smpsVcDecayLevel $0A, $01, $06, $01
smpsVcReleaseRate $0F, $0F, $0F, $0F
smpsVcTotalLevel $80, $1E, $80, $1E
|
;==========================================================
; 6502 assembly template for VSCode
; Originally created in 2019 by Ingo Hinterding // awsm of Mayday
;==========================================================
;==========================================================
; LABELS
;==========================================================
; C64 Labels
BGCOLOR = $d020
BORDERCOLOR = $d021
BASIC = $0801
SCREENRAM = $0400
;==========================================================
; BASIC Header
;==========================================================
* = BASIC
!byte $0b, $08
!byte $E3 ; BASIC line number: $E2=2018 $E3=2019 etc
!byte $07, $9E
!byte '0' + entry % 10000 / 1000
!byte '0' + entry % 1000 / 100
!byte '0' + entry % 100 / 10
!byte '0' + entry % 10
!byte $00, $00, $00 ; end of basic
;==========================================================
; CODE
;==========================================================
entry
lda #$00 ; the color value
sta BGCOLOR ; change background color
sta BORDERCOLOR ; change border color
ldy #$0c ; the string "hello world!" has 12 (= $0c) characters
ldx #$00 ; start at position 0 of the string
character_loop
lda hello,x ; load character number x of the string
sta SCREENRAM,x ; save it at position x of the screen ram
inx ; increment x by 1
dey ; decrement y by 1
bne character_loop ; is y positive? then repeat
rts ; exit the program
hello !scr "hello world!" ; our string to display
|
#note: r40 (the exception handler) and r46 (the start of usermode code) must
#be specified in hex (0xwhatever)
#I just don't see any reason not to, and it makes programming the script
#much nicer to deal with...
#load exception handler
lc r40, 0x80000050
leh r40
#enable exceptions
cle
#load TLB entries
#virtual page 0 is for instructions
#virtual page 1 is for data
lc r46, 0x0000005c #usermode start address
lc r47, 1 #interrupts off
lc r48, 1 #in user mode
lc r42, 0x00000000 #denotes VPN 0
lc r43, 0x0000000d #denotes VPN 0 maps to physical page 0
#and is fetchable, readable, and valid
tlbse r0, r42 #load into entry 0
lc r42, 0x00001000 #denotes VPN 1
lc r43, 0x0000101e #denotes VPN 1 maps to physical page 1
#and is readable, writable, valid, and dirty
#(dirty to prevent taking a
#read-only exception)
tlbse r48, r42 #load into entry 1
#this last tlb entry is designed to produce a bus error
lc r44, 2 #load into TLB entry 2
lc r42, 0x3fffe000 #denotes VPN 0x3fffe
lc r43, 0x3fffe01f #map VPN 0x3fffe to page 0x3fffe
#and is readable, writable, valid, and dirty
#(dirty to prevent taking a
#read-only exception)
tlbse r44, r42
#warp to user mode
rfe r46, r47, r48
#handle exceptions
lc r49, 0xdeadbeef
halt #or rather don't =)
lc r30, 1
ex4 r30, k2, 1
trap
#@expected values
#e3 = 0x000000a0
#mode = S
#interrupts = off
#exceptions = off
#r40 = 0x80000050
#r46 = 0x0000005c
#r47 = 1
#r48 = 1
#r42 = 0x3fffe000
#r43 = 0x3fffe01f
#r44 = 2
#r49 = 0xdeadbeef
#pc = 0x8000005c
#e0 = 0x00000060
#e2 = 0x00000060
#e1 = 0x00000001
#tlb 0:
# vpn = 0x00000
# os = 0x000
# ppn = 0x00000
# at = 0x00d
#tlb 1:
# vpn = 0x00001
# os = 0x000
# ppn = 0x00001
# at = 0x01e
#tlb 2:
# vpn = 0x3fffe
# os = 0x000
# ppn = 0x3fffe
# at = 0x01f
|
; ************************************************************************************************
; ************************************************************************************************
;
; Name: sound.asm
; Purpose: Sound storage
; Created: 6th April 2021
; Author: Paul Robson (paul@robsons.org.uk)
;
; ************************************************************************************************
; ************************************************************************************************
Channels = 16 ; # of sound channels.
.section storage
LiveChannels: ; # of channels currently playing
.fill 1
ChannelTime:
.fill Channels ; # of ticks until channels goes silent if non-zero
;
; These are the values used in the SOUND command, and the 4 byte buffer that is queued.
; + 2 bytes of additional data.
;
sndPitch: ; 16 bit pitch to play, as specified in Vera Documents.
.fill 2
sndExtra:
.fill 2
;
; These are updated using the token table so the order matters.
;
sndChannel: ; channel to use ($FF find unused from top down)
.fill 1
sndTime: ; time to play (in 1/10s)
.fill 1
;
;
;
sndType: ; output type waveform 0-3, as Vera documents.
.fill 1
sndVolume: ; volume 0-63.
.fill 1
;
; Sound queue. 6 bytes per entry. Time (00 = Not used), Channel, 4 Byte Data.
; Fits into one page so 42 or fewer entries here
;
sndQueueSize = 16
sndQueue:
.fill 6*sndQueueSize+1 ; extra byte is so copy zero when deleting last element.
.send storage
.section code
; ************************************************************************************************
;
; Sound command
;
; ************************************************************************************************
CommandSound: ;; [sound]
lda #0 ; clear the default sound options
sta sndPitch
sta sndPitch+1
sta sndType
lda #$FF ; values are 255,63 are masked.
sta sndChannel
sta sndVolume
lda #5 ; default time is 0.5s
sta sndTime
_ComSoundLoop:
lda (codePtr),y ; next token
cmp #TOK_EOL ; end of line/colon do the sound
beq _CSDoSound
cmp #TKW_COLON
beq _CSDoSound
cmp #TKW_AT ; is it AT pitch ?
beq _CSSetPitch
;
ldx #3 ; look up in the tokens table
_CSCheck:
cmp _ComSoundTokens,x ; if found token update value.
beq _CSFoundToken
dex
bpl _CSCheck
iny
cmp #TKW_CLEAR ; was it sound CLEAR
bne _CSSyntax
jmp SoundReset
_CSSyntax:
.throw Syntax
;
; Found token
;
_CSFoundToken:
.pshx ; save token ID 0-3
iny ; skip it
lda #0 ; get a small int
.main_evaluatesmall
.pulx ; restore token ID
lda esInt0 ; copy value to setup memory
sta sndChannel,x
jmp _ComSoundLoop
;
; Found AT <pitch>
;
_CSSetPitch:
iny ; skip AT
lda #0 ; get an integer.
.main_evaluateint
lda esInt2 ; check range
ora esInt3
bne _CSBadValue
lda esInt0 ; copy into pitch and loop back
sta sndPitch
lda esInt1
sta sndPitch+1
jmp _ComSoundLoop
_CSBadValue:
.throw BadValue
;
; Token table, order same as data above.
;
_ComSoundTokens:
.byte TKW_TO,TKW_TIME,TKW_TYPE,TKW_STEP
;
; Make sound out of the data.
;
_CSDoSound:
ldx sndChannel ; if channel >= 16 look for channel unused.
cpx #16
bcc _CSHaveChannel
ldx #15
_CSFindChannel:
lda channelTime,x ; time is zero e.g. sound off.
beq _CSHaveChannel
dex
bpl _CSFindChannel ; try all of them
.throw Hardware ; all channels in use.
;
_CSHaveChannel:
stx sndChannel ; update channel.
lda sndTime ; get how long
beq _CSExit ; if zero then exit
lda sndVolume ; get volume, max out at 63.
cmp #64
bcc _CSHaveVolume
lda #63
_CSHaveVolume:
ora #$C0 ; both channels
sta sndExtra ; write out.
;
lda sndType ; get waveform (bits 0-1 Pulse, Sawtooth, Triangle Noise)
ror a ; rotate into position 7,6
ror a
ror a
and #$C0 ; mask other bits
ora #63 ; 50% duty cycle.
sta sndExtra+1
.pshy
.pshx ; save channel #
ldx #sndPitch & 255 ; XY = sound data
ldy #sndPitch >> 8
jsr SoundAddQueue ; add it to the queue.
;
pla ; get channel #
jsr SoundCheckQueue ; check if we can play this one now, e.g. the queue was empty.
.puly
_CSExit:
rts
.send code |
<%
import collections
import pwnlib.abi
import pwnlib.constants
import pwnlib.shellcraft
%>
<%docstring>fallocate(fd, mode, offset, length) -> str
Invokes the syscall fallocate.
See 'man 2 fallocate' for more information.
Arguments:
fd(int): fd
mode(int): mode
offset(off_t): offset
len(off_t): len
Returns:
int
</%docstring>
<%page args="fd=0, mode=0, offset=0, length=0"/>
<%
abi = pwnlib.abi.ABI.syscall()
stack = abi.stack
regs = abi.register_arguments[1:]
allregs = pwnlib.shellcraft.registers.current()
can_pushstr = []
can_pushstr_array = []
argument_names = ['fd', 'mode', 'offset', 'length']
argument_values = [fd, mode, offset, length]
# Load all of the arguments into their destination registers / stack slots.
register_arguments = dict()
stack_arguments = collections.OrderedDict()
string_arguments = dict()
dict_arguments = dict()
array_arguments = dict()
syscall_repr = []
for name, arg in zip(argument_names, argument_values):
if arg is not None:
syscall_repr.append('%s=%r' % (name, arg))
# If the argument itself (input) is a register...
if arg in allregs:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[index] = arg
# The argument is not a register. It is a string value, and we
# are expecting a string value
elif name in can_pushstr and isinstance(arg, str):
string_arguments[name] = arg
# The argument is not a register. It is a dictionary, and we are
# expecting K:V paris.
elif name in can_pushstr_array and isinstance(arg, dict):
array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()]
# The arguent is not a register. It is a list, and we are expecting
# a list of arguments.
elif name in can_pushstr_array and isinstance(arg, (list, tuple)):
array_arguments[name] = arg
# The argument is not a register, string, dict, or list.
# It could be a constant string ('O_RDONLY') for an integer argument,
# an actual integer value, or a constant.
else:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[target] = arg
# Some syscalls have different names on various architectures.
# Determine which syscall number to use for the current architecture.
for syscall in ['SYS_fallocate']:
if hasattr(pwnlib.constants, syscall):
break
else:
raise Exception("Could not locate any syscalls: %r" % syscalls)
%>
/* fallocate(${', '.join(syscall_repr)}) */
%for name, arg in string_arguments.items():
${pwnlib.shellcraft.pushstr(arg, append_null=('\x00' not in arg))}
${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)}
%endfor
%for name, arg in array_arguments.items():
${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)}
%endfor
%for name, arg in stack_arguments.items():
${pwnlib.shellcraft.push(arg)}
%endfor
${pwnlib.shellcraft.setregs(register_arguments)}
${pwnlib.shellcraft.syscall(syscall)} |
pushpc
; Code that is run once after the game has been powered on.
; Overrides the following:
; LDA.b #$81 : STA $4200
org $00802F
JSL init_hook
NOP
pullpc
init_hook:
LDA #$81 : STA $4200
JSL init_expand
%ai8()
RTL
init_expand:
LDA #$01 : STA $420D ; enable fast rom
; enters AI=8
; If user holds Start+Select, we reinitialize.
; we need some manual joypad reading
LDA #$01 : STA $4016 : STZ $4016 ; pulse controller
STZ $00 : STZ $01
LDY #$10 ; reading 16 bits
-- LDA $4016 ; if the last bit is on, carry will be set, otherwise, it won't; A is still 1
LSR
ROL $00 : ROL $01 ; roll carry from A and then from $00
DEY : BNE -- ; decrement
%a16()
LDA $00
AND #$FF00 : CMP #$3000 : BEQ .forcereset
LDA !ram_ctrl_prachack_menu : CMP #$1010 : BEQ .noforcereset
.forcereset
JSR init_initialize_all
BRA .sram_initialized
.noforcereset
LDA !ram_sram_initialized : CMP #!SRAM_VERSION : BEQ .sram_initialized
.reinitialize
JSR init_initialize
.sram_initialized
; Some features probably should be turned off after a reset
%a8()
STZ !lowram_oob_toggle
.done
JSL music_init
RTL
init_initialize_all:
!PERM_INIT
init_initialize:
!INIT_ASSEMBLY
LDA #!SRAM_VERSION : STA !ram_sram_initialized
%i16()
LDA #$0000
LDX #$00FE
.loop
STA !sram_movies, X
DEX #2 : BPL .loop
%i8()
RTS
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r14
push %r15
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x1725, %rsi
lea addresses_D_ht+0x1bb3d, %rdi
clflush (%rdi)
nop
nop
nop
nop
inc %rdx
mov $15, %rcx
rep movsb
nop
nop
nop
xor $50031, %rsi
lea addresses_normal_ht+0x1327d, %r14
inc %rdi
mov (%r14), %r15
mfence
lea addresses_D_ht+0x43d, %rsi
lea addresses_WT_ht+0xb33d, %rdi
clflush (%rdi)
nop
nop
add $11986, %r13
mov $37, %rcx
rep movsl
nop
nop
nop
nop
and $19761, %rsi
lea addresses_UC_ht+0x1cd5d, %rcx
nop
nop
nop
nop
nop
and %r13, %r13
vmovups (%rcx), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $1, %xmm2, %r15
cmp $37567, %rsi
lea addresses_WC_ht+0x833d, %r14
inc %rcx
mov (%r14), %rdi
xor $49392, %rdi
lea addresses_UC_ht+0x873d, %r14
sub $1915, %r13
movups (%r14), %xmm7
vpextrq $1, %xmm7, %rdi
nop
mfence
lea addresses_UC_ht+0x15837, %rdx
nop
nop
nop
nop
cmp $28932, %r14
mov $0x6162636465666768, %r15
movq %r15, %xmm3
vmovups %ymm3, (%rdx)
nop
nop
nop
inc %rdx
lea addresses_UC_ht+0x1bc85, %rdx
nop
nop
nop
nop
dec %rdi
movw $0x6162, (%rdx)
nop
nop
nop
add %rdx, %rdx
lea addresses_normal_ht+0x7c5d, %r15
nop
nop
nop
cmp %rdx, %rdx
mov (%r15), %rsi
nop
nop
nop
nop
nop
xor %r14, %r14
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r15
pop %r14
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r8
push %rax
push %rbp
push %rcx
push %rdx
// Load
lea addresses_WC+0x22bd, %r13
xor $39620, %rax
mov (%r13), %edx
nop
nop
cmp $21446, %r13
// Store
lea addresses_A+0xd73d, %rcx
nop
dec %rbp
mov $0x5152535455565758, %r13
movq %r13, %xmm6
movntdq %xmm6, (%rcx)
nop
nop
nop
sub $22156, %rbp
// Faulty Load
lea addresses_A+0x1233d, %rbp
nop
nop
cmp %r14, %r14
movb (%rbp), %dl
lea oracles, %rcx
and $0xff, %rdx
shlq $12, %rdx
mov (%rcx,%rdx,1), %rdx
pop %rdx
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 2, 'NT': True, 'type': 'addresses_A'}, 'OP': 'LOAD'}
{'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 16, 'NT': True, 'type': 'addresses_A'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_A'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 2, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 1, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 2, 'NT': True, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; ##########################################################################
; MACROS for using Dbshow.dll
; ##########################################################################
ShowReturn MACRO hWindow, value
LOCAL lbl
LOCAL LibName
LOCAL ProcName
jmp lbl
LibName db "Dbshow.dll",0
ProcName db "ShowReturnValue",0
lbl:
pushad
push value
push hWindow
invoke LoadLibrary,ADDR LibName
invoke GetProcAddress,eax,ADDR ProcName
call eax
popad
ENDM
; ##########################################################################
UseTitleBar MACRO hWindow, value, dType
LOCAL lbl
LOCAL LibName
LOCAL ProcName
jmp lbl
LibName db "Dbshow.dll",0
ProcName db "UseTitleBar",0
lbl:
pushad
push dType
push value
push hWindow
invoke LoadLibrary,ADDR LibName
invoke GetProcAddress,eax,ADDR ProcName
call eax
popad
ENDM
; ##########################################################################
UseStatusBar MACRO hWindow, value, dType
LOCAL lbl
LOCAL LibName
LOCAL ProcName
jmp lbl
LibName db "Dbshow.dll",0
ProcName db "UseStatusBar",0
lbl:
pushad
push dType
push value
push hWindow
invoke LoadLibrary,ADDR LibName
invoke GetProcAddress,eax,ADDR ProcName
call eax
popad
ENDM
; ##########################################################################
ShowRegisters MACRO hWindow, dType
LOCAL lbl
LOCAL LibName
LOCAL ProcName
jmp lbl
LibName db "Dbshow.dll",0
ProcName db "ShowRegisters",0
lbl:
pushad
push dType
push esp
push ebp
push edi
push esi
push edx
push ecx
push ebx
push eax
push hWindow
invoke LoadLibrary,ADDR LibName
invoke GetProcAddress,eax,ADDR ProcName
call eax
popad
ENDM
; ##########################################################################
ClockitStart MACRO
invoke GetTickCount
push eax
ENDM
; ##########################################################################
ClockitStop MACRO hWind,num
LOCAL lbl
LOCAL LibName
LOCAL ProcName
invoke GetTickCount
pop edx
sub eax, edx
jmp lbl
LibName db "Dbshow.dll",0
ProcName db "StopClockMs",0
lbl:
mov edx,num
push edx
push eax
push hWind
invoke LoadLibrary,ADDR LibName
invoke GetProcAddress,eax,ADDR ProcName
call eax
ENDM
; ##########################################################################
|
;PSOS Development Build
;https://github.com/TheBenPerson/PSOS/tree/dev
;Copyright (C) 2016 - 2017 Ben Stockett <thebenstockett@gmail.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.
[BITS 16]
jmp boot
nop
db "PSOS-dev" ;OEM identifier
dw 512 ;bytes per sector
db 1 ;sectors per cluster
dw 1 + KERNEL_SIZE ;reserved sectors
db 1 ;FATs
dw 256 ;directory entries
dw 1 + KERNEL_SIZE + FAT_SIZE + ((ENTRIES * 32) / 512) + CLUSTERS ;sectors
db 0xF0 ;media descriptor byte
dw FAT_SIZE ;sectors per FAT
dw 15 ;sectors per track
dw 2 ;heads
dd 0 ;hidden sectors
dd 0 ;sectors (large)
db 0 ;drive number
db 0 ;reserved
db 0x29 ;signature
dd 127 ;volume ID
db "PSOS-dev " ;volume label
db "FAT16 " ;filesystem
boot:
jmp 0x7C0:start ;set code segment to 0x7C0
start:
mov ax, cs
mov ds, ax ;set up data segment
mov ax, 0x50
mov ss, ax
mov sp, 0xFFFF ;set up initial stack space
mov [drive], dl ;save drive number
mov ax, KERNEL_SEGMENT
mov es, ax
mov cl, 2 ;sector offset of 2
mov al, KERNEL_SIZE ;size in sectors of kernel
xor bx, bx ;offset of zero
mov ah, 0x2
xor ch, ch
xor dh, dh
mov dl, [drive]
int 0x13 ;load sectors
jnc .longJump
;oh-no! Something went wrong
xor ah, ah
mov al, 0x3
int 0x10 ;set video mode 3
mov ah, 0x1
mov cx, 0x700
int 0x10 ;disable cursor blink
mov si, errorMsg
.loop:
mov al, [si]
cmp al, 0
je .hang
cmp al, 0xA ;check for newline
jne .continue
push ax
mov cx, 160
xor dx, dx
mov ax, bx
div cx
mov cx, 160
sub cx, dx
add bx, cx ;bx += 160 - (bx % 160)
pop ax
inc si
jmp .loop
.continue:
mov [es:bx], al
mov byte [es:bx + 1], 0x4 ;red text
inc si
add bx, 2
jmp .loop
.hang:
cli
hlt ;hang forever
.longJump:
mov ax, KERNEL_SEGMENT
mov ds, ax ;set up data segment
mov ss, ax
mov sp, 0xFFFF ;set up kernel stack space
jmp KERNEL_SEGMENT:0
errorMsg:
db "Error loading kernel.", 0xA
db "Please power off and remove boot medium.", 0xA, 0xA
db " |\ _,,,--,,_", 0xA
db " /,`.-'`' ._ \-;;,_", 0xA
db " |,4- ) )_ .;.( `'-'", 0xA
db "'---''(_/._)-'(_\_)", 0xA
db "2 tired 2 werk. come bak latr.", 0xA, 0x0
times 509 - ($ - $$) db 0
db KERNEL_SIZE
drive: dw 0xAA55
|
/*
* Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#include "Box2D/Collision/Shapes/b2PolygonShape.h"
#include <new>
b2Shape* b2PolygonShape::Clone(b2BlockAllocator* allocator) const
{
void* mem = allocator->Allocate(sizeof(b2PolygonShape));
b2PolygonShape* clone = new (mem) b2PolygonShape;
*clone = *this;
return clone;
}
void b2PolygonShape::SetAsBox(float32 hx, float32 hy)
{
m_vertexCount = 4;
m_vertices[0].Set(-hx, -hy);
m_vertices[1].Set( hx, -hy);
m_vertices[2].Set( hx, hy);
m_vertices[3].Set(-hx, hy);
m_normals[0].Set(0.0f, -1.0f);
m_normals[1].Set(1.0f, 0.0f);
m_normals[2].Set(0.0f, 1.0f);
m_normals[3].Set(-1.0f, 0.0f);
m_centroid.SetZero();
}
void b2PolygonShape::SetAsBox(float32 hx, float32 hy, const b2Vec2& center, float32 angle)
{
m_vertexCount = 4;
m_vertices[0].Set(-hx, -hy);
m_vertices[1].Set( hx, -hy);
m_vertices[2].Set( hx, hy);
m_vertices[3].Set(-hx, hy);
m_normals[0].Set(0.0f, -1.0f);
m_normals[1].Set(1.0f, 0.0f);
m_normals[2].Set(0.0f, 1.0f);
m_normals[3].Set(-1.0f, 0.0f);
m_centroid = center;
b2Transform xf;
xf.position = center;
xf.R.Set(angle);
// Transform vertices and normals.
for (int32 i = 0; i < m_vertexCount; ++i)
{
m_vertices[i] = b2Mul(xf, m_vertices[i]);
m_normals[i] = b2Mul(xf.R, m_normals[i]);
}
}
void b2PolygonShape::SetAsEdge(const b2Vec2& v1, const b2Vec2& v2)
{
m_vertexCount = 2;
m_vertices[0] = v1;
m_vertices[1] = v2;
m_centroid = 0.5f * (v1 + v2);
m_normals[0] = b2Cross(v2 - v1, 1.0f);
m_normals[0].Normalize();
m_normals[1] = -m_normals[0];
}
static b2Vec2 ComputeCentroid(const b2Vec2* vs, int32 count)
{
b2Assert(count >= 2);
b2Vec2 c; c.Set(0.0f, 0.0f);
float32 area = 0.0f;
if (count == 2)
{
c = 0.5f * (vs[0] + vs[1]);
return c;
}
// pRef is the reference point for forming triangles.
// It's location doesn't change the result (except for rounding error).
b2Vec2 pRef(0.0f, 0.0f);
#if 0
// This code would put the reference point inside the polygon.
for (int32 i = 0; i < count; ++i)
{
pRef += vs[i];
}
pRef *= 1.0f / count;
#endif
const float32 inv3 = 1.0f / 3.0f;
for (int32 i = 0; i < count; ++i)
{
// Triangle vertices.
b2Vec2 p1 = pRef;
b2Vec2 p2 = vs[i];
b2Vec2 p3 = i + 1 < count ? vs[i+1] : vs[0];
b2Vec2 e1 = p2 - p1;
b2Vec2 e2 = p3 - p1;
float32 D = b2Cross(e1, e2);
float32 triangleArea = 0.5f * D;
area += triangleArea;
// Area weighted centroid
c += triangleArea * inv3 * (p1 + p2 + p3);
}
// Centroid
b2Assert(area > b2_epsilon);
c *= 1.0f / area;
return c;
}
void b2PolygonShape::Set(const b2Vec2* vertices, int32 count)
{
b2Assert(2 <= count && count <= b2_maxPolygonVertices);
m_vertexCount = count;
// Copy vertices.
for (int32 i = 0; i < m_vertexCount; ++i)
{
m_vertices[i] = vertices[i];
}
// Compute normals. Ensure the edges have non-zero length.
for (int32 i = 0; i < m_vertexCount; ++i)
{
int32 i1 = i;
int32 i2 = i + 1 < m_vertexCount ? i + 1 : 0;
b2Vec2 edge = m_vertices[i2] - m_vertices[i1];
b2Assert(edge.LengthSquared() > b2_epsilon * b2_epsilon);
m_normals[i] = b2Cross(edge, 1.0f);
m_normals[i].Normalize();
}
#ifdef _DEBUG
// Ensure the polygon is convex and the interior
// is to the left of each edge.
for (int32 i = 0; i < m_vertexCount; ++i)
{
int32 i1 = i;
int32 i2 = i + 1 < m_vertexCount ? i + 1 : 0;
b2Vec2 edge = m_vertices[i2] - m_vertices[i1];
for (int32 j = 0; j < m_vertexCount; ++j)
{
// Don't check vertices on the current edge.
if (j == i1 || j == i2)
{
continue;
}
b2Vec2 r = m_vertices[j] - m_vertices[i1];
// Your polygon is non-convex (it has an indentation) or
// has colinear edges.
float32 s = b2Cross(edge, r);
b2Assert(s > 0.0f);
}
}
#endif
// Compute the polygon centroid.
m_centroid = ComputeCentroid(m_vertices, m_vertexCount);
}
bool b2PolygonShape::TestPoint(const b2Transform& xf, const b2Vec2& p) const
{
b2Vec2 pLocal = b2MulT(xf.R, p - xf.position);
for (int32 i = 0; i < m_vertexCount; ++i)
{
float32 dot = b2Dot(m_normals[i], pLocal - m_vertices[i]);
if (dot > 0.0f)
{
return false;
}
}
return true;
}
bool b2PolygonShape::RayCast(b2RayCastOutput* output, const b2RayCastInput& input, const b2Transform& xf) const
{
// Put the ray into the polygon's frame of reference.
b2Vec2 p1 = b2MulT(xf.R, input.p1 - xf.position);
b2Vec2 p2 = b2MulT(xf.R, input.p2 - xf.position);
b2Vec2 d = p2 - p1;
if (m_vertexCount == 2)
{
b2Vec2 v1 = m_vertices[0];
b2Vec2 v2 = m_vertices[1];
b2Vec2 normal = m_normals[0];
// q = p1 + t * d
// dot(normal, q - v1) = 0
// dot(normal, p1 - v1) + t * dot(normal, d) = 0
float32 numerator = b2Dot(normal, v1 - p1);
float32 denominator = b2Dot(normal, d);
if (denominator == 0.0f)
{
return false;
}
float32 t = numerator / denominator;
if (t < 0.0f || 1.0f < t)
{
return false;
}
b2Vec2 q = p1 + t * d;
// q = v1 + s * r
// s = dot(q - v1, r) / dot(r, r)
b2Vec2 r = v2 - v1;
float32 rr = b2Dot(r, r);
if (rr == 0.0f)
{
return false;
}
float32 s = b2Dot(q - v1, r) / rr;
if (s < 0.0f || 1.0f < s)
{
return false;
}
output->fraction = t;
if (numerator > 0.0f)
{
output->normal = -normal;
}
else
{
output->normal = normal;
}
return true;
}
else
{
float32 lower = 0.0f, upper = input.maxFraction;
int32 index = -1;
for (int32 i = 0; i < m_vertexCount; ++i)
{
// p = p1 + a * d
// dot(normal, p - v) = 0
// dot(normal, p1 - v) + a * dot(normal, d) = 0
float32 numerator = b2Dot(m_normals[i], m_vertices[i] - p1);
float32 denominator = b2Dot(m_normals[i], d);
if (denominator == 0.0f)
{
if (numerator < 0.0f)
{
return false;
}
}
else
{
// Note: we want this predicate without division:
// lower < numerator / denominator, where denominator < 0
// Since denominator < 0, we have to flip the inequality:
// lower < numerator / denominator <==> denominator * lower > numerator.
if (denominator < 0.0f && numerator < lower * denominator)
{
// Increase lower.
// The segment enters this half-space.
lower = numerator / denominator;
index = i;
}
else if (denominator > 0.0f && numerator < upper * denominator)
{
// Decrease upper.
// The segment exits this half-space.
upper = numerator / denominator;
}
}
// The use of epsilon here causes the assert on lower to trip
// in some cases. Apparently the use of epsilon was to make edge
// shapes work, but now those are handled separately.
//if (upper < lower - b2_epsilon)
if (upper < lower)
{
return false;
}
}
b2Assert(0.0f <= lower && lower <= input.maxFraction);
if (index >= 0)
{
output->fraction = lower;
output->normal = b2Mul(xf.R, m_normals[index]);
return true;
}
}
return false;
}
void b2PolygonShape::ComputeAABB(b2AABB* aabb, const b2Transform& xf) const
{
b2Vec2 lower = b2Mul(xf, m_vertices[0]);
b2Vec2 upper = lower;
for (int32 i = 1; i < m_vertexCount; ++i)
{
b2Vec2 v = b2Mul(xf, m_vertices[i]);
lower = b2Min(lower, v);
upper = b2Max(upper, v);
}
b2Vec2 r(m_radius, m_radius);
aabb->lowerBound = lower - r;
aabb->upperBound = upper + r;
}
void b2PolygonShape::ComputeMass(b2MassData* massData, float32 density) const
{
// Polygon mass, centroid, and inertia.
// Let rho be the polygon density in mass per unit area.
// Then:
// mass = rho * int(dA)
// centroid.x = (1/mass) * rho * int(x * dA)
// centroid.y = (1/mass) * rho * int(y * dA)
// I = rho * int((x*x + y*y) * dA)
//
// We can compute these integrals by summing all the integrals
// for each triangle of the polygon. To evaluate the integral
// for a single triangle, we make a change of variables to
// the (u,v) coordinates of the triangle:
// x = x0 + e1x * u + e2x * v
// y = y0 + e1y * u + e2y * v
// where 0 <= u && 0 <= v && u + v <= 1.
//
// We integrate u from [0,1-v] and then v from [0,1].
// We also need to use the Jacobian of the transformation:
// D = cross(e1, e2)
//
// Simplification: triangle centroid = (1/3) * (p1 + p2 + p3)
//
// The rest of the derivation is handled by computer algebra.
b2Assert(m_vertexCount >= 2);
// A line segment has zero mass.
if (m_vertexCount == 2)
{
massData->center = 0.5f * (m_vertices[0] + m_vertices[1]);
massData->mass = 0.0f;
massData->I = 0.0f;
return;
}
b2Vec2 center; center.Set(0.0f, 0.0f);
float32 area = 0.0f;
float32 I = 0.0f;
// pRef is the reference point for forming triangles.
// It's location doesn't change the result (except for rounding error).
b2Vec2 pRef(0.0f, 0.0f);
#if 0
// This code would put the reference point inside the polygon.
for (int32 i = 0; i < m_vertexCount; ++i)
{
pRef += m_vertices[i];
}
pRef *= 1.0f / count;
#endif
const float32 k_inv3 = 1.0f / 3.0f;
for (int32 i = 0; i < m_vertexCount; ++i)
{
// Triangle vertices.
b2Vec2 p1 = pRef;
b2Vec2 p2 = m_vertices[i];
b2Vec2 p3 = i + 1 < m_vertexCount ? m_vertices[i+1] : m_vertices[0];
b2Vec2 e1 = p2 - p1;
b2Vec2 e2 = p3 - p1;
float32 D = b2Cross(e1, e2);
float32 triangleArea = 0.5f * D;
area += triangleArea;
// Area weighted centroid
center += triangleArea * k_inv3 * (p1 + p2 + p3);
float32 px = p1.x, py = p1.y;
float32 ex1 = e1.x, ey1 = e1.y;
float32 ex2 = e2.x, ey2 = e2.y;
float32 intx2 = k_inv3 * (0.25f * (ex1*ex1 + ex2*ex1 + ex2*ex2) + (px*ex1 + px*ex2)) + 0.5f*px*px;
float32 inty2 = k_inv3 * (0.25f * (ey1*ey1 + ey2*ey1 + ey2*ey2) + (py*ey1 + py*ey2)) + 0.5f*py*py;
I += D * (intx2 + inty2);
}
// Total mass
massData->mass = density * area;
// Center of mass
b2Assert(area > b2_epsilon);
center *= 1.0f / area;
massData->center = center;
// Inertia tensor relative to the local origin.
massData->I = density * I;
}
|
SECTION rodata_font_fzx
PUBLIC _ff_dkud2_Eclipse
_ff_dkud2_Eclipse:
BINARY "font/fzx/fonts/dkud2/Eclipse/eclipse.fzx"
|
; A250480: a(1) = 0, and for n > 1: if n is a prime, a(n) = n, otherwise a(n) = A020639(n) - 1, where A020639(n) gives the least prime dividing n.
; 0,2,3,1,5,1,7,1,2,1,11,1,13,1,2,1,17,1,19,1,2,1,23,1,4,1,2,1,29,1,31,1,2,1,4,1,37,1,2,1,41,1,43,1,2,1,47,1,6,1,2,1,53,1,4,1,2,1,59,1,61,1,2,1,4,1,67,1,2,1,71,1,73,1,2,1,6,1,79,1,2,1,83,1,4,1,2,1,89,1,6,1,2,1,4,1,97,1,2,1
mov $5,2
mov $6,$0
lpb $5
mov $0,$6
mov $3,0
sub $5,1
add $0,$5
sub $0,1
lpb $0
sub $0,1
mov $2,$0
max $2,0
seq $2,251758 ; Let n>=2 be a positive integer with divisors 1 = d_1 < d_2 < ... < d_k = n, and s = d_1*d_2 + d_2*d_3 + ... + d_(k-1)*d_k. The sequence lists the values a(n) = floor(n^2/s).
add $3,$2
lpe
mov $4,$5
mul $4,$3
add $1,$4
mov $7,$3
lpe
min $6,1
mul $6,$7
sub $1,$6
mov $0,$1
|
%define safe_copy_memory _ZN6kernel16safe_copy_memoryEPKvPvm
%define length_of_user_string _ZN6kernel21length_of_user_stringEPKv
%define copy_until_null_or_n_from_user _ZN6kernel30copy_until_null_or_n_from_userEPKvPvm
; Safe function ABI:
; During a safe operation E(R)BX contains the address to go to in case of a fault,
; E(R)IP gets set to this address in case of a fault by the memory manager.
section .safe_operations
; Copies exactly bytes into dst, returns 1 if success or 0 if faulted.
; bool safe_copy_memory(void* src, void* dst, size_t bytes)
global safe_copy_memory
safe_copy_memory:
push rbx
; swap src & dst for movsb
xchg rdi, rsi
; third parameter to rcx
mov rcx, rdx
mov rbx, .on_access_violation
rep movsb
mov rax, 1
jmp .done
.on_access_violation:
mov rax, 0
.done:
pop rbx
ret
; returns string length including the null terminator, or 0 if faulted
; size_t length_of_user_string(void* str)
global length_of_user_string
length_of_user_string:
; preserve non-scratch
push rbx
mov rbx, .on_access_violation
mov rax, 0 ; null terminator
mov rcx, 0xFFFFFFFFFFFFFFFF
repnz scasb
mov rax, 0xFFFFFFFFFFFFFFFF
sub rax, rcx
jmp .done
.on_access_violation:
mov rax, 0
.done:
pop rbx
ret
; Copies up to max_length or up to the null byte to the dst from src.
; Returns the number of bytes copied including the null byte, or 0 if faulted.
; size_t copy_until_null_or_n_from_user(void* src, void* dst, size_t max_length)
global copy_until_null_or_n_from_user
copy_until_null_or_n_from_user:
; preserve non-scratch
push rbx
mov rbx, .on_access_violation
xor rax, rax
.next:
; if (length == 0) return
or rdx, rdx
jz .done
; char c = *src
mov cl, byte [rdi]
; *dst = c
mov [rsi], cl
; bytes_copied++
inc rax
; if (c == '\0') return
or cl, cl
jz .done
; src++, dst++, length--
inc rdi
inc rsi
dec rdx
jmp .next
.on_access_violation:
mov rax, 0
.done:
pop rbx
ret
|
; A213673: (n^2 - A000695(n))/4.
; 0,0,0,1,0,2,4,7,0,4,8,13,16,22,28,35,0,8,16,25,32,42,52,63,64,76,88,101,112,126,140,155,0,16,32,49,64,82,100,119,128,148,168,189,208,230,252,275,256,280,304,329,352,378,404,431,448,476,504,533,560,590,620,651,0,32,64,97,128,162,196,231,256,292,328,365,400,438,476,515,512,552,592,633,672,714,756,799,832,876,920,965,1008,1054,1100,1147,1024,1072,1120,1169
lpb $0
seq $2,17328 ; a(n) = (10*n + 4)^12.
gcd $2,$0
sub $0,$2
mul $2,$0
add $3,$2
lpe
mov $0,$3
div $0,2
|
db 0 ; species ID placeholder
db 75, 75, 55, 30, 105, 85
; hp atk def spd sat sdf
db GRASS, GRASS ; type
db 120 ; catch rate
db 146 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F0 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/sunflora/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_SLOW ; growth rate
dn EGG_PLANT, EGG_PLANT ; egg groups
; tm/hm learnset
tmhm CURSE, TOXIC, HIDDEN_POWER, SUNNY_DAY, SWEET_SCENT, SNORE, HYPER_BEAM, PROTECT, GIGA_DRAIN, ENDURE, FRUSTRATION, SOLARBEAM, RETURN, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, REST, ATTRACT, CUT, FLASH
; end
|
dnl PowerPC-32 mpn_sublsh1_n -- rp[] = up[] - (vp[] << 1)
dnl Copyright 2003, 2005 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU Lesser General Public License as published
dnl by the Free Software Foundation; either version 2.1 of the License, or (at
dnl your option) any later version.
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
dnl License for more details.
dnl You should have received a copy of the GNU Lesser General Public License
dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write
dnl to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
dnl Boston, MA 02110-1301, USA.
include(`../config.m4')
C cycles/limb
C 603e: ?
C 604e: 4.0
C 75x (G3): 5.0
C 7400,7410 (G4): 5.0
C 744x,745x (G4+): 5.0
C power4/ppc970: 4.25
C power5: 5.0
C INPUT PARAMETERS
C rp r3
C up r4
C vp r5
C n r6
define(`rp',`r3')
define(`up',`r4')
define(`vp',`r5')
define(`s0',`r6')
define(`s1',`r7')
define(`u0',`r8')
define(`v0',`r10')
define(`v1',`r11')
ASM_START()
PROLOGUE(mpn_sublsh1_n)
mtctr r6 C copy n in ctr
lwz v0, 0(vp) C load v limb
lwz u0, 0(up) C load u limb
addic up, up, -4 C update up; set cy
addi rp, rp, -4 C update rp
slwi s1, v0, 1
bdz .Lend C If done, skip loop
.Loop: lwz v1, 4(vp) C load v limb
subfe s1, s1, u0 C add limbs with cy, set cy
srwi s0, v0, 31 C shift down previous v limb
stw s1, 4(rp) C store result limb
lwzu u0, 8(up) C load u limb and update up
rlwimi s0, v1, 1, 0,30 C left shift v limb and merge with prev v limb
bdz .Lexit C decrement ctr and exit if done
lwzu v0, 8(vp) C load v limb and update vp
subfe s0, s0, u0 C add limbs with cy, set cy
srwi s1, v1, 31 C shift down previous v limb
stwu s0, 8(rp) C store result limb and update rp
lwz u0, 4(up) C load u limb
rlwimi s1, v0, 1, 0,30 C left shift v limb and merge with prev v limb
bdnz .Loop C decrement ctr and loop back
.Lend: subfe r7, s1, u0
srwi r4, v0, 31
stw r7, 4(rp) C store last result limb
subfze r3, r4
neg r3, r3
blr
.Lexit: subfe r7, s0, u0
srwi r4, v1, 31
stw r7, 8(rp) C store last result limb
subfze r3, r4
neg r3, r3
blr
EPILOGUE()
|
//===-- ValueSymbolTable.cpp - Implement the ValueSymbolTable class -------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the ValueSymbolTable class for the IR library.
//
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "valuesymtab"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
// Class destructor
ValueSymbolTable::~ValueSymbolTable() {
#ifndef NDEBUG // Only do this in -g mode...
for (iterator VI = vmap.begin(), VE = vmap.end(); VI != VE; ++VI)
dbgs() << "Value still in symbol table! Type = '"
<< *VI->getValue()->getType() << "' Name = '"
<< VI->getKeyData() << "'\n";
assert(vmap.empty() && "Values remain in symbol table!");
#endif
}
// Insert a value into the symbol table with the specified name...
//
void ValueSymbolTable::reinsertValue(Value* V) {
assert(V->hasName() && "Can't insert nameless Value into symbol table");
// Try inserting the name, assuming it won't conflict.
if (vmap.insert(V->Name)) {
//DEBUG(dbgs() << " Inserted value: " << V->Name << ": " << *V << "\n");
return;
}
// Otherwise, there is a naming conflict. Rename this value.
SmallString<256> UniqueName(V->getName().begin(), V->getName().end());
// The name is too already used, just free it so we can allocate a new name.
V->Name->Destroy();
unsigned BaseSize = UniqueName.size();
while (1) {
// Trim any suffix off and append the next number.
UniqueName.resize(BaseSize);
raw_svector_ostream(UniqueName) << ++LastUnique;
// Try insert the vmap entry with this suffix.
ValueName &NewName = vmap.GetOrCreateValue(UniqueName);
if (NewName.getValue() == 0) {
// Newly inserted name. Success!
NewName.setValue(V);
V->Name = &NewName;
//DEBUG(dbgs() << " Inserted value: " << UniqueName << ": " << *V << "\n");
return;
}
}
}
void ValueSymbolTable::removeValueName(ValueName *V) {
//DEBUG(dbgs() << " Removing Value: " << V->getKeyData() << "\n");
// Remove the value from the symbol table.
vmap.remove(V);
}
/// createValueName - This method attempts to create a value name and insert
/// it into the symbol table with the specified name. If it conflicts, it
/// auto-renames the name and returns that instead.
ValueName *ValueSymbolTable::createValueName(StringRef Name, Value *V) {
// In the common case, the name is not already in the symbol table.
ValueName &Entry = vmap.GetOrCreateValue(Name);
if (Entry.getValue() == 0) {
Entry.setValue(V);
//DEBUG(dbgs() << " Inserted value: " << Entry.getKeyData() << ": "
// << *V << "\n");
return &Entry;
}
// Otherwise, there is a naming conflict. Rename this value.
SmallString<256> UniqueName(Name.begin(), Name.end());
while (1) {
// Trim any suffix off and append the next number.
UniqueName.resize(Name.size());
raw_svector_ostream(UniqueName) << ++LastUnique;
// Try insert the vmap entry with this suffix.
ValueName &NewName = vmap.GetOrCreateValue(UniqueName);
if (NewName.getValue() == 0) {
// Newly inserted name. Success!
NewName.setValue(V);
//DEBUG(dbgs() << " Inserted value: " << UniqueName << ": " << *V << "\n");
return &NewName;
}
}
}
// dump - print out the symbol table
//
void ValueSymbolTable::dump() const {
//DEBUG(dbgs() << "ValueSymbolTable:\n");
for (const_iterator I = begin(), E = end(); I != E; ++I) {
//DEBUG(dbgs() << " '" << I->getKeyData() << "' = ");
I->getValue()->dump();
//DEBUG(dbgs() << "\n");
}
}
|
org 24100
load_1:
ld hl, loader_table_genesis
ld (loader_table), hl
ld hl, genesis_str
ld (loader_file),hl
start:
ld b, 7 ; RAM 7, ROM 3 (+3DOS)
call setrambank
deact_ramdisk:
ld hl, $0000
ld de, $0000
call DOS_EST_1346
JP NC, 0 ; reset if failed
ld hl, (loader_file) ;
ld bc, $0001 ; File handle 0, exclusive read
ld de, $0002 ; Open, place pointer after header
call DOS_OPEN ; open file
jp nc, 0 ; reset if open failed (change into something better!!!)
start_load: ld hl, (loader_table)
ld b, (hl) ; b==iteratons
inc hl
load_loop: push bc
ld a, (hl)
ld ixl, a
inc hl
ld a, (hl)
ld ixh, a
inc hl ; ix==load address, hl== address of size
ld e, (hl)
inc hl
ld d, (hl)
inc hl ; ix==load address, hl== start of store address, de == length
ld a, (hl)
ld (destination_address), a
inc hl
ld a, (hl) ; destination_address ==store address
ld (destination_address+1), a
inc hl
ld c, (hl) ; C == RAM BANK & compressed
push hl
ld a,ixh
ld h, a
ld a,ixl
ld l, a
push ix
push de ; save for later
push bc
ld bc, $0000 ; b=file descriptor 0, load to RAM BANK 0
call DOS_READ ; read bytes
;jp nc, 0 ; reset if read failed (change into something better!!!)
; check for errors!!!!!
pop bc
pop de
pop ix ; hl still in the stack
; pop hl
push bc
ld a, c
and $07
ld b, a
call setrambank ; set RAM BANK
pop bc
ld a, c
and $80
jr z, not_compressed
compressed: di
ld de, (destination_address) ; de = destination address
push ix
pop hl ; hl = source address
push iy
call depack ; call depacker
pop iy
jr continue_loop_ei
not_compressed: ; block is not compressed
push ix
push de
pop bc ; bc = length
pop hl ; hl = source address
ld de, (destination_address) ; de = dest address
ldir ; just copy!
continue_loop_ei:
ei
continue_loop: ld b, $07
call setrambank ; set the RAM BANK back to 7 (+3DOS)
pop hl ; get the HL pointer back!
inc hl ; and point to the next block
pop bc ; get the counter back!
djnz load_loop
ld e, (hl)
inc hl
ld d, (hl) ; get the execution address in de
push de
close_file:
ld b, 0
call DOS_CLOSE ; close file
;jp nc, 0 ; reset if close failed (change into something better!!!)
call DOS_MOTOR_OFF ; disconnect drive motor
set_ram_paging:
ld b, $10 ; RAM 0, ROM 2 (48k BASIC)
call setrambank
launch_program: pop hl ; get the execution address
LD IY, 5C3Ah ; re-establish the IY pointer (must be done!)
jp (hl) ; and run!
; INPUT: B: page to set
setrambank:
di
ld A, ($5B5C)
and $E8
or b
ld BC, $7FFD
ld ($5b5c), a ; save in the BASIC variable
out (c), a
ei
ret
; DEPACKER
depack: ld ixl,128
apbranch1: ldi
aploop0: ld ixh,1 ;LWM = 0
aploop: call ap_getbit
jr nc,apbranch1
call ap_getbit
jr nc,apbranch2
call ap_getbit
jr nc,apbranch3
ld bc,16 ;get an offset
apget4bits: call ap_getbit
rl c
jr nc,apget4bits
jr nz,apbranch4
ld a,b
apwritebyte: ld (de),a ;write a 0
inc de
jr aploop0
apbranch4: and a
ex de,hl ;write a previous byte (1-15 away from dest)
sbc hl,bc
ld a,(hl)
add hl,bc
ex de,hl
jr apwritebyte
apbranch3: ld c,(hl) ;use 7 bit offset, length = 2 or 3
inc hl
rr c
ret z ;if a zero is encountered here, it's EOF
ld a,2
ld b,0
adc a,b
push hl
ld iyh,b
ld iyl,c
ld h,d
ld l,e
sbc hl,bc
ld c,a
jr ap_finishup2
apbranch2: call ap_getgamma ;use a gamma code * 256 for offset, another gamma code for length
dec c
ld a,c
sub ixh
jr z,ap_r0_gamma ;if gamma code is 2, use old r0 offset,
dec a
;do I even need this code?
;bc=bc*256+(hl), lazy 16bit way
ld b,a
ld c,(hl)
inc hl
ld iyh,b
ld iyl,c
push bc
call ap_getgamma
ex (sp),hl ;bc = len, hl=offs
push de
ex de,hl
ld a,4
cp d
jr nc,apskip2
inc bc
or a
apskip2: ld hl,127
sbc hl,de
jr c,apskip3
inc bc
inc bc
apskip3: pop hl ;bc = len, de = offs, hl=junk
push hl
or a
ap_finishup: sbc hl,de
pop de ;hl=dest-offs, bc=len, de = dest
ap_finishup2: ldir
pop hl
ld ixh,b
jr aploop
ap_r0_gamma: call ap_getgamma ;and a new gamma code for length
push hl
push de
ex de,hl
ld d,iyh
ld e,iyl
jr ap_finishup
ap_getbit: ld a,ixl
add a,a
ld ixl,a
ret nz
ld a,(hl)
inc hl
rla
ld ixl,a
ret
ap_getgamma: ld bc,1
ap_getgammaloop:call ap_getbit
rl c
rl b
call ap_getbit
jr c,ap_getgammaloop
ret
DOS_EST_1346 equ $13F
DOS_OPEN equ $106
DOS_READ equ $112
DOS_CLOSE equ $109
DOS_MOTOR_OFF equ $19c
loader_table dw 0
loader_file dw 0
destination_address dw 0
genesis_str db "GENESIS.BIN",$ff
loader_table_genesis:
db 8 ; 8 entries
dw 32768 ; load at 32768
dw 5052 ; load 3827 bytes (loading.bin)
dw 16384 ; after loading, copy to address 16384 (screen)
db $80 ; RAM Bank 0, compressed
dw 32768
dw 4194 ; load 1853 bytes (sprites.bin)
dw 51200 ; after loading, copy to 51200
db $81 ; RAM Bank 1, not compressed
dw 32768
dw 11473 ; load 9097 bytes (ram3.bin)
dw 49152 ; after loading, copy to 49152
db $03 ; RAM Bank 3, not compressed
dw 32768
dw 13531 ; load 9097 bytes (ram4.bin)
dw 49152 ; after loading, copy to 49152
db $04 ; RAM Bank 4, not compressed
dw 32768
dw 8668 ; load 9097 bytes (ram0.bin)
dw 49152 ; after loading, copy to 49152
db $80 ; RAM Bank 0, compressed
dw 32768
dw 8474 ; load 9097 bytes (ram6.bin)
dw 49152 ; after loading, copy to 49152
db $86 ; RAM Bank 6, compressed
dw 24600
dw 8149 ; load 9097 bytes (test.bin)
dw 24600 ; after loading, do not copy
db $00 ; RAM Bank 0, not compressed
dw 33025
dw 2263 ; load 9097 bytes (engine.bin)
dw 33025 ; after loading, do not copy
db $00 ; RAM Bank 0, not compressed
dw 24600 ; randomize usr 24600
|
#include <dray/dray.hpp>
#include <dray/io/blueprint_reader.hpp>
#include <dray/utils/png_encoder.hpp>
#ifdef MPI_ENABLED
#include <mpi.h>
#endif
int main (int argc, char *argv[])
{
#ifdef MPI_ENABLED
MPI_Init(nullptr, nullptr);
MPI_Comm comm = MPI_COMM_WORLD;
dray::dray::mpi_comm(MPI_Comm_c2f(comm));
#endif
std::string config_file = "";
if (argc != 2)
{
std::cout << "Missing configure file name\n";
exit (1);
}
config_file = argv[1];
conduit::Node options;
options.load(config_file,"yaml");
if(dray::dray::mpi_rank() == 0)
{
options.print();
}
if(!options.has_path("root_file"))
{
if(dray::dray::mpi_rank() == 0)
{
std::cout<<"Missing root file\n";
}
exit(1);
}
if(!options.has_path("axis"))
{
if(dray::dray::mpi_rank() == 0)
{
std::cout<<"Missing axis\n";
}
exit(1);
}
if(!options.has_path("direction"))
{
if(dray::dray::mpi_rank() == 0)
{
std::cout<<"Missing direction\n";
}
exit(1);
}
if(!options.has_path("location"))
{
if(dray::dray::mpi_rank() == 0)
{
std::cout<<"Missing locaton\n";
}
exit(1);
}
int axis = options["axis"].to_int32();
if(axis < 0 || axis > 2)
{
if(dray::dray::mpi_rank() == 0)
{
std::cout<<"Bad axis "<<axis<<"\n";
}
exit(1);
}
int direction = options["direction"].to_int32();;
double location = options["location"].to_float64();
std::string root_file = options["root_file"].as_string();
conduit::Node dataset;
dray::BlueprintReader::load_blueprint(root_file, dataset);
conduit::Node chopped;
const int domains = dataset.number_of_children();
for(int i = 0; i < domains; ++i)
{
conduit::Node &dom = dataset.child(i);
//if(i == 0) dom.print();
conduit::Node &coords = dom["coordsets"].child(0);
if(coords["type"].as_string() != "explicit")
{
std::cout<<"only explicit coordinates supported\n";
}
const int total_size = coords["values/x"].dtype().number_of_elements();;
conduit::float64_array array;
if(axis == 0)
{
array = coords["values/x"].value();
}
else if(axis == 1)
{
array = coords["values/y"].value();
}
else
{
array = coords["values/z"].value();
}
double min_v = 1e32;
double max_v = -1e32;
for(int i = 0; i < total_size; ++i)
{
double val = array[i];
min_v = std::min(min_v,val);
max_v = std::max(max_v,val);
}
bool keep = true;
if(direction < 0 && max_v > location)
{
keep = false;
}
if(direction > 0 && min_v < location)
{
keep = false;
}
if(keep)
{
chopped.append().set_external(dom);
}
}
// this needs to be a multi-domain data set
dray::BlueprintReader::save_blueprint("chopped",chopped);
#ifdef MPI_ENABLED
MPI_Finalize();
#endif
}
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: textSelectManager.asm
AUTHOR: John Wedgwood, Apr 17, 1992
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
John 4/17/92 Initial revision
DESCRIPTION:
Manager file for the TextSelect module.
$Id: textselectManager.asm,v 1.1 97/04/07 11:20:07 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;-----------------------------------------------------------------------------
; Include common definitions
;-----------------------------------------------------------------------------
include textGeode.def
include texttext.def
include textstorage.def
include textssp.def
include textattr.def
include textselect.def
include textregion.def
include texttrans.def
include textline.def
include textundo.def
include Internal/im.def
ifdef USE_FEP
include Internal/fepDr.def
endif
include system.def
;-----------------------------------------------------------------------------
; Include definitions for this module
;-----------------------------------------------------------------------------
include tslConstant.def
;-----------------------------------------------------------------------------
; Include variables and tables for this module
;-----------------------------------------------------------------------------
include tslVariables.asm
include tslMain.asm
include tslMisc.asm
include tslUtils.asm
include tslMethodMouse.asm
include tslMethodSelect.asm
include tslMethodFocus.asm
include tslMethodCursor.asm
include tslInvert.asm
include tslCursor.asm
include tslKbdShortcuts.asm
|
;
; (c) Copyright 2021 by Tobias Bindhammer. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
; * The name of its author may not be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> 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.
;
!convtab pet
!cpu 6510
!src "music.inc"
!src "config.inc"
!src "constants.inc"
.CHECK_EVEN = 1
!if CONFIG_LOADER = 1 {
;loader zp-addresses
.filenum = CONFIG_ZP_ADDR + 0
.barrier = .filenum
!if CONFIG_DECOMP = 0 {
bitfire_load_addr_lo = .filenum ;in case of no loadcompd, store the hi- and lobyte of loadaddress separatedly
bitfire_load_addr_hi = .filenum + 1
} else {
bitfire_load_addr_lo = .lz_src + 0
bitfire_load_addr_hi = .lz_src + 1
}
!if CONFIG_DEBUG = 1 {
bitfire_errors = CONFIG_ZP_ADDR + 1
}
}
!if CONFIG_DECOMP = 1 {
.lz_bits = CONFIG_ZP_ADDR + 1 + CONFIG_DEBUG
.lz_dst = CONFIG_ZP_ADDR + 2 + CONFIG_DEBUG
.lz_src = CONFIG_ZP_ADDR + 4 + CONFIG_DEBUG
.lz_len_hi = CONFIG_ZP_ADDR + 6 + CONFIG_DEBUG
}
bitfire_install_ = CONFIG_INSTALLER_ADDR ;define that label here, as we only aggregate labels from this file into loader_*.inc
* = CONFIG_RESIDENT_ADDR
!if CONFIG_FRAMEWORK = 1 & CONFIG_FRAMEWORK_FRAMECOUNTER = 1 {
link_frame_count
!word 0
}
!if CONFIG_NMI_GAPS = 1 {
!align 255,2
.lz_gap1
nop
nop
nop
nop
nop
nop
}
!if CONFIG_AUTODETECT = 1 {
link_chip_types
link_sid_type ;%00000001 ;bit set = new, bit cleared = old
link_cia1_type ;%00000010
link_cia2_type ;%00000100
!byte $00
}
!if CONFIG_FRAMEWORK = 1 {
!if CONFIG_FRAMEWORK_BASEIRQ = 1 {
link_player
pha
tya
pha
txa
pha
inc $01 ;should be save with $01 == $34/$35, except when music is @ >= $e000
!if CONFIG_FRAMEWORK_MUSIC_NMI = 1 {
lda $dd0d
} else {
dec $d019
}
jsr link_music_play
dec $01
pla
tax
pla
tay
pla
rti
}
link_music_play
!if CONFIG_FRAMEWORK_FRAMECOUNTER = 1 {
inc link_frame_count + 0
bne +
inc link_frame_count + 1
+
link_music_addr = * + 1
jmp link_music_play_side1
}
;this is the music play hook for all parts that they should call instead of for e.g. jsr $1003, it has a variable music location to be called
;and advances the frame counter if needed
;those calls could be a macro, but they are handy to be jumped to so loading happens while having all mem free, and code is entered afterwards
; !if CONFIG_DECOMP = 1 {
;; ;expect $01 to be $35
; !if CONFIG_LOADER = 1 {
;
; ;XXX TODO not used much, throw out
;link_load_next_double
; ;loads a splitted file, first part up to $d000 second part under IO
; jsr link_load_next_comp
;link_load_next_raw_decomp
; jsr link_load_next_raw
; }
;link_decomp_under_io
; dec $01 ;bank out IO
; jsr link_decomp ;depack
; inc $01 ;bank in again
; rts
; }
}
!if CONFIG_LOADER = 1 {
;XXX we do not wait for the floppy to be idle, as we waste enough time with depacking or the fallthrough on load_raw to have an idle floppy
bitfire_send_byte_
;ldx #$37
;stx $dd02
sec
ror
sta .filenum
ldx #$3f
txa
.ld_loop
and #$2f
bcs +
eor #$10
+
eor #$20
sta $dd02 - $3f,x
pha ;/!\ ATTENTION needed more than ever with spin down and turn disc, do never remove again
pla
pha
pla
lsr <(.filenum - $3f),x ;fetch next bit from filenumber and waste cycles
bne .ld_loop
-
bit $dd00 ;/!\ ATTENTION wait for drive to become busy, also needed, do not remove, do not try again to save cycles/bytes here :-(
bmi -
stx $dd02 ;restore $dd02
rts
!if CONFIG_FRAMEWORK = 1 {
link_load_next_raw
lda #BITFIRE_LOAD_NEXT
link_load_raw
}
bitfire_loadraw_
jsr bitfire_send_byte_ ;easy, open...
-
.ld_load_raw
jsr .ld_pblock ;fetch all blocks until eof
bcc -
.ld_pend
rts ;XXX TODO can be omitted, maybe as we would skip blockloading on eof?
;just run into ld_pblock code again that will then jump to .ld_pend and rts
.ld_pblock
lda $dd00 ;bit 6 is always set if not ready or idle/EOF so no problem with just an ASL
asl ;focus on bit 7 and 6 and copy bit 7 to carry (set if floppy is idle/eof is reached)
bmi .ld_pend ;block ready?
.ld_pblock_
ldx #$60 ;set rts
jsr .bitfire_ack_ ;start data transfer (6 bits of payload possible on first byte, as first two bits are used to signal block ready + no eof). Also sets an rts in receive loop
php ;preserve flag
;extract errors here:
!if CONFIG_NMI_GAPS = 0 & CONFIG_DEBUG = 1 {
asr #$7c
lsr
adc <bitfire_errors
sta <bitfire_errors
}
!if CONFIG_DECOMP = 1 { ;decompressor only needs to be setup if there
jsr .ld_get_byte ;fetch barrier
sta .barrier
}
.bitfire_load_block
jsr .ld_get_byte ;fetch blockaddr hi
sta .ld_store + 2 ;where to place the block?
tay ;preserve value in Y
jsr .ld_get_byte
sta .ld_store + 1
;lo/hi-1 in a/y for later use
plp
bmi .ld_skip_stax ;#$fc -> first block, fetch load-address
iny ;increment, as last .ld_get_byte call decremented y by 1
sta <bitfire_load_addr_lo
sty <bitfire_load_addr_hi
.ld_skip_stax
jsr .ld_get_byte ;fetch blocklen
tay
ldx #$99 ;sta $xxxx,y
.bitfire_ack_
stx .ld_store
.ld_get_byte
ldx #$8e ;opcode for stx -> repair any rts being set (also accidently) by y-index-check
top ;top XXX TODO
.ld_en_exit
ldx #$60
stx .ld_gend ;XXX TODO would be nice if we could do that with ld_store in same time, but happens at different timeslots :-(
bpl + ;do bpl first and waste another 2 cycles on loop entry, so that floppy manages to switch from preamble to send_data
bitfire_ntsc5
;.ld_gloop
bmi .ld_gentry
.ld_gloop
ldx #$3f
bitfire_ntsc0 ora $dd00 - $3f,x
;bitfire_ntsc0 ora $dd00
stx $dd02
lsr ;%xxxxx111
lsr ;%xxxxxx11 1
dey
beq .ld_en_exit
+
ldx #$37
bitfire_ntsc1 ora $dd00
stx $dd02
ror ;c = 1
ror ;c = 1 a = %11xxxxxx
ldx #$3f
sax .ld_nibble + 1
bitfire_ntsc2 and $dd00
stx $dd02
.ld_nibble ora #$00
.ld_store sta $b00b,y
.ld_gentry
lax <CONFIG_LAX_ADDR
bitfire_ntsc3 adc $dd00 ;a is anything between 38 and 3b after add (37 + 00..03 + carry), so bit 3 and 4 is always set, bits 6 and 7 are given by floppy
;%xx111xxx
.ld_gend
stx $dd02 ;carry is cleared now, we can exit here and do our rts with .ld_gend
lsr ;%xxx111xx
lsr ;%xxxx111x
bitfire_ntsc4 bpl .ld_gloop ;BRA, a is anything between 0e and 3e
!if >* != >.ld_gloop { !error "getloop code crosses page!" }
;XXX TODO in fact the branch can also take 4 cycles if needed, ora $dd00 - $3f,x wastes one cycle anyway
}
;---------------------------------------------------------------------------------
;DEPACKER STUFF
;---------------------------------------------------------------------------------
!if CONFIG_DECOMP = 1 {
bitfire_decomp_
link_decomp
!if CONFIG_LOADER = 1 {
lda #(.lz_start_over - .lz_skip_poll) - 2
ldx #$60
bne .loadcomp_entry
!if CONFIG_FRAMEWORK = 1 {
link_load_next_comp
lda #BITFIRE_LOAD_NEXT
link_load_comp
}
bitfire_loadcomp_
jsr bitfire_send_byte_ ;returns now with x = $3f
lda #(.lz_poll - .lz_skip_poll) - 2
ldx #$08
.loadcomp_entry
sta .lz_skip_poll + 1
stx .lz_skip_fetch
jsr .lz_next_page_ ;shuffle in data first until first block is present, returns with Y = 0, X = 0
}
;copy over end_pos and lz_dst from stream
ldy #$00 ;needs to be set in any case, also plain decomp enters here
jsr .lz_get_byte ;y will stay 0
sta <.lz_dst + 1
jsr .lz_get_byte ;y will stay 0
sta <.lz_dst + 0
sty .lz_offset_lo + 1 ;initialize offset with $0000
sty .lz_offset_hi + 1
sty <.lz_len_hi ;reset len - XXX TODO could also be cleared upon installer, as the depacker leaves that value clean again
lda #$40 ;start with an empty lz_bits, first asl <.lz_bits leads to literal this way and bits are refilled upon next shift
sta <.lz_bits
bne .lz_start_over ;start with a literal
;------------------
;SELDOM STUFF
;------------------
.lz_l_page
dec <.lz_len_hi
bcs .lz_cp_lit
;------------------
;GET BYTE FROM STREAM
;------------------
.lz_get_byte
lda (.lz_src),y
inc <.lz_src + 0
beq .lz_next_page
rts
!if CONFIG_NMI_GAPS = 1 {
!ifdef .lz_gap2 {
!warn .lz_gap2 - *, " bytes left until gap2"
}
!align 255,2
.lz_gap2
!if .lz_gap2 - .lz_gap1 > $0100 {
!error "code on first page too big, second gap does not fit!"
}
nop
nop
nop
}
.lz_dcp
dcp .lz_len_hi
bcs .lz_match_big
;------------------
;POINTER HANDLING LITERAL COPY
;------------------
.lz_dst_inc
inc <.lz_dst + 1
bcs .lz_dst_inc_
.lz_src_inc
!if CONFIG_LOADER = 1 {
jsr .lz_next_page ;sets X = 0, so all sane
} else {
inc <.lz_src + 1
}
bcs .lz_src_inc_
;------------------
;POLLING
;------------------
.lz_poll
!if CONFIG_LOADER = 1 {
bit $dd00
bvs .lz_start_over
jsr .ld_pblock_ ;yes, fetch another block, call is disabled for plain decomp
}
;------------------
;LITERAL
;------------------
.lz_start_over
lda #$01 ;we fall through this check on entry and start with literal
asl <.lz_bits
bcs .lz_match ;after each match check for another match or literal?
.lz_literal
jsr .lz_length
tax
beq .lz_l_page ;happens very seldom, so let's do that with lz_l_page that also decrements lz_len_hi, it returns on c = 1, what is always true after jsr .lz_length
.lz_cp_lit
lda (.lz_src),y ;Need to copy this way, or wie copy from area that is blocked by barrier
sta (.lz_dst),y
inc <.lz_src + 0
beq .lz_src_inc
.lz_src_inc_
inc <.lz_dst + 0
beq .lz_dst_inc
.lz_dst_inc_
dex
bne .lz_cp_lit
lda <.lz_len_hi ;more pages to copy?
bne .lz_l_page ;happens very seldom
;------------------
;NEW OR OLD OFFSET
;------------------
;in case of type bit == 0 we can always receive length (not length - 1), can this used for an optimization? can we fetch length beforehand? and then fetch offset? would make length fetch simpler? place some other bit with offset?
rol ;A = 0, C = 1 -> A = 1
asl <.lz_bits
;rol
;bne .lz_match
;else A = 0
;but only for lowbyte?!
bcs .lz_match ;either match with new offset or old offset
;------------------
;DO MATCH
;------------------
.lz_repeat
jsr .lz_length
sbc #$01
bcc .lz_dcp ;fix highbyte of length in case and set carry again (a = $ff -> compare delivers carry = 1)
;sec ;XXX TODO in fact we could save on the sbc #$01 as the sec and adc later on corrects that again, but y would turn out one too less
.lz_match_big ;we enter with length - 1 here from normal match
eor #$ff
tay
;XXX TODO save on eor #$ff and do sbc lz_dst + 0?
eor #$ff ;restore A
.lz_match_len2 ;entry from new_offset handling
adc <.lz_dst + 0
sta <.lz_dst + 0
tax ;remember for later end check, cheaper this way
bcs .lz_clc ;/!\ branch happens very seldom, if so, clear carry
dec <.lz_dst + 1 ;subtract one more in this case
.lz_clc_back
.lz_offset_lo sbc #$00 ;carry is cleared, subtract (offset + 1) in fact we could use sbx here, but would not respect carry, but a and x are same, but need x later anyway for other purpose
sta .lz_msrcr + 0
lda <.lz_dst + 1
.lz_offset_hi sbc #$00
sta .lz_msrcr + 1
; ;XXX TODO would have dst + 0 and + 1 in X and A here, of any use?
.lz_cp_match
;XXX TODO if repeated offset: add literal size to .lz_msrcr and done?
.lz_msrcr = * + 1
lda $beef,y
sta (.lz_dst),y
iny
bne .lz_cp_match
inc <.lz_dst + 1
lda <.lz_len_hi ;check for more loop runs
bne .lz_m_page ;do more page runs? Yes? Fall through
.lz_check_poll
cpx <.lz_src + 0 ;check for end condition when depacking inplace, .lz_dst + 0 still in X
!if .CHECK_EVEN = 1 {
.lz_skip_poll bne .lz_start_over ;-> can be changed to .lz_poll, depending on decomp/loadcomp
}
lda <.lz_dst + 1
sbc <.lz_src + 1
!if .CHECK_EVEN = 1 {
bne .lz_start_over
} else {
.lz_skip_poll bcc .lz_start_over
}
;jmp .ld_load_raw ;but should be able to skip fetch, so does not work this way
;top ;if lz_src + 1 gets incremented, the barrier check hits in even later, so at least one block is loaded, if it was $ff, we at least load the last block @ $ffxx, it must be the last block being loaded anyway
;as last block is forced, we would always wait for last block to be loaded if we enter this loop, no matter how :-)
;------------------
;NEXT PAGE IN STREAM
;------------------
.lz_next_page
inc <.lz_src + 1
.lz_next_page_
!if CONFIG_LOADER = 1 {
.lz_skip_fetch
php ;save carry
pha ;and A
txa
pha
.lz_fetch_sector ;entry of loop
jsr .ld_pblock ;fetch another block
bcs .lz_fetch_eof ;eof? yes, finish, only needed if files reach up to $ffxx -> barrier will be 0 then and upcoming check will always hit in -> this would suck
;XXX TODO send a high enough barrier on last block being sent
lda <.lz_src + 1 ;get current depack position
cmp <.barrier ;next pending block/barrier reached? If barrier == 0 this test will always loop on first call or until first-block with load-address arrives, no matter what .bitfire_lz_sector_ptr has as value \o/
;on first successful .ld_pblock they will be set with valid values and things will be checked against correct barrier
bcs .lz_fetch_sector ;already reached, loop
.lz_fetch_eof ;not reached, go on depacking
;Y = 0 ;XXX TODO could be used to return somewhat dirty from a jsr situation, this would pull two bytes from stack and return
pla
tax
pla
plp
}
rts
;------------------
;FETCH A NEW OFFSET
;------------------
- ;lz_length as inline
asl <.lz_bits ;fetch payload bit
rol ;can also moved to front and executed once on start
.lz_match
asl <.lz_bits
bcc -
bne +
jsr .lz_refill_bits
+
sbc #$01 ;XXX TODO can be omitted if just endposition is checked, but 0 does not exist as value?
bcc .lz_eof ;underflow. must have been 0
lsr
sta .lz_offset_hi + 1 ;hibyte of offset
lda (.lz_src),y ;fetch another byte directly
ror
sta .lz_offset_lo + 1
inc <.lz_src + 0 ;postponed, so no need to save A on next_page call
bne +
!if CONFIG_LOADER = 1 {
jsr .lz_next_page ;preserves carry, all sane
} else {
inc <.lz_src + 1
}
+
lda #$01
ldy #$fe
bcs .lz_match_len2 ;length = 1 ^ $ff, do it the very short way :-)
-
asl <.lz_bits ;fetch first payload bit
;XXX TODO we could check bit 7 before further asl?
rol ;can also moved to front and executed once on start
asl <.lz_bits
bcc -
bne .lz_match_big
ldy #$00 ;only now y = 0 is needed
jsr .lz_refill_bits ;fetch remaining bits
bcs .lz_match_big
;------------------
;SELDOM STUFF
;------------------
.lz_clc
clc
bcc .lz_clc_back
.lz_m_page
dec <.lz_len_hi
inc .lz_msrcr + 1 ;XXX TODO only needed if more pages follow
bne .lz_cp_match
;------------------
;ELIAS FETCH
;------------------
.lz_refill_bits
tax
lda (.lz_src),y
rol
sta <.lz_bits
inc <.lz_src + 0 ;postponed, so no need to save A on next_page call
bne + ;XXX TODO if we would prefer beq, 0,2% saving
!if CONFIG_LOADER = 1 {
jsr .lz_next_page ;preserves carry and A, clears X, Y, all sane
} else {
inc <.lz_src + 1
}
+
txa
bcs .lz_lend
;lda #$00
;slo <.lz_bits
.lz_get_loop
asl <.lz_bits ;fetch payload bit
.lz_length_16_
rol ;can also moved to front and executed once on start
bcs .lz_length_16 ;first 1 drops out from lowbyte, need to extend to 16 bit, unfortunatedly this does not work with inverted numbers
.lz_length
asl <.lz_bits
bcc .lz_get_loop
beq .lz_refill_bits
.lz_lend
.lz_eof
rts
.lz_length_16 ;happens very rarely
pha ;save LSB
tya ;was lda #$01, but A = 0 + rol makes this also start with MSB = 1
jsr .lz_length_16_ ;get up to 7 more bits
sta <.lz_len_hi ;save MSB
pla ;restore LSB
rts
}
bitfire_resident_size = * - CONFIG_RESIDENT_ADDR
;set end_address for inplace to real end of file if not inplaced? so nothing can go wrong? or set it to $ffff? also sane
;XXX TODO
;decide upon 2 bits with bit <.lz_bits? bmi + bvs + bvc? bpl/bmi decides if repeat or not, bvs = length 2/check for new bits and redecide, other lengths do not need to check, this can alos be used on other occasions?
;do a jmp ($00xx) to determine branch?
|
; A080957: Expansion of (5 - 9*x + 6*x^2)/(1-x)^4.
; 5,11,20,34,55,85,126,180,249,335,440,566,715,889,1090,1320,1581,1875,2204,2570,2975,3421,3910,4444,5025,5655,6336,7070,7859,8705,9610,10576,11605,12699,13860,15090,16391,17765,19214,20740,22345,24031,25800,27654,29595,31625,33746,35960,38269,40675,43180,45786,48495,51309,54230,57260,60401,63655,67024,70510,74115,77841,81690,85664,89765,93995,98356,102850,107479,112245,117150,122196,127385,132719,138200,143830,149611,155545,161634,167880,174285,180851,187580,194474,201535,208765,216166,223740,231489,239415,247520,255806,264275,272929,281770,290800,300021,309435,319044,328850
mov $2,5
lpb $0
add $2,$0
sub $0,1
add $1,$2
lpe
add $1,5
mov $0,$1
|
#include <n64/n64.hpp>
namespace ares::Nintendo64 {
SI si;
#include "dma.cpp"
#include "io.cpp"
#include "debugger.cpp"
#include "serialization.cpp"
auto SI::load(Node::Object parent) -> void {
node = parent->append<Node::Object>("SI");
debugger.load(node);
/*if(auto fp = system.pak->read("pif.sm5.rom")) {
//load 1KB ROM and mirror it to 4KB
fp->read({SM5K::ROM, 1024});
memory::copy(&SM5K::ROM[1024], &SM5K::ROM[0], 1024);
memory::copy(&SM5K::ROM[2048], &SM5K::ROM[0], 1024);
memory::copy(&SM5K::ROM[3072], &SM5K::ROM[0], 1024);
}*/
}
auto SI::unload() -> void {
debugger = {};
node.reset();
}
auto SI::addressCRC(u16 address) const -> n5 {
n5 crc = 0;
for(u32 i : range(16)) {
n5 xor = crc & 0x10 ? 0x15 : 0x00;
crc <<= 1;
if(address & 0x8000) crc |= 1;
address <<= 1;
crc ^= xor;
}
return crc;
}
auto SI::dataCRC(array_view<u8> data) const -> n8 {
n8 crc = 0;
for(u32 i : range(33)) {
for(u32 j : reverse(range(8))) {
n8 xor = crc & 0x80 ? 0x85 : 0x00;
crc <<= 1;
if(i < 32) {
if(data[i] & 1 << j) crc |= 1;
}
crc ^= xor;
}
}
return crc;
}
auto SI::run() -> void {
auto flags = pi.ram.read<Byte>(0x3f);
//controller polling
if(flags & 0x01) {
//todo: this flag is supposed to be cleared, but doing so breaks inputs
//flags &= ~0x01;
scan();
}
//CIC-NUS-6105 challenge/response
if(flags & 0x02) {
flags &= ~0x02;
challenge();
}
//unknown purpose
if(flags & 0x04) {
flags &= ~0x04;
debug(unimplemented, "[SI::main] flags & 0x04");
}
//must be sent within 5s of the console booting, or SM5 will lock the N64
if(flags & 0x08) {
flags &= ~0x08;
}
//PIF ROM lockout
if(flags & 0x10) {
flags &= ~0x10;
pi.io.romLockout = 1;
}
//initialization
if(flags & 0x20) {
flags &= ~0x20;
flags |= 0x80; //set completion flag
}
//clear PIF RAM
if(flags & 0x40) {
flags &= ~0x40;
pi.ram.fill();
}
pi.ram.write<Byte>(0x3f, flags);
}
auto SI::scan() -> void {
ControllerPort* controllers[4] = {
&controllerPort1,
&controllerPort2,
&controllerPort3,
&controllerPort4,
};
static constexpr bool Debug = 0;
if constexpr(Debug) {
print("{\n");
for(u32 y : range(8)) {
print(" ");
for(u32 x : range(8)) {
print(hex(pi.ram.read<Byte>(y * 8 + x), 2L), " ");
}
print("\n");
}
print("}\n");
}
n3 channel = 0; //0-5
for(u32 offset = 0; offset < 64;) {
n8 send = pi.ram.read<Byte>(offset++);
if(send == 0x00) { channel++; continue; }
if(send == 0xfd) continue; //channel reset
if(send == 0xfe) break; //end of packets
if(send == 0xff) continue; //alignment padding
n8 recvOffset = offset;
n8 recv = pi.ram.read<Byte>(offset++);
if(recv == 0xfe) break; //end of packets
//clear flags from lengths
send &= 0x3f;
recv &= 0x3f;
n8 input[64];
for(u32 index : range(send)) {
input[index] = pi.ram.read<Byte>(offset++);
}
n8 output[64];
b1 valid = 0;
//status
if(input[0] == 0x00 || input[0] == 0xff) {
//controller
if(channel < 4) {
if(auto& device = controllers[channel]->device) {
if(auto gamepad = dynamic_cast<Gamepad*>(device.data())) {
output[0] = 0x05; //0x05 = gamepad
output[1] = 0x00;
output[2] = 0x02; //0x02 = nothing present in controller slot
if(gamepad->ram || gamepad->motor || gamepad->transferPak) {
output[2] = 0x01; //0x01 = pak present
}
}
if(dynamic_cast<Mouse*>(device.data())) {
output[0] = 0x02; //0x02 = mouse
output[1] = 0x00;
output[2] = 0x00;
}
valid = 1;
}
}
//cartridge EEPROM (4kbit)
if(channel >= 4 && cartridge.eeprom.size == 512) {
output[0] = 0x00;
output[1] = 0x80;
output[2] = 0x00;
valid = 1;
}
//cartridge EEPROM (16kbit)
if(channel >= 4 && cartridge.eeprom.size == 2048) {
output[0] = 0x00;
output[1] = 0xc0;
output[2] = 0x00;
valid = 1;
}
}
//read controller state
if(input[0] == 0x01) {
if(channel < 4 && controllers[channel]->device) {
u32 data = controllers[channel]->device->read();
output[0] = data >> 24;
output[1] = data >> 16;
output[2] = data >> 8;
output[3] = data >> 0;
if(recv <= 4) {
pi.ram.write<Byte>(recvOffset, 0x00 | recv & 0x3f);
} else {
pi.ram.write<Byte>(recvOffset, 0x40 | recv & 0x3f);
}
valid = 1;
}
}
//read pak
if(input[0] == 0x02 && send >= 3 && recv >= 1) {
if(auto& device = controllers[channel]->device) {
if(auto gamepad = dynamic_cast<Gamepad*>(device.data())) {
//controller pak
if(auto& ram = gamepad->ram) {
u32 address = (input[1] << 8 | input[2] << 0) & ~31;
if(addressCRC(address) == (n5)input[2]) {
for(u32 index : range(recv - 1)) {
output[index] = ram.read<Byte>(address++);
}
output[recv - 1] = dataCRC({&output[0], recv - 1});
valid = 1;
}
}
//rumble pak
if(gamepad->motor) {
u32 address = (input[1] << 8 | input[2] << 0) & ~31;
if(addressCRC(address) == (n5)input[2]) {
for(u32 index : range(recv - 1)) {
output[index] = 0x80;
}
output[recv - 1] = dataCRC({&output[0], recv - 1});
valid = 1;
}
}
//transfer pak
if(auto& transferPak = gamepad->transferPak) {
u32 address = (input[1] << 8 | input[2] << 0) & ~31;
if(addressCRC(address) == (n5)input[2]) {
for(u32 index : range(recv - 1)) {
output[index] = transferPak.read(address++);
}
output[recv - 1] = dataCRC({&output[0], recv - 1});
valid = 1;
}
}
}
}
}
//write pak
if(input[0] == 0x03 && send >= 3 && recv >= 1) {
if(auto& device = controllers[channel]->device) {
if(auto gamepad = dynamic_cast<Gamepad*>(device.data())) {
//controller pak
if(auto& ram = gamepad->ram) {
u32 address = (input[1] << 8 | input[2] << 0) & ~31;
if(addressCRC(address) == (n5)input[2]) {
for(u32 index : range(send - 3)) {
ram.write<Byte>(address++, input[3 + index]);
}
output[0] = dataCRC({&input[3], send - 3});
valid = 1;
}
}
//rumble pak
if(gamepad->motor) {
u32 address = (input[1] << 8 | input[2] << 0) & ~31;
if(addressCRC(address) == (n5)input[2]) {
output[0] = dataCRC({&input[3], send - 3});
valid = 1;
gamepad->rumble(input[3] & 1);
}
}
//transfer pak
if(auto& transferPak = gamepad->transferPak) {
u32 address = (input[1] << 8 | input[2] << 0) & ~31;
if(addressCRC(address) == (n5)input[2]) {
for(u32 index : range(send - 3)) {
transferPak.write(address++, input[3 + index]);
}
output[0] = dataCRC({&input[3], send - 3});
valid = 1;
}
}
}
}
}
//read EEPROM
if(input[0] == 0x04 && send >= 2) {
u32 address = input[1] * 8;
for(u32 index : range(recv)) {
output[index] = cartridge.eeprom.read<Byte>(address++);
}
valid = 1;
}
//write EEPROM
if(input[0] == 0x05 && send >= 2 && recv >= 1) {
u32 address = input[1] * 8;
for(u32 index : range(send - 2)) {
cartridge.eeprom.write<Byte>(address++, input[2 + index]);
}
output[0] = 0x00;
valid = 1;
}
//RTC status
if(input[0] == 0x06) {
debug(unimplemented, "[SI::main] RTC status");
}
//RTC read
if(input[0] == 0x07) {
debug(unimplemented, "[SI::main] RTC read");
}
//RTC write
if(input[0] == 0x08) {
debug(unimplemented, "[SI::main] RTC write");
}
if(!valid) {
pi.ram.write<Byte>(recvOffset, 0x80 | recv & 0x3f);
}
for(u32 index : range(recv)) {
pi.ram.write<Byte>(offset++, output[index]);
}
channel++;
}
if constexpr(Debug) {
print("[\n");
for(u32 y : range(8)) {
print(" ");
for(u32 x : range(8)) {
print(hex(pi.ram.read<Byte>(y * 8 + x), 2L), " ");
}
print("\n");
}
print("]\n");
}
}
//CIC-NUS-6105 anti-piracy challenge/response
auto SI::challenge() -> void {
static n4 lut[32] = {
0x4, 0x7, 0xa, 0x7, 0xe, 0x5, 0xe, 0x1,
0xc, 0xf, 0x8, 0xf, 0x6, 0x3, 0x6, 0x9,
0x4, 0x1, 0xa, 0x7, 0xe, 0x5, 0xe, 0x1,
0xc, 0x9, 0x8, 0x5, 0x6, 0x3, 0xc, 0x9,
};
n4 challenge[30];
n4 response[30];
//15 bytes -> 30 nibbles
for(u32 address : range(15)) {
auto data = pi.ram.read<Byte>(0x30 + address);
challenge[address << 1 | 0] = data >> 4;
challenge[address << 1 | 1] = data >> 0;
}
n4 key = 0xb;
n1 sel = 0;
for(u32 address : range(30)) {
n4 data = key + 5 * challenge[address];
response[address] = data;
key = lut[sel << 4 | data];
n1 mod = data >> 3;
n3 mag = data >> 0;
if(mod) mag = ~mag;
if(mag % 3 != 1) mod = !mod;
if(sel) {
if(data == 0x1 || data == 0x9) mod = 1;
if(data == 0xb || data == 0xe) mod = 0;
}
sel = mod;
}
//30 nibbles -> 15 bytes
for(u32 address : range(15)) {
n8 data = 0;
data |= response[address << 1 | 0] << 4;
data |= response[address << 1 | 1] << 0;
pi.ram.write<Byte>(0x30 + address, data);
}
}
auto SI::power(bool reset) -> void {
io = {};
}
}
|
%ifdef CONFIG
{
"RegData": {
"RAX": "0x400",
"MM7": ["0x8000000000000000", "0x3FFF"]
},
"Mode": "32BIT"
}
%endif
lea edx, [.data]
fld dword [edx + 8 * 0]
fistp dword [edx + 8 * 1]
fld1
mov eax, [edx + 8 * 1]
hlt
.data:
dq 0x44800000
dq 0
|
###############################################################################
# Copyright 2019 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.text
.p2align 6, 0x90
.globl _cpSqr_avx2_V0
_cpSqr_avx2_V0:
push %rbx
push %rbp
push %r12
push %r13
sub $(56), %rsp
movslq %edx, %rdx
vpxor %ymm11, %ymm11, %ymm11
vmovdqu %ymm11, (%rsi,%rdx,8)
lea (3)(%rdx), %rax
and $(-4), %rax
shr $(2), %rax
movq %rdi, (%rsp)
movq %rsi, (8)(%rsp)
movq %rdx, (16)(%rsp)
movq %rax, (24)(%rsp)
mov %rcx, %rdi
shl $(2), %rax
movq %rdi, (40)(%rsp)
lea (%rdi,%rax,8), %rbx
lea (%rbx,%rax,8), %r9
movq %r9, (32)(%rsp)
.Lclr_dbl_loopgas_1:
vmovdqu (%rsi), %ymm0
vpaddq %ymm0, %ymm0, %ymm0
vmovdqu %ymm11, (%rdi)
vmovdqu %ymm11, (%rbx)
vmovdqu %ymm0, (%r9)
add $(32), %rsi
add $(32), %rdi
add $(32), %rbx
add $(32), %r9
sub $(4), %rax
jg .Lclr_dbl_loopgas_1
movq (8)(%rsp), %rsi
movq (40)(%rsp), %rdi
movq (32)(%rsp), %r9
mov %rsi, %rax
mov $(4), %rcx
.p2align 6, 0x90
.Lsqr_offset_loopgas_1:
movq (24)(%rsp), %r10
mov $(3), %r12
and %r10, %r12
lea (-7)(%r10), %r11
shr $(2), %r10
sub $(1), %r10
push %r9
push %rsi
push %rdi
push %rax
.p2align 6, 0x90
.Lsqr_outer_loopgas_1:
vpbroadcastq (%rax), %ymm10
vpbroadcastq (32)(%rax), %ymm11
vpbroadcastq (64)(%rax), %ymm12
vpbroadcastq (96)(%rax), %ymm13
vmovdqu (128)(%r9), %ymm7
vmovdqu (160)(%r9), %ymm8
vmovdqu (192)(%r9), %ymm9
vpmuludq (%rsi), %ymm10, %ymm0
vpmuludq (32)(%r9), %ymm10, %ymm1
vpmuludq (64)(%r9), %ymm10, %ymm2
vpmuludq (96)(%r9), %ymm10, %ymm3
vpmuludq %ymm7, %ymm10, %ymm4
vpmuludq %ymm8, %ymm10, %ymm5
vpmuludq %ymm9, %ymm10, %ymm6
vpmuludq (32)(%rsi), %ymm11, %ymm14
vpaddq %ymm14, %ymm2, %ymm2
vpmuludq (64)(%r9), %ymm11, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (96)(%r9), %ymm11, %ymm14
vpaddq %ymm14, %ymm4, %ymm4
vpmuludq %ymm7, %ymm11, %ymm14
vpaddq %ymm14, %ymm5, %ymm5
vpmuludq %ymm8, %ymm11, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (64)(%rsi), %ymm12, %ymm14
vpaddq %ymm14, %ymm4, %ymm4
vpmuludq (96)(%r9), %ymm12, %ymm14
vpaddq %ymm14, %ymm5, %ymm5
vpmuludq %ymm7, %ymm12, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (96)(%rsi), %ymm13, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
vpaddq (160)(%rdi), %ymm5, %ymm5
vmovdqu %ymm5, (160)(%rdi)
vpaddq (192)(%rdi), %ymm6, %ymm6
vmovdqu %ymm6, (192)(%rdi)
push %r11
push %rdi
push %r9
add $(224), %rdi
add $(224), %r9
.p2align 6, 0x90
.Lsqr_inner_loopgas_1:
vmovdqu (%r9), %ymm6
vpmuludq %ymm7, %ymm13, %ymm0
vpmuludq %ymm8, %ymm12, %ymm1
vpmuludq %ymm9, %ymm11, %ymm2
vpmuludq %ymm6, %ymm10, %ymm3
vpaddq %ymm1, %ymm0, %ymm0
vpaddq %ymm2, %ymm0, %ymm0
vpaddq %ymm3, %ymm0, %ymm0
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vmovdqa %ymm8, %ymm7
vmovdqa %ymm9, %ymm8
vmovdqa %ymm6, %ymm9
add $(32), %r9
add $(32), %rdi
sub $(1), %r11
jg .Lsqr_inner_loopgas_1
vpmuludq %ymm9, %ymm11, %ymm1
vpmuludq %ymm8, %ymm12, %ymm2
vpmuludq %ymm7, %ymm13, %ymm3
vpaddq %ymm2, %ymm1, %ymm1
vpaddq %ymm3, %ymm1, %ymm1
vpaddq (%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (%rdi)
vpmuludq %ymm9, %ymm12, %ymm2
vpmuludq %ymm8, %ymm13, %ymm3
vpaddq %ymm3, %ymm2, %ymm2
vpaddq (32)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (32)(%rdi)
vpmuludq %ymm9, %ymm13, %ymm3
vpaddq (64)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (64)(%rdi)
pop %r9
pop %rdi
pop %r11
add $(128), %r9
add $(256), %rdi
add $(128), %rax
add $(128), %rsi
sub $(4), %r11
sub $(1), %r10
jg .Lsqr_outer_loopgas_1
cmp $(2), %r12
ja .L_4n_3gas_1
jz .L_4n_2gas_1
jp .L_4n_1gas_1
jmp .L_4n_0gas_1
.L_4n_3gas_1:
vpbroadcastq (%rax), %ymm10
vpmuludq (%rsi), %ymm10, %ymm0
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpmuludq (32)(%r9), %ymm10, %ymm1
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpmuludq (64)(%r9), %ymm10, %ymm2
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpmuludq (96)(%r9), %ymm10, %ymm3
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpmuludq (128)(%r9), %ymm10, %ymm4
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
vpmuludq (160)(%r9), %ymm10, %ymm5
vpaddq (160)(%rdi), %ymm5, %ymm5
vmovdqu %ymm5, (160)(%rdi)
vpmuludq (192)(%r9), %ymm10, %ymm6
vpaddq (192)(%rdi), %ymm6, %ymm6
vmovdqu %ymm6, (192)(%rdi)
add $(64), %rdi
add $(32), %rsi
add $(32), %rax
add $(32), %r9
.L_4n_2gas_1:
vpbroadcastq (%rax), %ymm10
vpmuludq (%rsi), %ymm10, %ymm0
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpmuludq (32)(%r9), %ymm10, %ymm1
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpmuludq (64)(%r9), %ymm10, %ymm2
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpmuludq (96)(%r9), %ymm10, %ymm3
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpmuludq (128)(%r9), %ymm10, %ymm4
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
vpmuludq (160)(%r9), %ymm10, %ymm5
vpaddq (160)(%rdi), %ymm5, %ymm5
vmovdqu %ymm5, (160)(%rdi)
add $(64), %rdi
add $(32), %rsi
add $(32), %rax
add $(32), %r9
.L_4n_1gas_1:
vpbroadcastq (%rax), %ymm10
vpmuludq (%rsi), %ymm10, %ymm0
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpmuludq (32)(%r9), %ymm10, %ymm1
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpmuludq (64)(%r9), %ymm10, %ymm2
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpmuludq (96)(%r9), %ymm10, %ymm3
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpmuludq (128)(%r9), %ymm10, %ymm4
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
add $(64), %rdi
add $(32), %rsi
add $(32), %rax
add $(32), %r9
.L_4n_0gas_1:
vpbroadcastq (%rax), %ymm10
vpbroadcastq (32)(%rax), %ymm11
vpbroadcastq (64)(%rax), %ymm12
vpbroadcastq (96)(%rax), %ymm13
vpmuludq (%rsi), %ymm10, %ymm0
vpmuludq (32)(%r9), %ymm10, %ymm1
vpmuludq (64)(%r9), %ymm10, %ymm2
vpmuludq (96)(%r9), %ymm10, %ymm3
vpmuludq (32)(%rsi), %ymm11, %ymm14
vpaddq %ymm14, %ymm2, %ymm2
vpmuludq (64)(%r9), %ymm11, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (96)(%r9), %ymm11, %ymm4
vpmuludq (64)(%rsi), %ymm12, %ymm14
vpaddq %ymm14, %ymm4, %ymm4
vpmuludq (96)(%r9), %ymm12, %ymm5
vpmuludq (96)(%rsi), %ymm13, %ymm6
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
vpaddq (160)(%rdi), %ymm5, %ymm5
vmovdqu %ymm5, (160)(%rdi)
vpaddq (192)(%rdi), %ymm6, %ymm6
vmovdqu %ymm6, (192)(%rdi)
pop %rax
pop %rdi
pop %rsi
pop %r9
add $(8), %rdi
add $(8), %rax
sub $(1), %rcx
jg .Lsqr_offset_loopgas_1
add $(56), %rsp
vzeroupper
pop %r13
pop %r12
pop %rbp
pop %rbx
ret
.p2align 6, 0x90
.globl _cpSqr_avx2
_cpSqr_avx2:
push %rbx
push %rbp
push %r12
push %r13
sub $(56), %rsp
movslq %edx, %rdx
vpxor %ymm11, %ymm11, %ymm11
vmovdqu %ymm11, (%rsi,%rdx,8)
lea (3)(%rdx), %rax
and $(-4), %rax
shr $(2), %rax
movq %rdi, (%rsp)
movq %rsi, (8)(%rsp)
movq %rdx, (16)(%rsp)
movq %rax, (24)(%rsp)
mov %rcx, %rdi
shl $(2), %rax
movq %rdi, (40)(%rsp)
lea (%rdi,%rax,8), %rbx
lea (%rbx,%rax,8), %r9
movq %r9, (32)(%rsp)
.Lclr_dbl_loopgas_2:
vmovdqu (%rsi), %ymm0
vpaddq %ymm0, %ymm0, %ymm0
vmovdqu %ymm11, (%rdi)
vmovdqu %ymm11, (%rbx)
vmovdqu %ymm0, (%r9)
add $(32), %rsi
add $(32), %rdi
add $(32), %rbx
add $(32), %r9
sub $(4), %rax
jg .Lclr_dbl_loopgas_2
movq (8)(%rsp), %rsi
movq (40)(%rsp), %rdi
movq (32)(%rsp), %r9
mov %rsi, %rax
mov $(4), %rcx
.p2align 6, 0x90
.Lsqr_offset_loopgas_2:
movq (24)(%rsp), %r10
mov $(3), %r12
and %r10, %r12
lea (-7)(%r10), %r11
shr $(2), %r10
sub $(1), %r10
push %r9
push %rsi
push %rdi
push %rax
.p2align 6, 0x90
.Lsqr_outer_loopgas_2:
vpbroadcastq (%rax), %ymm10
vpbroadcastq (32)(%rax), %ymm11
vpbroadcastq (64)(%rax), %ymm12
vpbroadcastq (96)(%rax), %ymm13
vmovdqu (128)(%r9), %ymm7
vmovdqu (160)(%r9), %ymm8
vmovdqu (192)(%r9), %ymm9
vpmuludq (%rsi), %ymm10, %ymm0
vpmuludq (32)(%r9), %ymm10, %ymm1
vpmuludq (64)(%r9), %ymm10, %ymm2
vpmuludq (96)(%r9), %ymm10, %ymm3
vpmuludq %ymm7, %ymm10, %ymm4
vpmuludq %ymm8, %ymm10, %ymm5
vpmuludq %ymm9, %ymm10, %ymm6
vpmuludq (32)(%rsi), %ymm11, %ymm14
vpaddq %ymm14, %ymm2, %ymm2
vpmuludq (64)(%r9), %ymm11, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (96)(%r9), %ymm11, %ymm14
vpaddq %ymm14, %ymm4, %ymm4
vpmuludq %ymm7, %ymm11, %ymm14
vpaddq %ymm14, %ymm5, %ymm5
vpmuludq %ymm8, %ymm11, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (64)(%rsi), %ymm12, %ymm14
vpaddq %ymm14, %ymm4, %ymm4
vpmuludq (96)(%r9), %ymm12, %ymm14
vpaddq %ymm14, %ymm5, %ymm5
vpmuludq %ymm7, %ymm12, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpmuludq (96)(%rsi), %ymm13, %ymm14
vpaddq %ymm14, %ymm6, %ymm6
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
vpaddq (160)(%rdi), %ymm5, %ymm5
vmovdqu %ymm5, (160)(%rdi)
vpaddq (192)(%rdi), %ymm6, %ymm6
vmovdqu %ymm6, (192)(%rdi)
push %r11
push %rdi
push %r9
add $(224), %rdi
add $(224), %r9
sub $(4), %r11
jl .Lexit_sqr_inner_loop4gas_2
.p2align 6, 0x90
.Lsqr_inner_loop4gas_2:
vmovdqu (%r9), %ymm6
vpmuludq %ymm7, %ymm13, %ymm14
vpaddq (%rdi), %ymm14, %ymm0
vpmuludq %ymm8, %ymm12, %ymm14
vpaddq %ymm14, %ymm0, %ymm0
vpmuludq %ymm9, %ymm11, %ymm14
vpaddq %ymm14, %ymm0, %ymm0
vpmuludq %ymm6, %ymm10, %ymm14
vpaddq %ymm14, %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vmovdqu (32)(%r9), %ymm7
vpmuludq %ymm8, %ymm13, %ymm14
vpaddq (32)(%rdi), %ymm14, %ymm1
vpmuludq %ymm9, %ymm12, %ymm14
vpaddq %ymm14, %ymm1, %ymm1
vpmuludq %ymm6, %ymm11, %ymm14
vpaddq %ymm14, %ymm1, %ymm1
vpmuludq %ymm7, %ymm10, %ymm14
vpaddq %ymm14, %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vmovdqu (64)(%r9), %ymm8
vpmuludq %ymm9, %ymm13, %ymm14
vpaddq (64)(%rdi), %ymm14, %ymm2
vpmuludq %ymm6, %ymm12, %ymm14
vpaddq %ymm14, %ymm2, %ymm2
vpmuludq %ymm7, %ymm11, %ymm14
vpaddq %ymm14, %ymm2, %ymm2
vpmuludq %ymm8, %ymm10, %ymm14
vpaddq %ymm14, %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vmovdqu (96)(%r9), %ymm9
vpmuludq %ymm6, %ymm13, %ymm14
vpaddq (96)(%rdi), %ymm14, %ymm3
vpmuludq %ymm7, %ymm12, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq %ymm8, %ymm11, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq %ymm9, %ymm10, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
add $(128), %r9
add $(128), %rdi
sub $(4), %r11
jge .Lsqr_inner_loop4gas_2
.Lexit_sqr_inner_loop4gas_2:
add $(4), %r11
jz .Lexit_sqr_inner_loopgas_2
.Lsqr_inner_loopgas_2:
vmovdqu (%r9), %ymm6
vpmuludq %ymm7, %ymm13, %ymm14
vpaddq (%rdi), %ymm14, %ymm0
vpmuludq %ymm8, %ymm12, %ymm14
vpaddq %ymm14, %ymm0, %ymm0
vpmuludq %ymm9, %ymm11, %ymm14
vpaddq %ymm14, %ymm0, %ymm0
vpmuludq %ymm6, %ymm10, %ymm14
vpaddq %ymm14, %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vmovdqa %ymm8, %ymm7
vmovdqa %ymm9, %ymm8
vmovdqa %ymm6, %ymm9
add $(32), %r9
add $(32), %rdi
sub $(1), %r11
jg .Lsqr_inner_loopgas_2
.Lexit_sqr_inner_loopgas_2:
vpmuludq %ymm9, %ymm11, %ymm1
vpmuludq %ymm8, %ymm12, %ymm2
vpmuludq %ymm7, %ymm13, %ymm3
vpaddq %ymm2, %ymm1, %ymm1
vpaddq %ymm3, %ymm1, %ymm1
vpaddq (%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (%rdi)
vpmuludq %ymm9, %ymm12, %ymm2
vpmuludq %ymm8, %ymm13, %ymm3
vpaddq %ymm3, %ymm2, %ymm2
vpaddq (32)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (32)(%rdi)
vpmuludq %ymm9, %ymm13, %ymm3
vpaddq (64)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (64)(%rdi)
pop %r9
pop %rdi
pop %r11
add $(128), %r9
add $(256), %rdi
add $(128), %rax
add $(128), %rsi
sub $(4), %r11
sub $(1), %r10
jg .Lsqr_outer_loopgas_2
cmp $(2), %r12
ja .L_4n_3gas_2
jz .L_4n_2gas_2
jp .L_4n_1gas_2
jmp .L_4n_0gas_2
.L_4n_3gas_2:
vpbroadcastq (%rax), %ymm10
vpmuludq (%rsi), %ymm10, %ymm0
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpmuludq (32)(%r9), %ymm10, %ymm1
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpmuludq (64)(%r9), %ymm10, %ymm2
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpmuludq (96)(%r9), %ymm10, %ymm3
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpmuludq (128)(%r9), %ymm10, %ymm4
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
vpmuludq (160)(%r9), %ymm10, %ymm5
vpaddq (160)(%rdi), %ymm5, %ymm5
vmovdqu %ymm5, (160)(%rdi)
vpmuludq (192)(%r9), %ymm10, %ymm6
vpaddq (192)(%rdi), %ymm6, %ymm6
vmovdqu %ymm6, (192)(%rdi)
add $(64), %rdi
add $(32), %rsi
add $(32), %rax
add $(32), %r9
.L_4n_2gas_2:
vpbroadcastq (%rax), %ymm10
vpmuludq (%rsi), %ymm10, %ymm0
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpmuludq (32)(%r9), %ymm10, %ymm1
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpmuludq (64)(%r9), %ymm10, %ymm2
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpmuludq (96)(%r9), %ymm10, %ymm3
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpmuludq (128)(%r9), %ymm10, %ymm4
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
vpmuludq (160)(%r9), %ymm10, %ymm5
vpaddq (160)(%rdi), %ymm5, %ymm5
vmovdqu %ymm5, (160)(%rdi)
add $(64), %rdi
add $(32), %rsi
add $(32), %rax
add $(32), %r9
.L_4n_1gas_2:
vpbroadcastq (%rax), %ymm10
vpmuludq (%rsi), %ymm10, %ymm0
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpmuludq (32)(%r9), %ymm10, %ymm1
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpmuludq (64)(%r9), %ymm10, %ymm2
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpmuludq (96)(%r9), %ymm10, %ymm3
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpmuludq (128)(%r9), %ymm10, %ymm4
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
add $(64), %rdi
add $(32), %rsi
add $(32), %rax
add $(32), %r9
.L_4n_0gas_2:
vpbroadcastq (%rax), %ymm10
vpbroadcastq (32)(%rax), %ymm11
vpbroadcastq (64)(%rax), %ymm12
vpbroadcastq (96)(%rax), %ymm13
vpmuludq (%rsi), %ymm10, %ymm0
vpmuludq (32)(%r9), %ymm10, %ymm1
vpmuludq (64)(%r9), %ymm10, %ymm2
vpmuludq (96)(%r9), %ymm10, %ymm3
vpmuludq (32)(%rsi), %ymm11, %ymm14
vpaddq %ymm14, %ymm2, %ymm2
vpmuludq (64)(%r9), %ymm11, %ymm14
vpaddq %ymm14, %ymm3, %ymm3
vpmuludq (96)(%r9), %ymm11, %ymm4
vpmuludq (64)(%rsi), %ymm12, %ymm14
vpaddq %ymm14, %ymm4, %ymm4
vpmuludq (96)(%r9), %ymm12, %ymm5
vpmuludq (96)(%rsi), %ymm13, %ymm6
vpaddq (%rdi), %ymm0, %ymm0
vmovdqu %ymm0, (%rdi)
vpaddq (32)(%rdi), %ymm1, %ymm1
vmovdqu %ymm1, (32)(%rdi)
vpaddq (64)(%rdi), %ymm2, %ymm2
vmovdqu %ymm2, (64)(%rdi)
vpaddq (96)(%rdi), %ymm3, %ymm3
vmovdqu %ymm3, (96)(%rdi)
vpaddq (128)(%rdi), %ymm4, %ymm4
vmovdqu %ymm4, (128)(%rdi)
vpaddq (160)(%rdi), %ymm5, %ymm5
vmovdqu %ymm5, (160)(%rdi)
vpaddq (192)(%rdi), %ymm6, %ymm6
vmovdqu %ymm6, (192)(%rdi)
pop %rax
pop %rdi
pop %rsi
pop %r9
add $(8), %rdi
add $(8), %rax
sub $(1), %rcx
jg .Lsqr_offset_loopgas_2
add $(56), %rsp
vzeroupper
pop %r13
pop %r12
pop %rbp
pop %rbx
ret
.p2align 6, 0x90
.globl _cpMontRed_avx2
_cpMontRed_avx2:
push %rbx
push %rbp
push %r12
push %r13
sub $(72), %rsp
movslq %ecx, %r9
movq %rdi, (%rsp)
movq %rsi, (8)(%rsp)
movq %rdx, (16)(%rsp)
movq %r9, (24)(%rsp)
lea (%r9,%r9), %rcx
movq %rcx, (32)(%rsp)
lea (3)(%r9), %r11
and $(-4), %r11
movq %r11, (40)(%rsp)
mov $(3), %r11
and %r9, %r11
movq %r11, (48)(%rsp)
mov %rdx, %rbx
vpxor %ymm11, %ymm11, %ymm11
vmovdqu %ymm11, (%rbx,%r9,8)
vmovdqu %ymm11, (%rsi,%rcx,8)
.p2align 6, 0x90
.Louter_reduction_loop4gas_3:
movq (%rsi), %r10
movq (8)(%rsi), %r11
movq (16)(%rsi), %r12
movq (24)(%rsi), %r13
mov %r10, %rdx
imul %r8d, %edx
and $(134217727), %edx
vmovd %edx, %xmm8
vpbroadcastq %xmm8, %ymm8
mov %rdx, %rax
imulq (%rbx), %rax
add %rax, %r10
shr $(27), %r10
mov %rdx, %rax
imulq (8)(%rbx), %rax
add %rax, %r11
add %r10, %r11
mov %rdx, %rax
imulq (16)(%rbx), %rax
add %rax, %r12
imulq (24)(%rbx), %rdx
add %rdx, %r13
cmp $(1), %r9
jz .Llast_1gas_3
mov %r11, %rdx
imul %r8d, %edx
and $(134217727), %edx
vmovd %edx, %xmm9
vpbroadcastq %xmm9, %ymm9
mov %rdx, %rax
imulq (%rbx), %rax
add %rax, %r11
shr $(27), %r11
mov %rdx, %rax
imulq (8)(%rbx), %rax
add %rax, %r12
add %r11, %r12
imulq (16)(%rbx), %rdx
add %rdx, %r13
cmp $(2), %r9
jz .Llast_2gas_3
mov %r12, %rdx
imul %r8d, %edx
and $(134217727), %edx
vmovd %edx, %xmm10
vpbroadcastq %xmm10, %ymm10
mov %rdx, %rax
imulq (%rbx), %rax
add %rax, %r12
shr $(27), %r12
imulq (8)(%rbx), %rdx
add %rdx, %r13
add %r12, %r13
cmp $(3), %r9
jz .Llast_3gas_3
mov %r13, %rdx
imul %r8d, %edx
and $(134217727), %edx
vmovd %edx, %xmm11
vpbroadcastq %xmm11, %ymm11
imulq (%rbx), %rdx
add %rdx, %r13
shr $(27), %r13
vmovq %r13, %xmm0
vpaddq (32)(%rsi), %ymm0, %ymm0
vmovdqu %ymm0, (32)(%rsi)
add $(32), %rbx
add $(32), %rsi
movq (40)(%rsp), %r11
sub $(4), %r11
.p2align 6, 0x90
.Linner_reduction_loop16gas_3:
sub $(16), %r11
jl .Lexit_inner_reduction_loop16gas_3
vmovdqu (%rsi), %ymm0
vmovdqu (32)(%rsi), %ymm1
vmovdqu (64)(%rsi), %ymm2
vmovdqu (96)(%rsi), %ymm3
vpmuludq (%rbx), %ymm8, %ymm13
vpaddq %ymm13, %ymm0, %ymm0
vpmuludq (32)(%rbx), %ymm8, %ymm13
vpaddq %ymm13, %ymm1, %ymm1
vpmuludq (64)(%rbx), %ymm8, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (96)(%rbx), %ymm8, %ymm13
vpaddq %ymm13, %ymm3, %ymm3
vpmuludq (-8)(%rbx), %ymm9, %ymm13
vpaddq %ymm13, %ymm0, %ymm0
vpmuludq (24)(%rbx), %ymm9, %ymm13
vpaddq %ymm13, %ymm1, %ymm1
vpmuludq (56)(%rbx), %ymm9, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (88)(%rbx), %ymm9, %ymm13
vpaddq %ymm13, %ymm3, %ymm3
vpmuludq (-16)(%rbx), %ymm10, %ymm13
vpaddq %ymm13, %ymm0, %ymm0
vpmuludq (16)(%rbx), %ymm10, %ymm13
vpaddq %ymm13, %ymm1, %ymm1
vpmuludq (48)(%rbx), %ymm10, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (80)(%rbx), %ymm10, %ymm13
vpaddq %ymm13, %ymm3, %ymm3
vpmuludq (-24)(%rbx), %ymm11, %ymm13
vpaddq %ymm13, %ymm0, %ymm0
vpmuludq (8)(%rbx), %ymm11, %ymm13
vpaddq %ymm13, %ymm1, %ymm1
vpmuludq (40)(%rbx), %ymm11, %ymm13
vpaddq %ymm13, %ymm2, %ymm2
vpmuludq (72)(%rbx), %ymm11, %ymm13
vpaddq %ymm13, %ymm3, %ymm3
vmovdqu %ymm0, (%rsi)
vmovdqu %ymm1, (32)(%rsi)
vmovdqu %ymm2, (64)(%rsi)
vmovdqu %ymm3, (96)(%rsi)
add $(128), %rsi
add $(128), %rbx
jmp .Linner_reduction_loop16gas_3
.Lexit_inner_reduction_loop16gas_3:
add $(16), %r11
jz .Lexit_inner_reductiongas_3
.Linner_reduction_loop4gas_3:
sub $(4), %r11
jl .Lexit_inner_reductiongas_3
vmovdqu (%rsi), %ymm0
vpmuludq (%rbx), %ymm8, %ymm13
vpaddq %ymm13, %ymm0, %ymm0
vpmuludq (-8)(%rbx), %ymm9, %ymm13
vpaddq %ymm13, %ymm0, %ymm0
vpmuludq (-16)(%rbx), %ymm10, %ymm13
vpaddq %ymm13, %ymm0, %ymm0
vpmuludq (-24)(%rbx), %ymm11, %ymm13
vpaddq %ymm13, %ymm0, %ymm0
vmovdqu %ymm0, (%rsi)
add $(32), %rsi
add $(32), %rbx
jmp .Linner_reduction_loop4gas_3
.Lexit_inner_reductiongas_3:
movq (48)(%rsp), %rax
cmp $(2), %rax
ja .L_4n_3gas_3
jz .L_4n_2gas_3
jp .Lnext_reduction_loop4gas_3
.L_4n_0gas_3:
vpmuludq (-8)(%rbx), %ymm9, %ymm0
vpmuludq (-16)(%rbx), %ymm10, %ymm1
vpmuludq (-24)(%rbx), %ymm11, %ymm2
vpaddq %ymm1, %ymm0, %ymm0
vpaddq %ymm2, %ymm0, %ymm0
vpaddq (%rsi), %ymm0, %ymm0
vmovdqu %ymm0, (%rsi)
jmp .Lnext_reduction_loop4gas_3
.L_4n_2gas_3:
vpmuludq (-24)(%rbx), %ymm11, %ymm0
vpaddq (%rsi), %ymm0, %ymm0
vmovdqu %ymm0, (%rsi)
jmp .Lnext_reduction_loop4gas_3
.L_4n_3gas_3:
vpmuludq (-16)(%rbx), %ymm10, %ymm0
vpmuludq (-24)(%rbx), %ymm11, %ymm1
vpaddq %ymm1, %ymm0, %ymm0
vpaddq (%rsi), %ymm0, %ymm0
vmovdqu %ymm0, (%rsi)
.Lnext_reduction_loop4gas_3:
movq (8)(%rsp), %rsi
add $(32), %rsi
movq %rsi, (8)(%rsp)
movq (16)(%rsp), %rbx
sub $(4), %r9
jg .Louter_reduction_loop4gas_3
.Lexit_outer_reduction_loop4gas_3:
cmp $(2), %r9
ja .Llast_3gas_3
jz .Llast_2gas_3
jp .Llast_1gas_3
jmp .Lnormalizationgas_3
.Llast_3gas_3:
movq %r13, (24)(%rsi)
add $(32), %rsi
add $(32), %rbx
movq (40)(%rsp), %r11
sub $(4), %r11
.p2align 6, 0x90
.Lrem_loop4_4n_3gas_3:
vpmuludq (%rbx), %ymm8, %ymm0
vpmuludq (-8)(%rbx), %ymm9, %ymm1
vpmuludq (-16)(%rbx), %ymm10, %ymm2
vpaddq %ymm1, %ymm0, %ymm0
vpaddq %ymm2, %ymm0, %ymm0
vpaddq (%rsi), %ymm0, %ymm0
vmovdqu %ymm0, (%rsi)
add $(32), %rsi
add $(32), %rbx
sub $(4), %r11
jg .Lrem_loop4_4n_3gas_3
vpmuludq (-16)(%rbx), %ymm10, %ymm2
vpaddq (%rsi), %ymm2, %ymm2
vmovdqu %ymm2, (%rsi)
jmp .Lnormalizationgas_3
.Llast_2gas_3:
movq %r12, (16)(%rsi)
movq %r13, (24)(%rsi)
add $(32), %rbx
add $(32), %rsi
movq (40)(%rsp), %r11
sub $(4), %r11
.p2align 6, 0x90
.Lrem_loop4_4n_2gas_3:
vpmuludq (%rbx), %ymm8, %ymm0
vpmuludq (-8)(%rbx), %ymm9, %ymm1
vpaddq %ymm1, %ymm0, %ymm0
vpaddq (%rsi), %ymm0, %ymm0
vmovdqu %ymm0, (%rsi)
add $(32), %rsi
add $(32), %rbx
sub $(4), %r11
jg .Lrem_loop4_4n_2gas_3
jmp .Lnormalizationgas_3
.Llast_1gas_3:
movq %r11, (8)(%rsi)
movq %r12, (16)(%rsi)
movq %r13, (24)(%rsi)
add $(32), %rbx
add $(32), %rsi
movq (40)(%rsp), %r11
sub $(4), %r11
.p2align 6, 0x90
.Lrem_loop4_4n_1gas_3:
vpmuludq (%rbx), %ymm8, %ymm0
vpaddq (%rsi), %ymm0, %ymm0
vmovdqu %ymm0, (%rsi)
add $(32), %rbx
add $(32), %rsi
sub $(4), %r11
jg .Lrem_loop4_4n_1gas_3
.p2align 6, 0x90
.Lnormalizationgas_3:
movq (48)(%rsp), %rax
movq (8)(%rsp), %rsi
movq (%rsp), %rdi
movq (24)(%rsp), %r9
lea (%rsi,%rax,8), %rsi
xor %rax, %rax
.Lnorm_loopgas_3:
addq (%rsi), %rax
add $(8), %rsi
mov $(134217727), %rdx
and %rax, %rdx
shr $(27), %rax
movq %rdx, (%rdi)
add $(8), %rdi
sub $(1), %r9
jg .Lnorm_loopgas_3
movq %rax, (%rdi)
add $(72), %rsp
vzeroupper
pop %r13
pop %r12
pop %rbp
pop %rbx
ret
|
include "player.asm"
include "ball.asm"
include "palettes.asm"
include "tiles.asm"
include "states/ingame.asm"
Game_Main:
moveq #0, d0
lea Palette, a0
jsr VDP_LoadPalette
moveq #0, d0
moveq #tiles_count, d1
lea Tiles, a0
jsr VDP_LoadTiles
; Clear trashed d0 and d1
moveq #0, d0
moveq #0, d1
; Enable interrupts
move.w #$2300, sr
bra.w Ingame_Init
Game_NextFrame:
jsr Input_Update
jsr Spr_ClearTable
jsr Entity_Draw
jsr Spr_UpdateTable
jsr VDP_WaitForVSync
jsr DMA_Queue_Process
rts
Game_HINT:
rte
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1991 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: fsdFile.asm
AUTHOR: Adam de Boor, Oct 16, 1991
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
Adam 10/16/91 Initial revision
DESCRIPTION:
File-module related FSD support routines.
$Id: fsdFile.asm,v 1.1 97/04/05 01:17:48 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
kinit segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDRegister
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Register another FS driver in the system.
CALLED BY: RESTRICTED GLOBAL
PASS: cx:dx = strategy routine
ax = FSDFlags
bx = handle of driver
di = number of bytes of private data required for each
DiskDesc
RETURN: dx = FSDriver offset (for use in calling FSDInitDrive)
DESTROYED: ax, bx, cx
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 7/26/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDRegister proc far
uses ds
.enter
if FULL_EXECUTE_IN_PLACE
EC< push bx, si >
EC< movdw bxsi, cxdx >
EC< call ECAssertValidFarPointerXIP >
EC< pop bx, si >
endif
;
; Save input parameters from destruction and lock the FSIR for
; our exclusive use, placing the result in DS so we can allocate
; things (rather than the more-normal ES)
;
push ax, bx, cx
call FSDLockInfoExcl
mov ds, ax
assume ds:FSInfoResource
;
; Now allocate a record for the new driver and pop the various things
; we saved into it.
;
mov cx, size FSDriver
call LMemAlloc
mov bx, ax
pop ds:[bx].FSD_flags, \
ds:[bx].FSD_handle, \
ds:[bx].FSD_strategy.segment
mov ds:[bx].FSD_strategy.offset, dx
mov ds:[bx].FSD_diskPrivSize, di
;
; Link the new record at the head of the list.
;
xchg ds:[FIH_fsdList], ax
mov ds:[bx].FSD_next, ax
mov dx, bx
;
; If the driver is marked as a primary FSD, set it as THE primary
; FSD.
;
test ds:[bx].FSD_flags, mask FSDF_PRIMARY
jz fetchPermanentName
EC < push bx >
EC < mov bx, ds:[FIH_primaryFSD] >
EC < test ds:[bx].FSD_flags, mask FSDF_SKELETON >
EC < ERROR_Z TOO_MANY_PRIMARY_FSDs >
EC < pop bx >
mov ds:[FIH_primaryFSD], bx
fetchPermanentName:
;
; Fetch the driver's permanent name from its core block so we can find
; the thing in DiskRestore without having to grab the geodeSem.
;
push di, es
lea di, ds:[bx].FSD_name
segmov es, ds
mov bx, ds:[bx].FSD_handle
mov ax, GGIT_PERM_NAME_ONLY
call GeodeGetInfo
pop di, es
;
; Make sure the skeleton disk's private data chunk is big enough to
; accomodate that much private data.
;
mov cx, di
jcxz done ; no private data needed by
; this driver, so need to
; do nothing
mov di, ds:[fsdTemplateDisk].DD_private
tst di
jz allocNewPrivChunk
ChunkSizePtr ds, di, ax
cmp ax, cx ; current size big enough?
jae done ; yes
xchg ax, di ; ax <- chunk
call LMemReAlloc
storePrivChunkAddr:
mov ds:[fsdTemplateDisk].DD_private, ax
; store new address
; of the beast
done:
;
; Done playing with ourselves...
;
call FSDUnlockInfoExcl
.leave
ret
allocNewPrivChunk:
; cx = size required
call LMemAlloc
jmp storePrivChunkAddr
assume ds:dgroup
FSDRegister endp
kinit ends
FSResident segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDUnregister
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Remove a filesystem driver from the system. An FSD may not
be removed unless all the drives that refer to it have
been removed.
CALLED BY: (GLOBAL)
PASS: dx = offset of FSDriver to remove
RETURN: carry set if driver may not be removed, as there's a
driver still defined that refers to it
carry clear if driver removed
DESTROYED: ax, dx
SIDE EFFECTS: various
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 5/12/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDUnregister proc far
uses ds, bx, si
.enter
call FSDLockInfoExcl
mov ds, ax
assume ds:FSInfoResource
EC < mov ax, offset FIH_fsdList - offset FSD_next >
EC <ensureIsFSDLoop: >
EC < mov_tr bx, ax >
EC < mov ax, ds:[bx].FSD_next >
EC < cmp dx, ax >
EC < je isFSD >
EC < tst ax >
EC < jnz ensureIsFSDLoop >
EC < ERROR INVALID_FSDRIVER_OFFSET >
EC <isFSD: >
;
; Make sure there are no drives referencing the FSD.
;
mov si, offset FIH_driveList - offset DSE_next
driveCheckLoop:
mov bx, si
mov si, ds:[bx].DSE_next
tst si
jz allDrivesGone
cmp ds:[si].DSE_fsd, dx
jne driveCheckLoop
stc
jmp done
allDrivesGone:
;
; Now locate the thing that points to the driver being removed
;
mov si, offset FIH_fsdList - offset FSD_next
findPrevFSDLoop:
mov bx, si
mov si, ds:[bx].FSD_next
cmp si, dx
jne findPrevFSDLoop
;
; Unlink the driver from the chain.
;
mov si, ds:[si].FSD_next
mov ds:[bx].FSD_next, si
;
; If the driver was the primary, clear out references to it.
;
cmp ds:[FIH_primaryFSD], dx
jne nukeIt
push es
LoadVarSeg es, ax
assume es:dgroup
mov es:[defaultDrivers].DDT_fileSystem, 0
mov ds:[FIH_primaryFSD], 0
pop es
assume es:nothing
nukeIt:
;
; Finally, biff the chunk.
;
mov_tr ax, dx
call LMemFree
clc
done:
call FSDUnlockInfoExcl
assume ds:dgroup
.leave
ret
FSDUnregister endp
FSResident ends
;--------------------------------------------------------------
FileCommon segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDInformOldFSDOfPathNukage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Inform the FSD on which the passed path block was located
that the thing is about to be freed.
CALLED BY: FileDeletePath, SetCurPathUsingStdPath, GLOBAL
PASS: bx = FilePath block
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 10/21/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDInformOldFSDOfPathNukage proc far
uses bp, si, di, ds
.enter
LoadVarSeg ds
mov si, ds:[bx].HM_otherInfo
test si, DISK_IS_STD_PATH_MASK ; StandardPath?
jnz done ; yes
mov di, DR_FS_CUR_PATH_DELETE
call DiskCallFSD
done:
.leave
ret
FSDInformOldFSDOfPathNukage endp
FileCommon ends
;----------------------------------------------
FSResident segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDInt21
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Call to DOS after grabbing the DOS/BIOS lock
CALLED BY: ?
PASS: registers set up for DOS call
RETURN: ?
DESTROYED: nothing by us...
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 4/ 6/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDInt21 proc near
.enter
;disallow calling function 0 this way (really old-fashioned exit), as it
; sends the machine off the deep end, making it hard to debug
EC < cmp ah, 0 >
EC < ERROR_E GASP_CHOKE_WHEEZE >
;
; Gain exclusive access to DOS/BIOS
;
call SysLockBIOSFar
;
; Copy dosAddr into callVector.segment and callTemporary. We use this,
; instead of callVector itself, because callVector.offset is already
; set up by ProcCallModuleRoutine when it attempts to lock a non-
; resident resource. As such, the offset portion is unbiffable. The
; segment portion, however, cannot possibly have been set up yet, and
; callTemporary is never used anywhere, so...
;
push ds
push ax
LoadVarSeg ds, ax
mov ax, ds:dosAddr.segment
mov ss:TPD_callTemporary, ax
mov ax, ds:dosAddr.offset
mov ss:TPD_callVector.segment, ax
pop ax
pop ds
;
; Emulate interrupt
;
; Turn off the trap flag first, as otherwise we'll turn trapping
; back on when we return from the interrupt
SSP < call SaveAndDisableSingleStepping >
pushf
INT_OFF
if TEST_RECORD_INT21
call FSDRecordInt21Call ; destroys flags
endif
call {dword}ss:TPD_callVector.segment
SSP < call RestoreSingleStepping >
;
; Handle critical errors in the gross way necessitated by some versions
; of DOS.
;
pushf
cmp ss:TPD_callTemporary, 1 ; Error detected?
ja noCritical ; Nope (DOS must have
; been in a segment >
; 1)
pop ax ; Set carry in saved
or ax, ss:TPD_callTemporary ; flags if appropriate
push ax
mov ax, ss:TPD_callVector.segment ; ax <- error code
noCritical:
if TEST_RECORD_INT21
call FSDEndInt21Call ; destroys flags
endif
popf
;
; Release DOS/BIOS lock
;
call SysUnlockBIOSFar
done::
.leave
ret
FSDInt21 endp
if TEST_RECORD_INT21
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDRecordInt21Call
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Records calls made to DOS with Int21
CALLED BY: FSDInt21
PASS: AH = Int21Call enumerated type (function)
Interrupts are OFF
RETURN: Nothing
DESTROYED: flags
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 4/15/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDRecordInt21Call proc near
uses ax, bx, ds
.enter
; Record the current time
;
push ax
LoadVarSeg ds, ax
call TimerStartCount ; record starting count
mov ds:[recInt21Start].TR_ticks, bx
mov ds:[recInt21Start].TR_units, ax
pop ax
; Increment the usage count
;
mov al, ah
clr ah
shl ax, 1
mov bx, ax
shl ax, 1
add bx, ax ; offset into recInt21Table=> BX
add bx, offset recInt21Table
inc ds:[bx].IRE_count
mov ds:[recInt21Func], bx
; Now track any amount we are reading or writing
;
clr bx ; use as a high word later
cmp ax, MSDOS_READ_FILE * 4
je readFile
cmp ax, MSDOS_WRITE_FILE * 4
je writeFile
done:
.leave
ret
; Record information for file reads or writes
readFile:
adddw ds:[recFileReads], bxcx
jmp done
writeFile:
adddw ds:[recFileWrites], bxcx
jmp done
FSDRecordInt21Call endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDEndInt21Call
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Record the time spent in an Int21 call
CALLED BY: FSDInt21
PASS: Inerrupts ON
RETURN: Nothing
DESTROYED: flags
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
Don 4/16/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDEndInt21Call proc near
uses ax, bx, si, ds
.enter
; Now record the end of the call
;
LoadVarSeg ds, ax
mov bx, ds:[recInt21Start].TR_ticks
mov ax, ds:[recInt21Start].TR_units
mov si, ds:[recInt21Func] ; elapsed time buffer => DS:SI
call TimerEndCount ; update elapsed time
.leave
ret
FSDEndInt21Call endp
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDRecordError
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Record a critical error for the current thread.
CALLED BY: FS driver
PASS: ax = error code to return
bx = 0 if should not set carry on return
= 1 if should set carry on return
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
store the error code in TPD_callVector.segment and the
carry/error flag in TPD_callTemporary. Since DOS must be in
a segment other than 0 or 1, we can safely use callTemporary
being below 1 as a signal that an error occurred.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 4/16/90 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDRecordError proc far
.enter
mov ss:[TPD_callTemporary], bx
mov ss:[TPD_callVector.segment], ax
.leave
ret
FSDRecordError endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDGetThreadPathDiskHandle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Fetch the disk handle from the current thread's current
path.
CALLED BY: FSDs
PASS: nothing
RETURN: bx = disk handle for thread's current path. This may
be a member of the StandardPath enum. If
BX & DISK_IS_STD_PATH_MASK
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 10/23/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDGetThreadPathDiskHandle proc far
uses ds
.enter
LoadVarSeg ds, bx
mov bx, ss:[TPD_curPath]
tst bx
jz done ; XXX: necessary?
mov bx, ds:[bx].HM_otherInfo
done:
.leave
ret
FSDGetThreadPathDiskHandle endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDCheckOpenCloseNotifyEnabled
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: See if FCNT_OPEN/FCNT_CLOSE notification is enabled
CALLED BY: (RESTRICTED GLOBAL)
PASS: nothing
RETURN: carry set if notification is enabled
DESTROYED: nothing
SIDE EFFECTS: none
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDCheckOpenCloseNotifyEnabled proc far
uses ds
.enter
LoadVarSeg ds
tst ds:[openCloseNotificationCount]
jz done
stc
done:
.leave
ret
FSDCheckOpenCloseNotifyEnabled endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDGenerateNotify
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Generate file-change notification from the passed
parameters.
CALLED BY: (RESTRICTED GLOBAL)
PASS: ax = FileChangeNotificationType
if ax != FCNT_BATCH
si = disk handle
cxdx = ID to pass (either of affected file or
containing directory)
ds:bx = file name, if needed
else
bx = handle of FileChangeBatchNotificationData
RETURN: carry set if notification discarded due to lack of memory
DESTROYED: ax, bx, cx, dx
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/10/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDGenerateNotify proc far
uses es, si, di, bp
.enter
tst ss:[TPD_fsNotifyBatch]
jz straightNotify
call FSDAddNotifyToBatch
jmp done
straightNotify:
cmp ax, FCNT_BATCH
jne notBatch
mov_tr dx, ax
jmp sendNotify
notBatch:
;
; Allocate a data block to convey our meaning.
;
push ax, bx, cx
mov ax, size FileChangeNotificationData
mov cx, ALLOC_DYNAMIC_LOCK or mask HF_SHARABLE
call MemAllocFar
jc memErr
;
; Store the constant parts of the data (disk handle, and ID for
; something).
;
mov es, ax
mov es:[FCND_disk], si
mov es:[FCND_id].low, dx
pop es:[FCND_id].high
;
; See if we need to copy a filename in.
;
pop si ; ds:si <- filename
pop dx ; dx <- FCNT
CheckHack <FCNT_CREATE eq 0 and FCNT_RENAME eq 1>
cmp dx, FCNT_RENAME ; only rename and create take a
; file name.
ja unlockBlock ; => no name required
;
; Copy the filename from ds:di to es:FCND_name
;
mov di, offset FCND_name
LocalCopyString ;copy NULL-terminated string
unlockBlock:
call MemUnlock
sendNotify:
;
; Initialize the reference count for the data block to 1, to
; account for what GCNListSend does.
;
mov ax, 1
call MemInitRefCount
mov bp, bx ; bp <- data block
;
; Record the MSG_NOTIFY_FILE_CHANGE going to no class in particular.
;
mov ax, MSG_NOTIFY_FILE_CHANGE
clr bx, si
mov di, mask MF_RECORD
call ObjMessage
;
; Call GCNListSend
;
mov cx, di ; cx <- event handle
mov bx, MANUFACTURER_ID_GEOWORKS ; bxax <- list ID
mov ax, GCNSLT_FILE_SYSTEM
mov dx, bp ; dx <- data block
mov bp, mask GCNLSF_FORCE_QUEUE ; now would be a bad
; time to field this
; message on this
; thread...
call GCNListSend
clc ; GCNListSend may
; modify flags...
done:
.leave
ret
memErr:
pop ax, bx, cx
jmp done
FSDGenerateNotify endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDAddNotifyToBatch
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Add the passed notification to the batch we're building
for this thread.
CALLED BY: (INTERNAL) FSDGenerateNotify
PASS: ax = FileChangeNotificationType
si = disk handle
cxdx = ID to pass (either of affected file or containing
directory)
ds:bx = file name, if needed
RETURN: nothing
DESTROYED: ax, bx, cx, dx, es, si, di, bp
SIDE EFFECTS: a new block for ss:[TPD_fsNotifyBatch] may be allocated
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/12/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDAddNotifyToBatch proc near
.enter
mov di, bx ; save file name
mov bx, ss:[TPD_fsNotifyBatch]
push ax ; save notification type
lockIt:
call MemLock
mov es, ax
cmp es:[FCBND_end], FSD_MAX_BATCH_SIZE
jbe addToThisOne
;
; Not enough room here. Allocate a new block and link it to the existing
; one through the HM_otherInfo.
;
call MemUnlock
push bx
call FSDAllocNewBatchBlock
pop ax
jc memErr
call MemModifyOtherInfo
mov ss:[TPD_fsNotifyBatch], bx
jmp lockIt
addToThisOne:
;
; Enlarge the block enough to hold the data for the notification,
; coping with some things having a name (FCNT_CREATE, FCNT_RENAME)
; and others not.
;
pop ax
push ax
cmp ax, FCNT_RENAME
mov ax, size FileChangeBatchNotificationItem
ja haveSize
mov ax, size FileChangeBatchNotificationItem + \
size FileLongName
haveSize:
push cx
add ax, es:[FCBND_end]
mov bp, ax
add ax, FSD_ALLOC_GRANULARITY-1 ; round up
andnf ax, not (FSD_ALLOC_GRANULARITY-1)
;
; Now see if we actually need to call MemReAlloc (faster to perform
; this check ourselves than having to get the heap semaphore and
; all that other stuff just to realize there's no change in size)
;
LoadVarSeg es, cx
mov cx, es:[bx].HM_size
shl cx
shl cx
shl cx
shl cx
cmp cx, ax
jb enlargeIt
mov es, es:[bx].HM_addr ; reload ES, since we're not
; changing it (block is locked)
;
; Fetch where we're to put this notification and adjust the pointer for
; the next time.
;
storeNotification:
mov bx, es:[FCBND_end]
FSDANTB_haveOffset label near
ForceRef FSDANTB_haveOffset ; for showcalls -F
mov es:[FCBND_end], bp
;
; Record all the fixed information.
;
pop es:[bx].FCBNI_id.high
mov es:[bx].FCBNI_id.low, dx
mov es:[bx].FCBNI_disk, si
pop ax
mov es:[bx].FCBNI_type, ax
;
; Copy the name in, if appropriate.
;
cmp ax, FCNT_RENAME
ja notificationComplete
mov si, di ; ds:si <- file name
lea di, es:[bx].FCBNI_name ; es:di <- dest
mov cx, length FileLongName
LocalCopyNString ;rep movsb/movsw
notificationComplete:
;
; Unlock the batch block and return.
;
mov bx, ss:[TPD_fsNotifyBatch]
call MemUnlock
clc
done:
.leave
ret
enlargeErr:
pop cx
memErr:
pop ax
jmp done
enlargeIt:
mov cx, (mask HAF_ZERO_INIT) shl 8
call MemReAlloc
jc enlargeErr
mov es, ax
jmp storeNotification
FSDAddNotifyToBatch endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FSDAllocNewBatchBlock
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Allocate a block to batch up file-system change notifications
CALLED BY: (INTERNAL)
PASS: nothing
RETURN: bx = handle of block
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 11/12/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FSDAllocNewBatchBlock proc near
uses ax, ds, cx
.enter
mov ax, FSD_ALLOC_GRANULARITY
mov cx, ALLOC_DYNAMIC_LOCK or mask HF_SHARABLE
call MemAllocFar
jc done
mov ds, ax
mov ds:[FCBND_end], offset FCBND_items
clr ax ; null-terminate
call MemModifyOtherInfo ; in case only item in list
call MemUnlock
done:
.leave
ret
FSDAllocNewBatchBlock endp
FSResident ends
|
//===- DebugInfoMetadata.cpp - Implement debug info metadata --------------===//
//
// The LLVM37 Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the debug info Metadata classes.
//
//===----------------------------------------------------------------------===//
#include "llvm37/IR/DebugInfoMetadata.h"
#include "LLVMContextImpl.h"
#include "MetadataImpl.h"
#include "llvm37/ADT/StringSwitch.h"
#include "llvm37/IR/Function.h"
using namespace llvm37;
DILocation::DILocation(LLVM37Context &C, StorageType Storage, unsigned Line,
unsigned Column, ArrayRef<Metadata *> MDs)
: MDNode(C, DILocationKind, Storage, MDs) {
assert((MDs.size() == 1 || MDs.size() == 2) &&
"Expected a scope and optional inlined-at");
// Set line and column.
assert(Column < (1u << 16) && "Expected 16-bit column");
SubclassData32 = Line;
SubclassData16 = Column;
}
static void adjustColumn(unsigned &Column) {
// Set to unknown on overflow. We only have 16 bits to play with here.
if (Column >= (1u << 16))
Column = 0;
}
DILocation *DILocation::getImpl(LLVM37Context &Context, unsigned Line,
unsigned Column, Metadata *Scope,
Metadata *InlinedAt, StorageType Storage,
bool ShouldCreate) {
// Fixup column.
adjustColumn(Column);
assert(Scope && "Expected scope");
if (Storage == Uniqued) {
if (auto *N =
getUniqued(Context.pImpl->DILocations,
DILocationInfo::KeyTy(Line, Column, Scope, InlinedAt)))
return N;
if (!ShouldCreate)
return nullptr;
} else {
assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
}
SmallVector<Metadata *, 2> Ops;
Ops.push_back(Scope);
if (InlinedAt)
Ops.push_back(InlinedAt);
return storeImpl(new (Ops.size())
DILocation(Context, Storage, Line, Column, Ops),
Storage, Context.pImpl->DILocations);
}
unsigned DILocation::computeNewDiscriminator() const {
// FIXME: This seems completely wrong.
//
// 1. If two modules are generated in the same context, then the second
// Module will get different discriminators than it would have if it were
// generated in its own context.
// 2. If this function is called after round-tripping to bitcode instead of
// before, it will give a different (and potentially incorrect!) return.
//
// The discriminator should instead be calculated from local information
// where it's actually needed. This logic should be moved to
// AddDiscriminators::runOnFunction(), where it doesn't pollute the
// LLVM37Context.
std::pair<const char *, unsigned> Key(getFilename().data(), getLine());
return ++getContext().pImpl->DiscriminatorTable[Key];
}
unsigned DINode::getFlag(StringRef Flag) {
return StringSwitch<unsigned>(Flag)
#define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
#include "llvm37/IR/DebugInfoFlags.def"
.Default(0);
}
const char *DINode::getFlagString(unsigned Flag) {
switch (Flag) {
default:
return "";
#define HANDLE_DI_FLAG(ID, NAME) \
case Flag##NAME: \
return "DIFlag" #NAME;
#include "llvm37/IR/DebugInfoFlags.def"
}
}
unsigned DINode::splitFlags(unsigned Flags,
SmallVectorImpl<unsigned> &SplitFlags) {
// Accessibility flags need to be specially handled, since they're packed
// together.
if (unsigned A = Flags & FlagAccessibility) {
if (A == FlagPrivate)
SplitFlags.push_back(FlagPrivate);
else if (A == FlagProtected)
SplitFlags.push_back(FlagProtected);
else
SplitFlags.push_back(FlagPublic);
Flags &= ~A;
}
#define HANDLE_DI_FLAG(ID, NAME) \
if (unsigned Bit = Flags & ID) { \
SplitFlags.push_back(Bit); \
Flags &= ~Bit; \
}
#include "llvm37/IR/DebugInfoFlags.def"
return Flags;
}
DIScopeRef DIScope::getScope() const {
if (auto *T = dyn_cast<DIType>(this))
return T->getScope();
if (auto *SP = dyn_cast<DISubprogram>(this))
return SP->getScope();
if (auto *LB = dyn_cast<DILexicalBlockBase>(this))
return DIScopeRef(LB->getScope());
if (auto *NS = dyn_cast<DINamespace>(this))
return DIScopeRef(NS->getScope());
if (auto *M = dyn_cast<DIModule>(this))
return DIScopeRef(M->getScope());
assert((isa<DIFile>(this) || isa<DICompileUnit>(this)) &&
"Unhandled type of scope.");
return nullptr;
}
StringRef DIScope::getName() const {
if (auto *T = dyn_cast<DIType>(this))
return T->getName();
if (auto *SP = dyn_cast<DISubprogram>(this))
return SP->getName();
if (auto *NS = dyn_cast<DINamespace>(this))
return NS->getName();
if (auto *M = dyn_cast<DIModule>(this))
return M->getName();
assert((isa<DILexicalBlockBase>(this) || isa<DIFile>(this) ||
isa<DICompileUnit>(this)) &&
"Unhandled type of scope.");
return "";
}
static StringRef getString(const MDString *S) {
if (S)
return S->getString();
return StringRef();
}
#ifndef NDEBUG
static bool isCanonical(const MDString *S) {
return !S || !S->getString().empty();
}
#endif
GenericDINode *GenericDINode::getImpl(LLVM37Context &Context, unsigned Tag,
MDString *Header,
ArrayRef<Metadata *> DwarfOps,
StorageType Storage, bool ShouldCreate) {
unsigned Hash = 0;
if (Storage == Uniqued) {
GenericDINodeInfo::KeyTy Key(Tag, getString(Header), DwarfOps);
if (auto *N = getUniqued(Context.pImpl->GenericDINodes, Key))
return N;
if (!ShouldCreate)
return nullptr;
Hash = Key.getHash();
} else {
assert(ShouldCreate && "Expected non-uniqued nodes to always be created");
}
// Use a nullptr for empty headers.
assert(isCanonical(Header) && "Expected canonical MDString");
Metadata *PreOps[] = {Header};
return storeImpl(new (DwarfOps.size() + 1) GenericDINode(
Context, Storage, Hash, Tag, PreOps, DwarfOps),
Storage, Context.pImpl->GenericDINodes);
}
void GenericDINode::recalculateHash() {
setHash(GenericDINodeInfo::KeyTy::calculateHash(this));
}
#define UNWRAP_ARGS_IMPL(...) __VA_ARGS__
#define UNWRAP_ARGS(ARGS) UNWRAP_ARGS_IMPL ARGS
#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) \
do { \
if (Storage == Uniqued) { \
if (auto *N = getUniqued(Context.pImpl->CLASS##s, \
CLASS##Info::KeyTy(UNWRAP_ARGS(ARGS)))) \
return N; \
if (!ShouldCreate) \
return nullptr; \
} else { \
assert(ShouldCreate && \
"Expected non-uniqued nodes to always be created"); \
} \
} while (false)
#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) \
return storeImpl(new (ArrayRef<Metadata *>(OPS).size()) \
CLASS(Context, Storage, UNWRAP_ARGS(ARGS), OPS), \
Storage, Context.pImpl->CLASS##s)
#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) \
return storeImpl(new (0u) CLASS(Context, Storage, UNWRAP_ARGS(ARGS)), \
Storage, Context.pImpl->CLASS##s)
#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) \
return storeImpl(new (ArrayRef<Metadata *>(OPS).size()) \
CLASS(Context, Storage, OPS), \
Storage, Context.pImpl->CLASS##s)
DISubrange *DISubrange::getImpl(LLVM37Context &Context, int64_t Count, int64_t Lo,
StorageType Storage, bool ShouldCreate) {
DEFINE_GETIMPL_LOOKUP(DISubrange, (Count, Lo));
DEFINE_GETIMPL_STORE_NO_OPS(DISubrange, (Count, Lo));
}
DIEnumerator *DIEnumerator::getImpl(LLVM37Context &Context, int64_t Value,
MDString *Name, StorageType Storage,
bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIEnumerator, (Value, getString(Name)));
Metadata *Ops[] = {Name};
DEFINE_GETIMPL_STORE(DIEnumerator, (Value), Ops);
}
DIBasicType *DIBasicType::getImpl(LLVM37Context &Context, unsigned Tag,
MDString *Name, uint64_t SizeInBits,
uint64_t AlignInBits, unsigned Encoding,
StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(
DIBasicType, (Tag, getString(Name), SizeInBits, AlignInBits, Encoding));
Metadata *Ops[] = {nullptr, nullptr, Name};
DEFINE_GETIMPL_STORE(DIBasicType, (Tag, SizeInBits, AlignInBits, Encoding),
Ops);
}
DIDerivedType *DIDerivedType::getImpl(
LLVM37Context &Context, unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
Metadata *ExtraData, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIDerivedType, (Tag, getString(Name), File, Line, Scope,
BaseType, SizeInBits, AlignInBits,
OffsetInBits, Flags, ExtraData));
Metadata *Ops[] = {File, Scope, Name, BaseType, ExtraData};
DEFINE_GETIMPL_STORE(
DIDerivedType, (Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags),
Ops);
}
DICompositeType *DICompositeType::getImpl(
LLVM37Context &Context, unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams, MDString *Identifier, StorageType Storage,
bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DICompositeType,
(Tag, getString(Name), File, Line, Scope, BaseType,
SizeInBits, AlignInBits, OffsetInBits, Flags, Elements,
RuntimeLang, VTableHolder, TemplateParams,
getString(Identifier)));
Metadata *Ops[] = {File, Scope, Name, BaseType,
Elements, VTableHolder, TemplateParams, Identifier};
DEFINE_GETIMPL_STORE(DICompositeType, (Tag, Line, RuntimeLang, SizeInBits,
AlignInBits, OffsetInBits, Flags),
Ops);
}
DISubroutineType *DISubroutineType::getImpl(LLVM37Context &Context,
unsigned Flags, Metadata *TypeArray,
StorageType Storage,
bool ShouldCreate) {
DEFINE_GETIMPL_LOOKUP(DISubroutineType, (Flags, TypeArray));
Metadata *Ops[] = {nullptr, nullptr, nullptr, nullptr,
TypeArray, nullptr, nullptr, nullptr};
DEFINE_GETIMPL_STORE(DISubroutineType, (Flags), Ops);
}
DIFile *DIFile::getImpl(LLVM37Context &Context, MDString *Filename,
MDString *Directory, StorageType Storage,
bool ShouldCreate) {
assert(isCanonical(Filename) && "Expected canonical MDString");
assert(isCanonical(Directory) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIFile, (getString(Filename), getString(Directory)));
Metadata *Ops[] = {Filename, Directory};
DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIFile, Ops);
}
DICompileUnit *DICompileUnit::getImpl(
LLVM37Context &Context, unsigned SourceLanguage, Metadata *File,
MDString *Producer, bool IsOptimized, MDString *Flags,
unsigned RuntimeVersion, MDString *SplitDebugFilename,
unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
Metadata *Subprograms, Metadata *GlobalVariables,
Metadata *ImportedEntities, uint64_t DWOId,
StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Producer) && "Expected canonical MDString");
assert(isCanonical(Flags) && "Expected canonical MDString");
assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(
DICompileUnit,
(SourceLanguage, File, getString(Producer), IsOptimized, getString(Flags),
RuntimeVersion, getString(SplitDebugFilename), EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables, ImportedEntities, DWOId));
Metadata *Ops[] = {File, Producer, Flags, SplitDebugFilename, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
ImportedEntities};
DEFINE_GETIMPL_STORE(
DICompileUnit,
(SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind, DWOId), Ops);
}
DISubprogram *DILocalScope::getSubprogram() const {
if (auto *Block = dyn_cast<DILexicalBlockBase>(this))
return Block->getScope()->getSubprogram();
return const_cast<DISubprogram *>(cast<DISubprogram>(this));
}
DISubprogram *DISubprogram::getImpl(
LLVM37Context &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
unsigned Flags, bool IsOptimized, Metadata *Function,
Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
assert(isCanonical(LinkageName) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DISubprogram,
(Scope, getString(Name), getString(LinkageName), File,
Line, Type, IsLocalToUnit, IsDefinition, ScopeLine,
ContainingType, Virtuality, VirtualIndex, Flags,
IsOptimized, Function, TemplateParams, Declaration,
Variables));
Metadata *Ops[] = {File, Scope, Name, Name,
LinkageName, Type, ContainingType, Function,
TemplateParams, Declaration, Variables};
DEFINE_GETIMPL_STORE(DISubprogram,
(Line, ScopeLine, Virtuality, VirtualIndex, Flags,
IsLocalToUnit, IsDefinition, IsOptimized),
Ops);
}
Function *DISubprogram::getFunction() const {
// FIXME: Should this be looking through bitcasts?
return dyn_cast_or_null<Function>(getFunctionConstant());
}
bool DISubprogram::describes(const Function *F) const {
assert(F && "Invalid function");
if (F == getFunction())
return true;
StringRef Name = getLinkageName();
if (Name.empty())
Name = getName();
return F->getName() == Name;
}
void DISubprogram::replaceFunction(Function *F) {
replaceFunction(F ? ConstantAsMetadata::get(F)
: static_cast<ConstantAsMetadata *>(nullptr));
}
DILexicalBlock *DILexicalBlock::getImpl(LLVM37Context &Context, Metadata *Scope,
Metadata *File, unsigned Line,
unsigned Column, StorageType Storage,
bool ShouldCreate) {
assert(Scope && "Expected scope");
DEFINE_GETIMPL_LOOKUP(DILexicalBlock, (Scope, File, Line, Column));
Metadata *Ops[] = {File, Scope};
DEFINE_GETIMPL_STORE(DILexicalBlock, (Line, Column), Ops);
}
DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVM37Context &Context,
Metadata *Scope, Metadata *File,
unsigned Discriminator,
StorageType Storage,
bool ShouldCreate) {
assert(Scope && "Expected scope");
DEFINE_GETIMPL_LOOKUP(DILexicalBlockFile, (Scope, File, Discriminator));
Metadata *Ops[] = {File, Scope};
DEFINE_GETIMPL_STORE(DILexicalBlockFile, (Discriminator), Ops);
}
DINamespace *DINamespace::getImpl(LLVM37Context &Context, Metadata *Scope,
Metadata *File, MDString *Name, unsigned Line,
StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DINamespace, (Scope, File, getString(Name), Line));
Metadata *Ops[] = {File, Scope, Name};
DEFINE_GETIMPL_STORE(DINamespace, (Line), Ops);
}
DIModule *DIModule::getImpl(LLVM37Context &Context, Metadata *Scope,
MDString *Name, MDString *ConfigurationMacros,
MDString *IncludePath, MDString *ISysRoot,
StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIModule,
(Scope, getString(Name), getString(ConfigurationMacros),
getString(IncludePath), getString(ISysRoot)));
Metadata *Ops[] = {Scope, Name, ConfigurationMacros, IncludePath, ISysRoot};
DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DIModule, Ops);
}
DITemplateTypeParameter *DITemplateTypeParameter::getImpl(LLVM37Context &Context,
MDString *Name,
Metadata *Type,
StorageType Storage,
bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DITemplateTypeParameter, (getString(Name), Type));
Metadata *Ops[] = {Name, Type};
DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(DITemplateTypeParameter, Ops);
}
DITemplateValueParameter *DITemplateValueParameter::getImpl(
LLVM37Context &Context, unsigned Tag, MDString *Name, Metadata *Type,
Metadata *Value, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DITemplateValueParameter,
(Tag, getString(Name), Type, Value));
Metadata *Ops[] = {Name, Type, Value};
DEFINE_GETIMPL_STORE(DITemplateValueParameter, (Tag), Ops);
}
DIGlobalVariable *
DIGlobalVariable::getImpl(LLVM37Context &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line,
Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
Metadata *Variable,
Metadata *StaticDataMemberDeclaration,
StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
assert(isCanonical(LinkageName) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIGlobalVariable,
(Scope, getString(Name), getString(LinkageName), File,
Line, Type, IsLocalToUnit, IsDefinition, Variable,
StaticDataMemberDeclaration));
Metadata *Ops[] = {Scope, Name, File, Type,
Name, LinkageName, Variable, StaticDataMemberDeclaration};
DEFINE_GETIMPL_STORE(DIGlobalVariable, (Line, IsLocalToUnit, IsDefinition),
Ops);
}
DILocalVariable *DILocalVariable::getImpl(LLVM37Context &Context, unsigned Tag,
Metadata *Scope, MDString *Name,
Metadata *File, unsigned Line,
Metadata *Type, unsigned Arg,
unsigned Flags, StorageType Storage,
bool ShouldCreate) {
// 64K ought to be enough for any frontend.
assert(Arg <= UINT16_MAX && "Expected argument number to fit in 16-bits");
assert(Scope && "Expected scope");
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DILocalVariable, (Tag, Scope, getString(Name), File,
Line, Type, Arg, Flags));
Metadata *Ops[] = {Scope, Name, File, Type};
DEFINE_GETIMPL_STORE(DILocalVariable, (Tag, Line, Arg, Flags), Ops);
}
DIExpression *DIExpression::getImpl(LLVM37Context &Context,
ArrayRef<uint64_t> Elements,
StorageType Storage, bool ShouldCreate) {
DEFINE_GETIMPL_LOOKUP(DIExpression, (Elements));
DEFINE_GETIMPL_STORE_NO_OPS(DIExpression, (Elements));
}
unsigned DIExpression::ExprOperand::getSize() const {
switch (getOp()) {
case dwarf::DW_OP_bit_piece:
return 3;
case dwarf::DW_OP_plus:
return 2;
default:
return 1;
}
}
bool DIExpression::isValid() const {
for (auto I = expr_op_begin(), E = expr_op_end(); I != E; ++I) {
// Check that there's space for the operand.
if (I->get() + I->getSize() > E->get())
return false;
// Check that the operand is valid.
switch (I->getOp()) {
default:
return false;
case dwarf::DW_OP_bit_piece:
// Piece expressions must be at the end.
return I->get() + I->getSize() == E->get();
case dwarf::DW_OP_plus:
case dwarf::DW_OP_deref:
break;
}
}
return true;
}
bool DIExpression::isBitPiece() const {
assert(isValid() && "Expected valid expression");
if (unsigned N = getNumElements())
if (N >= 3)
return getElement(N - 3) == dwarf::DW_OP_bit_piece;
return false;
}
uint64_t DIExpression::getBitPieceOffset() const {
assert(isBitPiece() && "Expected bit piece");
return getElement(getNumElements() - 2);
}
uint64_t DIExpression::getBitPieceSize() const {
assert(isBitPiece() && "Expected bit piece");
return getElement(getNumElements() - 1);
}
DIObjCProperty *DIObjCProperty::getImpl(
LLVM37Context &Context, MDString *Name, Metadata *File, unsigned Line,
MDString *GetterName, MDString *SetterName, unsigned Attributes,
Metadata *Type, StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
assert(isCanonical(GetterName) && "Expected canonical MDString");
assert(isCanonical(SetterName) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIObjCProperty,
(getString(Name), File, Line, getString(GetterName),
getString(SetterName), Attributes, Type));
Metadata *Ops[] = {Name, File, GetterName, SetterName, Type};
DEFINE_GETIMPL_STORE(DIObjCProperty, (Line, Attributes), Ops);
}
DIImportedEntity *DIImportedEntity::getImpl(LLVM37Context &Context, unsigned Tag,
Metadata *Scope, Metadata *Entity,
unsigned Line, MDString *Name,
StorageType Storage,
bool ShouldCreate) {
assert(isCanonical(Name) && "Expected canonical MDString");
DEFINE_GETIMPL_LOOKUP(DIImportedEntity,
(Tag, Scope, Entity, Line, getString(Name)));
Metadata *Ops[] = {Scope, Entity, Name};
DEFINE_GETIMPL_STORE(DIImportedEntity, (Tag, Line), Ops);
}
|
; A022325: a(n) = a(n-1) + a(n-2) + 1, with a(0) = 1 and a(1) = 11.
; 1,11,13,25,39,65,105,171,277,449,727,1177,1905,3083,4989,8073,13063,21137,34201,55339,89541,144881,234423,379305,613729,993035,1606765,2599801,4206567,6806369,11012937,17819307,28832245,46651553,75483799,122135353,197619153,319754507,517373661,837128169,1354501831,2191630001,3546131833,5737761835,9283893669,15021655505,24305549175,39327204681,63632753857,102959958539,166592712397,269552670937,436145383335,705698054273,1141843437609,1847541491883,2989384929493,4836926421377,7826311350871,12663237772249,20489549123121,33152786895371,53642336018493,86795122913865,140437458932359,227232581846225,367670040778585,594902622624811,962572663403397,1557475286028209,2520047949431607,4077523235459817,6597571184891425
mov $1,1
mov $3,9
lpb $0
sub $0,1
mov $2,$1
add $3,1
add $1,$3
mov $3,$2
lpe
|
// Distributed under the MIT License.
// See LICENSE.txt for details.
#include "Framework/TestingFramework.hpp"
#include <cstddef>
#include <limits>
#include <string>
#include "Domain/Structure/SegmentId.hpp"
#include "Domain/Structure/Side.hpp"
#include "ErrorHandling/Error.hpp"
#include "Framework/TestHelpers.hpp"
#include "Utilities/ConstantExpressions.hpp"
#include "Utilities/GetOutput.hpp"
SPECTRE_TEST_CASE("Unit.Domain.SegmentId", "[Domain][Unit]") {
// Test equality operator:
SegmentId segment_one(4, 3);
SegmentId segment_two(4, 3);
SegmentId segment_three(4, 0);
SegmentId segment_four(5, 4);
CHECK(segment_one == segment_two);
CHECK(segment_two != segment_three);
CHECK(segment_two != segment_four);
// Test pup operations:
test_serialization(segment_one);
// Test parent and child operations:
for (size_t level = 0; level < 5; ++level) {
const double segment_length = 2.0 / two_to_the(level);
double midpoint = -1.0 + 0.5 * segment_length;
for (size_t segment_index = 0; segment_index < two_to_the(level);
++segment_index) {
SegmentId id(level, segment_index);
CHECK(id.midpoint() == midpoint);
CHECK((id.endpoint(Side::Upper) + id.endpoint(Side::Lower)) / 2. ==
midpoint);
CHECK(id.endpoint(Side::Upper) - id.endpoint(Side::Lower) ==
segment_length);
midpoint += segment_length;
CHECK(id == id.id_of_child(Side::Lower).id_of_parent());
CHECK(id == id.id_of_child(Side::Upper).id_of_parent());
CHECK(id.overlaps(id));
if (0 != level) {
CHECK(id.overlaps(id.id_of_parent()));
const Side side_of_parent =
0 == segment_index % 2 ? Side::Lower : Side::Upper;
CHECK(id == id.id_of_parent().id_of_child(side_of_parent));
CHECK_FALSE(id.overlaps(
id.id_of_parent().id_of_child(opposite(side_of_parent))));
}
CHECK(id.id_of_child(Side::Lower).id_of_sibling() ==
id.id_of_child(Side::Upper));
CHECK(id.id_of_child(Side::Upper).id_of_sibling() ==
id.id_of_child(Side::Lower));
CHECK(id.id_of_child(Side::Lower).id_of_abutting_nibling() ==
id.id_of_child(Side::Upper).id_of_child(Side::Lower));
CHECK(id.id_of_child(Side::Upper).id_of_abutting_nibling() ==
id.id_of_child(Side::Lower).id_of_child(Side::Upper));
CHECK(id.id_of_child(Side::Lower).side_of_sibling() == Side::Upper);
CHECK(id.id_of_child(Side::Upper).side_of_sibling() == Side::Lower);
}
}
// Test retrieval functions:
SegmentId level_2_index_3(2, 3);
CHECK(level_2_index_3.refinement_level() == 2);
CHECK(level_2_index_3.index() == 3);
// Test output operator:
SegmentId level_3_index_2(3, 2);
CHECK(get_output(level_3_index_2) == "L3I2");
}
// [[OutputRegex, index = 8, refinement_level = 3]]
[[noreturn]] SPECTRE_TEST_CASE("Unit.Domain.SegmentId.BadIndex",
"[Domain][Unit]") {
ASSERTION_TEST();
#ifdef SPECTRE_DEBUG
auto failed_segment_id = SegmentId(3, 8);
static_cast<void>(failed_segment_id);
ERROR("Failed to trigger ASSERT in an assertion test");
#endif
}
// [[OutputRegex, on root refinement level!]]
[[noreturn]] SPECTRE_TEST_CASE("Unit.Domain.SegmentId.NoParent",
"[Domain][Unit]") {
ASSERTION_TEST();
#ifdef SPECTRE_DEBUG
auto root_segment_id = SegmentId(0, 0);
root_segment_id.id_of_parent();
ERROR("Failed to trigger ASSERT in an assertion test");
#endif
}
// [[OutputRegex, The segment on the root refinement level has no sibling]]
[[noreturn]] SPECTRE_TEST_CASE("Unit.Domain.SegmentId.NoSibling",
"[Domain][Unit]") {
ASSERTION_TEST();
#ifdef SPECTRE_DEBUG
auto root_segment_id = SegmentId(0, 0);
root_segment_id.id_of_sibling();
ERROR("Failed to trigger ASSERT in an assertion test");
#endif
}
// [[OutputRegex, The segment on the root refinement level has no abutting
// nibling]]
[[noreturn]] SPECTRE_TEST_CASE("Unit.Domain.SegmentId.NoNibling",
"[Domain][Unit]") {
ASSERTION_TEST();
#ifdef SPECTRE_DEBUG
auto root_segment_id = SegmentId(0, 0);
root_segment_id.id_of_abutting_nibling();
ERROR("Failed to trigger ASSERT in an assertion test");
#endif
}
// [[OutputRegex, The segment on the root refinement level has no sibling]]
[[noreturn]] SPECTRE_TEST_CASE("Unit.Domain.SegmentId.NoSibling2",
"[Domain][Unit]") {
ASSERTION_TEST();
#ifdef SPECTRE_DEBUG
auto root_segment_id = SegmentId(0, 0);
root_segment_id.side_of_sibling();
ERROR("Failed to trigger ASSERT in an assertion test");
#endif
}
|
;COUNT NUMBER ZEROS, POSITIVES, NEGATIVES
;INPUT : 00A0H
;OUTPUT : 00B0H <- NUMBER OF ZEROS
; 00B1H <- NUMBER OF POSITIVE
; 00B2H <- NUMBER OF NEGATIVE
LXI H, 00A0H
MOV C, M ;C <- NUMBER OF DATA
INX H
MVI B, 00H ;B <- NUMBER OF ZEROS
MVI D, 00H ;D <- NUMBER OF POSITIVES
MVI E, 00H ;E <- NUMBER OF NEGATIVES
L1: MOV A, M
ADI 00H
JZ ZERO
RLC
JC NEG
INR D
JMP L1_END
NEG: INR E
JMP L1_END
ZERO: INR B
L1_END: INX H
DCR C
JNZ L1
MOV A, B
STA 00B0H
MOV A, D
STA 00B1H
MOV A, E
STA 00B2H
HLT |
#include "stdafx.h"
#include "bindings.h"
#include "../GeometryLib/vector3d.h"
#include "../GeometryLib/vector2d.h"
#include "../GeometryLib/transform3d.h"
#include "../GeometryLib/bounding-box.h"
#include "../GeometryLib/bounding-cylinder.h"
#include "color.h"
#include "renderer.h"
#include "xml-load.h"
Binding::~Binding()
{
for (auto it = boundObjects.begin(); it != boundObjects.end(); ++it)
delete (*it);
}
void Binding::update(double value)
{
for (auto it = boundObjects.begin(); it != boundObjects.end(); ++it)
(*it)->update(value);
}
void Binding::addBoundObject(Bindable* pObj)
{
boundObjects.push_back(pObj);
} |
[bits 64]
rdtscp
clgi
invlpga
invlpga [rax], ecx
invlpga [eax], ecx
; invlpga [ax], ecx ; invalid
skinit
; skinit [rax] ; invalid
skinit [eax]
stgi
vmload
vmload [rax]
vmload [eax]
vmmcall
vmrun
vmrun [rax]
vmrun [eax]
vmsave
vmsave [rax]
vmsave [eax]
[bits 32]
invlpga
invlpga [eax], ecx
invlpga [ax], ecx
skinit
skinit [eax]
; skinit [ax] ; invalid
vmload
vmload [eax]
vmload [ax]
vmrun
vmrun [eax]
vmrun [ax]
vmsave
vmsave [eax]
vmsave [ax]
|
/*
* Copyright (c) 2014 Matt Fichman
*
* 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, APEXPRESS 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 "http/Common.hpp"
#include "http/http.hpp"
int main() {
auto coro = coro::start([]{
try {
//http::Response res = http::get("https://192.168.1.154/foob");
//
http::Response res = http::post("https://192.168.1.154/user/login",
"{ \"UserId\": \"matt\", \"Password\": \"matt\"} ");
auto sessionId = res.cookie("SessionId");
std::cout << sessionId.value() << std::endl;
std::cout << sessionId.httpOnly() << std::endl;
std::cout << sessionId.secure() << std::endl;
std::cout << sessionId.path() << std::endl;
} catch (coro::SystemError const& ex) {
std::cerr << ex.what() << std::endl;
}
});
coro::run();
return 0;
}
|
; ===============================================================
; Nov 2014
; ===============================================================
;
; void z80_outp(uint16_t port, uint8_t data)
;
; Write data to 16-bit port.
;
; ===============================================================
SECTION code_clib
SECTION code_z80
PUBLIC asm_z80_outp
PUBLIC asm_cpu_outp
asm_z80_outp:
asm_cpu_outp:
; enter : bc = port
; l = data
;
; uses : none
out (c),l
ret
|
###############################################################################
# Copyright 2018 Intel Corporation
# All Rights Reserved.
#
# If this software was obtained under the Intel Simplified Software License,
# the following terms apply:
#
# The source code, information and material ("Material") contained herein is
# owned by Intel Corporation or its suppliers or licensors, and title to such
# Material remains with Intel Corporation or its suppliers or licensors. The
# Material contains proprietary information of Intel or its suppliers and
# licensors. The Material is protected by worldwide copyright laws and treaty
# provisions. No part of the Material may be used, copied, reproduced,
# modified, published, uploaded, posted, transmitted, distributed or disclosed
# in any way without Intel's prior express written permission. No license under
# any patent, copyright or other intellectual property rights in the Material
# is granted to or conferred upon you, either expressly, by implication,
# inducement, estoppel or otherwise. Any license under such intellectual
# property rights must be express and approved by Intel in writing.
#
# Unless otherwise agreed by Intel in writing, you may not remove or alter this
# notice or any other notice embedded in Materials by Intel or Intel's
# suppliers or licensors in any way.
#
#
# If this software was obtained under the Apache License, Version 2.0 (the
# "License"), the following terms apply:
#
# You may not use this file except in compliance with the License. You may
# obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
.section .note.GNU-stack,"",%progbits
.text
p256r1_data:
_prime256r1:
.long 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0, 0x0, 0x0, 0x1, 0xFFFFFFFF
.p2align 5, 0x90
.globl add_256
.type add_256, @function
add_256:
movl (%esi), %eax
addl (%ebx), %eax
movl %eax, (%edi)
movl (4)(%esi), %eax
adcl (4)(%ebx), %eax
movl %eax, (4)(%edi)
movl (8)(%esi), %eax
adcl (8)(%ebx), %eax
movl %eax, (8)(%edi)
movl (12)(%esi), %eax
adcl (12)(%ebx), %eax
movl %eax, (12)(%edi)
movl (16)(%esi), %eax
adcl (16)(%ebx), %eax
movl %eax, (16)(%edi)
movl (20)(%esi), %eax
adcl (20)(%ebx), %eax
movl %eax, (20)(%edi)
movl (24)(%esi), %eax
adcl (24)(%ebx), %eax
movl %eax, (24)(%edi)
movl (28)(%esi), %eax
adcl (28)(%ebx), %eax
movl %eax, (28)(%edi)
mov $(0), %eax
adc $(0), %eax
ret
.Lfe1:
.size add_256, .Lfe1-(add_256)
.p2align 5, 0x90
.globl sub_256
.type sub_256, @function
sub_256:
movl (%esi), %eax
subl (%ebx), %eax
movl %eax, (%edi)
movl (4)(%esi), %eax
sbbl (4)(%ebx), %eax
movl %eax, (4)(%edi)
movl (8)(%esi), %eax
sbbl (8)(%ebx), %eax
movl %eax, (8)(%edi)
movl (12)(%esi), %eax
sbbl (12)(%ebx), %eax
movl %eax, (12)(%edi)
movl (16)(%esi), %eax
sbbl (16)(%ebx), %eax
movl %eax, (16)(%edi)
movl (20)(%esi), %eax
sbbl (20)(%ebx), %eax
movl %eax, (20)(%edi)
movl (24)(%esi), %eax
sbbl (24)(%ebx), %eax
movl %eax, (24)(%edi)
movl (28)(%esi), %eax
sbbl (28)(%ebx), %eax
movl %eax, (28)(%edi)
mov $(0), %eax
adc $(0), %eax
ret
.Lfe2:
.size sub_256, .Lfe2-(sub_256)
.p2align 5, 0x90
.globl shl_256
.type shl_256, @function
shl_256:
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
movl (28)(%esi), %eax
movdqa %xmm0, %xmm2
psllq $(1), %xmm0
psrlq $(63), %xmm2
movdqa %xmm1, %xmm3
psllq $(1), %xmm1
psrlq $(63), %xmm3
palignr $(8), %xmm2, %xmm3
pslldq $(8), %xmm2
por %xmm3, %xmm1
por %xmm2, %xmm0
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
shr $(31), %eax
ret
.Lfe3:
.size shl_256, .Lfe3-(shl_256)
.p2align 5, 0x90
.globl shr_256
.type shr_256, @function
shr_256:
movd %eax, %xmm4
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
psllq $(63), %xmm4
movdqa %xmm0, %xmm2
psrlq $(1), %xmm0
psllq $(63), %xmm2
movdqa %xmm1, %xmm3
psrlq $(1), %xmm1
psllq $(63), %xmm3
palignr $(8), %xmm3, %xmm4
palignr $(8), %xmm2, %xmm3
por %xmm4, %xmm1
por %xmm3, %xmm0
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
ret
.Lfe4:
.size shr_256, .Lfe4-(shr_256)
.p2align 5, 0x90
.globl p256r1_add
.type p256r1_add, @function
p256r1_add:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(36), %esp
and $(-16), %esp
movl %eax, (32)(%esp)
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
movl (16)(%ebp), %ebx
call add_256
mov %eax, %edx
lea (%esp), %edi
movl (8)(%ebp), %esi
call .L__0000gas_5
.L__0000gas_5:
pop %ebx
sub $(.L__0000gas_5-p256r1_data), %ebx
lea ((_prime256r1-p256r1_data))(%ebx), %ebx
call sub_256
lea (%esp), %esi
movl (8)(%ebp), %edi
sub %eax, %edx
cmovne %edi, %esi
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
mov (32)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe5:
.size p256r1_add, .Lfe5-(p256r1_add)
.p2align 5, 0x90
.globl p256r1_sub
.type p256r1_sub, @function
p256r1_sub:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(36), %esp
and $(-16), %esp
movl %eax, (32)(%esp)
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
movl (16)(%ebp), %ebx
call sub_256
mov %eax, %edx
lea (%esp), %edi
movl (8)(%ebp), %esi
call .L__0001gas_6
.L__0001gas_6:
pop %ebx
sub $(.L__0001gas_6-p256r1_data), %ebx
lea ((_prime256r1-p256r1_data))(%ebx), %ebx
call add_256
lea (%esp), %esi
movl (8)(%ebp), %edi
test %edx, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
mov (32)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe6:
.size p256r1_sub, .Lfe6-(p256r1_sub)
.p2align 5, 0x90
.globl p256r1_neg
.type p256r1_neg, @function
p256r1_neg:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(36), %esp
and $(-16), %esp
movl %eax, (32)(%esp)
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
mov $(0), %eax
subl (%esi), %eax
movl %eax, (%edi)
mov $(0), %eax
sbbl (4)(%esi), %eax
movl %eax, (4)(%edi)
mov $(0), %eax
sbbl (8)(%esi), %eax
movl %eax, (8)(%edi)
mov $(0), %eax
sbbl (12)(%esi), %eax
movl %eax, (12)(%edi)
mov $(0), %eax
sbbl (16)(%esi), %eax
movl %eax, (16)(%edi)
mov $(0), %eax
sbbl (20)(%esi), %eax
movl %eax, (20)(%edi)
mov $(0), %eax
sbbl (24)(%esi), %eax
movl %eax, (24)(%edi)
mov $(0), %eax
sbbl (28)(%esi), %eax
movl %eax, (28)(%edi)
sbb %edx, %edx
lea (%esp), %edi
movl (8)(%ebp), %esi
call .L__0002gas_7
.L__0002gas_7:
pop %ebx
sub $(.L__0002gas_7-p256r1_data), %ebx
lea ((_prime256r1-p256r1_data))(%ebx), %ebx
call add_256
lea (%esp), %esi
movl (8)(%ebp), %edi
test %edx, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
mov (32)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe7:
.size p256r1_neg, .Lfe7-(p256r1_neg)
.p2align 5, 0x90
.globl p256r1_mul_by_2
.type p256r1_mul_by_2, @function
p256r1_mul_by_2:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(36), %esp
and $(-16), %esp
movl %eax, (32)(%esp)
lea (%esp), %edi
movl (12)(%ebp), %esi
call shl_256
mov %eax, %edx
mov %edi, %esi
movl (8)(%ebp), %edi
call .L__0003gas_8
.L__0003gas_8:
pop %ebx
sub $(.L__0003gas_8-p256r1_data), %ebx
lea ((_prime256r1-p256r1_data))(%ebx), %ebx
call sub_256
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
mov (32)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe8:
.size p256r1_mul_by_2, .Lfe8-(p256r1_mul_by_2)
.p2align 5, 0x90
.globl p256r1_mul_by_3
.type p256r1_mul_by_3, @function
p256r1_mul_by_3:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(72), %esp
and $(-16), %esp
movl %eax, (68)(%esp)
call .L__0004gas_9
.L__0004gas_9:
pop %eax
sub $(.L__0004gas_9-p256r1_data), %eax
lea ((_prime256r1-p256r1_data))(%eax), %eax
movl %eax, (64)(%esp)
lea (%esp), %edi
movl (12)(%ebp), %esi
call shl_256
mov %eax, %edx
mov %edi, %esi
lea (32)(%esp), %edi
mov (64)(%esp), %ebx
call sub_256
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
mov %edi, %esi
movl (12)(%ebp), %ebx
call add_256
mov %eax, %edx
movl (8)(%ebp), %edi
mov (64)(%esp), %ebx
call sub_256
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
mov (68)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe9:
.size p256r1_mul_by_3, .Lfe9-(p256r1_mul_by_3)
.p2align 5, 0x90
.globl p256r1_div_by_2
.type p256r1_div_by_2, @function
p256r1_div_by_2:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
mov %esp, %eax
sub $(36), %esp
and $(-16), %esp
movl %eax, (32)(%esp)
lea (%esp), %edi
movl (12)(%ebp), %esi
call .L__0005gas_10
.L__0005gas_10:
pop %ebx
sub $(.L__0005gas_10-p256r1_data), %ebx
lea ((_prime256r1-p256r1_data))(%ebx), %ebx
call add_256
mov $(0), %edx
movl (%esi), %ecx
and $(1), %ecx
cmovne %edi, %esi
cmove %edx, %eax
movl (8)(%ebp), %edi
call shr_256
mov (32)(%esp), %esp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe10:
.size p256r1_div_by_2, .Lfe10-(p256r1_div_by_2)
.p2align 5, 0x90
.globl p256r1_mul_mont_slm
.type p256r1_mul_mont_slm, @function
p256r1_mul_mont_slm:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
push %ebp
mov %esp, %eax
sub $(52), %esp
and $(-16), %esp
movl %eax, (48)(%esp)
pxor %mm0, %mm0
movq %mm0, (%esp)
movq %mm0, (8)(%esp)
movq %mm0, (16)(%esp)
movq %mm0, (24)(%esp)
movd %mm0, (32)(%esp)
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
movl (16)(%ebp), %ebp
movl %edi, (36)(%esp)
movl %esi, (40)(%esp)
movl %ebp, (44)(%esp)
mov $(8), %edi
movd (4)(%esi), %mm1
movd (8)(%esi), %mm2
movd (12)(%esi), %mm3
movd (16)(%esi), %mm4
.p2align 5, 0x90
.Lmmul_loopgas_11:
movd %edi, %mm7
movl (%ebp), %edx
movl (%esi), %eax
movd %edx, %mm0
add $(4), %ebp
movl %ebp, (44)(%esp)
pmuludq %mm0, %mm1
pmuludq %mm0, %mm2
mul %edx
addl (%esp), %eax
adc $(0), %edx
pmuludq %mm0, %mm3
pmuludq %mm0, %mm4
movd %mm1, %ecx
psrlq $(32), %mm1
add %edx, %ecx
movd %mm1, %edx
adc $(0), %edx
addl (4)(%esp), %ecx
movd (20)(%esi), %mm1
adc $(0), %edx
movd %mm2, %ebx
psrlq $(32), %mm2
add %edx, %ebx
movd %mm2, %edx
adc $(0), %edx
addl (8)(%esp), %ebx
movd (24)(%esi), %mm2
adc $(0), %edx
pmuludq %mm0, %mm1
pmuludq %mm0, %mm2
movd %mm3, %ebp
psrlq $(32), %mm3
add %edx, %ebp
movd %mm3, %edx
adc $(0), %edx
addl (12)(%esp), %ebp
movd (28)(%esi), %mm3
adc $(0), %edx
movd %mm4, %edi
psrlq $(32), %mm4
add %edx, %edi
movd %mm4, %edx
adc $(0), %edx
addl (16)(%esp), %edi
adc $(0), %edx
pmuludq %mm0, %mm3
movl %ecx, (%esp)
movl %ebx, (4)(%esp)
add %eax, %ebp
movl %ebp, (8)(%esp)
adc $(0), %edi
movl %edi, (12)(%esp)
mov $(0), %edi
adc $(0), %edi
movd %mm1, %ecx
psrlq $(32), %mm1
add %edx, %ecx
movd %mm1, %edx
adc $(0), %edx
addl (20)(%esp), %ecx
adc $(0), %edx
movd %mm2, %ebx
psrlq $(32), %mm2
add %edx, %ebx
movd %mm2, %edx
adc $(0), %edx
addl (24)(%esp), %ebx
adc $(0), %edx
movd %mm3, %ebp
psrlq $(32), %mm3
add %edx, %ebp
movd %mm3, %edx
adc $(0), %edx
addl (28)(%esp), %ebp
adc $(0), %edx
add %edi, %ecx
movl %ecx, (16)(%esp)
adc %eax, %ebx
movl %ebx, (20)(%esp)
mov %eax, %ecx
sbb $(0), %eax
sub %eax, %ebp
movl %ebp, (24)(%esp)
movd %mm7, %edi
sbb $(0), %ecx
mov $(0), %ebx
addl (32)(%esp), %edx
adc $(0), %ebx
add %ecx, %edx
movl %edx, (28)(%esp)
adc $(0), %ebx
movl %ebx, (32)(%esp)
sub $(1), %edi
movd (4)(%esi), %mm1
movd (8)(%esi), %mm2
movd (12)(%esi), %mm3
movd (16)(%esi), %mm4
jz .Lexit_mmul_loopgas_11
movl (44)(%esp), %ebp
jmp .Lmmul_loopgas_11
.Lexit_mmul_loopgas_11:
emms
mov (36)(%esp), %edi
lea (%esp), %esi
call .L__0006gas_11
.L__0006gas_11:
pop %ebx
sub $(.L__0006gas_11-p256r1_data), %ebx
lea ((_prime256r1-p256r1_data))(%ebx), %ebx
call sub_256
movl (32)(%esp), %edx
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
mov (48)(%esp), %esp
pop %ebp
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe11:
.size p256r1_mul_mont_slm, .Lfe11-(p256r1_mul_mont_slm)
.p2align 5, 0x90
.globl p256r1_sqr_mont_slm
.type p256r1_sqr_mont_slm, @function
p256r1_sqr_mont_slm:
push %ebp
mov %esp, %ebp
push %esi
push %edi
movl (12)(%ebp), %esi
movl (8)(%ebp), %edi
push %esi
push %esi
push %edi
call p256r1_mul_mont_slm
add $(12), %esp
pop %edi
pop %esi
pop %ebp
ret
.Lfe12:
.size p256r1_sqr_mont_slm, .Lfe12-(p256r1_sqr_mont_slm)
.p2align 5, 0x90
.globl p256r1_mred
.type p256r1_mred, @function
p256r1_mred:
push %ebp
mov %esp, %ebp
push %ebx
push %esi
push %edi
movl (12)(%ebp), %esi
mov $(8), %ecx
xor %edx, %edx
.p2align 5, 0x90
.Lmred_loopgas_13:
movl (%esi), %eax
mov $(0), %ebx
movl %ebx, (%esi)
movl (12)(%esi), %ebx
add %eax, %ebx
movl %ebx, (12)(%esi)
movl (16)(%esi), %ebx
adc $(0), %ebx
movl %ebx, (16)(%esi)
movl (20)(%esi), %ebx
adc $(0), %ebx
movl %ebx, (20)(%esi)
movl (24)(%esi), %ebx
adc %eax, %ebx
movl %ebx, (24)(%esi)
movl (28)(%esi), %ebx
push %eax
sbb $(0), %eax
sub %eax, %ebx
movl %ebx, (28)(%esi)
pop %eax
movl (32)(%esi), %ebx
sbb $(0), %eax
add %edx, %eax
mov $(0), %edx
adc $(0), %edx
add %eax, %ebx
movl %ebx, (32)(%esi)
adc $(0), %edx
lea (4)(%esi), %esi
sub $(1), %ecx
jnz .Lmred_loopgas_13
movl (8)(%ebp), %edi
call .L__0007gas_13
.L__0007gas_13:
pop %ebx
sub $(.L__0007gas_13-p256r1_data), %ebx
lea ((_prime256r1-p256r1_data))(%ebx), %ebx
call sub_256
sub %eax, %edx
cmove %edi, %esi
movdqu (%esi), %xmm0
movdqu (16)(%esi), %xmm1
movdqu %xmm0, (%edi)
movdqu %xmm1, (16)(%edi)
pop %edi
pop %esi
pop %ebx
pop %ebp
ret
.Lfe13:
.size p256r1_mred, .Lfe13-(p256r1_mred)
.p2align 5, 0x90
.globl p256r1_select_pp_w5
.type p256r1_select_pp_w5, @function
p256r1_select_pp_w5:
push %ebp
mov %esp, %ebp
push %esi
push %edi
pxor %xmm0, %xmm0
movl (8)(%ebp), %edi
movl (12)(%ebp), %esi
movl (16)(%ebp), %eax
movd %eax, %xmm7
pshufd $(0), %xmm7, %xmm7
mov $(1), %edx
movd %edx, %xmm6
pshufd $(0), %xmm6, %xmm6
movdqa %xmm0, (%edi)
movdqa %xmm0, (16)(%edi)
movdqa %xmm0, (32)(%edi)
movdqa %xmm0, (48)(%edi)
movdqa %xmm0, (64)(%edi)
movdqa %xmm0, (80)(%edi)
movdqa %xmm6, %xmm5
mov $(16), %ecx
.p2align 5, 0x90
.Lselect_loopgas_14:
movdqa %xmm5, %xmm4
pcmpeqd %xmm7, %xmm4
movdqa (%esi), %xmm0
pand %xmm4, %xmm0
por (%edi), %xmm0
movdqa %xmm0, (%edi)
movdqa (16)(%esi), %xmm1
pand %xmm4, %xmm1
por (16)(%edi), %xmm1
movdqa %xmm1, (16)(%edi)
movdqa (32)(%esi), %xmm0
pand %xmm4, %xmm0
por (32)(%edi), %xmm0
movdqa %xmm0, (32)(%edi)
movdqa (48)(%esi), %xmm1
pand %xmm4, %xmm1
por (48)(%edi), %xmm1
movdqa %xmm1, (48)(%edi)
movdqa (64)(%esi), %xmm0
pand %xmm4, %xmm0
por (64)(%edi), %xmm0
movdqa %xmm0, (64)(%edi)
movdqa (80)(%esi), %xmm1
pand %xmm4, %xmm1
por (80)(%edi), %xmm1
movdqa %xmm1, (80)(%edi)
paddd %xmm6, %xmm5
add $(96), %esi
sub $(1), %ecx
jnz .Lselect_loopgas_14
pop %edi
pop %esi
pop %ebp
ret
.Lfe14:
.size p256r1_select_pp_w5, .Lfe14-(p256r1_select_pp_w5)
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r12
push %r13
push %r15
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x15dcc, %rsi
lea addresses_D_ht+0xdb1c, %rdi
cmp $63510, %r12
mov $31, %rcx
rep movsw
nop
nop
nop
nop
nop
cmp $39203, %r13
lea addresses_A_ht+0x1cfec, %rbp
nop
nop
xor $58697, %r15
movb $0x61, (%rbp)
nop
nop
nop
dec %rbp
lea addresses_WC_ht+0x17b1c, %rdi
nop
nop
and %r13, %r13
mov $0x6162636465666768, %r15
movq %r15, %xmm4
movups %xmm4, (%rdi)
nop
nop
nop
nop
nop
cmp $60689, %rsi
lea addresses_WT_ht+0x123a4, %rsi
lea addresses_normal_ht+0xb71c, %rdi
sub %r10, %r10
mov $120, %rcx
rep movsb
and $41548, %r13
lea addresses_A_ht+0x1cd02, %rsi
lea addresses_A_ht+0x2b6c, %rdi
nop
nop
nop
inc %r15
mov $60, %rcx
rep movsb
nop
nop
nop
nop
nop
add %r10, %r10
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r15
pop %r13
pop %r12
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r9
push %rax
push %rcx
push %rdi
push %rsi
// Load
lea addresses_D+0x18b9c, %rcx
and $19779, %r12
mov (%rcx), %si
nop
and $59720, %rcx
// Store
lea addresses_WT+0xc81c, %r11
nop
sub %rdi, %rdi
mov $0x5152535455565758, %rsi
movq %rsi, %xmm7
vmovaps %ymm7, (%r11)
nop
cmp $33522, %rcx
// Load
lea addresses_US+0x81ee, %rcx
nop
nop
nop
nop
nop
inc %rsi
movups (%rcx), %xmm7
vpextrq $0, %xmm7, %r11
nop
nop
nop
nop
sub $14640, %rcx
// Load
lea addresses_WC+0x1d364, %r11
clflush (%r11)
nop
nop
nop
nop
xor $61715, %rax
movups (%r11), %xmm7
vpextrq $1, %xmm7, %r9
nop
sub %rax, %rax
// Store
lea addresses_normal+0xd71c, %r12
nop
cmp $43562, %rdi
movw $0x5152, (%r12)
nop
add $45476, %rax
// Load
lea addresses_PSE+0xd01c, %rdi
cmp %r9, %r9
movb (%rdi), %cl
sub %r11, %r11
// Faulty Load
lea addresses_normal+0x19b1c, %rsi
nop
nop
nop
sub $46235, %r12
movb (%rsi), %r9b
lea oracles, %rsi
and $0xff, %r9
shlq $12, %r9
mov (%rsi,%r9,1), %r9
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': True, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': True, 'congruent': 8, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'AVXalign': False, 'congruent': 3, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 9, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 8, 'size': 1, 'same': False, 'NT': True}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 4, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 11, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': True}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
[BITS 32]
MOV EDX, 123456789
INT 0x40
MOV EDX, 4
INT 0x40
|
/** @file inl2weight.cc
* @brief Xapian::InL2Weight class - the InL2 weighting scheme of the DFR framework.
*/
/* Copyright (C) 2013,2014 Aarsh Shah
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "xapian/weight.h"
#include "xapian/common/log2.h"
#include "xapian/weight/weightinternal.h"
#include "xapian/common/serialise-double.h"
#include "xapian/error.h"
using namespace std;
namespace Xapian {
InL2Weight::InL2Weight(double c)
: param_c(c)
{
if (param_c <= 0)
throw Xapian::InvalidArgumentError("Parameter c is invalid.");
need_stat(AVERAGE_LENGTH);
need_stat(DOC_LENGTH);
need_stat(DOC_LENGTH_MIN);
need_stat(COLLECTION_SIZE);
need_stat(WDF);
need_stat(WDF_MAX);
need_stat(WQF);
need_stat(TERMFREQ);
}
InL2Weight *
InL2Weight::clone() const
{
return new InL2Weight(param_c);
}
void
InL2Weight::init(double factor)
{
if (factor == 0.0) {
// This object is for the term-independent contribution, and that's
// always zero for this scheme.
return;
}
double wdfn_upper = get_wdf_upper_bound();
if (wdfn_upper == 0) {
upper_bound = 0.0;
return;
}
double termfrequency = get_termfreq();
double N = get_collection_size();
wdfn_upper *= log2(1 + (param_c * get_average_length()) /
get_doclength_lower_bound());
// wdfn * L = wdfn / (wdfn + 1) = 1 / (1 + 1 / wdfn).
// To maximize the product, we need to minimize the denominator and so we use wdfn_upper in (1 / wdfn).
double maximum_wdfn_product_L = wdfn_upper / (wdfn_upper + 1.0);
// This term is constant for all documents.
double idf_max = log2((N + 1) / (termfrequency + 0.5));
/* Calculate constant values to be used in get_sumpart() upfront. */
wqf_product_idf = get_wqf() * idf_max * factor;
c_product_avlen = param_c * get_average_length();
upper_bound = wqf_product_idf * maximum_wdfn_product_L * factor;
}
string
InL2Weight::name() const
{
return "Xapian::InL2Weight";
}
string
InL2Weight::short_name() const
{
return "inl2";
}
string
InL2Weight::serialise() const
{
return serialise_double(param_c);
}
InL2Weight *
InL2Weight::unserialise(const string & s) const
{
const char *ptr = s.data();
const char *end = ptr + s.size();
double c = unserialise_double(&ptr, end);
if (rare(ptr != end))
throw Xapian::SerialisationError("Extra data in InL2Weight::unserialise()");
return new InL2Weight(c);
}
double
InL2Weight::get_sumpart(Xapian::termcount wdf, Xapian::termcount len,
Xapian::termcount) const
{
if (wdf == 0) return 0.0;
double wdfn = wdf;
wdfn *= log2(1 + c_product_avlen / len);
double wdfn_product_L = wdfn / (wdfn + 1.0);
return (wqf_product_idf * wdfn_product_L);
}
double
InL2Weight::get_maxpart() const
{
return upper_bound;
}
double
InL2Weight::get_sumextra(Xapian::termcount, Xapian::termcount) const
{
return 0;
}
double
InL2Weight::get_maxextra() const
{
return 0;
}
InL2Weight *
InL2Weight::create_from_parameters(const char * p) const
{
if (*p == '\0')
return new Xapian::InL2Weight();
double k = 1.0;
if (!Xapian::Weight::Internal::double_param(&p, &k))
Xapian::Weight::Internal::parameter_error("Parameter is invalid", "inl2");
if (*p)
Xapian::Weight::Internal::parameter_error("Extra data after parameter", "inl2");
return new Xapian::InL2Weight(k);
}
}
|
/* Copyright 2019 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.
==============================================================================*/
// This file implements logic for lowering HLO dialect to LHLO dialect.
#include <algorithm>
#include <utility>
#include "mlir-hlo/Dialect/lhlo/IR/lhlo_ops.h"
#include "mlir-hlo/Dialect/lhlo/transforms/map_hlo_to_lhlo_op.h"
#include "mlir-hlo/Dialect/mhlo/IR/hlo_ops.h"
#include "mlir-hlo/Dialect/mhlo/transforms/PassDetail.h"
#include "mlir-hlo/Dialect/mhlo/transforms/passes.h"
#include "mlir-hlo/Dialect/mhlo/transforms/rewriters.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/Bufferization/IR/Bufferization.h"
#include "mlir/Dialect/Bufferization/Transforms/Bufferize.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/Shape/IR/Shape.h"
#include "mlir/Dialect/Shape/Transforms/Passes.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
#include "mlir/Dialect/StandardOps/Transforms/FuncConversions.h"
#include "mlir/Dialect/Tensor/IR/Tensor.h"
#include "mlir/IR/AffineMap.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BlockAndValueMapping.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
namespace mlir {
namespace mhlo {
namespace {
template <typename T>
using BaseOpConversion = OpConversionPattern<T>;
Value InsertDynamicAlloc(Location loc, Value result, Value shape_operand,
ConversionPatternRewriter* rewriter) {
auto result_type = result.getType().dyn_cast<RankedTensorType>();
if (!result_type) {
result.getDefiningOp()->emitOpError()
<< "tensor to buffer conversion expects ranked results";
}
auto memref_type =
MemRefType::get(result_type.getShape(), result_type.getElementType());
// Extract the required element out of the vector.
SmallVector<Value, 4> dynamic_operands;
for (auto shape_element : llvm::enumerate(result_type.getShape())) {
if (shape_element.value() != ShapedType::kDynamicSize) continue;
Value index =
rewriter->create<arith::ConstantIndexOp>(loc, shape_element.index());
Value alloc_operand =
rewriter->create<tensor::ExtractOp>(loc, shape_operand, index);
if (!alloc_operand.getType().isIndex()) {
alloc_operand = rewriter->create<arith::IndexCastOp>(
loc, alloc_operand, rewriter->getIndexType());
}
dynamic_operands.push_back(alloc_operand);
}
return rewriter->create<memref::AllocOp>(loc, memref_type, dynamic_operands);
}
Value InsertAlloc(Location loc, OpResult result,
ConversionPatternRewriter* rewriter) {
auto result_type = result.getType().dyn_cast<RankedTensorType>();
if (!result_type || !result_type.hasStaticShape()) {
result.getDefiningOp()->emitOpError()
<< "tensor to buffer conversion expects statically shaped results";
}
auto memref_type =
MemRefType::get(result_type.getShape(), result_type.getElementType());
OpBuilder::InsertionGuard guard(*rewriter);
rewriter->setInsertionPoint(result.getDefiningOp());
auto alloc = rewriter->create<memref::AllocOp>(loc, memref_type);
return alloc;
}
/// Converts the results of the operation `op` to memref types and append them
/// to the `results` vector.
LogicalResult ConvertResults(Operation* op, SmallVectorImpl<Value>& results,
ConversionPatternRewriter& rewriter) {
size_t num_operands = results.size();
SmallVector<Value, 2> tensor_operands;
for (auto result : llvm::enumerate(op->getResults())) {
RankedTensorType resultType =
result.value().getType().dyn_cast<RankedTensorType>();
if (!resultType) return failure();
if (resultType.hasStaticShape()) {
results.push_back(InsertAlloc(op->getLoc(), result.value(), &rewriter));
continue;
}
auto shape_type_op = dyn_cast<InferShapedTypeOpInterface>(op);
if (!shape_type_op) return failure();
if (tensor_operands.empty()) {
for (auto operand : ArrayRef<Value>(results).take_front(num_operands)) {
auto operand_type = operand.getType().dyn_cast<MemRefType>();
if (!operand_type) return failure();
tensor_operands.push_back(rewriter.create<bufferization::ToTensorOp>(
op->getLoc(),
RankedTensorType::get(operand_type.getShape(),
operand_type.getElementType()),
operand));
}
}
SmallVector<Value, 1> results_shape;
auto status = shape_type_op.reifyReturnTypeShapes(rewriter, tensor_operands,
results_shape);
if (failed(status)) return failure();
results.push_back(InsertDynamicAlloc(op->getLoc(), result.value(),
results_shape[result.index()],
&rewriter));
}
return success();
}
template <typename HloOpTy>
class HloToLhloOpConverter : public BaseOpConversion<HloOpTy> {
public:
using BaseOpConversion<HloOpTy>::BaseOpConversion;
LogicalResult matchAndRewrite(
HloOpTy hloOp, typename HloOpTy::Adaptor adaptor,
ConversionPatternRewriter& rewriter) const final {
Operation* op = hloOp.getOperation();
SmallVector<Value, 4> buffer_args(adaptor.getOperands());
if (failed(ConvertResults(op, buffer_args, rewriter))) return failure();
rewriter.create<mhlo::HloToLhloOp<HloOpTy>>(op->getLoc(), llvm::None,
buffer_args, op->getAttrs());
rewriter.replaceOp(op, llvm::makeArrayRef(buffer_args)
.drop_front(adaptor.getOperands().size()));
return success();
}
};
// This specialization exists so that LMHLO's Dot can be given a specific set of
// dimension numbers, when lowering from MHLO's Dot, which does not have
// dimension numbers (it uses DotGeneral for this generalized notion of dot
// products). When these two dialects are in sync with respect to the
// Dot/DotGeneral issue, this specialization should be deleted.
template <>
class HloToLhloOpConverter<mhlo::DotOp> : public BaseOpConversion<mhlo::DotOp> {
public:
using BaseOpConversion<mhlo::DotOp>::BaseOpConversion;
LogicalResult matchAndRewrite(
mhlo::DotOp hloOp, OpAdaptor adaptor,
ConversionPatternRewriter& rewriter) const final {
Operation* op = hloOp.getOperation();
SmallVector<Value, 2> buffer_args(adaptor.getOperands());
if (failed(ConvertResults(op, buffer_args, rewriter))) return failure();
auto dotOp = rewriter.create<lmhlo::DotOp>(op->getLoc(), llvm::None,
buffer_args, op->getAttrs());
// MHLO's Dot uses rank-2 operands, of the form ([N, M], [M, O]) -> [N, O].
auto dimension_numbers = mhlo::DotDimensionNumbersAttr::get(
rewriter.getContext(), /*lhsBatchingDimensions=*/{},
/*rhsBatchingDimensions=*/{}, /*lhsContractingDimensions=*/{1},
/*rhsContractingDimensions=*/{0});
dotOp.dot_dimension_numbersAttr(dimension_numbers);
rewriter.replaceOp(
op, ArrayRef<Value>(buffer_args).slice(adaptor.getOperands().size()));
return success();
}
};
struct HloToLhloCustomCallOpConverter
: public BaseOpConversion<mhlo::CustomCallOp> {
public:
using BaseOpConversion<mhlo::CustomCallOp>::BaseOpConversion;
LogicalResult matchAndRewrite(
mhlo::CustomCallOp hloOp, OpAdaptor adaptor,
ConversionPatternRewriter& rewriter) const final {
Operation* op = hloOp.getOperation();
SmallVector<Value, 2> buffer_args(adaptor.getOperands());
if (failed(ConvertResults(op, buffer_args, rewriter))) return failure();
auto lhloOp = rewriter.create<lmhlo::CustomCallOp>(
op->getLoc(), llvm::None, buffer_args, op->getAttrs());
// Setup AttrSizedOperandSegments attribute to indicate number of operands
// for args and outputs.
const int32_t segments[2] = {
static_cast<int32_t>(adaptor.getOperands().size()),
static_cast<int32_t>(op->getNumResults())};
lhloOp->setAttr(lhloOp.getOperandSegmentSizeAttr(),
rewriter.getI32VectorAttr(segments));
rewriter.replaceOp(
op, ArrayRef<Value>(buffer_args).slice(adaptor.getOperands().size()));
return success();
}
};
struct HloToLhloDotGeneralOpConverter
: public BaseOpConversion<mhlo::DotGeneralOp> {
using BaseOpConversion<mhlo::DotGeneralOp>::BaseOpConversion;
LogicalResult matchAndRewrite(
mhlo::DotGeneralOp dotGeneralOp, OpAdaptor adaptor,
ConversionPatternRewriter& rewriter) const final {
Operation* op = dotGeneralOp.getOperation();
if (op->getResults().empty()) return failure();
OpResult result = op->getResults()[0];
RankedTensorType resultType = result.getType().dyn_cast<RankedTensorType>();
if (!resultType) return failure();
// The third buffer argument will be filled with what used to be the return
// type of the DotGeneral.
if (adaptor.getOperands().size() != 2) return failure();
std::array<Value, 3> bufferArgs = {
adaptor.getOperands()[0], adaptor.getOperands()[1], {}};
if (resultType.hasStaticShape()) {
bufferArgs[2] = InsertAlloc(op->getLoc(), result, &rewriter);
} else {
SmallVector<Value, 1> results_shape;
auto shape_type_op = dyn_cast<InferShapedTypeOpInterface>(op);
if (failed(shape_type_op.reifyReturnTypeShapes(
rewriter, adaptor.getOperands(), results_shape)))
return failure();
bufferArgs[2] = InsertDynamicAlloc(op->getLoc(), result,
results_shape.front(), &rewriter);
}
rewriter.create<lmhlo::DotOp>(op->getLoc(), llvm::None, bufferArgs,
op->getAttrs());
rewriter.replaceOp(op, bufferArgs[2]);
return success();
}
};
struct HloToLhloReduceOpConverter : public BaseOpConversion<mhlo::ReduceOp> {
public:
using BaseOpConversion<mhlo::ReduceOp>::BaseOpConversion;
LogicalResult matchAndRewrite(
mhlo::ReduceOp op, OpAdaptor adaptor,
ConversionPatternRewriter& rewriter) const final {
auto loc = op.getLoc();
if (!llvm::hasSingleElement(op.body())) {
return op.emitOpError()
<< "tensor to buffer conversion expects a single block "
"in the region containing the operation";
}
SmallVector<Value, 4> buffer_args(adaptor.getOperands());
if (failed(ConvertResults(op, buffer_args, rewriter))) return failure();
auto new_op = rewriter.create<lmhlo::ReduceOp>(loc, llvm::None, buffer_args,
op->getAttrs());
// Copy over the operations inside the region.
rewriter.inlineRegionBefore(op.body(), new_op.body(), new_op.body().end());
// Convert the region signature to memref and add extra result.
auto& entry_block = new_op.body().front();
TypeConverter::SignatureConversion sig_conversion(
adaptor.getOperands().size());
for (auto arg : entry_block.getArguments()) {
auto old_type = arg.getType().cast<TensorType>();
auto new_type =
MemRefType::get(old_type.getShape(), old_type.getElementType());
sig_conversion.addInputs(arg.getArgNumber(), new_type);
}
auto return_op = cast<mhlo::ReturnOp>(entry_block.getTerminator());
if (auto tuple_ty =
return_op.results().front().getType().dyn_cast<TupleType>()) {
auto tuple_op = return_op.getODSOperands(0).front().getDefiningOp();
return_op.getOperation()->dropAllReferences();
rewriter.eraseOp(tuple_op);
return_op.getOperation()->setOperands(tuple_op->getOperands());
for (auto ty : tuple_ty) {
auto tensor_ty = ty.cast<TensorType>();
sig_conversion.addInputs(
MemRefType::get(tensor_ty.getShape(), tensor_ty.getElementType()));
}
} else {
auto result_type =
return_op.results().front().getType().cast<TensorType>();
sig_conversion.addInputs({MemRefType::get(result_type.getShape(),
result_type.getElementType())});
}
rewriter.applySignatureConversion(&new_op.body(), sig_conversion);
rewriter.replaceOp(
op, ArrayRef<Value>(buffer_args).slice(adaptor.getOperands().size()));
return success();
}
};
// Legalize mhlo.return to a lmhlo.copy and lmhlo.terminator.
struct HloToLhloReturnOpConverter : public BaseOpConversion<mhlo::ReturnOp> {
public:
using BaseOpConversion<mhlo::ReturnOp>::BaseOpConversion;
LogicalResult matchAndRewrite(
mhlo::ReturnOp op, OpAdaptor adaptor,
ConversionPatternRewriter& rewriter) const final {
auto loc = op.getLoc();
auto& entry_block = op->getParentRegion()->front();
auto num_arguments = entry_block.getNumArguments();
if (adaptor.getOperands().size() > num_arguments) {
return op.emitError(
"The number of operands that need Copy operations is more "
"than the number of target function arguments.");
}
// The index of the first output block argument.
auto dest_arg_idx = num_arguments - adaptor.getOperands().size();
// Create a lmhlo.copy for each operand of mhlo.return.
for (Value operand : adaptor.getOperands()) {
rewriter.create<lmhlo::CopyOp>(loc, operand,
entry_block.getArgument(dest_arg_idx));
++dest_arg_idx;
}
rewriter.replaceOpWithNewOp<lmhlo::TerminatorOp>(op);
return success();
}
};
// TODO(b/175789537) Remove this pattern.
class HloToLhloTensorStoreOpLegacyConverter
: public BaseOpConversion<mlir::memref::TensorStoreOp> {
public:
using BaseOpConversion<mlir::memref::TensorStoreOp>::BaseOpConversion;
LogicalResult matchAndRewrite(
mlir::memref::TensorStoreOp op, OpAdaptor adaptor,
ConversionPatternRewriter& rewriter) const final {
rewriter.replaceOpWithNewOp<lmhlo::CopyOp>(op, llvm::None,
adaptor.getOperands().front(),
adaptor.getOperands().back());
return success();
}
};
// Lowers from HLO dialect to LHLO dialect allocating/deallocating temporary
// buffers if necessary.
//
// Example fusion with HLO ops.
//
// func @fusion(%arg0: memref<2x2xf32>,
// %arg1: memref<2x2xf32>,
// %arg2: memref<2x2xf32>,
// %arg3: memref<2x2xf32>) {
// "lmhlo.fusion"() ({
// %0 = bufferization.to_tensor %arg1 : memref<2x2xf32>
// %1 = bufferization.to_tensor %arg2 : memref<2x2xf32>
// %2 = "mhlo.add"(%0, %1) :
// (tensor<2x2xf32>, tensor<2x2xf32>) -> tensor<2x2xf32>
// %3 = bufferization.to_tensor %arg0 : memref<2x2xf32>
// %4 = "mhlo.multiply"(%2, %3) :
// (tensor<2x2xf32>, tensor<2x2xf32>) -> tensor<2x2xf32>
// tensor_store %4, %arg3 : memref<2x2xf32>
// "lmhlo.terminator"() : () -> ()
// }) : () -> ()
// return
// }
//
// Transformed fusion with LHLO ops.
// func @fusion(%arg0: memref<2x2xf32>,
// %arg1: memref<2x2xf32>,
// %arg2: memref<2x2xf32>,
// %arg3: memref<2x2xf32>) {
// "lmhlo.fusion"() ( {
// %0 = alloc() : memref<2x2xf32>
// "lmhlo.add"(%arg1, %arg2, %0) :
// (memref<2x2xf32>, memref<2x2xf32>, memref<2x2xf32>) -> ()
// "lmhlo.multiply"(%0, %arg0, %arg3) :
// (memref<2x2xf32>, memref<2x2xf32>, memref<2x2xf32>) -> ()
// "lmhlo.terminator"() : () -> ()
// }) : () -> ()
// return
// }
//
// FuncOp signature conversion example:
//
// func @func_op(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>) -> tensor<4xf32> {
// %0 = "mhlo.maximum"(%arg0, %arg1) : (tensor<4xf32>, tensor<4xf32>) ->
// tensor<4xf32> %1 = "mhlo.add"(%arg0, %0) : (tensor<4xf32>,
// tensor<4xf32>) -> tensor<4xf32> return %1 : tensor<4xf32>
// }
//
// Transformed function with an extra argument for the result. The types have
// been converted from tensor to memref.
//
// func @func_op(%arg0: memref<4xf32>,
// %arg1: memref<4xf32>,
// %arg2: memref<4xf32>) {
// %0 = alloc() : memref<4xf32>
// "lmhlo.maximum"(%arg0, %arg1, %0) :
// (memref<4xf32>, memref<4xf32>, memref<4xf32>) -> ()
// %1 = alloc() : memref<4xf32>
// "lmhlo.add"(%arg0, %0, %1) :
// (memref<4xf32>, memref<4xf32>, memref<4xf32>) -> ()
// "lmhlo.copy"(%1, %arg2) : (memref<4xf32>, memref<4xf32>) -> ()
// "lmhlo.terminator"() : () -> ()
// }
struct HloLegalizeToLhlo : public HloLegalizeToLhloPassBase<HloLegalizeToLhlo> {
using HloLegalizeToLhloPassBase<HloLegalizeToLhlo>::HloLegalizeToLhloPassBase;
void getDependentDialects(DialectRegistry& registry) const override {
registry.insert<bufferization::BufferizationDialect, lmhlo::LmhloDialect,
memref::MemRefDialect, shape::ShapeDialect>();
}
public:
HloLegalizeToLhlo() = default;
void runOnOperation() override {
auto& context = getContext();
OwningRewritePatternList patterns(&context);
ConversionTarget target(context);
target.addLegalDialect<
arith::ArithmeticDialect, bufferization::BufferizationDialect,
lmhlo::LmhloDialect, memref::MemRefDialect, shape::ShapeDialect,
StandardOpsDialect, tensor::TensorDialect>();
target.addIllegalDialect<mhlo::MhloDialect>();
// Declare tensor_store illegal. bufferization.to_tensor may be used to
// reify output shape computation during dialect conversion and will be
// handled later.
target.addIllegalOp<mlir::memref::TensorStoreOp>();
// bufferization.to_memref is illegal if it has uses.
// TODO(b/175670649) Make bufferization.to_memref illegal.
target.addDynamicallyLegalOp<mlir::bufferization::ToMemrefOp>(
[](auto op) { return op->use_empty(); });
bufferization::BufferizeTypeConverter converter;
auto isMemRefType = [](Type type) { return type.isa<BaseMemRefType>(); };
target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) {
return converter.isSignatureLegal(op.getType()) &&
converter.isLegal(&op.getBody());
});
target.addDynamicallyLegalOp<CallOp>([&](CallOp op) {
return std::all_of(op.operand_type_begin(), op.operand_type_end(),
isMemRefType) &&
std::all_of(op.result_type_begin(), op.result_type_end(),
isMemRefType);
});
target.addDynamicallyLegalOp<mlir::ReturnOp>([&](mlir::ReturnOp op) {
return std::all_of(op.operand_type_begin(), op.operand_type_end(),
isMemRefType);
});
populateHLOToLHLOConversionPattern(&context, &converter, &patterns);
populateFuncOpTypeConversionPattern(patterns, converter);
populateCallOpTypeConversionPattern(patterns, converter);
populateBranchOpInterfaceTypeConversionPattern(patterns, converter);
populateReturnOpTypeConversionPattern(patterns, converter);
populateEliminateBufferizeMaterializationsPatterns(converter, patterns);
populateShapeStructuralTypeConversionsAndLegality(converter, patterns,
target);
// TODO(b/175789537) Remove this pattern.
patterns.insert<HloToLhloTensorStoreOpLegacyConverter>(&context);
if (failed(applyPartialConversion(getOperation(), target,
std::move(patterns))))
signalPassFailure();
}
};
} // namespace
// Simply lowers all mhlo ops to their lmhlo counterparts.
void populateDynamicHLOToLHLOConversionPattern(
MLIRContext* context, bufferization::BufferizeTypeConverter* converter,
OwningRewritePatternList* patterns) {
// clang-format off
patterns->insert<HloToLhloOpConverter<mhlo::DynamicBroadcastInDimOp>,
HloToLhloOpConverter<mhlo::DynamicGatherOp>,
HloToLhloOpConverter<mhlo::DynamicIotaOp>,
HloToLhloOpConverter<mhlo::DynamicPadOp>,
HloToLhloOpConverter<mhlo::DynamicReshapeOp>,
HloToLhloOpConverter<mhlo::RealDynamicSliceOp>
>(*converter, context);
// clang-format on
}
void populateHLOToLHLOConversionPattern(
MLIRContext* context, bufferization::BufferizeTypeConverter* converter,
OwningRewritePatternList* patterns) {
populateDynamicHLOToLHLOConversionPattern(context, converter, patterns);
// clang-format off
patterns->insert<
HloToLhloCustomCallOpConverter,
HloToLhloDotGeneralOpConverter,
HloToLhloOpConverter<mhlo::AbsOp>,
HloToLhloOpConverter<mhlo::AddOp>,
HloToLhloOpConverter<mhlo::AndOp>,
HloToLhloOpConverter<mhlo::Atan2Op>,
HloToLhloOpConverter<mhlo::BroadcastInDimOp>,
HloToLhloOpConverter<mhlo::CeilOp>,
HloToLhloOpConverter<mhlo::CompareOp>,
HloToLhloOpConverter<mhlo::ComplexOp>,
HloToLhloOpConverter<mhlo::ConcatenateOp>,
HloToLhloOpConverter<mhlo::ConstOp>,
HloToLhloOpConverter<mhlo::ConvOp>,
HloToLhloOpConverter<mhlo::ConvertOp>,
HloToLhloOpConverter<mhlo::CopyOp>,
HloToLhloOpConverter<mhlo::CosOp>,
HloToLhloOpConverter<mhlo::DivOp>,
HloToLhloOpConverter<mhlo::DotOp>,
HloToLhloOpConverter<mhlo::ExpOp>,
HloToLhloOpConverter<mhlo::Expm1Op>,
HloToLhloOpConverter<mhlo::FloorOp>,
HloToLhloOpConverter<mhlo::GatherOp>,
HloToLhloOpConverter<mhlo::ImagOp>,
HloToLhloOpConverter<mhlo::IotaOp>,
HloToLhloOpConverter<mhlo::IsFiniteOp>,
HloToLhloOpConverter<mhlo::LogOp>,
HloToLhloOpConverter<mhlo::LogisticOp>,
HloToLhloOpConverter<mhlo::MaxOp>,
HloToLhloOpConverter<mhlo::MinOp>,
HloToLhloOpConverter<mhlo::MulOp>,
HloToLhloOpConverter<mhlo::NegOp>,
HloToLhloOpConverter<mhlo::NotOp>,
HloToLhloOpConverter<mhlo::OrOp>,
HloToLhloOpConverter<mhlo::PowOp>,
HloToLhloOpConverter<mhlo::RealOp>,
HloToLhloOpConverter<mhlo::RemOp>,
HloToLhloOpConverter<mhlo::RsqrtOp>,
HloToLhloOpConverter<mhlo::ReshapeOp>,
HloToLhloOpConverter<mhlo::SelectOp>,
HloToLhloOpConverter<mhlo::ShiftLeftOp>,
HloToLhloOpConverter<mhlo::ShiftRightArithmeticOp>,
HloToLhloOpConverter<mhlo::ShiftRightLogicalOp>,
HloToLhloOpConverter<mhlo::SignOp>,
HloToLhloOpConverter<mhlo::SinOp>,
HloToLhloOpConverter<mhlo::SliceOp>,
HloToLhloOpConverter<mhlo::SqrtOp>,
HloToLhloOpConverter<mhlo::SubOp>,
HloToLhloOpConverter<mhlo::TanhOp>,
HloToLhloOpConverter<mhlo::TransposeOp>,
HloToLhloOpConverter<mhlo::XorOp>,
HloToLhloReduceOpConverter,
HloToLhloReturnOpConverter
>(*converter, context);
// clang-format on
}
std::unique_ptr<OperationPass<ModuleOp>> createLegalizeToLhloPass() {
return std::make_unique<HloLegalizeToLhlo>();
}
} // namespace mhlo
} // namespace mlir
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (C) 2022 Intel Corporation
;
; SPDX-License-Identifier: MIT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Function API:
; UINT32 crc32_ieee_by4(
; UINT32 init_crc, //initial CRC value, 32 bits
; const unsigned char *buf, //buffer pointer to calculate CRC on
; UINT64 len //buffer length in bytes (64-bit data)
; );
;
; Authors:
; Erdinc Ozturk
; Vinodh Gopal
; James Guilford
;
; Reference paper titled "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
; URL: http://download.intel.com/design/intarch/papers/323102.pdf
;
%include "reg_sizes.asm"
%define fetch_dist 1024
[bits 64]
default rel
section .text
%ifidn __OUTPUT_FORMAT__, win64
%xdefine arg1 rcx
%xdefine arg2 rdx
%xdefine arg3 r8
%xdefine arg1_low32 ecx
%else
%xdefine arg1 rdi
%xdefine arg2 rsi
%xdefine arg3 rdx
%xdefine arg1_low32 edi
%endif
%ifidn __OUTPUT_FORMAT__, win64
%define XMM_SAVE 16*2
%define VARIABLE_OFFSET 16*4+8
%else
%define VARIABLE_OFFSET 16*2+8
%endif
align 16
mk_global crc32_ieee_by4, function
crc32_ieee_by4:
endbranch
not arg1_low32
sub rsp,VARIABLE_OFFSET
%ifidn __OUTPUT_FORMAT__, win64
; push the xmm registers into the stack to maintain
movdqa [rsp + XMM_SAVE + 16*0],xmm6
movdqa [rsp + XMM_SAVE + 16*1],xmm7
%endif
; check if smaller than 128B
cmp arg3, 128
jl _less_than_128
; load the initial crc value
movd xmm6, arg1_low32 ; initial crc
; crc value does not need to be byte-reflected, but it needs to be
; moved to the high part of the register.
; because data will be byte-reflected and will align with initial
; crc at correct place.
pslldq xmm6, 12
movdqa xmm7, [SHUF_MASK]
; receive the initial 64B data, xor the initial crc value
movdqu xmm0, [arg2]
movdqu xmm1, [arg2+16]
movdqu xmm2, [arg2+32]
movdqu xmm3, [arg2+48]
pshufb xmm0, xmm7
; XOR the initial_crc value
pxor xmm0, xmm6
pshufb xmm1, xmm7
pshufb xmm2, xmm7
pshufb xmm3, xmm7
movdqa xmm6, [rk3] ; k3=2^480 mod POLY << 32
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;we subtract 128 instead of 64 to save one instruction from the loop
sub arg3, 128
; at this section of the code, there is 64*x+y (0<=y<64) bytes of
; buffer. The _fold_64_B_loop loop will fold 64B at a time until we
; have 64+y Bytes of buffer
; fold 64B at a time. This section of the code folds 4 xmm registers in parallel
_fold_64_B_loop:
;update the buffer pointer
add arg2, 64
prefetchnta [arg2+fetch_dist+0]
movdqa xmm4, xmm0
movdqa xmm5, xmm1
pclmulqdq xmm0, xmm6 , 0x11
pclmulqdq xmm1, xmm6 , 0x11
pclmulqdq xmm4, xmm6, 0x0
pclmulqdq xmm5, xmm6, 0x0
pxor xmm0, xmm4
pxor xmm1, xmm5
prefetchnta [arg2+fetch_dist+32]
movdqa xmm4, xmm2
movdqa xmm5, xmm3
pclmulqdq xmm2, xmm6, 0x11
pclmulqdq xmm3, xmm6, 0x11
pclmulqdq xmm4, xmm6, 0x0
pclmulqdq xmm5, xmm6, 0x0
pxor xmm2, xmm4
pxor xmm3, xmm5
movdqu xmm4, [arg2]
movdqu xmm5, [arg2+16]
pshufb xmm4, xmm7
pshufb xmm5, xmm7
pxor xmm0, xmm4
pxor xmm1, xmm5
movdqu xmm4, [arg2+32]
movdqu xmm5, [arg2+48]
pshufb xmm4, xmm7
pshufb xmm5, xmm7
pxor xmm2, xmm4
pxor xmm3, xmm5
sub arg3, 64
; check if there is another 64B in the buffer to be able to fold
jge _fold_64_B_loop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
add arg2, 64
;at this point, the arg2 is pointing at the last y Bytes of the buffer
; the 64B of data is in 4 of the xmm registers: xmm0, xmm1, xmm2, xmm3
movdqa xmm6, [rk1] ;k1
; fold the 4 xmm registers to 1 xmm register with different constants
movdqa xmm4, xmm0
pclmulqdq xmm0, xmm6, 0x11
pclmulqdq xmm4, xmm6, 0x0
pxor xmm1, xmm4
xorps xmm1, xmm0
movdqa xmm4, xmm1
pclmulqdq xmm1, xmm6, 0x11
pclmulqdq xmm4, xmm6, 0x0
pxor xmm2, xmm4
xorps xmm2, xmm1
movdqa xmm4, xmm2
pclmulqdq xmm2, xmm6, 0x11
pclmulqdq xmm4, xmm6, 0x0
pxor xmm3, xmm4
pxor xmm3, xmm2
;instead of 64, we add 48 to the loop counter to save 1 instruction from the loop
; instead of a cmp instruction, we use the negative flag with the jl instruction
add arg3, 64-16
jl _final_reduction_for_128
; now we have 16+y bytes left to reduce. 16 Bytes is in register xmm3 and the rest is in memory
; we can fold 16 bytes at a time if y>=16
; continue folding 16B at a time
_16B_reduction_loop:
movdqa xmm4, xmm3
pclmulqdq xmm3, xmm6, 0x11
pclmulqdq xmm4, xmm6, 0x0
pxor xmm3, xmm4
movdqu xmm0, [arg2]
pshufb xmm0, xmm7
pxor xmm3, xmm0
add arg2, 16
sub arg3, 16
; instead of a cmp instruction, we utilize the flags with the jge instruction
; equivalent of: cmp arg3, 16-16
; check if there is any more 16B in the buffer to be able to fold
jge _16B_reduction_loop
;now we have 16+z bytes left to reduce, where 0<= z < 16.
;first, we reduce the data in the xmm3 register
_final_reduction_for_128:
; check if any more data to fold. If not, compute the CRC of the final 128 bits
add arg3, 16
je _128_done
; here we are getting data that is less than 16 bytes.
; since we know that there was data before the pointer, we can offset
; the input pointer before the actual point, to receive exactly 16 bytes.
; after that the registers need to be adjusted.
_get_last_two_xmms:
movdqa xmm2, xmm3
movdqu xmm1, [arg2 - 16 + arg3]
pshufb xmm1, xmm7
shl arg3, 4
lea rax, [pshufb_shf_table + 15*16]
sub rax, arg3
movdqu xmm0, [rax]
pshufb xmm2, xmm0
pxor xmm0, [mask3]
pshufb xmm3, xmm0
pblendvb xmm1, xmm2 ;xmm0 is implicit
movdqa xmm2, xmm1
movdqa xmm4, xmm3
pclmulqdq xmm3, xmm6, 0x11
pclmulqdq xmm4, xmm6, 0x0
pxor xmm3, xmm4
pxor xmm3, xmm2
_128_done:
movdqa xmm6, [rk5]
movdqa xmm0, xmm3
;64b fold
pclmulqdq xmm3, xmm6, 0x1
pslldq xmm0, 8
pxor xmm3, xmm0
;32b fold
movdqa xmm0, xmm3
pand xmm0, [mask4]
psrldq xmm3, 12
pclmulqdq xmm3, xmm6, 0x10
pxor xmm3, xmm0
;barrett reduction
_barrett:
movdqa xmm6, [rk7]
movdqa xmm0, xmm3
pclmulqdq xmm3, xmm6, 0x01
pslldq xmm3, 4
pclmulqdq xmm3, xmm6, 0x11
pslldq xmm3, 4
pxor xmm3, xmm0
pextrd eax, xmm3,1
_cleanup:
not eax
%ifidn __OUTPUT_FORMAT__, win64
movdqa xmm6, [rsp + XMM_SAVE + 16*0]
movdqa xmm7, [rsp + XMM_SAVE + 16*1]
%endif
add rsp,VARIABLE_OFFSET
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 16
_less_than_128:
;check if there is enough buffer to be able to fold 16B at a time
cmp arg3, 32
jl _less_than_32
movdqa xmm7, [SHUF_MASK]
;if there is, load the constants
movdqa xmm6, [rk1] ;k1
movd xmm0, arg1_low32
pslldq xmm0, 12
movdqu xmm3, [arg2]
pshufb xmm3, xmm7
pxor xmm3, xmm0
;update the buffer pointer
add arg2, 16
;update the counter. subtract 32 instead of 16 to save one instruction from the loop
sub arg3, 32
jmp _16B_reduction_loop
align 16
_less_than_32:
mov eax, arg1_low32
test arg3, arg3
je _cleanup
movdqa xmm7, [SHUF_MASK]
movd xmm0, arg1_low32
pslldq xmm0, 12
cmp arg3, 16
je _exact_16_left
jl _less_than_16_left
movd xmm0, arg1_low32
pslldq xmm0, 12
movdqu xmm3, [arg2]
pshufb xmm3, xmm7
pxor xmm3, xmm0
add arg2, 16
sub arg3, 16
movdqa xmm6, [rk1] ;k1
jmp _get_last_two_xmms
align 16
_less_than_16_left:
; use stack space to load data less than 16 bytes, zero-out the 16B in memory first.
pxor xmm1, xmm1
mov r11, rsp
movdqa [r11], xmm1
cmp arg3, 4
jl _only_less_than_4
mov r9, arg3
cmp arg3, 8
jl _less_than_8_left
mov rax, [arg2]
mov [r11], rax
add r11, 8
sub arg3, 8
add arg2, 8
_less_than_8_left:
cmp arg3, 4
jl _less_than_4_left
mov eax, [arg2]
mov [r11], eax
add r11, 4
sub arg3, 4
add arg2, 4
_less_than_4_left:
cmp arg3, 2
jl _less_than_2_left
mov ax, [arg2]
mov [r11], ax
add r11, 2
sub arg3, 2
add arg2, 2
_less_than_2_left:
cmp arg3, 1
jl _zero_left
mov al, [arg2]
mov [r11], al
_zero_left:
movdqa xmm3, [rsp]
pshufb xmm3, xmm7
pxor xmm3, xmm0
shl r9, 4
lea rax, [pshufb_shf_table + 15*16]
sub rax, r9
movdqu xmm0, [rax]
pxor xmm0, [mask3]
pshufb xmm3, xmm0
jmp _128_done
align 16
_exact_16_left:
movdqu xmm3, [arg2]
pshufb xmm3, xmm7
pxor xmm3, xmm0
jmp _128_done
_only_less_than_4:
cmp arg3, 3
jl _only_less_than_3
mov al, [arg2]
mov [r11], al
mov al, [arg2+1]
mov [r11+1], al
mov al, [arg2+2]
mov [r11+2], al
movdqa xmm3, [rsp]
pshufb xmm3, xmm7
pxor xmm3, xmm0
psrldq xmm3, 5
jmp _barrett
_only_less_than_3:
cmp arg3, 2
jl _only_less_than_2
mov al, [arg2]
mov [r11], al
mov al, [arg2+1]
mov [r11+1], al
movdqa xmm3, [rsp]
pshufb xmm3, xmm7
pxor xmm3, xmm0
psrldq xmm3, 6
jmp _barrett
_only_less_than_2:
mov al, [arg2]
mov [r11], al
movdqa xmm3, [rsp]
pshufb xmm3, xmm7
pxor xmm3, xmm0
psrldq xmm3, 7
jmp _barrett
; precomputed constants
section .data
align 16
rk1:
DQ 0xf200aa6600000000
rk2:
DQ 0x17d3315d00000000
rk3:
DQ 0xd3504ec700000000
rk4:
DQ 0x57a8445500000000
rk5:
DQ 0xf200aa6600000000
rk6:
DQ 0x490d678d00000000
rk7:
DQ 0x0000000104d101df
rk8:
DQ 0x0000000104c11db7
mask:
dq 0xFFFFFFFFFFFFFFFF, 0x0000000000000000
mask2:
dq 0xFFFFFFFF00000000, 0xFFFFFFFFFFFFFFFF
mask3:
dq 0x8080808080808080, 0x8080808080808080
mask4:
dq 0xFFFFFFFFFFFFFFFF, 0x00000000FFFFFFFF
align 32
pshufb_shf_table:
dq 0x8887868584838281, 0x008f8e8d8c8b8a89 ; shl 15 (16-1) / shr1
dq 0x8988878685848382, 0x01008f8e8d8c8b8a ; shl 14 (16-3) / shr2
dq 0x8a89888786858483, 0x0201008f8e8d8c8b ; shl 13 (16-4) / shr3
dq 0x8b8a898887868584, 0x030201008f8e8d8c ; shl 12 (16-4) / shr4
dq 0x8c8b8a8988878685, 0x04030201008f8e8d ; shl 11 (16-5) / shr5
dq 0x8d8c8b8a89888786, 0x0504030201008f8e ; shl 10 (16-6) / shr6
dq 0x8e8d8c8b8a898887, 0x060504030201008f ; shl 9 (16-7) / shr7
dq 0x8f8e8d8c8b8a8988, 0x0706050403020100 ; shl 8 (16-8) / shr8
dq 0x008f8e8d8c8b8a89, 0x0807060504030201 ; shl 7 (16-9) / shr9
dq 0x01008f8e8d8c8b8a, 0x0908070605040302 ; shl 6 (16-10) / shr10
dq 0x0201008f8e8d8c8b, 0x0a09080706050403 ; shl 5 (16-11) / shr11
dq 0x030201008f8e8d8c, 0x0b0a090807060504 ; shl 4 (16-12) / shr12
dq 0x04030201008f8e8d, 0x0c0b0a0908070605 ; shl 3 (16-13) / shr13
dq 0x0504030201008f8e, 0x0d0c0b0a09080706 ; shl 2 (16-14) / shr14
dq 0x060504030201008f, 0x0e0d0c0b0a090807 ; shl 1 (16-15) / shr15
SHUF_MASK dq 0x08090A0B0C0D0E0F, 0x0001020304050607
;;; func core, ver, snum
slversion crc32_ieee_by4, 05, 02, 0017
|
/*
Copyright 2017-2019 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "lullaby/modules/lullscript/script_env.h"
namespace lull {
namespace {
using ::testing::Eq;
TEST(ScriptFunctionsMapTest, Map) {
ScriptEnv env;
ScriptValue res;
res = env.Exec("(make-map (1u 'a') (2u 123) (4u 'd'))");
EXPECT_THAT(res.Is<VariantMap>(), Eq(true));
EXPECT_THAT(res.Get<VariantMap>()->size(), Eq(size_t(3u)));
EXPECT_THAT(res.Get<VariantMap>()->count(1), Eq(size_t(1u)));
EXPECT_THAT(res.Get<VariantMap>()->count(2), Eq(size_t(1u)));
EXPECT_THAT(res.Get<VariantMap>()->count(3), Eq(size_t(0u)));
EXPECT_THAT(res.Get<VariantMap>()->count(4), Eq(size_t(1u)));
auto iter = res.Get<VariantMap>()->find(1);
EXPECT_THAT(iter->second.GetTypeId(), Eq(GetTypeId<std::string>()));
EXPECT_THAT(*iter->second.Get<std::string>(), Eq("a"));
iter = res.Get<VariantMap>()->find(2);
EXPECT_THAT(iter->second.GetTypeId(), Eq(GetTypeId<int>()));
EXPECT_THAT(*iter->second.Get<int>(), Eq(123));
iter = res.Get<VariantMap>()->find(4);
EXPECT_THAT(iter->second.GetTypeId(), Eq(GetTypeId<std::string>()));
EXPECT_THAT(*iter->second.Get<std::string>(), Eq("d"));
}
TEST(ScriptFunctionsMapTest, MapSize) {
ScriptEnv env;
ScriptValue res;
res = env.Exec("(map-size (make-map))");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(0));
res = env.Exec("(map-size {})");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(0));
res = env.Exec("(map-size (make-map (1u 'a')))");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(1));
res = env.Exec("(map-size (make-map (1u 'a') (2u 123) (4u 'd')))");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(3));
}
TEST(ScriptFunctionsMapTest, MapEmpty) {
ScriptEnv env;
ScriptValue res;
res = env.Exec("(map-empty (make-map))");
EXPECT_THAT(res.Is<bool>(), Eq(true));
EXPECT_THAT(*res.Get<bool>(), Eq(true));
res = env.Exec("(map-empty (make-map (1u 'a') (2u 123) (4u 'd')))");
EXPECT_THAT(res.Is<bool>(), Eq(true));
EXPECT_THAT(*res.Get<bool>(), Eq(false));
}
TEST(ScriptFunctionsMapTest, MapGet) {
ScriptEnv env;
ScriptValue res;
res = env.Exec("(map-get (make-map (1u 'a') (2u 123) (4u 'd')) 2u)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(123));
res = env.Exec("(map-get-or (make-map (1u 'a')) 2u 124)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(124));
}
TEST(ScriptFunctionsMapTest, MapInsert) {
ScriptEnv env;
ScriptValue res;
res = env.Exec("(= m (make-map (1u 'a') (2u 123) (4u 'd')))");
res = env.Exec("(map-size m)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(3));
res = env.Exec("(map-insert m 3u 456)");
res = env.Exec("(map-size m)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(4));
res = env.Exec("(map-get m 3u)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(456));
}
TEST(ScriptFunctionsMapTest, MapSet) {
ScriptEnv env;
ScriptValue res;
res = env.Exec("(= m (make-map (1u 'a') (2u 123) (4u 'd')))");
res = env.Exec("(map-size m)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(3));
// map-insert doesn't modify existing elements.
res = env.Exec("(map-insert m 2u 456)");
res = env.Exec("(map-size m)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(3));
res = env.Exec("(map-get m 2u)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(123));
// map-set does modify existing elements.
res = env.Exec("(map-set m 2u 456)");
res = env.Exec("(map-size m)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(3));
res = env.Exec("(map-get m 2u)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(456));
}
TEST(ScriptFunctionsMapTest, MapErase) {
ScriptEnv env;
ScriptValue res;
res = env.Exec("(= m (make-map (1u 'a') (2u 123) (4u 'd')))");
res = env.Exec("(map-size m)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(3));
res = env.Exec("(map-erase m 2u)");
res = env.Exec("(map-size m)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(2));
res = env.Exec("(map-get m 2u)");
EXPECT_THAT(res.IsNil(), Eq(true));
}
TEST(ScriptFunctionsMapTest, MapForeach) {
ScriptEnv env;
ScriptValue res;
res = env.Exec(
"(do (= sum 0)"
" (map-foreach (make-map (1u 2) (3u 4)) (k v) (= sum (+ sum v))) sum)");
EXPECT_THAT(res.Is<int>(), Eq(true));
EXPECT_THAT(*res.Get<int>(), Eq(6));
res = env.Exec(
"(do (= sum 0u)"
" (map-foreach (make-map (1u 2) (3u 4)) (k v) (= sum (+ sum k))) sum)");
EXPECT_THAT(res.Is<unsigned>(), Eq(true));
EXPECT_THAT(*res.Get<unsigned>(), Eq(4u));
}
} // namespace
} // namespace lull
|
obj/user/divzero.debug: 文件格式 elf32-i386
Disassembly of section .text:
00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
// See if we were started with arguments on the stack
cmpl $USTACKTOP, %esp
800020: 81 fc 00 e0 bf ee cmp $0xeebfe000,%esp
jne args_exist
800026: 75 04 jne 80002c <args_exist>
// If not, push dummy argc/argv arguments.
// This happens when we are loaded by the kernel,
// because the kernel does not know about passing arguments.
pushl $0
800028: 6a 00 push $0x0
pushl $0
80002a: 6a 00 push $0x0
0080002c <args_exist>:
args_exist:
call libmain
80002c: e8 2f 00 00 00 call 800060 <libmain>
1: jmp 1b
800031: eb fe jmp 800031 <args_exist+0x5>
00800033 <umain>:
int zero;
void
umain(int argc, char **argv)
{
800033: 55 push %ebp
800034: 89 e5 mov %esp,%ebp
800036: 83 ec 10 sub $0x10,%esp
zero = 0;
800039: c7 05 04 20 80 00 00 movl $0x0,0x802004
800040: 00 00 00
cprintf("1/0 is %08x!\n", 1/zero);
800043: b8 01 00 00 00 mov $0x1,%eax
800048: b9 00 00 00 00 mov $0x0,%ecx
80004d: 99 cltd
80004e: f7 f9 idiv %ecx
800050: 50 push %eax
800051: 68 e0 0f 80 00 push $0x800fe0
800056: e8 f2 00 00 00 call 80014d <cprintf>
}
80005b: 83 c4 10 add $0x10,%esp
80005e: c9 leave
80005f: c3 ret
00800060 <libmain>:
const volatile struct Env *thisenv;
const char *binaryname = "<unknown>";
void
libmain(int argc, char **argv)
{
800060: 55 push %ebp
800061: 89 e5 mov %esp,%ebp
800063: 56 push %esi
800064: 53 push %ebx
800065: 8b 5d 08 mov 0x8(%ebp),%ebx
800068: 8b 75 0c mov 0xc(%ebp),%esi
// set thisenv to point at our Env structure in envs[].
// LAB 3: Your code here.
envid_t envid = sys_getenvid();
80006b: e8 b7 0a 00 00 call 800b27 <sys_getenvid>
thisenv = envs + ENVX(envid);
800070: 25 ff 03 00 00 and $0x3ff,%eax
800075: 6b c0 7c imul $0x7c,%eax,%eax
800078: 05 00 00 c0 ee add $0xeec00000,%eax
80007d: a3 08 20 80 00 mov %eax,0x802008
// save the name of the program so that panic() can use it
if (argc > 0)
800082: 85 db test %ebx,%ebx
800084: 7e 07 jle 80008d <libmain+0x2d>
binaryname = argv[0];
800086: 8b 06 mov (%esi),%eax
800088: a3 00 20 80 00 mov %eax,0x802000
// call user main routine
umain(argc, argv);
80008d: 83 ec 08 sub $0x8,%esp
800090: 56 push %esi
800091: 53 push %ebx
800092: e8 9c ff ff ff call 800033 <umain>
// exit gracefully
exit();
800097: e8 0a 00 00 00 call 8000a6 <exit>
}
80009c: 83 c4 10 add $0x10,%esp
80009f: 8d 65 f8 lea -0x8(%ebp),%esp
8000a2: 5b pop %ebx
8000a3: 5e pop %esi
8000a4: 5d pop %ebp
8000a5: c3 ret
008000a6 <exit>:
#include <inc/lib.h>
void
exit(void)
{
8000a6: 55 push %ebp
8000a7: 89 e5 mov %esp,%ebp
8000a9: 83 ec 14 sub $0x14,%esp
// close_all();
sys_env_destroy(0);
8000ac: 6a 00 push $0x0
8000ae: e8 33 0a 00 00 call 800ae6 <sys_env_destroy>
}
8000b3: 83 c4 10 add $0x10,%esp
8000b6: c9 leave
8000b7: c3 ret
008000b8 <putch>:
};
static void
putch(int ch, struct printbuf *b)
{
8000b8: 55 push %ebp
8000b9: 89 e5 mov %esp,%ebp
8000bb: 53 push %ebx
8000bc: 83 ec 04 sub $0x4,%esp
8000bf: 8b 5d 0c mov 0xc(%ebp),%ebx
b->buf[b->idx++] = ch;
8000c2: 8b 13 mov (%ebx),%edx
8000c4: 8d 42 01 lea 0x1(%edx),%eax
8000c7: 89 03 mov %eax,(%ebx)
8000c9: 8b 4d 08 mov 0x8(%ebp),%ecx
8000cc: 88 4c 13 08 mov %cl,0x8(%ebx,%edx,1)
if (b->idx == 256-1) {
8000d0: 3d ff 00 00 00 cmp $0xff,%eax
8000d5: 74 09 je 8000e0 <putch+0x28>
sys_cputs(b->buf, b->idx);
b->idx = 0;
}
b->cnt++;
8000d7: 83 43 04 01 addl $0x1,0x4(%ebx)
}
8000db: 8b 5d fc mov -0x4(%ebp),%ebx
8000de: c9 leave
8000df: c3 ret
sys_cputs(b->buf, b->idx);
8000e0: 83 ec 08 sub $0x8,%esp
8000e3: 68 ff 00 00 00 push $0xff
8000e8: 8d 43 08 lea 0x8(%ebx),%eax
8000eb: 50 push %eax
8000ec: e8 b8 09 00 00 call 800aa9 <sys_cputs>
b->idx = 0;
8000f1: c7 03 00 00 00 00 movl $0x0,(%ebx)
8000f7: 83 c4 10 add $0x10,%esp
8000fa: eb db jmp 8000d7 <putch+0x1f>
008000fc <vcprintf>:
int
vcprintf(const char *fmt, va_list ap)
{
8000fc: 55 push %ebp
8000fd: 89 e5 mov %esp,%ebp
8000ff: 81 ec 18 01 00 00 sub $0x118,%esp
struct printbuf b;
b.idx = 0;
800105: c7 85 f0 fe ff ff 00 movl $0x0,-0x110(%ebp)
80010c: 00 00 00
b.cnt = 0;
80010f: c7 85 f4 fe ff ff 00 movl $0x0,-0x10c(%ebp)
800116: 00 00 00
vprintfmt((void*)putch, &b, fmt, ap);
800119: ff 75 0c pushl 0xc(%ebp)
80011c: ff 75 08 pushl 0x8(%ebp)
80011f: 8d 85 f0 fe ff ff lea -0x110(%ebp),%eax
800125: 50 push %eax
800126: 68 b8 00 80 00 push $0x8000b8
80012b: e8 1a 01 00 00 call 80024a <vprintfmt>
sys_cputs(b.buf, b.idx);
800130: 83 c4 08 add $0x8,%esp
800133: ff b5 f0 fe ff ff pushl -0x110(%ebp)
800139: 8d 85 f8 fe ff ff lea -0x108(%ebp),%eax
80013f: 50 push %eax
800140: e8 64 09 00 00 call 800aa9 <sys_cputs>
return b.cnt;
}
800145: 8b 85 f4 fe ff ff mov -0x10c(%ebp),%eax
80014b: c9 leave
80014c: c3 ret
0080014d <cprintf>:
int
cprintf(const char *fmt, ...)
{
80014d: 55 push %ebp
80014e: 89 e5 mov %esp,%ebp
800150: 83 ec 10 sub $0x10,%esp
va_list ap;
int cnt;
va_start(ap, fmt);
800153: 8d 45 0c lea 0xc(%ebp),%eax
cnt = vcprintf(fmt, ap);
800156: 50 push %eax
800157: ff 75 08 pushl 0x8(%ebp)
80015a: e8 9d ff ff ff call 8000fc <vcprintf>
va_end(ap);
return cnt;
}
80015f: c9 leave
800160: c3 ret
00800161 <printnum>:
* using specified putch function and associated pointer putdat.
*/
static void
printnum(void (*putch)(int, void*), void *putdat,
unsigned long long num, unsigned base, int width, int padc)
{
800161: 55 push %ebp
800162: 89 e5 mov %esp,%ebp
800164: 57 push %edi
800165: 56 push %esi
800166: 53 push %ebx
800167: 83 ec 1c sub $0x1c,%esp
80016a: 89 c7 mov %eax,%edi
80016c: 89 d6 mov %edx,%esi
80016e: 8b 45 08 mov 0x8(%ebp),%eax
800171: 8b 55 0c mov 0xc(%ebp),%edx
800174: 89 45 d8 mov %eax,-0x28(%ebp)
800177: 89 55 dc mov %edx,-0x24(%ebp)
// first recursively print all preceding (more significant) digits
if (num >= base) {
80017a: 8b 4d 10 mov 0x10(%ebp),%ecx
80017d: bb 00 00 00 00 mov $0x0,%ebx
800182: 89 4d e0 mov %ecx,-0x20(%ebp)
800185: 89 5d e4 mov %ebx,-0x1c(%ebp)
800188: 39 d3 cmp %edx,%ebx
80018a: 72 05 jb 800191 <printnum+0x30>
80018c: 39 45 10 cmp %eax,0x10(%ebp)
80018f: 77 7a ja 80020b <printnum+0xaa>
printnum(putch, putdat, num / base, base, width - 1, padc);
800191: 83 ec 0c sub $0xc,%esp
800194: ff 75 18 pushl 0x18(%ebp)
800197: 8b 45 14 mov 0x14(%ebp),%eax
80019a: 8d 58 ff lea -0x1(%eax),%ebx
80019d: 53 push %ebx
80019e: ff 75 10 pushl 0x10(%ebp)
8001a1: 83 ec 08 sub $0x8,%esp
8001a4: ff 75 e4 pushl -0x1c(%ebp)
8001a7: ff 75 e0 pushl -0x20(%ebp)
8001aa: ff 75 dc pushl -0x24(%ebp)
8001ad: ff 75 d8 pushl -0x28(%ebp)
8001b0: e8 eb 0b 00 00 call 800da0 <__udivdi3>
8001b5: 83 c4 18 add $0x18,%esp
8001b8: 52 push %edx
8001b9: 50 push %eax
8001ba: 89 f2 mov %esi,%edx
8001bc: 89 f8 mov %edi,%eax
8001be: e8 9e ff ff ff call 800161 <printnum>
8001c3: 83 c4 20 add $0x20,%esp
8001c6: eb 13 jmp 8001db <printnum+0x7a>
} else {
// print any needed pad characters before first digit
while (--width > 0)
putch(padc, putdat);
8001c8: 83 ec 08 sub $0x8,%esp
8001cb: 56 push %esi
8001cc: ff 75 18 pushl 0x18(%ebp)
8001cf: ff d7 call *%edi
8001d1: 83 c4 10 add $0x10,%esp
while (--width > 0)
8001d4: 83 eb 01 sub $0x1,%ebx
8001d7: 85 db test %ebx,%ebx
8001d9: 7f ed jg 8001c8 <printnum+0x67>
}
// then print this (the least significant) digit
putch("0123456789abcdef"[num % base], putdat);
8001db: 83 ec 08 sub $0x8,%esp
8001de: 56 push %esi
8001df: 83 ec 04 sub $0x4,%esp
8001e2: ff 75 e4 pushl -0x1c(%ebp)
8001e5: ff 75 e0 pushl -0x20(%ebp)
8001e8: ff 75 dc pushl -0x24(%ebp)
8001eb: ff 75 d8 pushl -0x28(%ebp)
8001ee: e8 cd 0c 00 00 call 800ec0 <__umoddi3>
8001f3: 83 c4 14 add $0x14,%esp
8001f6: 0f be 80 f8 0f 80 00 movsbl 0x800ff8(%eax),%eax
8001fd: 50 push %eax
8001fe: ff d7 call *%edi
}
800200: 83 c4 10 add $0x10,%esp
800203: 8d 65 f4 lea -0xc(%ebp),%esp
800206: 5b pop %ebx
800207: 5e pop %esi
800208: 5f pop %edi
800209: 5d pop %ebp
80020a: c3 ret
80020b: 8b 5d 14 mov 0x14(%ebp),%ebx
80020e: eb c4 jmp 8001d4 <printnum+0x73>
00800210 <sprintputch>:
int cnt;
};
static void
sprintputch(int ch, struct sprintbuf *b)
{
800210: 55 push %ebp
800211: 89 e5 mov %esp,%ebp
800213: 8b 45 0c mov 0xc(%ebp),%eax
b->cnt++;
800216: 83 40 08 01 addl $0x1,0x8(%eax)
if (b->buf < b->ebuf)
80021a: 8b 10 mov (%eax),%edx
80021c: 3b 50 04 cmp 0x4(%eax),%edx
80021f: 73 0a jae 80022b <sprintputch+0x1b>
*b->buf++ = ch;
800221: 8d 4a 01 lea 0x1(%edx),%ecx
800224: 89 08 mov %ecx,(%eax)
800226: 8b 45 08 mov 0x8(%ebp),%eax
800229: 88 02 mov %al,(%edx)
}
80022b: 5d pop %ebp
80022c: c3 ret
0080022d <printfmt>:
{
80022d: 55 push %ebp
80022e: 89 e5 mov %esp,%ebp
800230: 83 ec 08 sub $0x8,%esp
va_start(ap, fmt);
800233: 8d 45 14 lea 0x14(%ebp),%eax
vprintfmt(putch, putdat, fmt, ap);
800236: 50 push %eax
800237: ff 75 10 pushl 0x10(%ebp)
80023a: ff 75 0c pushl 0xc(%ebp)
80023d: ff 75 08 pushl 0x8(%ebp)
800240: e8 05 00 00 00 call 80024a <vprintfmt>
}
800245: 83 c4 10 add $0x10,%esp
800248: c9 leave
800249: c3 ret
0080024a <vprintfmt>:
{
80024a: 55 push %ebp
80024b: 89 e5 mov %esp,%ebp
80024d: 57 push %edi
80024e: 56 push %esi
80024f: 53 push %ebx
800250: 83 ec 2c sub $0x2c,%esp
800253: 8b 75 08 mov 0x8(%ebp),%esi
800256: 8b 5d 0c mov 0xc(%ebp),%ebx
800259: 8b 7d 10 mov 0x10(%ebp),%edi
80025c: e9 c1 03 00 00 jmp 800622 <vprintfmt+0x3d8>
padc = ' ';
800261: c6 45 d4 20 movb $0x20,-0x2c(%ebp)
altflag = 0;
800265: c7 45 d8 00 00 00 00 movl $0x0,-0x28(%ebp)
precision = -1;
80026c: c7 45 d0 ff ff ff ff movl $0xffffffff,-0x30(%ebp)
width = -1;
800273: c7 45 e0 ff ff ff ff movl $0xffffffff,-0x20(%ebp)
lflag = 0;
80027a: b9 00 00 00 00 mov $0x0,%ecx
switch (ch = *(unsigned char *) fmt++) {
80027f: 8d 47 01 lea 0x1(%edi),%eax
800282: 89 45 e4 mov %eax,-0x1c(%ebp)
800285: 0f b6 17 movzbl (%edi),%edx
800288: 8d 42 dd lea -0x23(%edx),%eax
80028b: 3c 55 cmp $0x55,%al
80028d: 0f 87 12 04 00 00 ja 8006a5 <vprintfmt+0x45b>
800293: 0f b6 c0 movzbl %al,%eax
800296: ff 24 85 40 11 80 00 jmp *0x801140(,%eax,4)
80029d: 8b 7d e4 mov -0x1c(%ebp),%edi
padc = '-';
8002a0: c6 45 d4 2d movb $0x2d,-0x2c(%ebp)
8002a4: eb d9 jmp 80027f <vprintfmt+0x35>
switch (ch = *(unsigned char *) fmt++) {
8002a6: 8b 7d e4 mov -0x1c(%ebp),%edi
padc = '0';
8002a9: c6 45 d4 30 movb $0x30,-0x2c(%ebp)
8002ad: eb d0 jmp 80027f <vprintfmt+0x35>
switch (ch = *(unsigned char *) fmt++) {
8002af: 0f b6 d2 movzbl %dl,%edx
8002b2: 8b 7d e4 mov -0x1c(%ebp),%edi
for (precision = 0; ; ++fmt) {
8002b5: b8 00 00 00 00 mov $0x0,%eax
8002ba: 89 4d e4 mov %ecx,-0x1c(%ebp)
precision = precision * 10 + ch - '0';
8002bd: 8d 04 80 lea (%eax,%eax,4),%eax
8002c0: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
ch = *fmt;
8002c4: 0f be 17 movsbl (%edi),%edx
if (ch < '0' || ch > '9')
8002c7: 8d 4a d0 lea -0x30(%edx),%ecx
8002ca: 83 f9 09 cmp $0x9,%ecx
8002cd: 77 55 ja 800324 <vprintfmt+0xda>
for (precision = 0; ; ++fmt) {
8002cf: 83 c7 01 add $0x1,%edi
precision = precision * 10 + ch - '0';
8002d2: eb e9 jmp 8002bd <vprintfmt+0x73>
precision = va_arg(ap, int);
8002d4: 8b 45 14 mov 0x14(%ebp),%eax
8002d7: 8b 00 mov (%eax),%eax
8002d9: 89 45 d0 mov %eax,-0x30(%ebp)
8002dc: 8b 45 14 mov 0x14(%ebp),%eax
8002df: 8d 40 04 lea 0x4(%eax),%eax
8002e2: 89 45 14 mov %eax,0x14(%ebp)
switch (ch = *(unsigned char *) fmt++) {
8002e5: 8b 7d e4 mov -0x1c(%ebp),%edi
if (width < 0)
8002e8: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
8002ec: 79 91 jns 80027f <vprintfmt+0x35>
width = precision, precision = -1;
8002ee: 8b 45 d0 mov -0x30(%ebp),%eax
8002f1: 89 45 e0 mov %eax,-0x20(%ebp)
8002f4: c7 45 d0 ff ff ff ff movl $0xffffffff,-0x30(%ebp)
8002fb: eb 82 jmp 80027f <vprintfmt+0x35>
8002fd: 8b 45 e0 mov -0x20(%ebp),%eax
800300: 85 c0 test %eax,%eax
800302: ba 00 00 00 00 mov $0x0,%edx
800307: 0f 49 d0 cmovns %eax,%edx
80030a: 89 55 e0 mov %edx,-0x20(%ebp)
switch (ch = *(unsigned char *) fmt++) {
80030d: 8b 7d e4 mov -0x1c(%ebp),%edi
800310: e9 6a ff ff ff jmp 80027f <vprintfmt+0x35>
800315: 8b 7d e4 mov -0x1c(%ebp),%edi
altflag = 1;
800318: c7 45 d8 01 00 00 00 movl $0x1,-0x28(%ebp)
goto reswitch;
80031f: e9 5b ff ff ff jmp 80027f <vprintfmt+0x35>
800324: 8b 4d e4 mov -0x1c(%ebp),%ecx
800327: 89 45 d0 mov %eax,-0x30(%ebp)
80032a: eb bc jmp 8002e8 <vprintfmt+0x9e>
lflag++;
80032c: 83 c1 01 add $0x1,%ecx
switch (ch = *(unsigned char *) fmt++) {
80032f: 8b 7d e4 mov -0x1c(%ebp),%edi
goto reswitch;
800332: e9 48 ff ff ff jmp 80027f <vprintfmt+0x35>
putch(va_arg(ap, int), putdat);
800337: 8b 45 14 mov 0x14(%ebp),%eax
80033a: 8d 78 04 lea 0x4(%eax),%edi
80033d: 83 ec 08 sub $0x8,%esp
800340: 53 push %ebx
800341: ff 30 pushl (%eax)
800343: ff d6 call *%esi
break;
800345: 83 c4 10 add $0x10,%esp
putch(va_arg(ap, int), putdat);
800348: 89 7d 14 mov %edi,0x14(%ebp)
break;
80034b: e9 cf 02 00 00 jmp 80061f <vprintfmt+0x3d5>
err = va_arg(ap, int);
800350: 8b 45 14 mov 0x14(%ebp),%eax
800353: 8d 78 04 lea 0x4(%eax),%edi
800356: 8b 00 mov (%eax),%eax
800358: 99 cltd
800359: 31 d0 xor %edx,%eax
80035b: 29 d0 sub %edx,%eax
if (err >= MAXERROR || (p = error_string[err]) == NULL)
80035d: 83 f8 0f cmp $0xf,%eax
800360: 7f 23 jg 800385 <vprintfmt+0x13b>
800362: 8b 14 85 a0 12 80 00 mov 0x8012a0(,%eax,4),%edx
800369: 85 d2 test %edx,%edx
80036b: 74 18 je 800385 <vprintfmt+0x13b>
printfmt(putch, putdat, "%s", p);
80036d: 52 push %edx
80036e: 68 19 10 80 00 push $0x801019
800373: 53 push %ebx
800374: 56 push %esi
800375: e8 b3 fe ff ff call 80022d <printfmt>
80037a: 83 c4 10 add $0x10,%esp
err = va_arg(ap, int);
80037d: 89 7d 14 mov %edi,0x14(%ebp)
800380: e9 9a 02 00 00 jmp 80061f <vprintfmt+0x3d5>
printfmt(putch, putdat, "error %d", err);
800385: 50 push %eax
800386: 68 10 10 80 00 push $0x801010
80038b: 53 push %ebx
80038c: 56 push %esi
80038d: e8 9b fe ff ff call 80022d <printfmt>
800392: 83 c4 10 add $0x10,%esp
err = va_arg(ap, int);
800395: 89 7d 14 mov %edi,0x14(%ebp)
printfmt(putch, putdat, "error %d", err);
800398: e9 82 02 00 00 jmp 80061f <vprintfmt+0x3d5>
if ((p = va_arg(ap, char *)) == NULL)
80039d: 8b 45 14 mov 0x14(%ebp),%eax
8003a0: 83 c0 04 add $0x4,%eax
8003a3: 89 45 cc mov %eax,-0x34(%ebp)
8003a6: 8b 45 14 mov 0x14(%ebp),%eax
8003a9: 8b 38 mov (%eax),%edi
p = "(null)";
8003ab: 85 ff test %edi,%edi
8003ad: b8 09 10 80 00 mov $0x801009,%eax
8003b2: 0f 44 f8 cmove %eax,%edi
if (width > 0 && padc != '-')
8003b5: 83 7d e0 00 cmpl $0x0,-0x20(%ebp)
8003b9: 0f 8e bd 00 00 00 jle 80047c <vprintfmt+0x232>
8003bf: 80 7d d4 2d cmpb $0x2d,-0x2c(%ebp)
8003c3: 75 0e jne 8003d3 <vprintfmt+0x189>
8003c5: 89 75 08 mov %esi,0x8(%ebp)
8003c8: 8b 75 d0 mov -0x30(%ebp),%esi
8003cb: 89 5d 0c mov %ebx,0xc(%ebp)
8003ce: 8b 5d e0 mov -0x20(%ebp),%ebx
8003d1: eb 6d jmp 800440 <vprintfmt+0x1f6>
for (width -= strnlen(p, precision); width > 0; width--)
8003d3: 83 ec 08 sub $0x8,%esp
8003d6: ff 75 d0 pushl -0x30(%ebp)
8003d9: 57 push %edi
8003da: e8 6e 03 00 00 call 80074d <strnlen>
8003df: 8b 4d e0 mov -0x20(%ebp),%ecx
8003e2: 29 c1 sub %eax,%ecx
8003e4: 89 4d c8 mov %ecx,-0x38(%ebp)
8003e7: 83 c4 10 add $0x10,%esp
putch(padc, putdat);
8003ea: 0f be 45 d4 movsbl -0x2c(%ebp),%eax
8003ee: 89 45 e0 mov %eax,-0x20(%ebp)
8003f1: 89 7d d4 mov %edi,-0x2c(%ebp)
8003f4: 89 cf mov %ecx,%edi
for (width -= strnlen(p, precision); width > 0; width--)
8003f6: eb 0f jmp 800407 <vprintfmt+0x1bd>
putch(padc, putdat);
8003f8: 83 ec 08 sub $0x8,%esp
8003fb: 53 push %ebx
8003fc: ff 75 e0 pushl -0x20(%ebp)
8003ff: ff d6 call *%esi
for (width -= strnlen(p, precision); width > 0; width--)
800401: 83 ef 01 sub $0x1,%edi
800404: 83 c4 10 add $0x10,%esp
800407: 85 ff test %edi,%edi
800409: 7f ed jg 8003f8 <vprintfmt+0x1ae>
80040b: 8b 7d d4 mov -0x2c(%ebp),%edi
80040e: 8b 4d c8 mov -0x38(%ebp),%ecx
800411: 85 c9 test %ecx,%ecx
800413: b8 00 00 00 00 mov $0x0,%eax
800418: 0f 49 c1 cmovns %ecx,%eax
80041b: 29 c1 sub %eax,%ecx
80041d: 89 75 08 mov %esi,0x8(%ebp)
800420: 8b 75 d0 mov -0x30(%ebp),%esi
800423: 89 5d 0c mov %ebx,0xc(%ebp)
800426: 89 cb mov %ecx,%ebx
800428: eb 16 jmp 800440 <vprintfmt+0x1f6>
if (altflag && (ch < ' ' || ch > '~'))
80042a: 83 7d d8 00 cmpl $0x0,-0x28(%ebp)
80042e: 75 31 jne 800461 <vprintfmt+0x217>
putch(ch, putdat);
800430: 83 ec 08 sub $0x8,%esp
800433: ff 75 0c pushl 0xc(%ebp)
800436: 50 push %eax
800437: ff 55 08 call *0x8(%ebp)
80043a: 83 c4 10 add $0x10,%esp
for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
80043d: 83 eb 01 sub $0x1,%ebx
800440: 83 c7 01 add $0x1,%edi
800443: 0f b6 57 ff movzbl -0x1(%edi),%edx
800447: 0f be c2 movsbl %dl,%eax
80044a: 85 c0 test %eax,%eax
80044c: 74 59 je 8004a7 <vprintfmt+0x25d>
80044e: 85 f6 test %esi,%esi
800450: 78 d8 js 80042a <vprintfmt+0x1e0>
800452: 83 ee 01 sub $0x1,%esi
800455: 79 d3 jns 80042a <vprintfmt+0x1e0>
800457: 89 df mov %ebx,%edi
800459: 8b 75 08 mov 0x8(%ebp),%esi
80045c: 8b 5d 0c mov 0xc(%ebp),%ebx
80045f: eb 37 jmp 800498 <vprintfmt+0x24e>
if (altflag && (ch < ' ' || ch > '~'))
800461: 0f be d2 movsbl %dl,%edx
800464: 83 ea 20 sub $0x20,%edx
800467: 83 fa 5e cmp $0x5e,%edx
80046a: 76 c4 jbe 800430 <vprintfmt+0x1e6>
putch('?', putdat);
80046c: 83 ec 08 sub $0x8,%esp
80046f: ff 75 0c pushl 0xc(%ebp)
800472: 6a 3f push $0x3f
800474: ff 55 08 call *0x8(%ebp)
800477: 83 c4 10 add $0x10,%esp
80047a: eb c1 jmp 80043d <vprintfmt+0x1f3>
80047c: 89 75 08 mov %esi,0x8(%ebp)
80047f: 8b 75 d0 mov -0x30(%ebp),%esi
800482: 89 5d 0c mov %ebx,0xc(%ebp)
800485: 8b 5d e0 mov -0x20(%ebp),%ebx
800488: eb b6 jmp 800440 <vprintfmt+0x1f6>
putch(' ', putdat);
80048a: 83 ec 08 sub $0x8,%esp
80048d: 53 push %ebx
80048e: 6a 20 push $0x20
800490: ff d6 call *%esi
for (; width > 0; width--)
800492: 83 ef 01 sub $0x1,%edi
800495: 83 c4 10 add $0x10,%esp
800498: 85 ff test %edi,%edi
80049a: 7f ee jg 80048a <vprintfmt+0x240>
if ((p = va_arg(ap, char *)) == NULL)
80049c: 8b 45 cc mov -0x34(%ebp),%eax
80049f: 89 45 14 mov %eax,0x14(%ebp)
8004a2: e9 78 01 00 00 jmp 80061f <vprintfmt+0x3d5>
8004a7: 89 df mov %ebx,%edi
8004a9: 8b 75 08 mov 0x8(%ebp),%esi
8004ac: 8b 5d 0c mov 0xc(%ebp),%ebx
8004af: eb e7 jmp 800498 <vprintfmt+0x24e>
if (lflag >= 2)
8004b1: 83 f9 01 cmp $0x1,%ecx
8004b4: 7e 3f jle 8004f5 <vprintfmt+0x2ab>
return va_arg(*ap, long long);
8004b6: 8b 45 14 mov 0x14(%ebp),%eax
8004b9: 8b 50 04 mov 0x4(%eax),%edx
8004bc: 8b 00 mov (%eax),%eax
8004be: 89 45 d8 mov %eax,-0x28(%ebp)
8004c1: 89 55 dc mov %edx,-0x24(%ebp)
8004c4: 8b 45 14 mov 0x14(%ebp),%eax
8004c7: 8d 40 08 lea 0x8(%eax),%eax
8004ca: 89 45 14 mov %eax,0x14(%ebp)
if ((long long) num < 0) {
8004cd: 83 7d dc 00 cmpl $0x0,-0x24(%ebp)
8004d1: 79 5c jns 80052f <vprintfmt+0x2e5>
putch('-', putdat);
8004d3: 83 ec 08 sub $0x8,%esp
8004d6: 53 push %ebx
8004d7: 6a 2d push $0x2d
8004d9: ff d6 call *%esi
num = -(long long) num;
8004db: 8b 55 d8 mov -0x28(%ebp),%edx
8004de: 8b 4d dc mov -0x24(%ebp),%ecx
8004e1: f7 da neg %edx
8004e3: 83 d1 00 adc $0x0,%ecx
8004e6: f7 d9 neg %ecx
8004e8: 83 c4 10 add $0x10,%esp
base = 10;
8004eb: b8 0a 00 00 00 mov $0xa,%eax
8004f0: e9 10 01 00 00 jmp 800605 <vprintfmt+0x3bb>
else if (lflag)
8004f5: 85 c9 test %ecx,%ecx
8004f7: 75 1b jne 800514 <vprintfmt+0x2ca>
return va_arg(*ap, int);
8004f9: 8b 45 14 mov 0x14(%ebp),%eax
8004fc: 8b 00 mov (%eax),%eax
8004fe: 89 45 d8 mov %eax,-0x28(%ebp)
800501: 89 c1 mov %eax,%ecx
800503: c1 f9 1f sar $0x1f,%ecx
800506: 89 4d dc mov %ecx,-0x24(%ebp)
800509: 8b 45 14 mov 0x14(%ebp),%eax
80050c: 8d 40 04 lea 0x4(%eax),%eax
80050f: 89 45 14 mov %eax,0x14(%ebp)
800512: eb b9 jmp 8004cd <vprintfmt+0x283>
return va_arg(*ap, long);
800514: 8b 45 14 mov 0x14(%ebp),%eax
800517: 8b 00 mov (%eax),%eax
800519: 89 45 d8 mov %eax,-0x28(%ebp)
80051c: 89 c1 mov %eax,%ecx
80051e: c1 f9 1f sar $0x1f,%ecx
800521: 89 4d dc mov %ecx,-0x24(%ebp)
800524: 8b 45 14 mov 0x14(%ebp),%eax
800527: 8d 40 04 lea 0x4(%eax),%eax
80052a: 89 45 14 mov %eax,0x14(%ebp)
80052d: eb 9e jmp 8004cd <vprintfmt+0x283>
num = getint(&ap, lflag);
80052f: 8b 55 d8 mov -0x28(%ebp),%edx
800532: 8b 4d dc mov -0x24(%ebp),%ecx
base = 10;
800535: b8 0a 00 00 00 mov $0xa,%eax
80053a: e9 c6 00 00 00 jmp 800605 <vprintfmt+0x3bb>
if (lflag >= 2)
80053f: 83 f9 01 cmp $0x1,%ecx
800542: 7e 18 jle 80055c <vprintfmt+0x312>
return va_arg(*ap, unsigned long long);
800544: 8b 45 14 mov 0x14(%ebp),%eax
800547: 8b 10 mov (%eax),%edx
800549: 8b 48 04 mov 0x4(%eax),%ecx
80054c: 8d 40 08 lea 0x8(%eax),%eax
80054f: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
800552: b8 0a 00 00 00 mov $0xa,%eax
800557: e9 a9 00 00 00 jmp 800605 <vprintfmt+0x3bb>
else if (lflag)
80055c: 85 c9 test %ecx,%ecx
80055e: 75 1a jne 80057a <vprintfmt+0x330>
return va_arg(*ap, unsigned int);
800560: 8b 45 14 mov 0x14(%ebp),%eax
800563: 8b 10 mov (%eax),%edx
800565: b9 00 00 00 00 mov $0x0,%ecx
80056a: 8d 40 04 lea 0x4(%eax),%eax
80056d: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
800570: b8 0a 00 00 00 mov $0xa,%eax
800575: e9 8b 00 00 00 jmp 800605 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
80057a: 8b 45 14 mov 0x14(%ebp),%eax
80057d: 8b 10 mov (%eax),%edx
80057f: b9 00 00 00 00 mov $0x0,%ecx
800584: 8d 40 04 lea 0x4(%eax),%eax
800587: 89 45 14 mov %eax,0x14(%ebp)
base = 10;
80058a: b8 0a 00 00 00 mov $0xa,%eax
80058f: eb 74 jmp 800605 <vprintfmt+0x3bb>
if (lflag >= 2)
800591: 83 f9 01 cmp $0x1,%ecx
800594: 7e 15 jle 8005ab <vprintfmt+0x361>
return va_arg(*ap, unsigned long long);
800596: 8b 45 14 mov 0x14(%ebp),%eax
800599: 8b 10 mov (%eax),%edx
80059b: 8b 48 04 mov 0x4(%eax),%ecx
80059e: 8d 40 08 lea 0x8(%eax),%eax
8005a1: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
8005a4: b8 08 00 00 00 mov $0x8,%eax
8005a9: eb 5a jmp 800605 <vprintfmt+0x3bb>
else if (lflag)
8005ab: 85 c9 test %ecx,%ecx
8005ad: 75 17 jne 8005c6 <vprintfmt+0x37c>
return va_arg(*ap, unsigned int);
8005af: 8b 45 14 mov 0x14(%ebp),%eax
8005b2: 8b 10 mov (%eax),%edx
8005b4: b9 00 00 00 00 mov $0x0,%ecx
8005b9: 8d 40 04 lea 0x4(%eax),%eax
8005bc: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
8005bf: b8 08 00 00 00 mov $0x8,%eax
8005c4: eb 3f jmp 800605 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
8005c6: 8b 45 14 mov 0x14(%ebp),%eax
8005c9: 8b 10 mov (%eax),%edx
8005cb: b9 00 00 00 00 mov $0x0,%ecx
8005d0: 8d 40 04 lea 0x4(%eax),%eax
8005d3: 89 45 14 mov %eax,0x14(%ebp)
base = 8;
8005d6: b8 08 00 00 00 mov $0x8,%eax
8005db: eb 28 jmp 800605 <vprintfmt+0x3bb>
putch('0', putdat);
8005dd: 83 ec 08 sub $0x8,%esp
8005e0: 53 push %ebx
8005e1: 6a 30 push $0x30
8005e3: ff d6 call *%esi
putch('x', putdat);
8005e5: 83 c4 08 add $0x8,%esp
8005e8: 53 push %ebx
8005e9: 6a 78 push $0x78
8005eb: ff d6 call *%esi
num = (unsigned long long)
8005ed: 8b 45 14 mov 0x14(%ebp),%eax
8005f0: 8b 10 mov (%eax),%edx
8005f2: b9 00 00 00 00 mov $0x0,%ecx
goto number;
8005f7: 83 c4 10 add $0x10,%esp
(uintptr_t) va_arg(ap, void *);
8005fa: 8d 40 04 lea 0x4(%eax),%eax
8005fd: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
800600: b8 10 00 00 00 mov $0x10,%eax
printnum(putch, putdat, num, base, width, padc);
800605: 83 ec 0c sub $0xc,%esp
800608: 0f be 7d d4 movsbl -0x2c(%ebp),%edi
80060c: 57 push %edi
80060d: ff 75 e0 pushl -0x20(%ebp)
800610: 50 push %eax
800611: 51 push %ecx
800612: 52 push %edx
800613: 89 da mov %ebx,%edx
800615: 89 f0 mov %esi,%eax
800617: e8 45 fb ff ff call 800161 <printnum>
break;
80061c: 83 c4 20 add $0x20,%esp
err = va_arg(ap, int);
80061f: 8b 7d e4 mov -0x1c(%ebp),%edi
while ((ch = *(unsigned char *) fmt++) != '%') { //先将非格式化字符输出到控制台。
800622: 83 c7 01 add $0x1,%edi
800625: 0f b6 47 ff movzbl -0x1(%edi),%eax
800629: 83 f8 25 cmp $0x25,%eax
80062c: 0f 84 2f fc ff ff je 800261 <vprintfmt+0x17>
if (ch == '\0') //如果没有格式化字符直接返回
800632: 85 c0 test %eax,%eax
800634: 0f 84 8b 00 00 00 je 8006c5 <vprintfmt+0x47b>
putch(ch, putdat);
80063a: 83 ec 08 sub $0x8,%esp
80063d: 53 push %ebx
80063e: 50 push %eax
80063f: ff d6 call *%esi
800641: 83 c4 10 add $0x10,%esp
800644: eb dc jmp 800622 <vprintfmt+0x3d8>
if (lflag >= 2)
800646: 83 f9 01 cmp $0x1,%ecx
800649: 7e 15 jle 800660 <vprintfmt+0x416>
return va_arg(*ap, unsigned long long);
80064b: 8b 45 14 mov 0x14(%ebp),%eax
80064e: 8b 10 mov (%eax),%edx
800650: 8b 48 04 mov 0x4(%eax),%ecx
800653: 8d 40 08 lea 0x8(%eax),%eax
800656: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
800659: b8 10 00 00 00 mov $0x10,%eax
80065e: eb a5 jmp 800605 <vprintfmt+0x3bb>
else if (lflag)
800660: 85 c9 test %ecx,%ecx
800662: 75 17 jne 80067b <vprintfmt+0x431>
return va_arg(*ap, unsigned int);
800664: 8b 45 14 mov 0x14(%ebp),%eax
800667: 8b 10 mov (%eax),%edx
800669: b9 00 00 00 00 mov $0x0,%ecx
80066e: 8d 40 04 lea 0x4(%eax),%eax
800671: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
800674: b8 10 00 00 00 mov $0x10,%eax
800679: eb 8a jmp 800605 <vprintfmt+0x3bb>
return va_arg(*ap, unsigned long);
80067b: 8b 45 14 mov 0x14(%ebp),%eax
80067e: 8b 10 mov (%eax),%edx
800680: b9 00 00 00 00 mov $0x0,%ecx
800685: 8d 40 04 lea 0x4(%eax),%eax
800688: 89 45 14 mov %eax,0x14(%ebp)
base = 16;
80068b: b8 10 00 00 00 mov $0x10,%eax
800690: e9 70 ff ff ff jmp 800605 <vprintfmt+0x3bb>
putch(ch, putdat);
800695: 83 ec 08 sub $0x8,%esp
800698: 53 push %ebx
800699: 6a 25 push $0x25
80069b: ff d6 call *%esi
break;
80069d: 83 c4 10 add $0x10,%esp
8006a0: e9 7a ff ff ff jmp 80061f <vprintfmt+0x3d5>
putch('%', putdat);
8006a5: 83 ec 08 sub $0x8,%esp
8006a8: 53 push %ebx
8006a9: 6a 25 push $0x25
8006ab: ff d6 call *%esi
for (fmt--; fmt[-1] != '%'; fmt--)
8006ad: 83 c4 10 add $0x10,%esp
8006b0: 89 f8 mov %edi,%eax
8006b2: eb 03 jmp 8006b7 <vprintfmt+0x46d>
8006b4: 83 e8 01 sub $0x1,%eax
8006b7: 80 78 ff 25 cmpb $0x25,-0x1(%eax)
8006bb: 75 f7 jne 8006b4 <vprintfmt+0x46a>
8006bd: 89 45 e4 mov %eax,-0x1c(%ebp)
8006c0: e9 5a ff ff ff jmp 80061f <vprintfmt+0x3d5>
}
8006c5: 8d 65 f4 lea -0xc(%ebp),%esp
8006c8: 5b pop %ebx
8006c9: 5e pop %esi
8006ca: 5f pop %edi
8006cb: 5d pop %ebp
8006cc: c3 ret
008006cd <vsnprintf>:
int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
8006cd: 55 push %ebp
8006ce: 89 e5 mov %esp,%ebp
8006d0: 83 ec 18 sub $0x18,%esp
8006d3: 8b 45 08 mov 0x8(%ebp),%eax
8006d6: 8b 55 0c mov 0xc(%ebp),%edx
struct sprintbuf b = {buf, buf+n-1, 0};
8006d9: 89 45 ec mov %eax,-0x14(%ebp)
8006dc: 8d 4c 10 ff lea -0x1(%eax,%edx,1),%ecx
8006e0: 89 4d f0 mov %ecx,-0x10(%ebp)
8006e3: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
if (buf == NULL || n < 1)
8006ea: 85 c0 test %eax,%eax
8006ec: 74 26 je 800714 <vsnprintf+0x47>
8006ee: 85 d2 test %edx,%edx
8006f0: 7e 22 jle 800714 <vsnprintf+0x47>
return -E_INVAL;
// print the string to the buffer
vprintfmt((void*)sprintputch, &b, fmt, ap);
8006f2: ff 75 14 pushl 0x14(%ebp)
8006f5: ff 75 10 pushl 0x10(%ebp)
8006f8: 8d 45 ec lea -0x14(%ebp),%eax
8006fb: 50 push %eax
8006fc: 68 10 02 80 00 push $0x800210
800701: e8 44 fb ff ff call 80024a <vprintfmt>
// null terminate the buffer
*b.buf = '\0';
800706: 8b 45 ec mov -0x14(%ebp),%eax
800709: c6 00 00 movb $0x0,(%eax)
return b.cnt;
80070c: 8b 45 f4 mov -0xc(%ebp),%eax
80070f: 83 c4 10 add $0x10,%esp
}
800712: c9 leave
800713: c3 ret
return -E_INVAL;
800714: b8 fd ff ff ff mov $0xfffffffd,%eax
800719: eb f7 jmp 800712 <vsnprintf+0x45>
0080071b <snprintf>:
int
snprintf(char *buf, int n, const char *fmt, ...)
{
80071b: 55 push %ebp
80071c: 89 e5 mov %esp,%ebp
80071e: 83 ec 08 sub $0x8,%esp
va_list ap;
int rc;
va_start(ap, fmt);
800721: 8d 45 14 lea 0x14(%ebp),%eax
rc = vsnprintf(buf, n, fmt, ap);
800724: 50 push %eax
800725: ff 75 10 pushl 0x10(%ebp)
800728: ff 75 0c pushl 0xc(%ebp)
80072b: ff 75 08 pushl 0x8(%ebp)
80072e: e8 9a ff ff ff call 8006cd <vsnprintf>
va_end(ap);
return rc;
}
800733: c9 leave
800734: c3 ret
00800735 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1
int
strlen(const char *s)
{
800735: 55 push %ebp
800736: 89 e5 mov %esp,%ebp
800738: 8b 55 08 mov 0x8(%ebp),%edx
int n;
for (n = 0; *s != '\0'; s++)
80073b: b8 00 00 00 00 mov $0x0,%eax
800740: eb 03 jmp 800745 <strlen+0x10>
n++;
800742: 83 c0 01 add $0x1,%eax
for (n = 0; *s != '\0'; s++)
800745: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1)
800749: 75 f7 jne 800742 <strlen+0xd>
return n;
}
80074b: 5d pop %ebp
80074c: c3 ret
0080074d <strnlen>:
int
strnlen(const char *s, size_t size)
{
80074d: 55 push %ebp
80074e: 89 e5 mov %esp,%ebp
800750: 8b 4d 08 mov 0x8(%ebp),%ecx
800753: 8b 55 0c mov 0xc(%ebp),%edx
int n;
for (n = 0; size > 0 && *s != '\0'; s++, size--)
800756: b8 00 00 00 00 mov $0x0,%eax
80075b: eb 03 jmp 800760 <strnlen+0x13>
n++;
80075d: 83 c0 01 add $0x1,%eax
for (n = 0; size > 0 && *s != '\0'; s++, size--)
800760: 39 d0 cmp %edx,%eax
800762: 74 06 je 80076a <strnlen+0x1d>
800764: 80 3c 01 00 cmpb $0x0,(%ecx,%eax,1)
800768: 75 f3 jne 80075d <strnlen+0x10>
return n;
}
80076a: 5d pop %ebp
80076b: c3 ret
0080076c <strcpy>:
char *
strcpy(char *dst, const char *src)
{
80076c: 55 push %ebp
80076d: 89 e5 mov %esp,%ebp
80076f: 53 push %ebx
800770: 8b 45 08 mov 0x8(%ebp),%eax
800773: 8b 4d 0c mov 0xc(%ebp),%ecx
char *ret;
ret = dst;
while ((*dst++ = *src++) != '\0')
800776: 89 c2 mov %eax,%edx
800778: 83 c1 01 add $0x1,%ecx
80077b: 83 c2 01 add $0x1,%edx
80077e: 0f b6 59 ff movzbl -0x1(%ecx),%ebx
800782: 88 5a ff mov %bl,-0x1(%edx)
800785: 84 db test %bl,%bl
800787: 75 ef jne 800778 <strcpy+0xc>
/* do nothing */;
return ret;
}
800789: 5b pop %ebx
80078a: 5d pop %ebp
80078b: c3 ret
0080078c <strcat>:
char *
strcat(char *dst, const char *src)
{
80078c: 55 push %ebp
80078d: 89 e5 mov %esp,%ebp
80078f: 53 push %ebx
800790: 8b 5d 08 mov 0x8(%ebp),%ebx
int len = strlen(dst);
800793: 53 push %ebx
800794: e8 9c ff ff ff call 800735 <strlen>
800799: 83 c4 04 add $0x4,%esp
strcpy(dst + len, src);
80079c: ff 75 0c pushl 0xc(%ebp)
80079f: 01 d8 add %ebx,%eax
8007a1: 50 push %eax
8007a2: e8 c5 ff ff ff call 80076c <strcpy>
return dst;
}
8007a7: 89 d8 mov %ebx,%eax
8007a9: 8b 5d fc mov -0x4(%ebp),%ebx
8007ac: c9 leave
8007ad: c3 ret
008007ae <strncpy>:
char *
strncpy(char *dst, const char *src, size_t size) {
8007ae: 55 push %ebp
8007af: 89 e5 mov %esp,%ebp
8007b1: 56 push %esi
8007b2: 53 push %ebx
8007b3: 8b 75 08 mov 0x8(%ebp),%esi
8007b6: 8b 4d 0c mov 0xc(%ebp),%ecx
8007b9: 89 f3 mov %esi,%ebx
8007bb: 03 5d 10 add 0x10(%ebp),%ebx
size_t i;
char *ret;
ret = dst;
for (i = 0; i < size; i++) {
8007be: 89 f2 mov %esi,%edx
8007c0: eb 0f jmp 8007d1 <strncpy+0x23>
*dst++ = *src;
8007c2: 83 c2 01 add $0x1,%edx
8007c5: 0f b6 01 movzbl (%ecx),%eax
8007c8: 88 42 ff mov %al,-0x1(%edx)
// If strlen(src) < size, null-pad 'dst' out to 'size' chars
if (*src != '\0')
src++;
8007cb: 80 39 01 cmpb $0x1,(%ecx)
8007ce: 83 d9 ff sbb $0xffffffff,%ecx
for (i = 0; i < size; i++) {
8007d1: 39 da cmp %ebx,%edx
8007d3: 75 ed jne 8007c2 <strncpy+0x14>
}
return ret;
}
8007d5: 89 f0 mov %esi,%eax
8007d7: 5b pop %ebx
8007d8: 5e pop %esi
8007d9: 5d pop %ebp
8007da: c3 ret
008007db <strlcpy>:
size_t
strlcpy(char *dst, const char *src, size_t size)
{
8007db: 55 push %ebp
8007dc: 89 e5 mov %esp,%ebp
8007de: 56 push %esi
8007df: 53 push %ebx
8007e0: 8b 75 08 mov 0x8(%ebp),%esi
8007e3: 8b 55 0c mov 0xc(%ebp),%edx
8007e6: 8b 4d 10 mov 0x10(%ebp),%ecx
8007e9: 89 f0 mov %esi,%eax
8007eb: 8d 5c 0e ff lea -0x1(%esi,%ecx,1),%ebx
char *dst_in;
dst_in = dst;
if (size > 0) {
8007ef: 85 c9 test %ecx,%ecx
8007f1: 75 0b jne 8007fe <strlcpy+0x23>
8007f3: eb 17 jmp 80080c <strlcpy+0x31>
while (--size > 0 && *src != '\0')
*dst++ = *src++;
8007f5: 83 c2 01 add $0x1,%edx
8007f8: 83 c0 01 add $0x1,%eax
8007fb: 88 48 ff mov %cl,-0x1(%eax)
while (--size > 0 && *src != '\0')
8007fe: 39 d8 cmp %ebx,%eax
800800: 74 07 je 800809 <strlcpy+0x2e>
800802: 0f b6 0a movzbl (%edx),%ecx
800805: 84 c9 test %cl,%cl
800807: 75 ec jne 8007f5 <strlcpy+0x1a>
*dst = '\0';
800809: c6 00 00 movb $0x0,(%eax)
}
return dst - dst_in;
80080c: 29 f0 sub %esi,%eax
}
80080e: 5b pop %ebx
80080f: 5e pop %esi
800810: 5d pop %ebp
800811: c3 ret
00800812 <strcmp>:
int
strcmp(const char *p, const char *q)
{
800812: 55 push %ebp
800813: 89 e5 mov %esp,%ebp
800815: 8b 4d 08 mov 0x8(%ebp),%ecx
800818: 8b 55 0c mov 0xc(%ebp),%edx
while (*p && *p == *q)
80081b: eb 06 jmp 800823 <strcmp+0x11>
p++, q++;
80081d: 83 c1 01 add $0x1,%ecx
800820: 83 c2 01 add $0x1,%edx
while (*p && *p == *q)
800823: 0f b6 01 movzbl (%ecx),%eax
800826: 84 c0 test %al,%al
800828: 74 04 je 80082e <strcmp+0x1c>
80082a: 3a 02 cmp (%edx),%al
80082c: 74 ef je 80081d <strcmp+0xb>
return (int) ((unsigned char) *p - (unsigned char) *q);
80082e: 0f b6 c0 movzbl %al,%eax
800831: 0f b6 12 movzbl (%edx),%edx
800834: 29 d0 sub %edx,%eax
}
800836: 5d pop %ebp
800837: c3 ret
00800838 <strncmp>:
int
strncmp(const char *p, const char *q, size_t n)
{
800838: 55 push %ebp
800839: 89 e5 mov %esp,%ebp
80083b: 53 push %ebx
80083c: 8b 45 08 mov 0x8(%ebp),%eax
80083f: 8b 55 0c mov 0xc(%ebp),%edx
800842: 89 c3 mov %eax,%ebx
800844: 03 5d 10 add 0x10(%ebp),%ebx
while (n > 0 && *p && *p == *q)
800847: eb 06 jmp 80084f <strncmp+0x17>
n--, p++, q++;
800849: 83 c0 01 add $0x1,%eax
80084c: 83 c2 01 add $0x1,%edx
while (n > 0 && *p && *p == *q)
80084f: 39 d8 cmp %ebx,%eax
800851: 74 16 je 800869 <strncmp+0x31>
800853: 0f b6 08 movzbl (%eax),%ecx
800856: 84 c9 test %cl,%cl
800858: 74 04 je 80085e <strncmp+0x26>
80085a: 3a 0a cmp (%edx),%cl
80085c: 74 eb je 800849 <strncmp+0x11>
if (n == 0)
return 0;
else
return (int) ((unsigned char) *p - (unsigned char) *q);
80085e: 0f b6 00 movzbl (%eax),%eax
800861: 0f b6 12 movzbl (%edx),%edx
800864: 29 d0 sub %edx,%eax
}
800866: 5b pop %ebx
800867: 5d pop %ebp
800868: c3 ret
return 0;
800869: b8 00 00 00 00 mov $0x0,%eax
80086e: eb f6 jmp 800866 <strncmp+0x2e>
00800870 <strchr>:
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
800870: 55 push %ebp
800871: 89 e5 mov %esp,%ebp
800873: 8b 45 08 mov 0x8(%ebp),%eax
800876: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for (; *s; s++)
80087a: 0f b6 10 movzbl (%eax),%edx
80087d: 84 d2 test %dl,%dl
80087f: 74 09 je 80088a <strchr+0x1a>
if (*s == c)
800881: 38 ca cmp %cl,%dl
800883: 74 0a je 80088f <strchr+0x1f>
for (; *s; s++)
800885: 83 c0 01 add $0x1,%eax
800888: eb f0 jmp 80087a <strchr+0xa>
return (char *) s;
return 0;
80088a: b8 00 00 00 00 mov $0x0,%eax
}
80088f: 5d pop %ebp
800890: c3 ret
00800891 <strfind>:
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
800891: 55 push %ebp
800892: 89 e5 mov %esp,%ebp
800894: 8b 45 08 mov 0x8(%ebp),%eax
800897: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for (; *s; s++)
80089b: eb 03 jmp 8008a0 <strfind+0xf>
80089d: 83 c0 01 add $0x1,%eax
8008a0: 0f b6 10 movzbl (%eax),%edx
if (*s == c)
8008a3: 38 ca cmp %cl,%dl
8008a5: 74 04 je 8008ab <strfind+0x1a>
8008a7: 84 d2 test %dl,%dl
8008a9: 75 f2 jne 80089d <strfind+0xc>
break;
return (char *) s;
}
8008ab: 5d pop %ebp
8008ac: c3 ret
008008ad <memset>:
#if ASM
void *
memset(void *v, int c, size_t n)
{
8008ad: 55 push %ebp
8008ae: 89 e5 mov %esp,%ebp
8008b0: 57 push %edi
8008b1: 56 push %esi
8008b2: 53 push %ebx
8008b3: 8b 7d 08 mov 0x8(%ebp),%edi
8008b6: 8b 4d 10 mov 0x10(%ebp),%ecx
char *p;
if (n == 0)
8008b9: 85 c9 test %ecx,%ecx
8008bb: 74 13 je 8008d0 <memset+0x23>
return v;
if ((int)v%4 == 0 && n%4 == 0) {
8008bd: f7 c7 03 00 00 00 test $0x3,%edi
8008c3: 75 05 jne 8008ca <memset+0x1d>
8008c5: f6 c1 03 test $0x3,%cl
8008c8: 74 0d je 8008d7 <memset+0x2a>
c = (c<<24)|(c<<16)|(c<<8)|c;
asm volatile("cld; rep stosl\n"
:: "D" (v), "a" (c), "c" (n/4)
: "cc", "memory");
} else
asm volatile("cld; rep stosb\n"
8008ca: 8b 45 0c mov 0xc(%ebp),%eax
8008cd: fc cld
8008ce: f3 aa rep stos %al,%es:(%edi)
:: "D" (v), "a" (c), "c" (n)
: "cc", "memory");
return v;
}
8008d0: 89 f8 mov %edi,%eax
8008d2: 5b pop %ebx
8008d3: 5e pop %esi
8008d4: 5f pop %edi
8008d5: 5d pop %ebp
8008d6: c3 ret
c &= 0xFF;
8008d7: 0f b6 55 0c movzbl 0xc(%ebp),%edx
c = (c<<24)|(c<<16)|(c<<8)|c;
8008db: 89 d3 mov %edx,%ebx
8008dd: c1 e3 08 shl $0x8,%ebx
8008e0: 89 d0 mov %edx,%eax
8008e2: c1 e0 18 shl $0x18,%eax
8008e5: 89 d6 mov %edx,%esi
8008e7: c1 e6 10 shl $0x10,%esi
8008ea: 09 f0 or %esi,%eax
8008ec: 09 c2 or %eax,%edx
8008ee: 09 da or %ebx,%edx
:: "D" (v), "a" (c), "c" (n/4)
8008f0: c1 e9 02 shr $0x2,%ecx
asm volatile("cld; rep stosl\n"
8008f3: 89 d0 mov %edx,%eax
8008f5: fc cld
8008f6: f3 ab rep stos %eax,%es:(%edi)
8008f8: eb d6 jmp 8008d0 <memset+0x23>
008008fa <memmove>:
void *
memmove(void *dst, const void *src, size_t n)
{
8008fa: 55 push %ebp
8008fb: 89 e5 mov %esp,%ebp
8008fd: 57 push %edi
8008fe: 56 push %esi
8008ff: 8b 45 08 mov 0x8(%ebp),%eax
800902: 8b 75 0c mov 0xc(%ebp),%esi
800905: 8b 4d 10 mov 0x10(%ebp),%ecx
const char *s;
char *d;
s = src;
d = dst;
if (s < d && s + n > d) {
800908: 39 c6 cmp %eax,%esi
80090a: 73 35 jae 800941 <memmove+0x47>
80090c: 8d 14 0e lea (%esi,%ecx,1),%edx
80090f: 39 c2 cmp %eax,%edx
800911: 76 2e jbe 800941 <memmove+0x47>
s += n;
d += n;
800913: 8d 3c 08 lea (%eax,%ecx,1),%edi
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
800916: 89 d6 mov %edx,%esi
800918: 09 fe or %edi,%esi
80091a: f7 c6 03 00 00 00 test $0x3,%esi
800920: 74 0c je 80092e <memmove+0x34>
asm volatile("std; rep movsl\n"
:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
else
asm volatile("std; rep movsb\n"
:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
800922: 83 ef 01 sub $0x1,%edi
800925: 8d 72 ff lea -0x1(%edx),%esi
asm volatile("std; rep movsb\n"
800928: fd std
800929: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
// Some versions of GCC rely on DF being clear
asm volatile("cld" ::: "cc");
80092b: fc cld
80092c: eb 21 jmp 80094f <memmove+0x55>
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
80092e: f6 c1 03 test $0x3,%cl
800931: 75 ef jne 800922 <memmove+0x28>
:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
800933: 83 ef 04 sub $0x4,%edi
800936: 8d 72 fc lea -0x4(%edx),%esi
800939: c1 e9 02 shr $0x2,%ecx
asm volatile("std; rep movsl\n"
80093c: fd std
80093d: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
80093f: eb ea jmp 80092b <memmove+0x31>
} else {
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
800941: 89 f2 mov %esi,%edx
800943: 09 c2 or %eax,%edx
800945: f6 c2 03 test $0x3,%dl
800948: 74 09 je 800953 <memmove+0x59>
asm volatile("cld; rep movsl\n"
:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
else
asm volatile("cld; rep movsb\n"
80094a: 89 c7 mov %eax,%edi
80094c: fc cld
80094d: f3 a4 rep movsb %ds:(%esi),%es:(%edi)
:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
}
return dst;
}
80094f: 5e pop %esi
800950: 5f pop %edi
800951: 5d pop %ebp
800952: c3 ret
if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
800953: f6 c1 03 test $0x3,%cl
800956: 75 f2 jne 80094a <memmove+0x50>
:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
800958: c1 e9 02 shr $0x2,%ecx
asm volatile("cld; rep movsl\n"
80095b: 89 c7 mov %eax,%edi
80095d: fc cld
80095e: f3 a5 rep movsl %ds:(%esi),%es:(%edi)
800960: eb ed jmp 80094f <memmove+0x55>
00800962 <memcpy>:
}
#endif
void *
memcpy(void *dst, const void *src, size_t n)
{
800962: 55 push %ebp
800963: 89 e5 mov %esp,%ebp
return memmove(dst, src, n);
800965: ff 75 10 pushl 0x10(%ebp)
800968: ff 75 0c pushl 0xc(%ebp)
80096b: ff 75 08 pushl 0x8(%ebp)
80096e: e8 87 ff ff ff call 8008fa <memmove>
}
800973: c9 leave
800974: c3 ret
00800975 <memcmp>:
int
memcmp(const void *v1, const void *v2, size_t n)
{
800975: 55 push %ebp
800976: 89 e5 mov %esp,%ebp
800978: 56 push %esi
800979: 53 push %ebx
80097a: 8b 45 08 mov 0x8(%ebp),%eax
80097d: 8b 55 0c mov 0xc(%ebp),%edx
800980: 89 c6 mov %eax,%esi
800982: 03 75 10 add 0x10(%ebp),%esi
const uint8_t *s1 = (const uint8_t *) v1;
const uint8_t *s2 = (const uint8_t *) v2;
while (n-- > 0) {
800985: 39 f0 cmp %esi,%eax
800987: 74 1c je 8009a5 <memcmp+0x30>
if (*s1 != *s2)
800989: 0f b6 08 movzbl (%eax),%ecx
80098c: 0f b6 1a movzbl (%edx),%ebx
80098f: 38 d9 cmp %bl,%cl
800991: 75 08 jne 80099b <memcmp+0x26>
return (int) *s1 - (int) *s2;
s1++, s2++;
800993: 83 c0 01 add $0x1,%eax
800996: 83 c2 01 add $0x1,%edx
800999: eb ea jmp 800985 <memcmp+0x10>
return (int) *s1 - (int) *s2;
80099b: 0f b6 c1 movzbl %cl,%eax
80099e: 0f b6 db movzbl %bl,%ebx
8009a1: 29 d8 sub %ebx,%eax
8009a3: eb 05 jmp 8009aa <memcmp+0x35>
}
return 0;
8009a5: b8 00 00 00 00 mov $0x0,%eax
}
8009aa: 5b pop %ebx
8009ab: 5e pop %esi
8009ac: 5d pop %ebp
8009ad: c3 ret
008009ae <memfind>:
void *
memfind(const void *s, int c, size_t n)
{
8009ae: 55 push %ebp
8009af: 89 e5 mov %esp,%ebp
8009b1: 8b 45 08 mov 0x8(%ebp),%eax
8009b4: 8b 4d 0c mov 0xc(%ebp),%ecx
const void *ends = (const char *) s + n;
8009b7: 89 c2 mov %eax,%edx
8009b9: 03 55 10 add 0x10(%ebp),%edx
for (; s < ends; s++)
8009bc: 39 d0 cmp %edx,%eax
8009be: 73 09 jae 8009c9 <memfind+0x1b>
if (*(const unsigned char *) s == (unsigned char) c)
8009c0: 38 08 cmp %cl,(%eax)
8009c2: 74 05 je 8009c9 <memfind+0x1b>
for (; s < ends; s++)
8009c4: 83 c0 01 add $0x1,%eax
8009c7: eb f3 jmp 8009bc <memfind+0xe>
break;
return (void *) s;
}
8009c9: 5d pop %ebp
8009ca: c3 ret
008009cb <strtol>:
long
strtol(const char *s, char **endptr, int base)
{
8009cb: 55 push %ebp
8009cc: 89 e5 mov %esp,%ebp
8009ce: 57 push %edi
8009cf: 56 push %esi
8009d0: 53 push %ebx
8009d1: 8b 4d 08 mov 0x8(%ebp),%ecx
8009d4: 8b 5d 10 mov 0x10(%ebp),%ebx
int neg = 0;
long val = 0;
// gobble initial whitespace
while (*s == ' ' || *s == '\t')
8009d7: eb 03 jmp 8009dc <strtol+0x11>
s++;
8009d9: 83 c1 01 add $0x1,%ecx
while (*s == ' ' || *s == '\t')
8009dc: 0f b6 01 movzbl (%ecx),%eax
8009df: 3c 20 cmp $0x20,%al
8009e1: 74 f6 je 8009d9 <strtol+0xe>
8009e3: 3c 09 cmp $0x9,%al
8009e5: 74 f2 je 8009d9 <strtol+0xe>
// plus/minus sign
if (*s == '+')
8009e7: 3c 2b cmp $0x2b,%al
8009e9: 74 2e je 800a19 <strtol+0x4e>
int neg = 0;
8009eb: bf 00 00 00 00 mov $0x0,%edi
s++;
else if (*s == '-')
8009f0: 3c 2d cmp $0x2d,%al
8009f2: 74 2f je 800a23 <strtol+0x58>
s++, neg = 1;
// hex or octal base prefix
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
8009f4: f7 c3 ef ff ff ff test $0xffffffef,%ebx
8009fa: 75 05 jne 800a01 <strtol+0x36>
8009fc: 80 39 30 cmpb $0x30,(%ecx)
8009ff: 74 2c je 800a2d <strtol+0x62>
s += 2, base = 16;
else if (base == 0 && s[0] == '0')
800a01: 85 db test %ebx,%ebx
800a03: 75 0a jne 800a0f <strtol+0x44>
s++, base = 8;
else if (base == 0)
base = 10;
800a05: bb 0a 00 00 00 mov $0xa,%ebx
else if (base == 0 && s[0] == '0')
800a0a: 80 39 30 cmpb $0x30,(%ecx)
800a0d: 74 28 je 800a37 <strtol+0x6c>
base = 10;
800a0f: b8 00 00 00 00 mov $0x0,%eax
800a14: 89 5d 10 mov %ebx,0x10(%ebp)
800a17: eb 50 jmp 800a69 <strtol+0x9e>
s++;
800a19: 83 c1 01 add $0x1,%ecx
int neg = 0;
800a1c: bf 00 00 00 00 mov $0x0,%edi
800a21: eb d1 jmp 8009f4 <strtol+0x29>
s++, neg = 1;
800a23: 83 c1 01 add $0x1,%ecx
800a26: bf 01 00 00 00 mov $0x1,%edi
800a2b: eb c7 jmp 8009f4 <strtol+0x29>
if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
800a2d: 80 79 01 78 cmpb $0x78,0x1(%ecx)
800a31: 74 0e je 800a41 <strtol+0x76>
else if (base == 0 && s[0] == '0')
800a33: 85 db test %ebx,%ebx
800a35: 75 d8 jne 800a0f <strtol+0x44>
s++, base = 8;
800a37: 83 c1 01 add $0x1,%ecx
800a3a: bb 08 00 00 00 mov $0x8,%ebx
800a3f: eb ce jmp 800a0f <strtol+0x44>
s += 2, base = 16;
800a41: 83 c1 02 add $0x2,%ecx
800a44: bb 10 00 00 00 mov $0x10,%ebx
800a49: eb c4 jmp 800a0f <strtol+0x44>
while (1) {
int dig;
if (*s >= '0' && *s <= '9')
dig = *s - '0';
else if (*s >= 'a' && *s <= 'z')
800a4b: 8d 72 9f lea -0x61(%edx),%esi
800a4e: 89 f3 mov %esi,%ebx
800a50: 80 fb 19 cmp $0x19,%bl
800a53: 77 29 ja 800a7e <strtol+0xb3>
dig = *s - 'a' + 10;
800a55: 0f be d2 movsbl %dl,%edx
800a58: 83 ea 57 sub $0x57,%edx
else if (*s >= 'A' && *s <= 'Z')
dig = *s - 'A' + 10;
else
break;
if (dig >= base)
800a5b: 3b 55 10 cmp 0x10(%ebp),%edx
800a5e: 7d 30 jge 800a90 <strtol+0xc5>
break;
s++, val = (val * base) + dig;
800a60: 83 c1 01 add $0x1,%ecx
800a63: 0f af 45 10 imul 0x10(%ebp),%eax
800a67: 01 d0 add %edx,%eax
if (*s >= '0' && *s <= '9')
800a69: 0f b6 11 movzbl (%ecx),%edx
800a6c: 8d 72 d0 lea -0x30(%edx),%esi
800a6f: 89 f3 mov %esi,%ebx
800a71: 80 fb 09 cmp $0x9,%bl
800a74: 77 d5 ja 800a4b <strtol+0x80>
dig = *s - '0';
800a76: 0f be d2 movsbl %dl,%edx
800a79: 83 ea 30 sub $0x30,%edx
800a7c: eb dd jmp 800a5b <strtol+0x90>
else if (*s >= 'A' && *s <= 'Z')
800a7e: 8d 72 bf lea -0x41(%edx),%esi
800a81: 89 f3 mov %esi,%ebx
800a83: 80 fb 19 cmp $0x19,%bl
800a86: 77 08 ja 800a90 <strtol+0xc5>
dig = *s - 'A' + 10;
800a88: 0f be d2 movsbl %dl,%edx
800a8b: 83 ea 37 sub $0x37,%edx
800a8e: eb cb jmp 800a5b <strtol+0x90>
// we don't properly detect overflow!
}
if (endptr)
800a90: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
800a94: 74 05 je 800a9b <strtol+0xd0>
*endptr = (char *) s;
800a96: 8b 75 0c mov 0xc(%ebp),%esi
800a99: 89 0e mov %ecx,(%esi)
return (neg ? -val : val);
800a9b: 89 c2 mov %eax,%edx
800a9d: f7 da neg %edx
800a9f: 85 ff test %edi,%edi
800aa1: 0f 45 c2 cmovne %edx,%eax
}
800aa4: 5b pop %ebx
800aa5: 5e pop %esi
800aa6: 5f pop %edi
800aa7: 5d pop %ebp
800aa8: c3 ret
00800aa9 <sys_cputs>:
return ret;
}
void
sys_cputs(const char *s, size_t len)
{
800aa9: 55 push %ebp
800aaa: 89 e5 mov %esp,%ebp
800aac: 57 push %edi
800aad: 56 push %esi
800aae: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800aaf: b8 00 00 00 00 mov $0x0,%eax
800ab4: 8b 55 08 mov 0x8(%ebp),%edx
800ab7: 8b 4d 0c mov 0xc(%ebp),%ecx
800aba: 89 c3 mov %eax,%ebx
800abc: 89 c7 mov %eax,%edi
800abe: 89 c6 mov %eax,%esi
800ac0: cd 30 int $0x30
syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
800ac2: 5b pop %ebx
800ac3: 5e pop %esi
800ac4: 5f pop %edi
800ac5: 5d pop %ebp
800ac6: c3 ret
00800ac7 <sys_cgetc>:
int
sys_cgetc(void)
{
800ac7: 55 push %ebp
800ac8: 89 e5 mov %esp,%ebp
800aca: 57 push %edi
800acb: 56 push %esi
800acc: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800acd: ba 00 00 00 00 mov $0x0,%edx
800ad2: b8 01 00 00 00 mov $0x1,%eax
800ad7: 89 d1 mov %edx,%ecx
800ad9: 89 d3 mov %edx,%ebx
800adb: 89 d7 mov %edx,%edi
800add: 89 d6 mov %edx,%esi
800adf: cd 30 int $0x30
return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
800ae1: 5b pop %ebx
800ae2: 5e pop %esi
800ae3: 5f pop %edi
800ae4: 5d pop %ebp
800ae5: c3 ret
00800ae6 <sys_env_destroy>:
int
sys_env_destroy(envid_t envid)
{
800ae6: 55 push %ebp
800ae7: 89 e5 mov %esp,%ebp
800ae9: 57 push %edi
800aea: 56 push %esi
800aeb: 53 push %ebx
800aec: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800aef: b9 00 00 00 00 mov $0x0,%ecx
800af4: 8b 55 08 mov 0x8(%ebp),%edx
800af7: b8 03 00 00 00 mov $0x3,%eax
800afc: 89 cb mov %ecx,%ebx
800afe: 89 cf mov %ecx,%edi
800b00: 89 ce mov %ecx,%esi
800b02: cd 30 int $0x30
if(check && ret > 0)
800b04: 85 c0 test %eax,%eax
800b06: 7f 08 jg 800b10 <sys_env_destroy+0x2a>
return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
800b08: 8d 65 f4 lea -0xc(%ebp),%esp
800b0b: 5b pop %ebx
800b0c: 5e pop %esi
800b0d: 5f pop %edi
800b0e: 5d pop %ebp
800b0f: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800b10: 83 ec 0c sub $0xc,%esp
800b13: 50 push %eax
800b14: 6a 03 push $0x3
800b16: 68 ff 12 80 00 push $0x8012ff
800b1b: 6a 23 push $0x23
800b1d: 68 1c 13 80 00 push $0x80131c
800b22: e8 2f 02 00 00 call 800d56 <_panic>
00800b27 <sys_getenvid>:
envid_t
sys_getenvid(void)
{
800b27: 55 push %ebp
800b28: 89 e5 mov %esp,%ebp
800b2a: 57 push %edi
800b2b: 56 push %esi
800b2c: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800b2d: ba 00 00 00 00 mov $0x0,%edx
800b32: b8 02 00 00 00 mov $0x2,%eax
800b37: 89 d1 mov %edx,%ecx
800b39: 89 d3 mov %edx,%ebx
800b3b: 89 d7 mov %edx,%edi
800b3d: 89 d6 mov %edx,%esi
800b3f: cd 30 int $0x30
return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
800b41: 5b pop %ebx
800b42: 5e pop %esi
800b43: 5f pop %edi
800b44: 5d pop %ebp
800b45: c3 ret
00800b46 <sys_yield>:
void
sys_yield(void)
{
800b46: 55 push %ebp
800b47: 89 e5 mov %esp,%ebp
800b49: 57 push %edi
800b4a: 56 push %esi
800b4b: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800b4c: ba 00 00 00 00 mov $0x0,%edx
800b51: b8 0b 00 00 00 mov $0xb,%eax
800b56: 89 d1 mov %edx,%ecx
800b58: 89 d3 mov %edx,%ebx
800b5a: 89 d7 mov %edx,%edi
800b5c: 89 d6 mov %edx,%esi
800b5e: cd 30 int $0x30
syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
800b60: 5b pop %ebx
800b61: 5e pop %esi
800b62: 5f pop %edi
800b63: 5d pop %ebp
800b64: c3 ret
00800b65 <sys_page_alloc>:
int
sys_page_alloc(envid_t envid, void *va, int perm)
{
800b65: 55 push %ebp
800b66: 89 e5 mov %esp,%ebp
800b68: 57 push %edi
800b69: 56 push %esi
800b6a: 53 push %ebx
800b6b: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800b6e: be 00 00 00 00 mov $0x0,%esi
800b73: 8b 55 08 mov 0x8(%ebp),%edx
800b76: 8b 4d 0c mov 0xc(%ebp),%ecx
800b79: b8 04 00 00 00 mov $0x4,%eax
800b7e: 8b 5d 10 mov 0x10(%ebp),%ebx
800b81: 89 f7 mov %esi,%edi
800b83: cd 30 int $0x30
if(check && ret > 0)
800b85: 85 c0 test %eax,%eax
800b87: 7f 08 jg 800b91 <sys_page_alloc+0x2c>
return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
800b89: 8d 65 f4 lea -0xc(%ebp),%esp
800b8c: 5b pop %ebx
800b8d: 5e pop %esi
800b8e: 5f pop %edi
800b8f: 5d pop %ebp
800b90: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800b91: 83 ec 0c sub $0xc,%esp
800b94: 50 push %eax
800b95: 6a 04 push $0x4
800b97: 68 ff 12 80 00 push $0x8012ff
800b9c: 6a 23 push $0x23
800b9e: 68 1c 13 80 00 push $0x80131c
800ba3: e8 ae 01 00 00 call 800d56 <_panic>
00800ba8 <sys_page_map>:
int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
800ba8: 55 push %ebp
800ba9: 89 e5 mov %esp,%ebp
800bab: 57 push %edi
800bac: 56 push %esi
800bad: 53 push %ebx
800bae: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800bb1: 8b 55 08 mov 0x8(%ebp),%edx
800bb4: 8b 4d 0c mov 0xc(%ebp),%ecx
800bb7: b8 05 00 00 00 mov $0x5,%eax
800bbc: 8b 5d 10 mov 0x10(%ebp),%ebx
800bbf: 8b 7d 14 mov 0x14(%ebp),%edi
800bc2: 8b 75 18 mov 0x18(%ebp),%esi
800bc5: cd 30 int $0x30
if(check && ret > 0)
800bc7: 85 c0 test %eax,%eax
800bc9: 7f 08 jg 800bd3 <sys_page_map+0x2b>
return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
800bcb: 8d 65 f4 lea -0xc(%ebp),%esp
800bce: 5b pop %ebx
800bcf: 5e pop %esi
800bd0: 5f pop %edi
800bd1: 5d pop %ebp
800bd2: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800bd3: 83 ec 0c sub $0xc,%esp
800bd6: 50 push %eax
800bd7: 6a 05 push $0x5
800bd9: 68 ff 12 80 00 push $0x8012ff
800bde: 6a 23 push $0x23
800be0: 68 1c 13 80 00 push $0x80131c
800be5: e8 6c 01 00 00 call 800d56 <_panic>
00800bea <sys_page_unmap>:
int
sys_page_unmap(envid_t envid, void *va)
{
800bea: 55 push %ebp
800beb: 89 e5 mov %esp,%ebp
800bed: 57 push %edi
800bee: 56 push %esi
800bef: 53 push %ebx
800bf0: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800bf3: bb 00 00 00 00 mov $0x0,%ebx
800bf8: 8b 55 08 mov 0x8(%ebp),%edx
800bfb: 8b 4d 0c mov 0xc(%ebp),%ecx
800bfe: b8 06 00 00 00 mov $0x6,%eax
800c03: 89 df mov %ebx,%edi
800c05: 89 de mov %ebx,%esi
800c07: cd 30 int $0x30
if(check && ret > 0)
800c09: 85 c0 test %eax,%eax
800c0b: 7f 08 jg 800c15 <sys_page_unmap+0x2b>
return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
800c0d: 8d 65 f4 lea -0xc(%ebp),%esp
800c10: 5b pop %ebx
800c11: 5e pop %esi
800c12: 5f pop %edi
800c13: 5d pop %ebp
800c14: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800c15: 83 ec 0c sub $0xc,%esp
800c18: 50 push %eax
800c19: 6a 06 push $0x6
800c1b: 68 ff 12 80 00 push $0x8012ff
800c20: 6a 23 push $0x23
800c22: 68 1c 13 80 00 push $0x80131c
800c27: e8 2a 01 00 00 call 800d56 <_panic>
00800c2c <sys_env_set_status>:
// sys_exofork is inlined in lib.h
int
sys_env_set_status(envid_t envid, int status)
{
800c2c: 55 push %ebp
800c2d: 89 e5 mov %esp,%ebp
800c2f: 57 push %edi
800c30: 56 push %esi
800c31: 53 push %ebx
800c32: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800c35: bb 00 00 00 00 mov $0x0,%ebx
800c3a: 8b 55 08 mov 0x8(%ebp),%edx
800c3d: 8b 4d 0c mov 0xc(%ebp),%ecx
800c40: b8 08 00 00 00 mov $0x8,%eax
800c45: 89 df mov %ebx,%edi
800c47: 89 de mov %ebx,%esi
800c49: cd 30 int $0x30
if(check && ret > 0)
800c4b: 85 c0 test %eax,%eax
800c4d: 7f 08 jg 800c57 <sys_env_set_status+0x2b>
return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
800c4f: 8d 65 f4 lea -0xc(%ebp),%esp
800c52: 5b pop %ebx
800c53: 5e pop %esi
800c54: 5f pop %edi
800c55: 5d pop %ebp
800c56: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800c57: 83 ec 0c sub $0xc,%esp
800c5a: 50 push %eax
800c5b: 6a 08 push $0x8
800c5d: 68 ff 12 80 00 push $0x8012ff
800c62: 6a 23 push $0x23
800c64: 68 1c 13 80 00 push $0x80131c
800c69: e8 e8 00 00 00 call 800d56 <_panic>
00800c6e <sys_env_set_trapframe>:
int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
800c6e: 55 push %ebp
800c6f: 89 e5 mov %esp,%ebp
800c71: 57 push %edi
800c72: 56 push %esi
800c73: 53 push %ebx
800c74: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800c77: bb 00 00 00 00 mov $0x0,%ebx
800c7c: 8b 55 08 mov 0x8(%ebp),%edx
800c7f: 8b 4d 0c mov 0xc(%ebp),%ecx
800c82: b8 09 00 00 00 mov $0x9,%eax
800c87: 89 df mov %ebx,%edi
800c89: 89 de mov %ebx,%esi
800c8b: cd 30 int $0x30
if(check && ret > 0)
800c8d: 85 c0 test %eax,%eax
800c8f: 7f 08 jg 800c99 <sys_env_set_trapframe+0x2b>
return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
800c91: 8d 65 f4 lea -0xc(%ebp),%esp
800c94: 5b pop %ebx
800c95: 5e pop %esi
800c96: 5f pop %edi
800c97: 5d pop %ebp
800c98: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800c99: 83 ec 0c sub $0xc,%esp
800c9c: 50 push %eax
800c9d: 6a 09 push $0x9
800c9f: 68 ff 12 80 00 push $0x8012ff
800ca4: 6a 23 push $0x23
800ca6: 68 1c 13 80 00 push $0x80131c
800cab: e8 a6 00 00 00 call 800d56 <_panic>
00800cb0 <sys_env_set_pgfault_upcall>:
int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
800cb0: 55 push %ebp
800cb1: 89 e5 mov %esp,%ebp
800cb3: 57 push %edi
800cb4: 56 push %esi
800cb5: 53 push %ebx
800cb6: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800cb9: bb 00 00 00 00 mov $0x0,%ebx
800cbe: 8b 55 08 mov 0x8(%ebp),%edx
800cc1: 8b 4d 0c mov 0xc(%ebp),%ecx
800cc4: b8 0a 00 00 00 mov $0xa,%eax
800cc9: 89 df mov %ebx,%edi
800ccb: 89 de mov %ebx,%esi
800ccd: cd 30 int $0x30
if(check && ret > 0)
800ccf: 85 c0 test %eax,%eax
800cd1: 7f 08 jg 800cdb <sys_env_set_pgfault_upcall+0x2b>
return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
800cd3: 8d 65 f4 lea -0xc(%ebp),%esp
800cd6: 5b pop %ebx
800cd7: 5e pop %esi
800cd8: 5f pop %edi
800cd9: 5d pop %ebp
800cda: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800cdb: 83 ec 0c sub $0xc,%esp
800cde: 50 push %eax
800cdf: 6a 0a push $0xa
800ce1: 68 ff 12 80 00 push $0x8012ff
800ce6: 6a 23 push $0x23
800ce8: 68 1c 13 80 00 push $0x80131c
800ced: e8 64 00 00 00 call 800d56 <_panic>
00800cf2 <sys_ipc_try_send>:
int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
800cf2: 55 push %ebp
800cf3: 89 e5 mov %esp,%ebp
800cf5: 57 push %edi
800cf6: 56 push %esi
800cf7: 53 push %ebx
asm volatile("int %1\n" //执行int T_SYSCALL指令
800cf8: 8b 55 08 mov 0x8(%ebp),%edx
800cfb: 8b 4d 0c mov 0xc(%ebp),%ecx
800cfe: b8 0c 00 00 00 mov $0xc,%eax
800d03: be 00 00 00 00 mov $0x0,%esi
800d08: 8b 5d 10 mov 0x10(%ebp),%ebx
800d0b: 8b 7d 14 mov 0x14(%ebp),%edi
800d0e: cd 30 int $0x30
return syscall(SYS_ipc_try_send, 0, envid, value, (uint32_t) srcva, perm, 0);
}
800d10: 5b pop %ebx
800d11: 5e pop %esi
800d12: 5f pop %edi
800d13: 5d pop %ebp
800d14: c3 ret
00800d15 <sys_ipc_recv>:
int
sys_ipc_recv(void *dstva)
{
800d15: 55 push %ebp
800d16: 89 e5 mov %esp,%ebp
800d18: 57 push %edi
800d19: 56 push %esi
800d1a: 53 push %ebx
800d1b: 83 ec 0c sub $0xc,%esp
asm volatile("int %1\n" //执行int T_SYSCALL指令
800d1e: b9 00 00 00 00 mov $0x0,%ecx
800d23: 8b 55 08 mov 0x8(%ebp),%edx
800d26: b8 0d 00 00 00 mov $0xd,%eax
800d2b: 89 cb mov %ecx,%ebx
800d2d: 89 cf mov %ecx,%edi
800d2f: 89 ce mov %ecx,%esi
800d31: cd 30 int $0x30
if(check && ret > 0)
800d33: 85 c0 test %eax,%eax
800d35: 7f 08 jg 800d3f <sys_ipc_recv+0x2a>
return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
800d37: 8d 65 f4 lea -0xc(%ebp),%esp
800d3a: 5b pop %ebx
800d3b: 5e pop %esi
800d3c: 5f pop %edi
800d3d: 5d pop %ebp
800d3e: c3 ret
panic("syscall %d returned %d (> 0)", num, ret);
800d3f: 83 ec 0c sub $0xc,%esp
800d42: 50 push %eax
800d43: 6a 0d push $0xd
800d45: 68 ff 12 80 00 push $0x8012ff
800d4a: 6a 23 push $0x23
800d4c: 68 1c 13 80 00 push $0x80131c
800d51: e8 00 00 00 00 call 800d56 <_panic>
00800d56 <_panic>:
* It prints "panic: <message>", then causes a breakpoint exception,
* which causes JOS to enter the JOS kernel monitor.
*/
void
_panic(const char *file, int line, const char *fmt, ...)
{
800d56: 55 push %ebp
800d57: 89 e5 mov %esp,%ebp
800d59: 56 push %esi
800d5a: 53 push %ebx
va_list ap;
va_start(ap, fmt);
800d5b: 8d 5d 14 lea 0x14(%ebp),%ebx
// Print the panic message
cprintf("[%08x] user panic in %s at %s:%d: ",
800d5e: 8b 35 00 20 80 00 mov 0x802000,%esi
800d64: e8 be fd ff ff call 800b27 <sys_getenvid>
800d69: 83 ec 0c sub $0xc,%esp
800d6c: ff 75 0c pushl 0xc(%ebp)
800d6f: ff 75 08 pushl 0x8(%ebp)
800d72: 56 push %esi
800d73: 50 push %eax
800d74: 68 2c 13 80 00 push $0x80132c
800d79: e8 cf f3 ff ff call 80014d <cprintf>
sys_getenvid(), binaryname, file, line);
vcprintf(fmt, ap);
800d7e: 83 c4 18 add $0x18,%esp
800d81: 53 push %ebx
800d82: ff 75 10 pushl 0x10(%ebp)
800d85: e8 72 f3 ff ff call 8000fc <vcprintf>
cprintf("\n");
800d8a: c7 04 24 ec 0f 80 00 movl $0x800fec,(%esp)
800d91: e8 b7 f3 ff ff call 80014d <cprintf>
800d96: 83 c4 10 add $0x10,%esp
// Cause a breakpoint exception
while (1)
asm volatile("int3");
800d99: cc int3
800d9a: eb fd jmp 800d99 <_panic+0x43>
800d9c: 66 90 xchg %ax,%ax
800d9e: 66 90 xchg %ax,%ax
00800da0 <__udivdi3>:
800da0: 55 push %ebp
800da1: 57 push %edi
800da2: 56 push %esi
800da3: 53 push %ebx
800da4: 83 ec 1c sub $0x1c,%esp
800da7: 8b 54 24 3c mov 0x3c(%esp),%edx
800dab: 8b 6c 24 30 mov 0x30(%esp),%ebp
800daf: 8b 74 24 34 mov 0x34(%esp),%esi
800db3: 8b 5c 24 38 mov 0x38(%esp),%ebx
800db7: 85 d2 test %edx,%edx
800db9: 75 35 jne 800df0 <__udivdi3+0x50>
800dbb: 39 f3 cmp %esi,%ebx
800dbd: 0f 87 bd 00 00 00 ja 800e80 <__udivdi3+0xe0>
800dc3: 85 db test %ebx,%ebx
800dc5: 89 d9 mov %ebx,%ecx
800dc7: 75 0b jne 800dd4 <__udivdi3+0x34>
800dc9: b8 01 00 00 00 mov $0x1,%eax
800dce: 31 d2 xor %edx,%edx
800dd0: f7 f3 div %ebx
800dd2: 89 c1 mov %eax,%ecx
800dd4: 31 d2 xor %edx,%edx
800dd6: 89 f0 mov %esi,%eax
800dd8: f7 f1 div %ecx
800dda: 89 c6 mov %eax,%esi
800ddc: 89 e8 mov %ebp,%eax
800dde: 89 f7 mov %esi,%edi
800de0: f7 f1 div %ecx
800de2: 89 fa mov %edi,%edx
800de4: 83 c4 1c add $0x1c,%esp
800de7: 5b pop %ebx
800de8: 5e pop %esi
800de9: 5f pop %edi
800dea: 5d pop %ebp
800deb: c3 ret
800dec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
800df0: 39 f2 cmp %esi,%edx
800df2: 77 7c ja 800e70 <__udivdi3+0xd0>
800df4: 0f bd fa bsr %edx,%edi
800df7: 83 f7 1f xor $0x1f,%edi
800dfa: 0f 84 98 00 00 00 je 800e98 <__udivdi3+0xf8>
800e00: 89 f9 mov %edi,%ecx
800e02: b8 20 00 00 00 mov $0x20,%eax
800e07: 29 f8 sub %edi,%eax
800e09: d3 e2 shl %cl,%edx
800e0b: 89 54 24 08 mov %edx,0x8(%esp)
800e0f: 89 c1 mov %eax,%ecx
800e11: 89 da mov %ebx,%edx
800e13: d3 ea shr %cl,%edx
800e15: 8b 4c 24 08 mov 0x8(%esp),%ecx
800e19: 09 d1 or %edx,%ecx
800e1b: 89 f2 mov %esi,%edx
800e1d: 89 4c 24 08 mov %ecx,0x8(%esp)
800e21: 89 f9 mov %edi,%ecx
800e23: d3 e3 shl %cl,%ebx
800e25: 89 c1 mov %eax,%ecx
800e27: d3 ea shr %cl,%edx
800e29: 89 f9 mov %edi,%ecx
800e2b: 89 5c 24 0c mov %ebx,0xc(%esp)
800e2f: d3 e6 shl %cl,%esi
800e31: 89 eb mov %ebp,%ebx
800e33: 89 c1 mov %eax,%ecx
800e35: d3 eb shr %cl,%ebx
800e37: 09 de or %ebx,%esi
800e39: 89 f0 mov %esi,%eax
800e3b: f7 74 24 08 divl 0x8(%esp)
800e3f: 89 d6 mov %edx,%esi
800e41: 89 c3 mov %eax,%ebx
800e43: f7 64 24 0c mull 0xc(%esp)
800e47: 39 d6 cmp %edx,%esi
800e49: 72 0c jb 800e57 <__udivdi3+0xb7>
800e4b: 89 f9 mov %edi,%ecx
800e4d: d3 e5 shl %cl,%ebp
800e4f: 39 c5 cmp %eax,%ebp
800e51: 73 5d jae 800eb0 <__udivdi3+0x110>
800e53: 39 d6 cmp %edx,%esi
800e55: 75 59 jne 800eb0 <__udivdi3+0x110>
800e57: 8d 43 ff lea -0x1(%ebx),%eax
800e5a: 31 ff xor %edi,%edi
800e5c: 89 fa mov %edi,%edx
800e5e: 83 c4 1c add $0x1c,%esp
800e61: 5b pop %ebx
800e62: 5e pop %esi
800e63: 5f pop %edi
800e64: 5d pop %ebp
800e65: c3 ret
800e66: 8d 76 00 lea 0x0(%esi),%esi
800e69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
800e70: 31 ff xor %edi,%edi
800e72: 31 c0 xor %eax,%eax
800e74: 89 fa mov %edi,%edx
800e76: 83 c4 1c add $0x1c,%esp
800e79: 5b pop %ebx
800e7a: 5e pop %esi
800e7b: 5f pop %edi
800e7c: 5d pop %ebp
800e7d: c3 ret
800e7e: 66 90 xchg %ax,%ax
800e80: 31 ff xor %edi,%edi
800e82: 89 e8 mov %ebp,%eax
800e84: 89 f2 mov %esi,%edx
800e86: f7 f3 div %ebx
800e88: 89 fa mov %edi,%edx
800e8a: 83 c4 1c add $0x1c,%esp
800e8d: 5b pop %ebx
800e8e: 5e pop %esi
800e8f: 5f pop %edi
800e90: 5d pop %ebp
800e91: c3 ret
800e92: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
800e98: 39 f2 cmp %esi,%edx
800e9a: 72 06 jb 800ea2 <__udivdi3+0x102>
800e9c: 31 c0 xor %eax,%eax
800e9e: 39 eb cmp %ebp,%ebx
800ea0: 77 d2 ja 800e74 <__udivdi3+0xd4>
800ea2: b8 01 00 00 00 mov $0x1,%eax
800ea7: eb cb jmp 800e74 <__udivdi3+0xd4>
800ea9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
800eb0: 89 d8 mov %ebx,%eax
800eb2: 31 ff xor %edi,%edi
800eb4: eb be jmp 800e74 <__udivdi3+0xd4>
800eb6: 66 90 xchg %ax,%ax
800eb8: 66 90 xchg %ax,%ax
800eba: 66 90 xchg %ax,%ax
800ebc: 66 90 xchg %ax,%ax
800ebe: 66 90 xchg %ax,%ax
00800ec0 <__umoddi3>:
800ec0: 55 push %ebp
800ec1: 57 push %edi
800ec2: 56 push %esi
800ec3: 53 push %ebx
800ec4: 83 ec 1c sub $0x1c,%esp
800ec7: 8b 6c 24 3c mov 0x3c(%esp),%ebp
800ecb: 8b 74 24 30 mov 0x30(%esp),%esi
800ecf: 8b 5c 24 34 mov 0x34(%esp),%ebx
800ed3: 8b 7c 24 38 mov 0x38(%esp),%edi
800ed7: 85 ed test %ebp,%ebp
800ed9: 89 f0 mov %esi,%eax
800edb: 89 da mov %ebx,%edx
800edd: 75 19 jne 800ef8 <__umoddi3+0x38>
800edf: 39 df cmp %ebx,%edi
800ee1: 0f 86 b1 00 00 00 jbe 800f98 <__umoddi3+0xd8>
800ee7: f7 f7 div %edi
800ee9: 89 d0 mov %edx,%eax
800eeb: 31 d2 xor %edx,%edx
800eed: 83 c4 1c add $0x1c,%esp
800ef0: 5b pop %ebx
800ef1: 5e pop %esi
800ef2: 5f pop %edi
800ef3: 5d pop %ebp
800ef4: c3 ret
800ef5: 8d 76 00 lea 0x0(%esi),%esi
800ef8: 39 dd cmp %ebx,%ebp
800efa: 77 f1 ja 800eed <__umoddi3+0x2d>
800efc: 0f bd cd bsr %ebp,%ecx
800eff: 83 f1 1f xor $0x1f,%ecx
800f02: 89 4c 24 04 mov %ecx,0x4(%esp)
800f06: 0f 84 b4 00 00 00 je 800fc0 <__umoddi3+0x100>
800f0c: b8 20 00 00 00 mov $0x20,%eax
800f11: 89 c2 mov %eax,%edx
800f13: 8b 44 24 04 mov 0x4(%esp),%eax
800f17: 29 c2 sub %eax,%edx
800f19: 89 c1 mov %eax,%ecx
800f1b: 89 f8 mov %edi,%eax
800f1d: d3 e5 shl %cl,%ebp
800f1f: 89 d1 mov %edx,%ecx
800f21: 89 54 24 0c mov %edx,0xc(%esp)
800f25: d3 e8 shr %cl,%eax
800f27: 09 c5 or %eax,%ebp
800f29: 8b 44 24 04 mov 0x4(%esp),%eax
800f2d: 89 c1 mov %eax,%ecx
800f2f: d3 e7 shl %cl,%edi
800f31: 89 d1 mov %edx,%ecx
800f33: 89 7c 24 08 mov %edi,0x8(%esp)
800f37: 89 df mov %ebx,%edi
800f39: d3 ef shr %cl,%edi
800f3b: 89 c1 mov %eax,%ecx
800f3d: 89 f0 mov %esi,%eax
800f3f: d3 e3 shl %cl,%ebx
800f41: 89 d1 mov %edx,%ecx
800f43: 89 fa mov %edi,%edx
800f45: d3 e8 shr %cl,%eax
800f47: 0f b6 4c 24 04 movzbl 0x4(%esp),%ecx
800f4c: 09 d8 or %ebx,%eax
800f4e: f7 f5 div %ebp
800f50: d3 e6 shl %cl,%esi
800f52: 89 d1 mov %edx,%ecx
800f54: f7 64 24 08 mull 0x8(%esp)
800f58: 39 d1 cmp %edx,%ecx
800f5a: 89 c3 mov %eax,%ebx
800f5c: 89 d7 mov %edx,%edi
800f5e: 72 06 jb 800f66 <__umoddi3+0xa6>
800f60: 75 0e jne 800f70 <__umoddi3+0xb0>
800f62: 39 c6 cmp %eax,%esi
800f64: 73 0a jae 800f70 <__umoddi3+0xb0>
800f66: 2b 44 24 08 sub 0x8(%esp),%eax
800f6a: 19 ea sbb %ebp,%edx
800f6c: 89 d7 mov %edx,%edi
800f6e: 89 c3 mov %eax,%ebx
800f70: 89 ca mov %ecx,%edx
800f72: 0f b6 4c 24 0c movzbl 0xc(%esp),%ecx
800f77: 29 de sub %ebx,%esi
800f79: 19 fa sbb %edi,%edx
800f7b: 8b 5c 24 04 mov 0x4(%esp),%ebx
800f7f: 89 d0 mov %edx,%eax
800f81: d3 e0 shl %cl,%eax
800f83: 89 d9 mov %ebx,%ecx
800f85: d3 ee shr %cl,%esi
800f87: d3 ea shr %cl,%edx
800f89: 09 f0 or %esi,%eax
800f8b: 83 c4 1c add $0x1c,%esp
800f8e: 5b pop %ebx
800f8f: 5e pop %esi
800f90: 5f pop %edi
800f91: 5d pop %ebp
800f92: c3 ret
800f93: 90 nop
800f94: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
800f98: 85 ff test %edi,%edi
800f9a: 89 f9 mov %edi,%ecx
800f9c: 75 0b jne 800fa9 <__umoddi3+0xe9>
800f9e: b8 01 00 00 00 mov $0x1,%eax
800fa3: 31 d2 xor %edx,%edx
800fa5: f7 f7 div %edi
800fa7: 89 c1 mov %eax,%ecx
800fa9: 89 d8 mov %ebx,%eax
800fab: 31 d2 xor %edx,%edx
800fad: f7 f1 div %ecx
800faf: 89 f0 mov %esi,%eax
800fb1: f7 f1 div %ecx
800fb3: e9 31 ff ff ff jmp 800ee9 <__umoddi3+0x29>
800fb8: 90 nop
800fb9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
800fc0: 39 dd cmp %ebx,%ebp
800fc2: 72 08 jb 800fcc <__umoddi3+0x10c>
800fc4: 39 f7 cmp %esi,%edi
800fc6: 0f 87 21 ff ff ff ja 800eed <__umoddi3+0x2d>
800fcc: 89 da mov %ebx,%edx
800fce: 89 f0 mov %esi,%eax
800fd0: 29 f8 sub %edi,%eax
800fd2: 19 ea sbb %ebp,%edx
800fd4: e9 14 ff ff ff jmp 800eed <__umoddi3+0x2d>
|
// Copyright (c) 2006-2008 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 "webkit/glue/plugins/plugin_stream.h"
#include "base/logging.h"
#include "webkit/glue/plugins/plugin_instance.h"
namespace NPAPI {
PluginStream::PluginStream(
PluginInstance *instance,
const char *url,
bool need_notify,
void *notify_data)
: instance_(instance),
notify_needed_(need_notify),
notify_data_(notify_data),
close_on_write_data_(false),
opened_(false),
requested_plugin_mode_(NP_NORMAL),
temp_file_handle_(INVALID_HANDLE_VALUE),
seekable_stream_(false),
data_offset_(0) {
memset(&stream_, 0, sizeof(stream_));
stream_.url = _strdup(url);
temp_file_name_[0] = '\0';
}
void PluginStream::UpdateUrl(const char* url) {
DCHECK(!opened_);
free(const_cast<char*>(stream_.url));
stream_.url = _strdup(url);
}
void PluginStream::WriteAsFile() {
if (requested_plugin_mode_ == NP_ASFILE ||
requested_plugin_mode_ == NP_ASFILEONLY)
instance_->NPP_StreamAsFile(&stream_, temp_file_name_);
}
size_t PluginStream::WriteBytes(const char *buf, size_t length) {
DWORD bytes;
if (!WriteFile(temp_file_handle_, buf, length, &bytes, 0))
return 0U;
return static_cast<size_t>(bytes);
}
bool PluginStream::OpenTempFile() {
DCHECK(temp_file_handle_ == INVALID_HANDLE_VALUE);
// The reason for using all the Ascii versions of these filesystem
// calls is that the filename which we pass back to the plugin
// via NPAPI is an ascii filename. Otherwise, we'd use wide-chars.
//
// TODO:
// This is a bug in NPAPI itself, and it needs to be fixed.
// The case which will fail is if a user has a multibyte name,
// but has the system locale set to english. GetTempPathA will
// return junk in this case, causing us to be unable to open the
// file.
char temp_directory[MAX_PATH];
if (GetTempPathA(MAX_PATH, temp_directory) == 0)
return false;
if (GetTempFileNameA(temp_directory, "npstream", 0, temp_file_name_) == 0)
return false;
temp_file_handle_ = CreateFileA(temp_file_name_,
FILE_ALL_ACCESS,
FILE_SHARE_READ,
0,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
0);
if (temp_file_handle_ == INVALID_HANDLE_VALUE) {
temp_file_name_[0] = '\0';
return false;
}
return true;
}
void PluginStream::CloseTempFile() {
if (temp_file_handle_ != INVALID_HANDLE_VALUE) {
CloseHandle(temp_file_handle_);
temp_file_handle_ = INVALID_HANDLE_VALUE;
}
}
bool PluginStream::TempFileIsValid() {
return temp_file_handle_ != INVALID_HANDLE_VALUE;
}
} // namespace NPAPI
|
[BITS 16]
[ORG 0]
sectors equ 1
interrupt equ 0x13
fallback equ 0xa7
%include 'tests/bios_patches/interrupt_patch.asm'
; Fail all calls with 0x41 <= ah <= 0x49
interrupt_handler:
pushf
cmp ah,0x41
jb continue
cmp ah,0x49
jbe fail
continue:
popf
jmp fallback_handler
fail:
push bp
mov bp,sp
or word[ss:bp+8],1
pop bp
popf
iret
; Padding
times (512*sectors)-($-$$)-1 db 0
|
; A022342: Integers with "even" Zeckendorf expansions (do not end with ...+F_2 = ...+1) (the Fibonacci-even numbers); also, apart from first term, a(n) = Fibonacci successor to n-1.
; Submitted by Christian Krause
; 0,2,3,5,7,8,10,11,13,15,16,18,20,21,23,24,26,28,29,31,32,34,36,37,39,41,42,44,45,47,49,50,52,54,55,57,58,60,62,63,65,66,68,70,71,73,75,76,78,79,81,83,84,86,87,89,91,92,94,96,97,99,100,102,104,105,107,109,110,112,113,115,117,118,120,121,123,125,126,128,130,131,133,134,136,138,139,141,143,144,146,147,149,151,152,154,155,157,159,160
mov $2,$0
add $0,1
mov $1,$0
pow $1,2
lpb $1
add $2,2
trn $1,$2
lpe
add $0,$2
sub $0,3
div $0,2
|
; A151783: a(n) = 4^{wt(n)-1}.
; 1,1,4,1,4,4,16,1,4,4,16,4,16,16,64,1,4,4,16,4,16,16,64,4,16,16,64,16,64,64,256,1,4,4,16,4,16,16,64,4,16,16,64,16,64,64,256,4,16,16,64,16,64,64,256,16,64,64,256,64,256,256,1024,1,4,4,16,4,16,16,64,4,16,16,64,16,64
seq $0,48881 ; a(n) = A000120(n+1) - 1 = wt(n+1) - 1.
mov $1,4
pow $1,$0
mov $0,$1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.