This topic is locked, you cannot edit posts or make further replies.  [ 1075 posts ]  Go to page Previous  1 ... 31, 32, 33, 34, 35, 36, 37 ... 72  Next
The All-New Improved 24hr Thread 
Author Message
Spends far too much time on here

Joined: Thu Apr 23, 2009 6:12 pm
Posts: 2020
Location: Mute City
saspro wrote:
soddit112 wrote:
lol, i tried to quote all that wierd stuff (is it welsh?) you two wrote, and it hit the character limit :lol:

which turns out to be 60,000 chars


It's latin doofus ;)


i was close!!


Thu Aug 20, 2009 3:46 pm
Profile
Site Admin
User avatar

Joined: Thu Apr 23, 2009 5:53 pm
Posts: 8603
Location: location, location
So very close

_________________
Support X404, use our Amazon link
Get your X404 tat here
jonlumb wrote:
I've only ever done it with a chicken so far, but if required I wouldn't have any problems doing it with other animals at all.


Thu Aug 20, 2009 3:46 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 8:57 pm
Posts: 2220
Location: Here for now...
He is a dog afterall, we should be glad that he can even read and write English!

_________________
ProfessorF wrote:
(The author of this post assumes no responsibility for any jail time served by anyone making use of this suggestion.)


Thu Aug 20, 2009 3:47 pm
Profile WWW
Site Admin
User avatar

Joined: Thu Apr 23, 2009 5:53 pm
Posts: 8603
Location: location, location
Blue_Nowhere wrote:
He is a dog afterall, we should be glad that he can even read and write English!


True. Better than most humans as well.

_________________
Support X404, use our Amazon link
Get your X404 tat here
jonlumb wrote:
I've only ever done it with a chicken so far, but if required I wouldn't have any problems doing it with other animals at all.


Thu Aug 20, 2009 3:52 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
This seems really quiet, \ren't we usually a few hundred pages in by now?


Thu Aug 20, 2009 3:59 pm
Profile WWW
Site Admin
User avatar

Joined: Thu Apr 23, 2009 5:53 pm
Posts: 8603
Location: location, location
forquare1 wrote:
This seems really quiet, \ren't we usually a few hundred pages in by now?


Lack of spammers

_________________
Support X404, use our Amazon link
Get your X404 tat here
jonlumb wrote:
I've only ever done it with a chicken so far, but if required I wouldn't have any problems doing it with other animals at all.


Thu Aug 20, 2009 4:00 pm
Profile WWW
Spends far too much time on here

Joined: Thu Apr 23, 2009 6:12 pm
Posts: 2020
Location: Mute City
:cry:


Thu Aug 20, 2009 4:05 pm
Profile
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 8:57 pm
Posts: 2220
Location: Here for now...
I said a ohh boom boom let me hear you say wayhooooo

_________________
ProfessorF wrote:
(The author of this post assumes no responsibility for any jail time served by anyone making use of this suggestion.)


Thu Aug 20, 2009 4:08 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 6:44 pm
Posts: 4141
Location: Exeter
wayhooooo

_________________
"The woman is a riddle inside a mystery wrapped in an enigma I've had sex with."


Thu Aug 20, 2009 4:12 pm
Profile WWW
Site Admin
User avatar

Joined: Thu Apr 23, 2009 5:53 pm
Posts: 8603
Location: location, location
Blue_Nowhere wrote:
I said a ohh boom boom let me hear you say wayhooooo

_________________
Support X404, use our Amazon link
Get your X404 tat here
jonlumb wrote:
I've only ever done it with a chicken so far, but if required I wouldn't have any problems doing it with other animals at all.


Thu Aug 20, 2009 4:17 pm
Profile WWW
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:46 pm
Posts: 10022
so how come there wasn't a thread to tell us about the 24-hr thread? I had no idea, otherwise would have skived off work. Or at least prepared some pics for my usual postings.

_________________
Image
He fights for the users.


Thu Aug 20, 2009 4:39 pm
Profile
Doesn't have much of a life
User avatar

Joined: Fri Apr 24, 2009 4:00 pm
Posts: 940
Location: Pompy
cloaked_wolf wrote:
so how come there wasn't a thread to tell us about the 24-hr thread? I had no idea, otherwise would have skived off work. Or at least prepared some pics for my usual postings.

