Reading a little assembly

R-ASM-V4-2medium

Rebuild the flat-rate ceiling

A checkout service is replacing a platform-specific carrier-rate helper. Reconstruct these small helpers from the supplied reference release listings so the port keeps their returned values. In quote and capped commands, base is cents and pounds is a signed adjustment to billable pounds relative to that base quote, so a reweigh can make it negative. Inputs are between -1000000 and 1000000; all correct intermediate results fit signed 32-bit values. The program reads one well-formed command per line and prints one result. These are lesson-authored compiler artifacts, not a real vendor archive.

What needs to change

Rebuild cappedQuote so it returns what its reference listing computes.

Reproduce

  1. Run the sample with go run: capped 1000 30. Compare the printed number with the expected stdout, then try the fixtures above the ceiling.

Acceptance criteria

Your review marks · Saved in this browser. Test acceptance is tracked separately.

Notes

quote is supplied. The listing above cappedQuote was printed by go build -gcflags=-S (go1.27.3, arm64); its left column is the byte offset of each instruction.

Sign in to open this exercise

The ticket brief is public. Sign in to access the exercise. Paid exercises require Pro.

Sign in