assemblyhla

Code isn't jumping correctly


I'm currently trying to do my assignment but I'm having some issues.

This is the assignment

https://i.sstatic.net/7KRAL.png enter image description here

As it is right now, When I put 'CC' I only get back

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

When I should be getting back

Feed me(2 hex digits with the bits prsseeee): CC 
Fall Semester 
12 units 
CA Resident 
Parking 
Total Fees = $ 688

Here is what I've done so far.

I'm also only allowed to use

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

so far

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;

Solution

  • I think you had a few errors:

    Learning to handle binary values is initially un-intuitive.

    These are pretty typical errors of green assembly language programmers. Getting past them to a running program really helps build confidence. Do a lot more of this, you'll be pretty good at it.

    Learn to mentally simulate your code. This pays off like gold.