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 / OSBORNE / OXSDUMP.LBR / DUMPRSX.AQM / DUMPRSX.ASM
Assembly Source File  |  2000-06-30  |  6KB  |  235 lines

  1. ;        OSBORNE EXECUTIVE - Screen Dump Utility
  2. ;
  3. ;        - written Dec'84 by Mark Steinbrecher
  4. ;              (with help from Dave Mabry)
  5. ;
  6. ; This is an RSX to print the screen on an Osborne Executive
  7.  
  8. rsx    equ    60            ; BDOS RSX function call
  9. cr    equ    0dh            ; ASCII carriage return character
  10. lf    equ    0ah            ; ASCII line feed character
  11. freeram equ    0fb20h            ; Address of unused common memory
  12.                     ; for new conin
  13.  
  14. serial:
  15.     ds    6            ; Initialized by loader
  16. start:
  17.     jmp    begin            ; Start of RSX code
  18. next:
  19.     db    0c3h            ; Jump instruction
  20.     ds    2            ; Initialized by loader
  21. prev:
  22.     ds    2            ; Initialized by loader
  23. remove:
  24.     db    0            ; Don't remove
  25. nonbank:
  26.     db    0            ; Load in all systems
  27.     db    'dump    '        ; Name field
  28. loader:
  29.     ds    1            ; Loader flag
  30.     ds    2            ; Reserved
  31.  
  32.  
  33. ; Here starts the code that is executed by a call to BDOS with
  34. ;  RSX function number in C.
  35.  
  36. begin:
  37.     mov    a,c            ; Get BDOS function number
  38.     cpi    rsx            ; Is it for an RSX ?
  39.     jnz    next            ; No, pass it on
  40.     ldax    d            ; Get RSX function number
  41.     cpi    53            ; Is it for this RSX ?
  42.     jnz    next            ; No, pass it on
  43. ; Must save calling program's stack and use our owm
  44.     lxi    h,0
  45.     dad    sp
  46.     shld    stack
  47.     lxi    sp,stack
  48. ; Does calling program want us to remove ourself ?
  49.     mov    h,d
  50.     mov    l,e        ;HL point to rsxpb
  51.     inx    h
  52.     inx    h        ;Point to param1
  53.     mov    a,m        ;Fetch it
  54.     ora    a        ;Nonzero means remove
  55.     jz    beg05        ;Zero means initialize
  56.     call    next        ;In case there is another DUMP RSX
  57.     jmp    die        ;Suicide
  58. ; Check to see if we are the only DUMP RSX in memory
  59. beg05:
  60.     call    next        ;As if we are calling DUMP
  61.     ora    a        ;Returns zero if there is another
  62.     jz    die05        ;Suicide if another exists
  63.     xchg            ;HL point to RSX parameter block
  64.     inx    h
  65.     inx    h        ;Point to parameter 1
  66.     mov    a,m        ;Get low byte
  67.     ora    a        ;Check for zero
  68.     jnz    die        ;If not binary 0, then suicide
  69.     inx    h        ;Point to trigger passed in
  70.     mov    a,m
  71.     sta    trigger
  72. ; At this point, we have to initialize the RSX code to intercept
  73. ;  all console input calls.
  74. ;  But only if we haven't done it before.
  75.     lda    modified
  76.     ora    a
  77.     jnz    return        ;Bypass vector modification if done
  78.     lhld    1        ;Get warm boot vector
  79.     lxi    d,7
  80.     dad    d        ;Point to console in vector address
  81.     shld    conin$adr    ;Save for die also
  82.     push    h        ;save temporarily
  83.     mov    a,m        ;get low byte of conin vector address
  84.     inx    h        ;point to high byte
  85.     mov    h,m        ;get high byte of conin vector address
  86.     mov    l,a        ;hl reg now has conin address
  87.     shld    old$conin    ;store locally
  88.     call    patch        ;move patch code into unused BIOS ram
  89.     lxi     d,freeram     ;new console address to DE
  90.     pop    h        ;again point to conin vector in BIOS
  91.     mov    m,e             ;move low byte of unused BIOS ram address
  92.     inx    h        ;point to high byte of vector
  93.     mov    m,d               ;conin in vector is now patched !
  94. ; Now get the list out routine address in case application program
  95. ;  modifies location 1 (warm boot vector).  SuperCalc does this
  96. ;  and maybe others.
  97.     lhld    1        ;Address of BIOS jump table
  98.     lxi    d,13        ;Offset to address of list output
  99.     dad    d
  100.     mov    a,m        ;Low byte of list out address
  101.     inx    h
  102.     mov    h,m        ;High byte
  103.     mov    l,a
  104.     shld    l$out        ;save address
  105. ; Indicate that the console in has been modified.
  106.     mvi    a,0ffh        ;Set modified flag
  107.     sta    modified
  108. return:
  109.     lhld    stack        ;get old stack address
  110.     sphl            ;restore
  111.     mvi    a,0        ;Indicate success
  112.     ret            ;rsx initialization complete
  113.  
  114. die:
  115.     lda    modified    ;Have we modified the BIOS jump table ?
  116.     ora    a
  117.     jz    die05        ;No, then just die
  118.     lhld    old$conin    ;Get original address of CONIN
  119.     xchg            ; to DE
  120.     lhld    conin$adr    ;Point to address field in jump table
  121.     mov    m,e        ;Restore original jump address
  122.     inx    h
  123.     mov    m,d
  124. die05:
  125.     mvi    a,0ffh        ;True flag
  126.     sta    remove        ;Flag removal at next warm boot 
  127.     jmp    return
  128.  
  129. patch:
  130.     mvi    b,length     ;setup loop counter
  131.     lxi     h,freeram     ;setup address pointer for relocated code
  132.     lxi    d,st$code    ;setup address pointer for local code
  133. loop:    ldax    d
  134.     mov    m,a
  135.     inx    h
  136.     inx    d
  137.     dcr    b
  138.     jnz    loop
  139.     ret
  140. ;
  141. ; The code that follows is relocated to address <freeram> in common
  142. ;  memory by <patch:>.  Address <freeram> is patched into the conin
  143. ;  vector in the BIOS jump table so that all further console inputs
  144. ;  pass through this routine.
  145. st$code:
  146.     in     0        ;get current bank
  147.     push     psw         ;save temporarily
  148.     mvi    a,41h        ;setup bank 1 (TPA bank)
  149.     out    0        ;enable TPA
  150.     call    new$conin    ;vector to console input patch
  151.     mov    b,a        ;move console char. to B temporarily
  152.     pop    psw         ;get old bank back
  153.     out    0        ;enable old bank
  154.     mov    a,b        ;put console char. back in A
  155.     ret            ;ret with console character in A
  156. ;
  157. length    equ    $-st$code
  158. ;
  159. old:
  160.     lhld    old$conin
  161.     pchl
  162. ;
  163. new$conin:
  164.      push    h
  165.      lxi    h,0        ;Use a local stack
  166.      dad    sp
  167.      shld    stack
  168.     lxi    sp,stack
  169.     call    old        ;Go get character
  170.      push    psw        ;Save status
  171.     lxi    h,trigger    ;Compare with the trigger character
  172.     cmp    m        ;Is it the same ?
  173.     cz    doit        ;Go dump screen if yes
  174.      pop    psw        ;Else pass it by
  175.      lhld    stack
  176.      sphl    
  177.      pop    h
  178.     ret
  179.  
  180. doit:    
  181.     lxi    h,0c000h        ;point to start of screen ram
  182.     lxi    b,5018h            ;set up row and column counters
  183. next$row:
  184.     push    b            ;save row and column counts
  185. next$col:
  186.     mov    a,m            ;get next char. from screen
  187.     ani    7fh            ;strip attribute bit
  188.     cpi    20h            ;check for valid ASCII character
  189.     cm    bad
  190.     mov    c,a
  191.     push    h            ;save pointer
  192.     push    b
  193.     call    list$out        ;print character
  194.     pop    b
  195.     pop    h
  196.     inx    h            ;point to next character
  197.     dcr    b            ;decrement column counter
  198.     jnz    next$col        ;if not zero continue 
  199.     mvi    c,lf            ;row finished so print a crlf
  200.     push    h
  201.     call    list$out
  202.     mvi    c,cr
  203.     call    list$out
  204.     pop    h            ;recall screen ram pointer
  205.     pop    b            ;recall row count & reset col. counter
  206.     dcr    c            ;decrement row counter
  207.     rz                ;if row count=0, we're done
  208.     lxi    d,30h            ;row to row address offset
  209.     dad    d            ;not done so point to next row
  210.     jmp    next$row
  211. ;
  212. bad:
  213.     mvi    a,20h            ;replace nonprintable char. with space
  214.     ret
  215. ;
  216. list$out:
  217.     lhld    l$out            ;Get address of list out routine
  218.     pchl                ;Go do it
  219.  
  220. modified:
  221.     db    0            ;True -> BIOS jump table modified
  222. trigger:
  223.     ds    1            ;Place to store trigger character
  224. l$out:
  225.     ds    2            ;Place to store address of list out
  226. old$conin:
  227.     ds    2            ;Place to store address of old conin
  228. conin$adr:
  229.     ds    2            ;Place to store address of jump vector
  230.                     ; of CONIN in BIOS jump table
  231.     ds    30
  232. stack:
  233.     ds    2            ;Place to save original stack
  234.     end
  235.