multiply_and_divide.py (6463:fe6165923529) | multiply_and_divide.py (6485:4f70960761cd) |
---|---|
1# Copyright (c) 2007 The Hewlett-Packard Development Company 2# All rights reserved. 3# 4# Redistribution and use of this software in source and binary forms, 5# with or without modification, are permitted provided that the 6# following conditions are met: 7# 8# The software must be used only for Non-Commercial Use which means any --- 374 unchanged lines hidden (view full) --- 383{ 384 # Negate dividend 385 sub t1, t0, rax, flags=(ECF,), dataSize=1 386 ruflag t4, 3 387 sub t2, t0, ah, dataSize=1 388 sub t2, t2, t4 389 390 #Find the sign of the divisor | 1# Copyright (c) 2007 The Hewlett-Packard Development Company 2# All rights reserved. 3# 4# Redistribution and use of this software in source and binary forms, 5# with or without modification, are permitted provided that the 6# following conditions are met: 7# 8# The software must be used only for Non-Commercial Use which means any --- 374 unchanged lines hidden (view full) --- 383{ 384 # Negate dividend 385 sub t1, t0, rax, flags=(ECF,), dataSize=1 386 ruflag t4, 3 387 sub t2, t0, ah, dataSize=1 388 sub t2, t2, t4 389 390 #Find the sign of the divisor |
391 #FIXME!!! This depends on shifts setting the carry flag correctly. | |
392 slli t0, reg, 1, flags=(ECF,), dataSize=1 393 394 # Negate divisor 395 sub t3, t0, reg, dataSize=1 396 # Put the divisor's absolute value into t3 397 mov t3, t3, reg, flags=(nCECF,), dataSize=1 398 399 #Find the sign of the dividend | 391 slli t0, reg, 1, flags=(ECF,), dataSize=1 392 393 # Negate divisor 394 sub t3, t0, reg, dataSize=1 395 # Put the divisor's absolute value into t3 396 mov t3, t3, reg, flags=(nCECF,), dataSize=1 397 398 #Find the sign of the dividend |
400 #FIXME!!! This depends on shifts setting the carry flag correctly. | |
401 slli t0, ah, 1, flags=(ECF,), dataSize=1 402 403 # Put the dividend's absolute value into t1 and t2 404 mov t1, t1, rax, flags=(nCECF,), dataSize=1 405 mov t2, t2, ah, flags=(nCECF,), dataSize=1 406 407 # Do the initial part of the division 408 div1 t2, t3, dataSize=1 --- 26 unchanged lines hidden (view full) --- 435 mov ah, ah, t6, (nCECF,), dataSize=1 436 437 # Negate the quotient. 438 sub t4, t0, t5, dataSize=1 439 # If the dividend was negative, start using the negated quotient 440 mov t5, t5, t4, (CECF,), dataSize=1 441 442 # Check the sign of the divisor | 399 slli t0, ah, 1, flags=(ECF,), dataSize=1 400 401 # Put the dividend's absolute value into t1 and t2 402 mov t1, t1, rax, flags=(nCECF,), dataSize=1 403 mov t2, t2, ah, flags=(nCECF,), dataSize=1 404 405 # Do the initial part of the division 406 div1 t2, t3, dataSize=1 --- 26 unchanged lines hidden (view full) --- 433 mov ah, ah, t6, (nCECF,), dataSize=1 434 435 # Negate the quotient. 436 sub t4, t0, t5, dataSize=1 437 # If the dividend was negative, start using the negated quotient 438 mov t5, t5, t4, (CECF,), dataSize=1 439 440 # Check the sign of the divisor |
443 slli t0, t3, 1, flags=(ECF,), dataSize=1 | 441 slli t0, reg, 1, flags=(ECF,), dataSize=1 |
444 445 # Negate the (possibly already negated) quotient 446 sub t4, t0, t5, dataSize=1 447 # If the divisor was negative, put the negated quotient in rax. 448 mov rax, rax, t4, (CECF,), dataSize=1 449 # Otherwise put the one that wasn't negated (at least here) in rax. 450 mov rax, rax, t5, (nCECF,), dataSize=1 451}; 452 453def macroop IDIV_B_M 454{ 455 # Negate dividend 456 sub t1, t0, rax, flags=(ECF,), dataSize=1 457 ruflag t4, 3 458 sub t2, t0, ah, dataSize=1 459 sub t2, t2, t4 460 | 442 443 # Negate the (possibly already negated) quotient 444 sub t4, t0, t5, dataSize=1 445 # If the divisor was negative, put the negated quotient in rax. 446 mov rax, rax, t4, (CECF,), dataSize=1 447 # Otherwise put the one that wasn't negated (at least here) in rax. 448 mov rax, rax, t5, (nCECF,), dataSize=1 449}; 450 451def macroop IDIV_B_M 452{ 453 # Negate dividend 454 sub t1, t0, rax, flags=(ECF,), dataSize=1 455 ruflag t4, 3 456 sub t2, t0, ah, dataSize=1 457 sub t2, t2, t4 458 |
461 ld t3, seg, sib, disp | 459 ld t8, seg, sib, disp |
462 463 #Find the sign of the divisor | 460 461 #Find the sign of the divisor |
464 #FIXME!!! This depends on shifts setting the carry flag correctly. | |
465 slli t0, t3, 1, flags=(ECF,), dataSize=1 466 467 # Negate divisor | 462 slli t0, t3, 1, flags=(ECF,), dataSize=1 463 464 # Negate divisor |
468 sub t4, t0, t3, dataSize=1 | 465 sub t3, t0, t8, dataSize=1 |
469 # Put the divisor's absolute value into t3 | 466 # Put the divisor's absolute value into t3 |
470 mov t3, t3, t4, flags=(CECF,), dataSize=1 | 467 mov t3, t3, t8, flags=(nCECF,), dataSize=1 |
471 472 #Find the sign of the dividend | 468 469 #Find the sign of the dividend |
473 #FIXME!!! This depends on shifts setting the carry flag correctly. | |
474 slli t0, ah, 1, flags=(ECF,), dataSize=1 475 476 # Put the dividend's absolute value into t1 and t2 477 mov t1, t1, rax, flags=(nCECF,), dataSize=1 478 mov t2, t2, ah, flags=(nCECF,), dataSize=1 479 480 # Do the initial part of the division 481 div1 t2, t3, dataSize=1 --- 26 unchanged lines hidden (view full) --- 508 mov ah, ah, t6, (nCECF,), dataSize=1 509 510 # Negate the quotient. 511 sub t4, t0, t5, dataSize=1 512 # If the dividend was negative, start using the negated quotient 513 mov t5, t5, t4, (CECF,), dataSize=1 514 515 # Check the sign of the divisor | 470 slli t0, ah, 1, flags=(ECF,), dataSize=1 471 472 # Put the dividend's absolute value into t1 and t2 473 mov t1, t1, rax, flags=(nCECF,), dataSize=1 474 mov t2, t2, ah, flags=(nCECF,), dataSize=1 475 476 # Do the initial part of the division 477 div1 t2, t3, dataSize=1 --- 26 unchanged lines hidden (view full) --- 504 mov ah, ah, t6, (nCECF,), dataSize=1 505 506 # Negate the quotient. 507 sub t4, t0, t5, dataSize=1 508 # If the dividend was negative, start using the negated quotient 509 mov t5, t5, t4, (CECF,), dataSize=1 510 511 # Check the sign of the divisor |
516 slli t0, t3, 1, flags=(ECF,), dataSize=1 | 512 slli t0, t8, 1, flags=(ECF,), dataSize=1 |
517 518 # Negate the (possibly already negated) quotient 519 sub t4, t0, t5, dataSize=1 520 # If the divisor was negative, put the negated quotient in rax. 521 mov rax, rax, t4, (CECF,), dataSize=1 522 # Otherwise put the one that wasn't negated (at least here) in rax. 523 mov rax, rax, t5, (nCECF,), dataSize=1 524}; 525 526def macroop IDIV_B_P 527{ 528 # Negate dividend 529 sub t1, t0, rax, flags=(ECF,), dataSize=1 530 ruflag t4, 3 531 sub t2, t0, ah, dataSize=1 532 sub t2, t2, t4 533 534 rdip t7 | 513 514 # Negate the (possibly already negated) quotient 515 sub t4, t0, t5, dataSize=1 516 # If the divisor was negative, put the negated quotient in rax. 517 mov rax, rax, t4, (CECF,), dataSize=1 518 # Otherwise put the one that wasn't negated (at least here) in rax. 519 mov rax, rax, t5, (nCECF,), dataSize=1 520}; 521 522def macroop IDIV_B_P 523{ 524 # Negate dividend 525 sub t1, t0, rax, flags=(ECF,), dataSize=1 526 ruflag t4, 3 527 sub t2, t0, ah, dataSize=1 528 sub t2, t2, t4 529 530 rdip t7 |
535 ld t3, seg, riprel, disp | 531 ld t8, seg, riprel, disp |
536 537 #Find the sign of the divisor | 532 533 #Find the sign of the divisor |
538 #FIXME!!! This depends on shifts setting the carry flag correctly. | |
539 slli t0, t3, 1, flags=(ECF,), dataSize=1 540 541 # Negate divisor | 534 slli t0, t3, 1, flags=(ECF,), dataSize=1 535 536 # Negate divisor |
542 sub t4, t0, t3, dataSize=1 | 537 sub t3, t0, t8, dataSize=1 |
543 # Put the divisor's absolute value into t3 | 538 # Put the divisor's absolute value into t3 |
544 mov t3, t3, t4, flags=(CECF,), dataSize=1 | 539 mov t3, t3, t8, flags=(nCECF,), dataSize=1 |
545 546 #Find the sign of the dividend | 540 541 #Find the sign of the dividend |
547 #FIXME!!! This depends on shifts setting the carry flag correctly. | |
548 slli t0, ah, 1, flags=(ECF,), dataSize=1 549 550 # Put the dividend's absolute value into t1 and t2 551 mov t1, t1, rax, flags=(nCECF,), dataSize=1 552 mov t2, t2, ah, flags=(nCECF,), dataSize=1 553 554 # Do the initial part of the division 555 div1 t2, t3, dataSize=1 --- 26 unchanged lines hidden (view full) --- 582 mov ah, ah, t6, (nCECF,), dataSize=1 583 584 # Negate the quotient. 585 sub t4, t0, t5, dataSize=1 586 # If the dividend was negative, start using the negated quotient 587 mov t5, t5, t4, (CECF,), dataSize=1 588 589 # Check the sign of the divisor | 542 slli t0, ah, 1, flags=(ECF,), dataSize=1 543 544 # Put the dividend's absolute value into t1 and t2 545 mov t1, t1, rax, flags=(nCECF,), dataSize=1 546 mov t2, t2, ah, flags=(nCECF,), dataSize=1 547 548 # Do the initial part of the division 549 div1 t2, t3, dataSize=1 --- 26 unchanged lines hidden (view full) --- 576 mov ah, ah, t6, (nCECF,), dataSize=1 577 578 # Negate the quotient. 579 sub t4, t0, t5, dataSize=1 580 # If the dividend was negative, start using the negated quotient 581 mov t5, t5, t4, (CECF,), dataSize=1 582 583 # Check the sign of the divisor |
590 slli t0, t3, 1, flags=(ECF,), dataSize=1 | 584 slli t0, t8, 1, flags=(ECF,), dataSize=1 |
591 592 # Negate the (possibly already negated) quotient 593 sub t4, t0, t5, dataSize=1 594 # If the divisor was negative, put the negated quotient in rax. 595 mov rax, rax, t4, (CECF,), dataSize=1 596 # Otherwise put the one that wasn't negated (at least here) in rax. 597 mov rax, rax, t5, (nCECF,), dataSize=1 598}; --- 6 unchanged lines hidden (view full) --- 605{ 606 # Negate dividend 607 sub t1, t0, rax, flags=(ECF,) 608 ruflag t4, 3 609 sub t2, t0, rdx 610 sub t2, t2, t4 611 612 #Find the sign of the divisor | 585 586 # Negate the (possibly already negated) quotient 587 sub t4, t0, t5, dataSize=1 588 # If the divisor was negative, put the negated quotient in rax. 589 mov rax, rax, t4, (CECF,), dataSize=1 590 # Otherwise put the one that wasn't negated (at least here) in rax. 591 mov rax, rax, t5, (nCECF,), dataSize=1 592}; --- 6 unchanged lines hidden (view full) --- 599{ 600 # Negate dividend 601 sub t1, t0, rax, flags=(ECF,) 602 ruflag t4, 3 603 sub t2, t0, rdx 604 sub t2, t2, t4 605 606 #Find the sign of the divisor |
613 #FIXME!!! This depends on shifts setting the carry flag correctly. | |
614 slli t0, reg, 1, flags=(ECF,) 615 616 # Negate divisor 617 sub t3, t0, reg 618 # Put the divisor's absolute value into t3 619 mov t3, t3, reg, flags=(nCECF,) 620 621 #Find the sign of the dividend | 607 slli t0, reg, 1, flags=(ECF,) 608 609 # Negate divisor 610 sub t3, t0, reg 611 # Put the divisor's absolute value into t3 612 mov t3, t3, reg, flags=(nCECF,) 613 614 #Find the sign of the dividend |
622 #FIXME!!! This depends on shifts setting the carry flag correctly. | |
623 slli t0, rdx, 1, flags=(ECF,) 624 625 # Put the dividend's absolute value into t1 and t2 626 mov t1, t1, rax, flags=(nCECF,) 627 mov t2, t2, rdx, flags=(nCECF,) 628 629 # Do the initial part of the division 630 div1 t2, t3 --- 28 unchanged lines hidden (view full) --- 659 mov rdx, rdx, t6, (nCECF,) 660 661 # Negate the quotient. 662 sub t4, t0, t5 663 # If the dividend was negative, start using the negated quotient 664 mov t5, t5, t4, (CECF,) 665 666 # Check the sign of the divisor | 615 slli t0, rdx, 1, flags=(ECF,) 616 617 # Put the dividend's absolute value into t1 and t2 618 mov t1, t1, rax, flags=(nCECF,) 619 mov t2, t2, rdx, flags=(nCECF,) 620 621 # Do the initial part of the division 622 div1 t2, t3 --- 28 unchanged lines hidden (view full) --- 651 mov rdx, rdx, t6, (nCECF,) 652 653 # Negate the quotient. 654 sub t4, t0, t5 655 # If the dividend was negative, start using the negated quotient 656 mov t5, t5, t4, (CECF,) 657 658 # Check the sign of the divisor |
667 slli t0, t3, 1, flags=(ECF,) | 659 slli t0, reg, 1, flags=(ECF,) |
668 669 # Negate the (possibly already negated) quotient 670 sub t4, t0, t5 671 # If the divisor was negative, put the negated quotient in rax. 672 mov rax, rax, t4, (CECF,) 673 # Otherwise put the one that wasn't negated (at least here) in rax. 674 mov rax, rax, t5, (nCECF,) 675}; 676 677def macroop IDIV_M 678{ 679 # Negate dividend 680 sub t1, t0, rax, flags=(ECF,) 681 ruflag t4, 3 682 sub t2, t0, rdx 683 sub t2, t2, t4 684 | 660 661 # Negate the (possibly already negated) quotient 662 sub t4, t0, t5 663 # If the divisor was negative, put the negated quotient in rax. 664 mov rax, rax, t4, (CECF,) 665 # Otherwise put the one that wasn't negated (at least here) in rax. 666 mov rax, rax, t5, (nCECF,) 667}; 668 669def macroop IDIV_M 670{ 671 # Negate dividend 672 sub t1, t0, rax, flags=(ECF,) 673 ruflag t4, 3 674 sub t2, t0, rdx 675 sub t2, t2, t4 676 |
685 ld t3, seg, sib, disp | 677 ld t8, seg, sib, disp |
686 687 #Find the sign of the divisor 688 #FIXME!!! This depends on shifts setting the carry flag correctly. 689 slli t0, t3, 1, flags=(ECF,) 690 691 # Negate divisor | 678 679 #Find the sign of the divisor 680 #FIXME!!! This depends on shifts setting the carry flag correctly. 681 slli t0, t3, 1, flags=(ECF,) 682 683 # Negate divisor |
692 sub t4, t0, t3 | 684 sub t3, t0, t8 |
693 # Put the divisor's absolute value into t3 | 685 # Put the divisor's absolute value into t3 |
694 mov t3, t3, t4, flags=(CECF,) | 686 mov t3, t3, t8, flags=(nCECF,) |
695 696 #Find the sign of the dividend 697 #FIXME!!! This depends on shifts setting the carry flag correctly. 698 slli t0, rdx, 1, flags=(ECF,) 699 700 # Put the dividend's absolute value into t1 and t2 701 mov t1, t1, rax, flags=(nCECF,) 702 mov t2, t2, rdx, flags=(nCECF,) --- 31 unchanged lines hidden (view full) --- 734 mov rdx, rdx, t6, (nCECF,) 735 736 # Negate the quotient. 737 sub t4, t0, t5 738 # If the dividend was negative, start using the negated quotient 739 mov t5, t5, t4, (CECF,) 740 741 # Check the sign of the divisor | 687 688 #Find the sign of the dividend 689 #FIXME!!! This depends on shifts setting the carry flag correctly. 690 slli t0, rdx, 1, flags=(ECF,) 691 692 # Put the dividend's absolute value into t1 and t2 693 mov t1, t1, rax, flags=(nCECF,) 694 mov t2, t2, rdx, flags=(nCECF,) --- 31 unchanged lines hidden (view full) --- 726 mov rdx, rdx, t6, (nCECF,) 727 728 # Negate the quotient. 729 sub t4, t0, t5 730 # If the dividend was negative, start using the negated quotient 731 mov t5, t5, t4, (CECF,) 732 733 # Check the sign of the divisor |
742 slli t0, t3, 1, flags=(ECF,) | 734 slli t0, t8, 1, flags=(ECF,) |
743 744 # Negate the (possibly already negated) quotient 745 sub t4, t0, t5 746 # If the divisor was negative, put the negated quotient in rax. 747 mov rax, rax, t4, (CECF,) 748 # Otherwise put the one that wasn't negated (at least here) in rax. 749 mov rax, rax, t5, (nCECF,) 750}; 751 752def macroop IDIV_P 753{ 754 # Negate dividend 755 sub t1, t0, rax, flags=(ECF,) 756 ruflag t4, 3 757 sub t2, t0, rdx 758 sub t2, t2, t4 759 760 rdip t7 | 735 736 # Negate the (possibly already negated) quotient 737 sub t4, t0, t5 738 # If the divisor was negative, put the negated quotient in rax. 739 mov rax, rax, t4, (CECF,) 740 # Otherwise put the one that wasn't negated (at least here) in rax. 741 mov rax, rax, t5, (nCECF,) 742}; 743 744def macroop IDIV_P 745{ 746 # Negate dividend 747 sub t1, t0, rax, flags=(ECF,) 748 ruflag t4, 3 749 sub t2, t0, rdx 750 sub t2, t2, t4 751 752 rdip t7 |
761 ld t3, seg, riprel, disp | 753 ld t8, seg, riprel, disp |
762 763 #Find the sign of the divisor 764 #FIXME!!! This depends on shifts setting the carry flag correctly. 765 slli t0, t3, 1, flags=(ECF,) 766 767 # Negate divisor | 754 755 #Find the sign of the divisor 756 #FIXME!!! This depends on shifts setting the carry flag correctly. 757 slli t0, t3, 1, flags=(ECF,) 758 759 # Negate divisor |
768 sub t4, t0, t3 | 760 sub t3, t0, t8 |
769 # Put the divisor's absolute value into t3 | 761 # Put the divisor's absolute value into t3 |
770 mov t3, t3, t4, flags=(CECF,) | 762 mov t3, t3, t4, flags=(nCECF,) |
771 772 #Find the sign of the dividend 773 #FIXME!!! This depends on shifts setting the carry flag correctly. 774 slli t0, rdx, 1, flags=(ECF,) 775 776 # Put the dividend's absolute value into t1 and t2 777 mov t1, t1, rax, flags=(nCECF,) 778 mov t2, t2, rdx, flags=(nCECF,) --- 31 unchanged lines hidden (view full) --- 810 mov rdx, rdx, t6, (nCECF,) 811 812 # Negate the quotient. 813 sub t4, t0, t5 814 # If the dividend was negative, start using the negated quotient 815 mov t5, t5, t4, (CECF,) 816 817 # Check the sign of the divisor | 763 764 #Find the sign of the dividend 765 #FIXME!!! This depends on shifts setting the carry flag correctly. 766 slli t0, rdx, 1, flags=(ECF,) 767 768 # Put the dividend's absolute value into t1 and t2 769 mov t1, t1, rax, flags=(nCECF,) 770 mov t2, t2, rdx, flags=(nCECF,) --- 31 unchanged lines hidden (view full) --- 802 mov rdx, rdx, t6, (nCECF,) 803 804 # Negate the quotient. 805 sub t4, t0, t5 806 # If the dividend was negative, start using the negated quotient 807 mov t5, t5, t4, (CECF,) 808 809 # Check the sign of the divisor |
818 slli t0, t3, 1, flags=(ECF,) | 810 slli t0, t8, 1, flags=(ECF,) |
819 820 # Negate the (possibly already negated) quotient 821 sub t4, t0, t5 822 # If the divisor was negative, put the negated quotient in rax. 823 mov rax, rax, t4, (CECF,) 824 # Otherwise put the one that wasn't negated (at least here) in rax. 825 mov rax, rax, t5, (nCECF,) 826}; 827''' | 811 812 # Negate the (possibly already negated) quotient 813 sub t4, t0, t5 814 # If the divisor was negative, put the negated quotient in rax. 815 mov rax, rax, t4, (CECF,) 816 # Otherwise put the one that wasn't negated (at least here) in rax. 817 mov rax, rax, t5, (nCECF,) 818}; 819''' |