Looks like some of the other comments here have found a few of the optimisations already, but another one is that BIOS functions don't change register values unless specifically used for output --- in HLL jargon, all registers are effectively callee-save. Thus no need to e.g. use 16-bit move immediate when an 8-bit would be sufficient due to the other half already having the right value.