home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctchnqs / 1992 / number1 / log.asm < prev    next >
Assembly Source File  |  1991-10-17  |  2KB  |  55 lines

  1. ; ***
  2.  
  3. APPL_RAM        EQU     04F0h           ; starting BIOS ram address
  4. RAM_SIZE        EQU     16              ; size of reserved area
  5.  
  6. LOG_TEXT        SEGMENT  WORD PUBLIC 'CODE'
  7.               ASSUME        CS: LOG_TEXT
  8.         public  _LogByte
  9.  
  10. ; uses C calling convention as follows:
  11. ; void LogByte(char cByteToLog)
  12.  
  13. _LogByte        PROC    far
  14.         push    bp
  15.         mov     bp,sp
  16.  
  17.         push    ax              ; be polite and save all registers
  18.         push    cx
  19.         push    di
  20.         push    si
  21.         push    ds
  22.         push    es
  23.  
  24.         std                     ; we're going to start at the back
  25.                                 ; and work to the front
  26.  
  27.         xor        ax,ax           ; set ES and DS to segment 0
  28.         mov        ds,ax
  29.         mov     es,ax
  30.  
  31.         mov     di, APPL_RAM
  32.         add     di, RAM_SIZE-1  ; es:di -> last byte in RAM
  33.         mov     si, di
  34.         dec     si              ; ds:si -> next to last byte in RAM
  35.  
  36.         mov     cx, RAM_SIZE
  37.         dec     cx
  38.  
  39.         rep     movsb           ; shift all bytes right one byte
  40.  
  41.         mov     al, [bp+6]      ; get byte (assumes large model)
  42.         mov     [di], al        ; store it in first RAM location
  43.  
  44.         pop     es              ; restore registers as they were
  45.         pop     ds
  46.         pop     si
  47.         pop     di
  48.         pop     cx
  49.         pop     ax
  50.         pop     bp
  51.         ret
  52. _LogByte        endp
  53. LOG_TEXT        ENDS
  54. END
  55.