home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol027 / bitter.src < prev    next >
Encoding:
Text File  |  1985-02-10  |  1.8 KB  |  61 lines

  1. ;    FILE BITTER.SRC        CREATED 13-Nov-80
  2. ;    d.a. steele
  3. ;
  4. ;    This routine is written to be linked with a Pascal/Z program
  5. ;    and is to take a binary word (16 bits) and output it to the
  6. ;    console in a series of ones and zeros.  I.E. 005AH would be
  7. ;    printer as '         1011010'.  All leading zeros are supressed.
  8. ;
  9.         NAME        BITTER
  10.         ENTRY        BITTER
  11.  
  12. BIOS        EQU        5
  13.  
  14. Start1:        MOV        A,B    ;Get the number
  15.         ANA        D    ;Check against the mask bit
  16.         JNZ        Itsset    ;If it is set then print '1'
  17.         JMP        Itsnotset;Else print Theoutchar
  18. Start2:        RRAR        D    ;Rotate to the next bit
  19.         JNZ        Start1    ;And if it's not zero continue
  20.         RET
  21.  
  22. Itsset:        MVI        E,'1'    ;Prepair to output a '1'
  23.         PUSH        PSW    ;Save the number
  24.         MVI        A,'0'    ;Replace the leading space with a '1'
  25.         STA        Theoutchar
  26.         JMP        Outchar    ;Then output the 1
  27.  
  28. Itsnotset:    PUSH        PSW    ;save the number
  29.         LDA        Theoutchar;Get the char to output ' ' or '0'
  30.         MOV        E,A    ;Put it onto E for CP/M
  31.  
  32. Outchar:    PUSH        H    ;Get ready for call to BIOS
  33.         PUSH        B
  34.         MVI        C,2
  35.         CALL        BIOS
  36.         POP        B    ;Restore everything
  37.         POP        H
  38.         POP        PSW
  39.         JMP        Start2    ;Do the next bit
  40.  
  41.  
  42. Bitter:
  43.         POP        H    ;Save return address
  44.         POP        D    ;Get the number to be output
  45.         PUSH        H    ;Restore the return vector
  46.         MVI        A,'#'    ;Init. the lead character
  47.         STA        Theoutchar
  48.  
  49.         MVI        D,80H    ;Init. the mask bit
  50.         MOV        A,C    ;Store the low byte of the test number
  51.         STA        Lobyte
  52.  
  53.         CALL        Start1    ;Process the high  byte
  54.         LDA        Lobyte    ;now get the low byte
  55.         MOV        B,A    ;Save it in the B reg.
  56.         MVI        D,80H    ;Set the check bt again
  57.         CALL        Start1    ;Process the low byteè        XRA        A    ;Prepair to return to PascalZ
  58.         RET            ;And return
  59. Theoutchar:    DS        1
  60. Lobyte:        DS        1
  61.