;==CALLADDR.ASM====H Weinstein==============8304190600========================= ; San Diego CA 92128 ; ; A program for the public domain: ; ; Prints the address from which the ; ; CALL 100h ; ; instruction is executed by the CCP ; to begin the COM program of your ; command line under CP/M (TM Digital ; Research, Inc.). ; org 100h ; call crlf ;double space ; pop h ;get the return address off the stack push h ;copy it back to stack lxi d,-3 ;set up to subtract 3, i.e., add -3 dad d ;do the arithmetic push h ;preserve the result ; mov a,h ;get high-order address into accumulator call highord ;get high nibble into low nibble call prnt$asc ;convert it to ASCII and print it pop h ;get the address from stack push h ;copy it back to stack mov a,h ;high-order back to accumulator call prnt$asc ;convert low nibble to ASCII and print it ; ; Next segment does the same as above but for low-order address ; pop h push h mov a,l call highord call prnt$asc pop h mov a,l call prnt$asc ; call crlf ;another double space ; ret ;slip quietly back into CCP ; ; HIGH rotates bits 4 through 7 into bits 0 through 3 ; highord: rar rar rar rar ret ; ; PRNT$ASC converts to ASCII then prints the converted character ; No need to validate 0-9 or A-F because char is machine code ; prnt$asc: ani 0Fh ;mask low nibble and reset carry adi 90h ;begin conversion daa ;convert to BCD and force carry if character was > 09h ; ;NOTE: If original character was > 09h, the high nibble will now be ; 0h and the carry will be set. If it was not > 09h, the high ; nibble will now be 9h and carry will be reset. The next ; two instructions ought to be easy to walk through now. ; aci 40h ;add 40h plus carry daa ;convert to BCD, WHICH IS REALLY ASCII REPRESENTATION ; OF THE LOW NIBBLE AT ENTRY TO THIS SUBROUTINE. mov e,a ;move it to where BDOS can find it mvi c,2 ;ready console output service call 5 ;print the character in E ret ; crlf: call lfcr ;not really calling a subroutine: see below db 13,10,'$' ;CR, LF, delimiter for BDOS string printer service lfcr: mvi c,9 ;ready string printer service pop d ;use the return address from "call lfcr" as pointer call 5 ;print the string ret ; end 100h