シミュレーション

8ビットどうしの掛け算

2007年6月23日

新しいニーモニック表を用いたマシン語で、8ビットどうしの掛け算を行なった。このルーチンを汎用サブルーチンとしてメモリに確保しておき、これを利用する形で16ビットどうしの掛け算を行わせる予定。

void setRom(){
    int i;
    unsigned char data[256];
    char* asmdata[]={
        // Initialize when reset the computer
        "mov xh,0h",
        "mov xl,7h",
        "mov ss,x",
        "mov ds,x",
        "mov xh,fh",
        "mov xl,fh",
        "mov b2,x",
        "nop",
        "mov xh,6h",
        "mov xl,4h",
        "mov a1,x",
        "mov xh,6h",
        "mov xl,4h",
        "mov a2,x",
        "nop",
        "nop",

        // Begin the multiplying subroutine
        // Store b1/ss and initialize parameters
        "push b1",     //10
        "push ds", 
        "sub a1,a1",
        "mov ds,x",
        "mov xl,8h",
        "mov b1,x",
        "sub a1,a1",
        "mov [b2],x",
        "mov [b2-1],x",
        "mov [b2-3],x",
        "mov x,a2",         
        "mov [b2-2],x",

        // Main routine starts here
        // Shift a1 resister to right
        // Add a2 to data if required
        "mov x,[b2-2]", //1c
        "mov a2,x",
        "mov xh,2h",   
        "mov xl,fh",
        "shr a1",
        "if nc",
        "mov ip,x",
        "add a2,[b2]",
        "mov [b2],x",
        "mov x,[b2-1]",
        "if c",
        "inc x",
        "mov [b2-1],x",
        "mov x,[b2-3]",
        "mov a2,x",
        "dec ss:b2",
        "add a2,[b2]",
        "mov [b2],x",
        "inc ss:b2",

        // Shift a2 register to left
        "mov x,[b2-3]", //2f
        "mov a2,x",
        "shl a2",
        "mov x,a2",
        "mov [b2-3],x",
        "mov x,[b2-2]",
        "mov a2,x",
        "shl a2",
        "mov x,a2",
        "mov [b2-2],x",
        "mov x,[b2-3]",
        "if c",
        "inc x",
        "mov [b2-3],x",

        // Loop
        "mov xh,1h",   
        "mov xl,ch",
        "dec ds:b1",
        "if nz",
        "mov ip,x",

        // End
        "dec ss:b2",
        "dec ss:b2",
        "pop a1",
        "pop a2",
        "pop ds",
        "pop b1",
        "nop",
        "//",""};
    for (i=0;asmdata[i][0]!=0;i++) data[i]=assemble(asmdata[i]);
    memory.setSegment(0);
    for (i=0;i<256;i++) {
        memory.setAddr((unsigned char)i);
        memory.write(data[i]);
    }
    memory.setRom(0,255);
}

入力は、a1, a2 から行い、結果は a1, a2 に出力される。x レジスタとフラグは破壊される。

100 x 100 = 10000 (十進法で)となることを確認。

<%media(20070624-simulator.zip|simulator.zip)%>

コメント

pandora jewelry (2018年8月26日 03:59:07)