Because dinosaurs stole it...

_________________
Just your friendly neighbourhood mars-bar-man.

flickr


Thu Aug 20, 2009 5:13 pm
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
1 #!/usr/local/bin/perl
2
3 package x86unix; # GAS actually...
4
5 $label="L000";
6 $const="";
7 $constl=0;
8
9 $align=($main'aout)?"4":"16";
10 $under=($main'aout or $main'coff)?"_":"";
11 $dot=($main'aout)?"":".";
12 $com_start="#" if ($main'aout or $main'coff);
13
14 sub main'asm_init_output { @out=(); }
15 sub main'asm_get_output { return(@out); }
16 sub main'get_labels { return(@labels); }
17 sub main'external_label { push(@labels,@_); }
18
19 if ($main'cpp)
20 {
21 $align="ALIGN";
22 $under="";
23 $com_start='/*';
24 $com_end='*/';
25 }
26
27 %lb=( 'eax', '%al',
28 'ebx', '%bl',
29 'ecx', '%cl',
30 'edx', '%dl',
31 'ax', '%al',
32 'bx', '%bl',
33 'cx', '%cl',
34 'dx', '%dl',
35 );
36
37 %hb=( 'eax', '%ah',
38 'ebx', '%bh',
39 'ecx', '%ch',
40 'edx', '%dh',
41 'ax', '%ah',
42 'bx', '%bh',
43 'cx', '%ch',
44 'dx', '%dh',
45 );
46
47 %regs=( 'eax', '%eax',
48 'ebx', '%ebx',
49 'ecx', '%ecx',
50 'edx', '%edx',
51 'esi', '%esi',
52 'edi', '%edi',
53 'ebp', '%ebp',
54 'esp', '%esp',
55
56 'mm0', '%mm0',
57 'mm1', '%mm1',
58 'mm2', '%mm2',
59 'mm3', '%mm3',
60 'mm4', '%mm4',
61 'mm5', '%mm5',
62 'mm6', '%mm6',
63 'mm7', '%mm7',
64
65 'xmm0', '%xmm0',
66 'xmm1', '%xmm1',
67 'xmm2', '%xmm2',
68 'xmm3', '%xmm3',
69 'xmm4', '%xmm4',
70 'xmm5', '%xmm5',
71 'xmm6', '%xmm6',
72 'xmm7', '%xmm7',
73 );
74
75 %reg_val=(
76 'eax', 0x00,
77 'ebx', 0x03,
78 'ecx', 0x01,
79 'edx', 0x02,
80 'esi', 0x06,
81 'edi', 0x07,
82 'ebp', 0x05,
83 'esp', 0x04,
84 );
85
86 sub main'LB
87 {
88 (defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
89 return($lb{$_[0]});
90 }
91
92 sub main'HB
93 {
94 (defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
95 return($hb{$_[0]});
96 }
97
98 sub main'DWP
99 {
100 local($addr,$reg1,$reg2,$idx)=@_;
101
102 $ret="";
103 $addr =~ s/(^|[+ \t])([A-Za-z_]+[A-Za-z0-9_]+)($|[+ \t])/$1$under$2$3/;
104 $reg1="$regs{$reg1}" if defined($regs{$reg1});
105 $reg2="$regs{$reg2}" if defined($regs{$reg2});
106 $ret.=$addr if ($addr ne "") && ($addr ne 0);
107 if ($reg2 ne "")
108 {
109 if($idx ne "" && $idx != 0)
110 { $ret.="($reg1,$reg2,$idx)"; }
111 else
112 { $ret.="($reg1,$reg2)"; }
113 }
114 elsif ($reg1 ne "")
115 { $ret.="($reg1)" }
116 return($ret);
117 }
118
119 sub main'QWP
120 {
121 return(&main'DWP(@_));
122 }
123
124 sub main'BP
125 {
126 return(&main'DWP(@_));
127 }
128
129 sub main'BC
130 {
131 return @_;
132 }
133
134 sub main'DWC
135 {
136 return @_;
137 }
138
139 #sub main'BP
140 # {
141 # local($addr,$reg1,$reg2,$idx)=@_;
142 #
143 # $ret="";
144 #
145 # $addr =~ s/(^|[+ \t])([A-Za-z_]+)($|[+ \t])/$1$under$2$3/;
146 # $reg1="$regs{$reg1}" if defined($regs{$reg1});
147 # $reg2="$regs{$reg2}" if defined($regs{$reg2});
148 # $ret.=$addr if ($addr ne "") && ($addr ne 0);
149 # if ($reg2 ne "")
150 # { $ret.="($reg1,$reg2,$idx)"; }
151 # else
152 # { $ret.="($reg1)" }
153 # return($ret);
154 # }
155
156 sub main'mov { &out2("movl",@_); }
157 sub main'movb { &out2("movb",@_); }
158 sub main'and { &out2("andl",@_); }
159 sub main'or { &out2("orl",@_); }
160 sub main'shl { &out2("sall",@_); }
161 sub main'shr { &out2("shrl",@_); }
162 sub main'xor { &out2("xorl",@_); }
163 sub main'xorb { &out2("xorb",@_); }
164 sub main'add { &out2($_[0]=~/%[a-d][lh]/?"addb":"addl",@_); }
165 sub main'adc { &out2("adcl",@_); }
166 sub main'sub { &out2("subl",@_); }
167 sub main'sbb { &out2("sbbl",@_); }
168 sub main'rotl { &out2("roll",@_); }
169 sub main'rotr { &out2("rorl",@_); }
170 sub main'exch { &out2($_[0]=~/%[a-d][lh]/?"xchgb":"xchgl",@_); }
171 sub main'cmp { &out2("cmpl",@_); }
172 sub main'lea { &out2("leal",@_); }
173 sub main'mul { &out1("mull",@_); }
174 sub main'div { &out1("divl",@_); }
175 sub main'jmp { &out1("jmp",@_); }
176 sub main'jmp_ptr { &out1p("jmp",@_); }
177 sub main'je { &out1("je",@_); }
178 sub main'jle { &out1("jle",@_); }
179 sub main'jne { &out1("jne",@_); }
180 sub main'jnz { &out1("jnz",@_); }
181 sub main'jz { &out1("jz",@_); }
182 sub main'jge { &out1("jge",@_); }
183 sub main'jl { &out1("jl",@_); }
184 sub main'ja { &out1("ja",@_); }
185 sub main'jae { &out1("jae",@_); }
186 sub main'jb { &out1("jb",@_); }
187 sub main'jbe { &out1("jbe",@_); }
188 sub main'jc { &out1("jc",@_); }
189 sub main'jnc { &out1("jnc",@_); }
190 sub main'jno { &out1("jno",@_); }
191 sub main'dec { &out1("decl",@_); }
192 sub main'inc { &out1($_[0]=~/%[a-d][hl]/?"incb":"incl",@_); }
193 sub main'push { &out1("pushl",@_); $stack+=4; }
194 sub main'pop { &out1("popl",@_); $stack-=4; }
195 sub main'pushf { &out0("pushfl"); $stack+=4; }
196 sub main'popf { &out0("popfl"); $stack-=4; }
197 sub main'not { &out1("notl",@_); }
198 sub main'call { my $pre=$under;
199 foreach $i (%label)
200 { if ($label{$i} eq $_[0]) { $pre=''; last; } }
201 &out1("call",$pre.$_[0]);
202 }
203 sub main'ret { &out0("ret"); }
204 sub main'nop { &out0("nop"); }
205 sub main'test { &out2("testl",@_); }
206 sub main'bt { &out2("btl",@_); }
207 sub main'leave { &out0("leave"); }
208 sub main'cpuid { &out0(".byte\t0x0f,0xa2"); }
209 sub main'rdtsc { &out0(".byte\t0x0f,0x31"); }
210 sub main'halt { &out0("hlt"); }
211 sub main'movz { &out2("movzbl",@_); }
212 sub main'neg { &out1("negl",@_); }
213 sub main'cld { &out0("cld"); }
214
215 # SSE2
216 sub main'emms { &out0("emms"); }
217 sub main'movd { &out2("movd",@_); }
218 sub main'movq { &out2("movq",@_); }
219 sub main'movdqu { &out2("movdqu",@_); }
220 sub main'movdqa { &out2("movdqa",@_); }
221 sub main'movdq2q{ &out2("movdq2q",@_); }
222 sub main'movq2dq{ &out2("movq2dq",@_); }
223 sub main'paddq { &out2("paddq",@_); }
224 sub main'pmuludq{ &out2("pmuludq",@_); }
225 sub main'psrlq { &out2("psrlq",@_); }
226 sub main'psllq { &out2("psllq",@_); }
227 sub main'pxor { &out2("pxor",@_); }
228 sub main'por { &out2("por",@_); }
229 sub main'pand { &out2("pand",@_); }
230
231 # The bswapl instruction is new for the 486. Emulate if i386.
232 sub main'bswap
233 {
234 if ($main'i386)
235 {
236 &main'comment("bswapl @_");
237 &main'exch(main'HB(@_),main'LB(@_));
238 &main'rotr(@_,16);
239 &main'exch(main'HB(@_),main'LB(@_));
240 }
241 else
242 {
243 &out1("bswapl",@_);
244 }
245 }
246
247 sub out2
248 {
249 local($name,$p1,$p2)=@_;
250 local($l,$ll,$t);
251 local(%special)=( "roll",0xD1C0,"rorl",0xD1C8,
252 "rcll",0xD1D0,"rcrl",0xD1D8,
253 "shll",0xD1E0,"shrl",0xD1E8,
254 "sarl",0xD1F8);
255
256 if ((defined($special{$name})) && defined($regs{$p1}) && ($p2 == 1))
257 {
258 $op=$special{$name}|$reg_val{$p1};
259 $tmp1=sprintf(".byte %d\n",($op>>8)&0xff);
260 $tmp2=sprintf(".byte %d\t",$op &0xff);
261 push(@out,$tmp1);
262 push(@out,$tmp2);
263
264 $p2=&conv($p2);
265 $p1=&conv($p1);
266 &main'comment("$name $p2 $p1");
267 return;
268 }
269
270 push(@out,"\t$name\t");
271 $t=&conv($p2).",";
272 $l=length($t);
273 push(@out,$t);
274 $ll=4-($l+9)/8;
275 $tmp1=sprintf("\t" x $ll);
276 push(@out,$tmp1);
277 push(@out,&conv($p1)."\n");
278 }
279
280 sub out1
281 {
282 local($name,$p1)=@_;
283 local($l,$t);
284 local(%special)=("bswapl",0x0FC8);
285
286 if ((defined($special{$name})) && defined($regs{$p1}))
287 {
288 $op=$special{$name}|$reg_val{$p1};
289 $tmp1=sprintf(".byte %d\n",($op>>8)&0xff);
290 $tmp2=sprintf(".byte %d\t",$op &0xff);
291 push(@out,$tmp1);
292 push(@out,$tmp2);
293
294 $p2=&conv($p2);
295 $p1=&conv($p1);
296 &main'comment("$name $p2 $p1");
297 return;
298 }
299
300 push(@out,"\t$name\t".&conv($p1)."\n");
301 }
302
303 sub out1p
304 {
305 local($name,$p1)=@_;
306 local($l,$t);
307
308 push(@out,"\t$name\t*".&conv($p1)."\n");
309 }
310
311 sub out0
312 {
313 push(@out,"\t$_[0]\n");
314 }
315
316 sub conv
317 {
318 local($p)=@_;
319
320 # $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
321
322 $p=$regs{$p} if (defined($regs{$p}));
323
324 $p =~ s/^(-{0,1}[0-9A-Fa-f]+)$/\$$1/;
325 $p =~ s/^(0x[0-9A-Fa-f]+)$/\$$1/;
326 return $p;
327 }
328
329 sub main'file
330 {
331 local($file)=@_;
332
333 local($tmp)=<<"EOF";
334 .file "$file.s"
335 EOF
336 push(@out,$tmp);
337 }
338
339 sub main'function_begin
340 {
341 local($func)=@_;
342
343 &main'external_label($func);
344 $func=$under.$func;
345
346 local($tmp)=<<"EOF";
347 .text
348 .globl $func
349 EOF
350 push(@out,$tmp);
351 if ($main'cpp)
352 { $tmp=push(@out,"TYPE($func,\@function)\n"); }
353 elsif ($main'coff)
354 { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
355 elsif ($main'aout and !$main'pic)
356 { }
357 else { $tmp=push(@out,".type\t$func,\@function\n"); }
358 push(@out,".align\t$align\n");
359 push(@out,"$func:\n");
360 $tmp=<<"EOF";
361 pushl %ebp
362 pushl %ebx
363 pushl %esi
364 pushl %edi
365
366 EOF
367 push(@out,$tmp);
368 $stack=20;
369 }
370
371 sub main'function_begin_B
372 {
373 local($func,$extra)=@_;
374
375 &main'external_label($func);
376 $func=$under.$func;
377
378 local($tmp)=<<"EOF";
379 .text
380 .globl $func
381 EOF
382 push(@out,$tmp);
383 if ($main'cpp)
384 { push(@out,"TYPE($func,\@function)\n"); }
385 elsif ($main'coff)
386 { $tmp=push(@out,".def\t$func;\t.scl\t2;\t.type\t32;\t.endef\n"); }
387 elsif ($main'aout and !$main'pic)
388 { }
389 else { push(@out,".type $func,\@function\n"); }
390 push(@out,".align\t$align\n");
391 push(@out,"$func:\n");
392 $stack=4;
393 }
394
395 sub main'function_end
396 {
397 local($func)=@_;
398
399 $func=$under.$func;
400
401 local($tmp)=<<"EOF";
402 popl %edi
403 popl %esi
404 popl %ebx
405 popl %ebp
406 ret
407 ${dot}L_${func}_end:
408 EOF
409 push(@out,$tmp);
410
411 if ($main'cpp)
412 { push(@out,"SIZE($func,${dot}L_${func}_end-$func)\n"); }
413 elsif ($main'coff or $main'aout)
414 { }
415 else { push(@out,".size\t$func,${dot}L_${func}_end-$func\n"); }
416 push(@out,".ident \"$func\"\n");
417 $stack=0;
418 %label=();
419 }
420
421 sub main'function_end_A
422 {
423 local($func)=@_;
424
425 local($tmp)=<<"EOF";
426 popl %edi
427 popl %esi
428 popl %ebx
429 popl %ebp
430 ret
431 EOF
432 push(@out,$tmp);
433 }
434
435 sub main'function_end_B
436 {
437 local($func)=@_;
438
439 $func=$under.$func;
440
441 push(@out,"${dot}L_${func}_end:\n");
442 if ($main'cpp)
443 { push(@out,"SIZE($func,${dot}L_${func}_end-$func)\n"); }
444 elsif ($main'coff or $main'aout)
445 { }
446 else { push(@out,".size\t$func,${dot}L_${func}_end-$func\n"); }
447 push(@out,".ident \"$func\"\n");
448 $stack=0;
449 %label=();
450 }
451
452 sub main'wparam
453 {
454 local($num)=@_;
455
456 return(&main'DWP($stack+$num*4,"esp","",0));
457 }
458
459 sub main'stack_push
460 {
461 local($num)=@_;
462 $stack+=$num*4;
463 &main'sub("esp",$num*4);
464 }
465
466 sub main'stack_pop
467 {
468 local($num)=@_;
469 $stack-=$num*4;
470 &main'add("esp",$num*4);
471 }
472
473 sub main'swtmp
474 {
475 return(&main'DWP($_[0]*4,"esp","",0));
476 }
477
478 # Should use swtmp, which is above esp. Linix can trash the stack above esp
479 #sub main'wtmp
480 # {
481 # local($num)=@_;
482 #
483 # return(&main'DWP(-($num+1)*4,"esp","",0));
484 # }
485
486 sub main'comment
487 {
488 if (!defined($com_start) or $main'elf)
489 { # Regarding $main'elf above...
490 # GNU and SVR4 as'es use different comment delimiters,
491 push(@out,"\n"); # so we just skip ELF comments...
492 return;
493 }
494 foreach (@_)
495 {
496 if (/^\s*$/)
497 { push(@out,"\n"); }
498 else
499 { push(@out,"\t$com_start $_ $com_end\n"); }
500 }
501 }
502
503 sub main'public_label
504 {
505 $label{$_[0]}="${under}${_[0]}" if (!defined($label{$_[0]}));
506 push(@out,".globl\t$label{$_[0]}\n");
507 }
508
509 sub main'label
510 {
511 if (!defined($label{$_[0]}))
512 {
513 $label{$_[0]}="${dot}${label}${_[0]}";
514 $label++;
515 }
516 return($label{$_[0]});
517 }
518
519 sub main'set_label
520 {
521 if (!defined($label{$_[0]}))
522 {
523 $label{$_[0]}="${dot}${label}${_[0]}";
524 $label++;
525 }
526 if ($_[1]!=0)
527 {
528 if ($_[1]>1) { main'align($_[1]); }
529 else { push(@out,".align $align\n"); }
530 }
531 push(@out,"$label{$_[0]}:\n");
532 }
533
534 sub main'file_end
535 {
536 # try to detect if SSE2 or MMX extensions were used on ELF platform...
537 if ($main'elf && grep {/%[x]*mm[0-7]/i} @out) {
538 local($tmp);
539
540 push (@out,"\n.section\t.bss\n");
541 push (@out,".comm\t${under}OPENSSL_ia32cap_P,4,4\n");
542
543 push (@out,".section\t.init\n");
544 # One can argue that it's wasteful to craft every
545 # SSE/MMX module with this snippet... Well, it's 72
546 # bytes long and for the moment we have two modules.
547 # Let's argue when we have 7 modules or so...
548 #
549 # $1<<10 sets a reserved bit to signal that variable
550 # was initialized already...
551 &main'picmeup("edx","OPENSSL_ia32cap_P");
552 $tmp=<<___;
553 cmpl \$0,(%edx)
554 jne 1f
555 movl \$1<<10,(%edx)
556 pushf
557 popl %eax
558 movl %eax,%ecx
559 xorl \$1<<21,%eax
560 pushl %eax
561 popf
562 pushf
563 popl %eax
564 xorl %ecx,%eax
565 btl \$21,%eax
566 jnc 1f
567 pushl %edi
568 pushl %ebx
569 movl %edx,%edi
570 movl \$1,%eax
571 .byte 0x0f,0xa2
572 orl \$1<<10,%edx
573 movl %edx,0(%edi)
574 popl %ebx
575 popl %edi
576 jmp 1f
577 .align $align
578 1:
579 ___
580 push (@out,$tmp);
581 }
582
583 if ($const ne "")
584 {
585 push(@out,".section .rodata\n");
586 push(@out,$const);
587 $const="";
588 }
589 }
590
591 sub main'data_word
592 {
593 push(@out,"\t.long\t".join(',',@_)."\n");
594 }
595
596 sub main'align
597 {
598 my $val=$_[0],$p2,$i;
599 if ($main'aout) {
600 for ($p2=0;$val!=0;$val>>=1) { $p2++; }
601 $val=$p2-1;
602 $val.=",0x90";
603 }
604 push(@out,".align\t$val\n");
605 }
606
607 # debug output functions: puts, putx, printf
608
609 sub main'puts
610 {
611 &pushvars();
612 &main'push('$Lstring' . ++$constl);
613 &main'call('puts');
614 $stack-=4;
615 &main'add("esp",4);
616 &popvars();
617
618 $const .= "Lstring$constl:\n\t.string \"@_[0]\"\n";
619 }
620
621 sub main'putx
622 {
623 &pushvars();
624 &main'push($_[0]);
625 &main'push('$Lstring' . ++$constl);
626 &main'call('printf');
627 &main'add("esp",8);
628 $stack-=8;
629 &popvars();
630
631 $const .= "Lstring$constl:\n\t.string \"\%X\"\n";
632 }
633
634 sub main'printf
635 {
636 $ostack = $stack;
637 &pushvars();
638 for ($i = @_ - 1; $i >= 0; $i--)
639 {
640 if ($i == 0) # change this to support %s format strings
641 {
642 &main'push('$Lstring' . ++$constl);
643 $const .= "Lstring$constl:\n\t.string \"@_[$i]\"\n";
644 }
645 else
646 {
647 if ($_[$i] =~ /([0-9]*)\(%esp\)/)
648 {
649 &main'push(($1 + $stack - $ostack) . '(%esp)');
650 }
651 else
652 {
653 &main'push($_[$i]);
654 }
655 }
656 }
657 &main'call('printf');
658 $stack-=4*@_;
659 &main'add("esp",4*@_);
660 &popvars();
661 }
662
663 sub pushvars
664 {
665 &main'pushf();
666 &main'push("edx");
667 &main'push("ecx");
668 &main'push("eax");
669 }
670
671 sub popvars
672 {
673 &main'pop("eax");
674 &main'pop("ecx");
675 &main'pop("edx");
676 &main'popf();
677 }
678
679 sub main'picmeup
680 {
681 local($dst,$sym)=@_;
682 if ($main'cpp)
683 {
684 local($tmp)=<<___;
685 #if (defined(ELF) || defined(SOL)) && defined(PIC)
686 call 1f
687 1: popl $regs{$dst}
688 addl \$_GLOBAL_OFFSET_TABLE_+[.-1b],$regs{$dst}
689 movl $sym\@GOT($regs{$dst}),$regs{$dst}
690 #else
691 leal $sym,$regs{$dst}
692 #endif
693 ___
694 push(@out,$tmp);
695 }
696 elsif ($main'pic && ($main'elf || $main'aout))
697 {
698 &main'call(&main'label("PIC_me_up"));
699 &main'set_label("PIC_me_up");
700 &main'blindpop($dst);
701 &main'add($dst,"\$${under}_GLOBAL_OFFSET_TABLE_+[.-".
702 &main'label("PIC_me_up") . "]");
703 &main'mov($dst,&main'DWP($under.$sym."\@GOT",$dst));
704 }
705 else
706 {
707 &main'lea($dst,&main'DWP($sym));
708 }
709 }
710
711 sub main'blindpop { &out1("popl",@_); }
712
713 sub main'initseg
714 {
715 local($f)=@_;
716 local($tmp);
717 if ($main'elf)
718 {
719 $tmp=<<___;
720 .section .init
721 call $under$f
722 jmp .Linitalign
723 .align $align
724 .Linitalign:
725 ___
726 }
727 elsif ($main'coff)
728 {
729 $tmp=<<___; # applies to both Cygwin and Mingw
730 .section .ctors
731 .long $under$f
732 ___
733 }
734 elsif ($main'aout)
735 {
736 local($ctor)="${under}_GLOBAL_\$I\$$f";
737 $tmp=".text\n";
738 $tmp.=".type $ctor,\@function\n" if ($main'pic);
739 $tmp.=<<___; # OpenBSD way...
740 .globl $ctor
741 .align 2
742 $ctor:
743 jmp $under$f
744 ___
745 }
746 push(@out,$tmp) if ($tmp);
747 }
748
749 1;
750


Thu Aug 20, 2009 5:47 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
1 #!./perl -w
2
3 BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require './test.pl';
7 }
8
9 plan tests => 7 + 256;
10
11 is(
12 sprintf("%.40g ",0.01),
13 sprintf("%.40g", 0.01)." ",
14 q(the sprintf "%.<number>g" optimization)
15 );
16 is(
17 sprintf("%.40f ",0.01),
18 sprintf("%.40f", 0.01)." ",
19 q(the sprintf "%.<number>f" optimization)
20 );
21 {
22 chop(my $utf8_format = "%-3s\x{100}");
23 is(
24 sprintf($utf8_format, "\xe4"),
25 "\xe4 ",
26 q(width calculation under utf8 upgrade)
27 );
28 }
29
30 # Used to mangle PL_sv_undef
31 fresh_perl_is(
32 'print sprintf "xxx%n\n"; print undef',
33 'Modification of a read-only value attempted at - line 1.',
34 { switches => [ '-w' ] },
35 q(%n should not be able to modify read-only constants),
36 );
37
38 # check %NNN$ for range bounds, especially negative 2's complement
39
40 {
41 my ($warn, $bad) = (0,0);
42 local $SIG{__WARN__} = sub {
43 if ($_[0] =~ /uninitialized/) {
44 $warn++
45 }
46 else {
47 $bad++
48 }
49 };
50 my $result = sprintf join('', map("%$_\$s%" . ~$_ . '$s', 1..20)),
51 qw(a b c d);
52 is($result, "abcd", "only four valid values");
53 is($warn, 36, "expected warnings");
54 is($bad, 0, "unexpected warnings");
55 }
56
57 {
58 foreach my $ord (0 .. 255) {
59 my $bad = 0;
60 local $SIG{__WARN__} = sub {
61 unless ($_[0] =~ /^Invalid conversion in sprintf/ ||
62 $_[0] =~ /^Use of uninitialized value in sprintf/) {
63 warn $_[0];
64 $bad++;
65 }
66 };
67 my $r = eval {sprintf '%v' . chr $ord};
68 is ($bad, 0, "pattern '%v' . chr $ord");
69 }
70 }
71


Thu Aug 20, 2009 5:48 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
1 #!./perl
2
3 BEGIN {
4 chdir 't' if -d 't';
5 @INC = qw(../lib .);
6 require Config; import Config;
7 require "test.pl";
8 }
9
10 plan tests => 22;
11
12 if ($Config{ebcdic} eq 'define') {
13 $_ = join "", map chr($_), 129..233;
14
15 # 105 characters - 52 letters = 53 backslashes
16 # 105 characters + 53 backslashes = 158 characters
17 $_ = quotemeta $_;
18 is(length($_), 158, "quotemeta string");
19 # 104 non-backslash characters
20 is(tr/\\//cd, 104, "tr count non-backslashed");
21 } else { # some ASCII descendant, then.
22 $_ = join "", map chr($_), 32..127;
23
24 # 96 characters - 52 letters - 10 digits - 1 underscore = 33 backslashes
25 # 96 characters + 33 backslashes = 129 characters
26 $_ = quotemeta $_;
27 is(length($_), 129, "quotemeta string");
28 # 95 non-backslash characters
29 is(tr/\\//cd, 95, "tr count non-backslashed");
30 }
31
32 is(length(quotemeta ""), 0, "quotemeta empty string");
33
34 is("aA\UbB\LcC\EdD", "aABBccdD", 'aA\UbB\LcC\EdD');
35 is("aA\LbB\UcC\EdD", "aAbbCCdD", 'aA\LbB\UcC\EdD');
36 is("\L\upERL", "Perl", '\L\upERL');
37 is("\u\LpERL", "Perl", '\u\LpERL');
38 is("\U\lPerl", "pERL", '\U\lPerl');
39 is("\l\UPerl", "pERL", '\l\UPerl');
40 is("\u\LpE\Q#X#\ER\EL", "Pe\\#x\\#rL", '\u\LpE\Q#X#\ER\EL');
41 is("\l\UPe\Q!x!\Er\El", "pE\\!X\\!Rl", '\l\UPe\Q!x!\Er\El');
42 is("\Q\u\LpE.X.R\EL\E.", "Pe\\.x\\.rL.", '\Q\u\LpE.X.R\EL\E.');
43 is("\Q\l\UPe*x*r\El\E*", "pE\\*X\\*Rl*", '\Q\l\UPe*x*r\El\E*');
44 is("\U\lPerl\E\E\E\E", "pERL", '\U\lPerl\E\E\E\E');
45 is("\l\UPerl\E\E\E\E", "pERL", '\l\UPerl\E\E\E\E');
46
47 is(quotemeta("\x{263a}"), "\x{263a}", "quotemeta Unicode");
48 is(length(quotemeta("\x{263a}")), 1, "quotemeta Unicode length");
49
50 $a = "foo|bar";
51 is("a\Q\Ec$a", "acfoo|bar", '\Q\E');
52 is("a\L\Ec$a", "acfoo|bar", '\L\E');
53 is("a\l\Ec$a", "acfoo|bar", '\l\E');
54 is("a\U\Ec$a", "acfoo|bar", '\U\E');
55 is("a\u\Ec$a", "acfoo|bar", '\u\E');
56


Thu Aug 20, 2009 5:48 pm
Profile WWW
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 1075 posts ]  Go to page Previous  1 ... 31, 32, 33, 34, 35, 36, 37 ... 72  Next

Who is online

Users browsing this forum: No registered users and 20 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.