DOT: LXI D,TENSTABL ; POINTER :=addr (TENSTABL); PUSH D ; STACK := POINTER; MVI C,1 ; NONZERO := 1; MOV A,H ; A := ANSWER; RAL ; is ANSWER negative? JNC DOTPOSIT ; if not then go to positive routine; MOV A,L ; \ CMA ; > ANSWER :=- ANSWER - 1 [low order]; MOV L,A ; / MOV A,H ; \ CMA ; > ANSWER :- -ANSWER - 1 [high order]; MOV H,A ; / INX H ; ANSWER := (-ANSWER-1) + 1; MVI A,'-' ; A := '-' [ASCII leading minus]; CALL PUT ; OUTPUT := A [display minus sign]; DOTPOSIT:XTHL ; exchange POINTER and ANSWER; MOV E,M ; TEMP := M(POINTER) [low order]; INX H ; POINTER := POINTER + 1; MOV D,M ; TEMP := M(POINTER) [high order]; INX H ; POINTER := POINTER +1; XTHL ; exchange ANSWER and POINTER; MVI B,0 ; VALUE ;-0; DOTDIVID:MOV A,L ; \ SUB E ; > ANSWER := ANSWER - TEMP [low Order]; MOV A,H ; / MOV A,H ; \ SBB D ; > ANSWER := ANSWER - TEMP [high order]; MOV H,A ; / JM DOTOUT ; if ANSWER LT 0 then go put eharacter; INR B ; VALUE := VALUE + 1; JMP DOTDIVID ; reiterate, counting in VALUE; DOTOUT: DAD D ; ANSWER := ANSWER + TEMP; XRA A ; A := 0; CARRY := 0; ORA B ; is VALUE = 0? JNZ DOTPRNT ; if not then go print it; ORA C ; is NON2ERO = 0 [leading zero test]; JNZ DOTBYPA ; if not then bypass leading zero print; DOTPRNT:ORI '0' ; A :* A OR '0' [convert VALUE to ASCII]; MVI C,0 ; NONZERO := 0 [reset zero flag]; CALL PUT ; OUTPUT := A [display ASCII digit]; DOTBYPA:MOV A,E ; A := TEMP [low order]; CPI 1 ; is TEMP = 1 [low order]? JNZ DOTPOSIT ; if not them reiterate; POP D ; else flush stack RET ; and return; TENSTABL:DW 10000 ; \ DW 1000 ; | define constants for the DW 100 ; > decimal division routine DW 10 ; | (note: low Order at low DW 1 ; / memory address for 8080);