http://www.michaelkors-handbagss.us.com/ mk handbags
http://www.nikeair-max.co.uk/ nike air max
http://www.goyardbag.us.com/ goyard tote
http://www.fitflopsshoes.us.com/ fitflop sale
http://www.adidas-yeezyboost350.us.com/ yeezy
http://www.oakley--sunglassess.us.com/ oakley glasses
http://www.mulberrys.org.uk/ mulberry handbags
http://www.airmax270.co.uk/ nike air max 270
http://www.hermesbirkin-handbags.us.com/ Hermes Wallets
http://www.fitflop--shoes.us.com/ fitflop shoes
http://www.vapormaxs.us.com/ vapormax
http://www.burberry-bags.us.com/ burberry handbags
http://www.nikekdshoes.us.com/ nike kd
http://www.air-max-90.us.com/ nike air max 90
http://www.monclerjacket.org.uk/ moncler jacket mens
http://www.nike--shoes.co.uk/ nike air max
http://www.goyardbackpack.us.com/ goyard backpack
http://www.kd10-shoes.us.com/ kd 10
http://www.pumarihannafenty.us.com/ puma fenty
http://www.prada--handbags.us.com/ prada
http://www.barbours.org.uk/ barbour jacket
http://www.nikeairvapormaxflyknit.us.com/ vapormax
http://www.montblancs.us.com/ mont blanc pens
http://www.adidasoriginalsnmd.us.com/ adidas originals nmd
http://www.pandora-jewelrysale.us.com/ pandora jewelry
http://www.pandorauk.us.com/ pandora charms
http://www.ralphlauren--polo.us.com/ ralph lauren dresses
http://www.lebron15-shoes.us.com/ lebron shoes
http://www.barbourjackets.co.uk/ barbour outlet
http://www.polo-ralph-lauren.org.uk/ ralph lauren, polo
http://www.katespade--outlet.us.com/ kate spade purses
http://www.uggsformen.us.com/ uggs for men
http://www.adidas-ultraboost.us.com/ adidas ultra uncaged
http://www.jordan11spacejams.us.com/ space jam 11
http://www.airmax95.co.uk/ nike air max 95
http://www.burberrys.org.uk/ burberry purses
http://www.cartier-bracelet.us.com/ cartier
http://www.redbottom--shoes.us.com/ louboutin
http://www.pandorajewelryscharms.us.com/ pandora Charms
http://www.truereligion--jeans.us.com/ true religion jeans
http://www.airjordan11spacejam.us.com/ jordan 11
http://www.jordan--11.us.com/ jordan
http://www.swarovskisjewelry.us.com/ swarovski jewelry
http://www.kyrie-irving-shoes.us.com/ kyrie irving
http://www.uggs-forwomen.us.com/ uggs on sale
http://www.skecherss.us.com/ skechers shoes
http://www.ralphlaurenspoloshirts.us.com/ ralph lauren
http://www.ultra--boost.us.com/ adidas originals ultra boost
http://www.northface-jacket.us.com/ north face
http://www.under-armour-shoes.us.com/ under armour outlet
http://www.adidasoriginalsultraboost.us.com/ adidas ultra boost
http://www.ed-hardys.us.com/ ed hardy
http://www.prada--bags.us.com/ prada purse
http://www.adidas-yeezy-shoes.us.com/ Yeezy Boost 350 V2
http://www.fitflops-sale.us.com/ fitflop shoes
http://www.james-hardenshoes.us.com/ james harden
http://www.yeezyboost350v2.co.uk/ yeezy boost 350
http://www.eccoshoesoutlets.us.com/ ecco mens shoes
http://www.jimmychooheels.us.com/ jimmy choo trainers
http://www.nikeairmax97.co.uk/ nike air max 97
http://www.katespadepurses.us.com/ kate spade handbags
http://www.jordanretro11-shoes.us.com/ jordan
http://www.burberry--scarf.us.com/ burberry handbags
http://www.pandoras-uk.co.uk/ pandora charms
http://www.nikeair-max90.co.uk/ nike vapormax
http://www.rayban-glasses.us.com/ ray ban sunglasses
http://www.chrome--hearts.us.com/ chrome hearts bracelet
http://www.airmax-2018.us.com/ air max 90
http://www.adidasyeezys.org.uk/ adidas yeezy
http://www.nike--vapormax.us.com/ nike air vapormax
http://www.monclerjacketwomens.us.com/ moncler
http://www.bvlgaris.us.com/ bvlgari wallet
http://www.christianlouboutinredbottoms.us.com/ red bottom shoes
http://www.stephen-curry-shoes.us.com/ curry 4 shoes
http://www.fitflop--sandals.us.com/ fitflop sale
http://www.ferragamoshoess.us.com/ ferragamo shoes men
http://www.redbottoms-louboutin.us.com/ louboutin
http://www.salomon-boots.us.com/ salomon xa pro 3d
http://www.moncler--jacket.us.com/ moncler coat
http://www.nikeairmax270.org.uk/ nike air max 97
http://www.curry4-shoes.us.com/ curry shoes
http://www.supreme--clothing.us.com/ supreme shoes
http://www.chromeheartsjewelrys.us.com/ chrome hearts
http://www.new--balance.us.com/ new balance running shoes women
http://www.air-max-95.us.com/ air max 95 black
http://www.mcms.us.com/ mcm handbags
http://www.nikeairmax-95.us.com/ air max 95
http://www.salomonshoes.co.uk/ salomon
http://www.huaraches.us.com/ huaraches
http://www.hermes--belt.us.com/ hermes belt
http://www.kyrie-4.us.com/ kyrie irving shoes
http://www.coach--bags.us.com/ coach bags
http://www.louboutinredbottoms.us.com/ louboutin
http://www.northfacejacketoutlets.us.com/ womens north face jacket
http://www.pandoraearrings.us.com/ pandora rings
http://www.longchampbackpack.us.com/ longchamp bag
http://www.true--religion.us.com/ true religion jeans for women
http://www.oakley--glasses.us.com/ oakley sunglasses
http://www.adidasnmds.co.uk/ nmd
http://www.celines.us.com/ celine handbags
http://www.asics--shoes.us.com/ asics womens shoes
http://www.ugg--slippers.us.com/ ugg
http://www.nike-airmax-2018.us.com/ air max
http://www.jordan11.co.uk/ jordan retro
http://www.pandora--rings.us.com/ Pandora Charms
http://www.pandora-charmsjewelry.us.com/ pandora
http://www.nikeairmax-97.us.com/ air max 97
http://www.adidas-superstarshoes.us.com/ adidas superstar shoes
http://www.adidas--shoes.co.uk/ adidas
http://www.air-max-97.us.com/ air max 97 womens
http://www.moncler-coat.us.com/ moncler jacket mens
http://www.nikeairmax-90.us.com/ nike air max 90
http://www.skechers--shoes.us.com/ skechers women
http://www.polo-ralphlauren-outlet.us.com/ ralph lauren polo shirts
http://www.nikelebron15.us.com/ lebron james shoes
http://www.balenciagas-sneakers.us.com/ balenciaga
http://www.pandoras-jewelrys.us.com/ pandora earrings
http://www.valentino--shoes.us.com/ valentino
http://www.monclers.uk/ moncler jacket
http://www.monclerjacketmens.us.com/ moncler,moncler jacket
http://www.longchampbag.us.com/ longchamp backpack
http://www.michael-kors-bags.us.com/ michael kors bags
http://www.lacosteshirts.us.com/ lacoste
http://www.nike-airmax270.us.com/ air max
http://www.balenciaga--shoes.us.com/ balenciaga
http://www.airmax90shoes.us.com/ nike air max 90
http://www.birkenstocksandalssale.us.com/ birkenstock shoes
http://www.coachbags-outlet.us.com/ coach bags
http://www.pandora--jewelrys.us.com/ pandora jewelry
http://www.mulberry-handbags.us.com/ mulberry bag
http://www.yeezyboost350--v2.us.com/ yeezy shoes
http://www.salomon--shoes.us.com/ Salomon Speedcross 3
http://www.salvatore-ferragamo.us.com/ salvatore ferragamo
http://www.nike-huaraches.us.com/ nike huarache
http://www.uggs--boots.us.com/ ugg
http://www.ray--ban.us.com/ ray ban prescription sunglasses
http://www.asicss.us.com/ asics running shoes
http://www.ray--bansunglassess.us.com/ ray ban
http://www.chromehearts-jewelry.us.com/ chrome hearts sunglasses
http://www.kevin-durant-shoes.us.com/ kd 11
http://www.yeezyboost350shoes.us.com/ yeezy shoes
http://www.jordans11shoes.us.com/ jordan 11 space jam
http://www.rayban--glasses.us.com/ ray ban glasses
http://www.birkenstock--sandals.us.com/ birkenstock outlet
http://www.adidasnmd-womens.us.com/ adidas originals nmd
http://www.pandorajewelryrings.us.com/ pandora rings
http://www.pandorasjewelry.co.uk/ pandora jewelry
http://www.skechersuk.co.uk/ skechers for men
http://www.supremeshirt.us.com/ supreme clothing
http://www.adidasnmdrunnerr1.us.com/ didas ultra boost
http://www.mcm--bags.us.com/ mcm handbags
http://www.adidasyeezy-350.us.com/ adidas yeezy
http://www.swarovskis.us.com/ swarovski
http://www.salomonspeedcross3.us.com/ salomon xa pro 3d
http://www.mbts.us.com/ mbt mens shoes
http://www.air-max-270.us.com/ nike air max 270 men
http://www.katespadebags.us.com/ kate spade outlet
http://www.pandora-jewelrybracelet.us.com/ pandora rings
あって

コメント送信