dot: ld de,tenstabl ; POINTER :=addr (TENSTABL); push de ; STACK := POINTER; ld c,1 ; NONZERO := 1; ld a,h ; A := ANSWER; rla ; is ANSWER negative? jp nc,dotposit ; if not then go to positive routine; ld a,l ; \ cpl ; > ANSWER :=- ANSWER - 1 [low order]; ld l,a ; / ld a,h ; \ cpl ; > ANSWER :- -ANSWER - 1 [high order]; ld h,a ; / inc hl ; ANSWER := (-ANSWER-1) + 1; ld a,'-' ; A := '-' [ASCII leading minus]; call put ; OUTPUT := A [display minus sign]; dotposit: ex (sp),hl ; exchange POINTER and ANSWER; ld e,(hl) ; TEMP := M(POINTER) [low order]; inc hl ; POINTER := POINTER + 1; ld d,(hl) ; TEMP := M(POINTER) [high order]; inc hl ; POINTER := POINTER +1; ex (sp),hl ; exchange ANSWER and POINTER; ld b,0 ; VALUE ;-0; dotdivid: ld a,l ; \ sub e ; > ANSWER := ANSWER - TEMP [low Order]; ld a,h ; / ld a,h ; \ sbc a,d ; > ANSWER := ANSWER - TEMP [high order]; ld h,a ; / jp m,dotout ; if ANSWER LT 0 then go put eharacter; inc b ; VALUE := VALUE + 1; jp dotdivid ; reiterate, counting in VALUE; dotout: add hl,de ; ANSWER := ANSWER + TEMP; xor a ; A := 0; CARRY := 0; or b ; is VALUE = 0? jp nz,dotprnt ; if not then go print it; or c ; is NON2ERO = 0 [leading zero test]; jp nz,dotbypa ; if not then bypass leading zero print; dotprnt:or '0' ; A :* A OR '0' [convert VALUE to ASCII]; ld c,0 ; NONZERO := 0 [reset zero flag]; call put ; OUTPUT := A [display ASCII digit]; dotbypa:ld a,e ; A := TEMP [low order]; cp 1 ; is TEMP = 1 [low order]? jp nz,dotposit ; if not them reiterate; pop de ; 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);