home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / misc / calladdr.lbr / CALLADDR.AZM / CALLADDR.ASM
Encoding:
Assembly Source File  |  1993-10-25  |  2.4 KB  |  86 lines

  1. ;==CALLADDR.ASM====H Weinstein==============8304190600=========================
  2. ;           San Diego CA 92128
  3. ;
  4. ;    A program for the public domain:
  5. ;
  6. ;        Prints the address from which the
  7. ;
  8. ;            CALL 100h
  9. ;
  10. ;        instruction is executed by the CCP
  11. ;        to begin the COM program of your
  12. ;        command line under CP/M (TM Digital
  13. ;        Research, Inc.).
  14. ;
  15.     org 100h
  16. ;
  17.     call crlf    ;double space
  18. ;
  19.     pop h        ;get the return address off the stack
  20.     push h        ;copy it back to stack
  21.     lxi d,-3    ;set up to subtract 3, i.e., add -3
  22.     dad d        ;do the arithmetic
  23.     push h        ;preserve the result
  24. ;
  25.     mov a,h        ;get high-order address into accumulator
  26.     call highord    ;get high nibble into low nibble
  27.     call prnt$asc    ;convert it to ASCII and print it
  28.     pop h        ;get the address from stack
  29.     push h        ;copy it back to stack
  30.     mov a,h        ;high-order back to accumulator
  31.     call prnt$asc    ;convert low nibble to ASCII and print it
  32. ;
  33. ; Next segment does the same as above but for low-order address
  34. ;
  35.     pop h
  36.     push h
  37.     mov a,l
  38.     call highord
  39.     call prnt$asc
  40.     pop h        
  41.     mov a,l
  42.     call prnt$asc
  43. ;
  44.     call crlf    ;another double space
  45. ;
  46.     ret        ;slip quietly back into CCP
  47. ;
  48. ; HIGH rotates bits 4 through 7 into bits 0 through 3
  49. ;
  50. highord:
  51.     rar
  52.     rar
  53.     rar
  54.     rar
  55.     ret
  56. ;
  57. ; PRNT$ASC converts to ASCII then prints the converted character
  58. ;    No need to validate 0-9 or A-F because char is machine code
  59. ;
  60. prnt$asc:
  61.     ani 0Fh        ;mask low nibble and reset carry
  62.     adi 90h        ;begin conversion
  63.     daa        ;convert to BCD and force carry if character was > 09h
  64. ;
  65. ;NOTE: If original character was > 09h,    the high nibble will now be
  66. ;    0h and the carry will be set. If it was not > 09h, the high
  67. ;    nibble will now be 9h and carry will be reset.  The next
  68. ;    two instructions ought to be easy to walk through now.
  69. ;
  70.     aci 40h        ;add 40h plus carry
  71.     daa        ;convert to BCD, WHICH IS REALLY ASCII REPRESENTATION
  72.             ;  OF THE LOW NIBBLE AT ENTRY TO THIS SUBROUTINE.
  73.     mov e,a        ;move it to where BDOS can find it
  74.     mvi c,2        ;ready console output service
  75.     call 5        ;print the character in E
  76.     ret
  77. ;
  78. crlf:    call lfcr    ;not really calling a subroutine: see below
  79.     db 13,10,'$'    ;CR, LF, delimiter for BDOS string printer service
  80. lfcr:    mvi c,9        ;ready string printer service
  81.     pop d        ;use the return address from "call lfcr" as pointer
  82.     call 5        ;print the string
  83.     ret
  84. ;
  85.     end 100h
  86.