;//--------------------------------------------------------------- ;// refresh.s ;// ;// This program visually depicts the memory-refresh cycle, ;// by monitoring the PIT's OUT1 signal (port 0x61, bit 4). ;// ;// assemble with: $ as86 refresh.s -b refresh.b ;// install using: $ dd if=refresh.b of=/dev/fd0 seek=1 ;// ;// NOTE: This code begins executing with CS:IP = 1000:0002. ;// ;// programmer: ALLAN CRUSE ;// date begun: 01 MAY 2004 ;//--------------------------------------------------------------- .SECT .TEXT ;----------------------------------------------------------------- .WORD 0xABCD ; programming signature ;----------------------------------------------------------------- main: mov ax, cs ; address this segment mov ds, ax ; with DS register pop dword return_address ; store return-address mov ss, ax ; adjust SS register lea esp, tos0 ; and set new stacktop call reset_video_textmode call execute_program_demo push dword return_address ; recover our exit-address retf ; exit to program launcher ;----------------------------------------------------------------- return_address: .LONG 0 ; to store exit-address ;----------------------------------------------------------------- ;----------------------------------------------------------------- table: .WORD 0x171F, 0x1F1E ; lookup-table for output ;----------------------------------------------------------------- execute_program_demo: mov ax, #0xB800 ; address video memory mov es, ax ; with ES register mov di, #480 ; start on fourth line mov cx, #18 ; number of output lines imul cx, #80 ; times chars-per-line again: in al, #0x61 ; read PORT_B status and eax, #0x10 ; isolate OUT1 state shr eax, #4 ; shift OUT1 to low bit mov ax, table[eax*2] ; fetch output-character stosw ; write output-character loop again ; check OUT1 state again ret ; back to main routine ;----------------------------------------------------------------- ;----------------------------------------------------------------- msg: .ASCII "A visualization for the PC memory-refresh cycle " len: .WORD * - msg ; length of the message att: .BYTE 0x0E ;----------------------------------------------------------------- reset_video_textmode: mov ax, cs ; address this segment mov es, ax ; with ES register ; reset the video display-mode mov ax, #0x0003 ; standard 80x25 textmode int 0x10 ; request BIOS service ; draw the explanatory title lea bp, msg ; point ES:BP to message mov cx, len ; setup message's length mov bl, att ; specify attribute byte mov bh, #0 ; display-page is zero mov dx, #0x0110 ; row=1, col=16 mov ax, #0x1300 ; write_string service int 0x10 ; request BIOS service ; move the cursor beneath our output-window mov dx, #0x1600 ; row=22, col=0 mov ah, #0x02 ; set_cursor_position int 0x10 ; request BIOS service ret ;----------------------------------------------------------------- .ALIGN 16 ; alignment at paragraph .SPACE 512 ; reserved for stack use tos0: ; label fop top-of-stack ;----------------------------------------------------------------- END