home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG038.ARK / REL.ASM < prev    next >
Assembly Source File  |  1984-04-29  |  3KB  |  145 lines

  1. ;
  2. ; TITLE        RELOCATION TABLE BUILDER
  3. ; FILENAME    REL.ASM
  4. ; AUTHOR    Robert A. Van Valzah  7/23/78
  5. ; LAST REVISOR    R. A. V.   12/24/79
  6. ; REASON    revised spelling of signon
  7. ;
  8. ;
  9. vers    equ    6    ;version number
  10. ;
  11. BDOS    EQU    5
  12. ;
  13.     maclib    utl    ;get utl interface macro library
  14. ;
  15.     utl    setadrs,setlen,help
  16. ;
  17. setadrs:
  18.     MOV    H,B    ;GET PARAMETER 1 INTO REG HL
  19.     MOV    L,C
  20.     SHLD    CODE1    ;SAVE IT AS CODE IMAGE 1 POINTER
  21.     XCHG        ;GET PARM. 2 INTO HL
  22.     SHLD    CODE2    ;SAVE IT AS CODE IMAGE 2 POINTER
  23.     lxi    d,ackmsg ;send acknowledge message
  24.     mov    a,c    ;see if code 0 is on 8 byte boundry
  25.     ani    7
  26.     jz    smsg    ;yes - send ack message
  27.     lxi    d,nakmsg ;send error message
  28. smsg:
  29.     call    prmsg
  30.     RET
  31. nakmsg:
  32.     db    13, 10, 'Code must be on 8 byte boundry.'
  33.     db    0
  34. ackmsg:
  35.     db    13, 10, 'Code addresses recieved.'
  36.     db    0
  37. ;
  38. setlen:
  39.     PUSH    D    ;PUSH PARM. 2 (REL TBL ADR)
  40.     LHLD    CODE2    ;CODE IMAGE 2 POINTER INTO DE
  41.     XCHG
  42.     LHLD    CODE1    ;CODE IMAGE 1 POINTER IN HL
  43.     mov    a,c    ;make sure len is multiple of 8
  44.     ani    7
  45.     jz    comp    ;length is ok
  46.     lxi    d,lenmsg ;print error message
  47.     call    prmsg
  48.     pop    d    ;clean up stack before returning
  49.     ret
  50. lenmsg:
  51.     db    13, 10, 'Length must be a multiple of 8.'
  52.     db    0
  53. ;
  54. COMP:
  55.     LDAX    D    ;GET A BYTE FROM IMAGE 2
  56.     sub    M    ;COMPARE TO SAME BYTE IN IMAGE 1
  57.     JNZ    SETBIT    ;IF NOT EQUAL, SET REL BIT
  58.     ORA    A    ;EQUAL, RESET BIT
  59.     JMP    SHIFTBIT
  60. SETBIT:
  61.     cpi    1    ;warn if difference is not 1 or -1
  62.     jz    diffok    ;difference of 1 is ok
  63.     cpi    0ffh
  64.     jz    diffok    ;difference of -1 is ok
  65.     push b ! push d ! push h
  66.     lxi    d,warnmes ;issue waring message
  67.     call    prmsg
  68.     pop    d    ;get code 0 address back
  69.     push    d    ;and save again
  70.     call    hexode    ;print error address
  71.     mvi    a,'H'
  72.     call    conout
  73.     pop h ! pop d ! pop b
  74. diffok:
  75.     STC        ;SET REL BIT
  76. SHIFTBIT:
  77.     LDA    BITS    ;GET OTHER BITS OF THIS WORD
  78.     RAL        ;SHIFT NEW BITS INTO POSITION
  79.     STA    BITS    ;SAVE BACK NEW REL WORD
  80.     INX    H    ;BUMP IMAGE 1 POINTER
  81.     INX    D    ;BUMP IMAGE 2 POINTER
  82.     MOV    A,L    ;SEE IF AT 8 BYTE BOUNDRY
  83.     ANI  0000$0111B    ;THIS MEANS REL WORD IS FULL
  84.     JNZ    ENDTEST    ;NOT FULL - JUST SEE IF DONE
  85.     XTHL        ;FULL - WRITE TO REL TABLE
  86.     LDA    BITS    ;GET REL WORD
  87.     MOV    M,A    ;PUT IN TABLE
  88.     INX    H    ;BUMP TABLE POINTER
  89.     XTHL        ;TABLE POINTER BACK ON THE STACK
  90. ENDTEST:
  91.     DCX    B    ;DECREMENT LENGTH
  92.     MOV    A,B    ;SEE IF DONE (LENGTH = 0)
  93.     ORA    C
  94.     JNZ    COMP    ;NOPE - KEEP COMPARING
  95.     call    crlf
  96.     POP    d    ;REMOVE REL TBL ADR FROM STACK
  97.     dcx    d
  98.     call    hexode    ;print last reloc table adr
  99.     lxi    d,donemsg ;print done message
  100.     call    prmsg
  101.     RET        ;BACK TO SID
  102. donemsg:
  103.     db    'H is last address of reloc table.'
  104.     db    0
  105. warnmes:
  106.     db    13, 10, 'Warning, difference not 1 or -1 at '
  107.     db    0
  108. ;
  109. help:
  110.     lxi    d,helpmsg
  111.     call    prmsg
  112.     ret
  113. ;
  114. INIT:
  115.     lxi    d,signon ;print signon message
  116.     call    prmsg
  117.     ret
  118. signon:
  119.     db    13, 10, 'REL.UTL Vers '
  120.     db    vers / 10+'0', '.', vers mod 10+'0'
  121.     db    13, 10, 'Ready to build relocation tables.'
  122.     db    13, 10, 'Type C.HELP for more help.'
  123.     db    0
  124. helpmsg:
  125.     db    13, 10, 'Format is:'
  126.     db    13, 10, 'C.SETADRS,<adr of one code image>,'
  127.     db    '<adr of other code image>'
  128.     db    13, 10, 'C.SETLEN,<len of code to be relocated>,'
  129.     db    '<dest. adr of rel table>'
  130.     db    13, 10, 'The call to SETADRS must precede the'
  131.     db    ' call to SETLEN.'
  132.     db    13, 10, 'The relocation table will be built'
  133.     db    ' when SETLEN is called.'
  134.     db    0
  135. ;
  136. CODE1    DW    0
  137. CODE2    DW    0
  138. BITS    DB    0
  139. ;
  140.     org    (($-1) and 0fff8h) + 8 ;org up mod 8
  141. ;
  142. codelen    equ    $-base
  143. ;
  144.     end    setadrs
  145.