title Module from library BASE_1 : DIVREC name ('DIVREC') maclib baselib.lib ; Divide 16 bit number by 128 computing record size ; Copyright (C) Werner Cirsovius ; Hohe Weide 44 ; D-20253 Hamburg ; Tel.: +49-40-4223247 ; Version 1.1 September 1988 ; ENTRY Reg pair HL holds 16 bit number ; EXIT Reg pair HL holds record count ; Reg pair DE holds original number entry divrec ; ; Algorithm: x/128 = (2*x)/256 ; divrec: push hl xor a ; Clear hi end add hl,hl ; Get MSB of lo into LSB of hi adc a,a ; Get MSB of hi ld l,h ; Divide by 256 ld h,a pop de ; Return old number ret end