我目前正在尝试完成我的任务,但我遇到了一些问题。

这是任务

https://i.imgur.com/UfilSVp.png
assembly - 代码跳转不正确-LMLPHP

就像现在一样,当我放“CC”时,我只会回来

Feed me(2 hex digits with the bits prsseeee):CC
Fall Semester
Total Fees = $ 97

我应该什么时候回来
Feed me(2 hex digits with the bits prsseeee): CC
Fall Semester
12 units
CA Resident
Parking
Total Fees = $ 688

这是我到目前为止所做的。

我也只能使用

** http://homepage.smc.edu/stahl_howard/cs17/FileManager/referenceguides/referenceguideiv.htm

到目前为止
program SMCFee;
    #include( "stdlib.hhf" );
    static
        total : int32 := 0;

begin SMCFee;

    stdout.put("Feed me(2 hex digits with the bits prsseeee):" );
    stdin.get(BL);

    ror(4, BL);
    and(%0000011, BL);

    cmp(BL, %00);
    je Fall;
    cmp(BL, %01);
    je Winter;
    cmp(BL, %10);
    je Spring;
    cmp(BL, %11);
    je Summer;

    Fall:
        stdout.put("Fall Semester",nl);
        add(50, total);
        ror(1, BL);
        and(%0000001, BL);
        cmp(BL, 0);
        je NoFallResident;
        cmp(BL, 1);
        je FallResident;
            FallResident:

                rol(6, BL);
                and(%00001111, BL);
                mov(BL, AL);
                stdout.put(AL,nl);
                stdout.put("CA Resident");
                FallUnitCheck:
                cmp(AL, 0);
                jle FallParkingCheck;
                add(46, total);
                dec(AL);
                jmp FallUnitCheck;
                    FallParkingCheck:
                        ror(7, BL);
                        and(%0000001, BL);
                        cmp(BL, 0);
                        je NoFallResidentParking;
                        cmp(BL, 1);
                        je FallResidentParking;
                        FallResidentParking:
                            stdout.put("Parking",nl);
                            add(85, total);
                            jmp zend;
                        NoFallResidentParking:
                            jmp zend;
            NoFallResident:
                ror(1, BL);
                and(%0000001, BL);
                cmp(BL, 0);
                je FallNoResidentParking;
                cmp(BL, 1);
                je NoFallNoResidentParking;
                    FallNoResidentParking:
                    NoFallNoResidentParking:


    Winter:
        add(47, total);
        jmp zend;


    Spring:
        add(47, total);
        jmp zend;


    Summer:
        add(50, total);
        jmp zend;

    zend:
        stdout.put("Total Fees = $ ",total);
end SMCFee;

最佳答案

我认为你有几个错误:

  • 错误的基数前缀 [@Fifoernik 指出]
  • 错位的 JMP 指令
  • 对 AND 如何用于“屏蔽”的误解
  • 屏蔽后输入数据的损失。

  • 学习处理二进制值最初是不直观的。

    这些是绿色汇编语言程序员的典型错误。
    让他们通过一个正在运行的程序确实有助于建立信心。
    多做这些,你会很擅长的。

    学习在心理上模拟你的代码。这会像金子一样得到返回。

    关于assembly - 代码跳转不正确,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34961558/

    10-11 22:39
    查看更多