Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Instruction timings
  • Loading branch information
reenigne committed Oct 29, 2011
1 parent 8bd49ca commit 8740169
Show file tree
Hide file tree
Showing 4 changed files with 607 additions and 243 deletions.
73 changes: 73 additions & 0 deletions 8088/cga/artifact/artifact.asm
@@ -0,0 +1,73 @@
org 0
cpu 8086

mov ax,6
int 0x10

mov al,0x1a
mov dx,0x3d8
out dx,al

; mov al,0x0f
mov al,1
mov dx,0x3d9
out dx,al

mov al,0

mov ax,0xb800
mov es,ax
screenLoop:
mov di,0
cld

rowLoop:

mov cx,6
lineLoop:
push cx
mov cx,80
rep stosb
add di,0x2000-80
mov cx,80
rep stosb
sub di,0x2000
pop cx
loop lineLoop

add al,0x11
test al,0xf
jnz rowLoop

colourLoop:
push ax
mov ah,0
int 0x16
pop ax

inc al
mov dx,0x3d9
out dx,al
loop colourLoop


; ; Set up the 8259 PIC to read the IRR lines
; mov al,0x0a ; OCW3 - no bit 5 action, no poll command issued, act on bit 0,
; out 0x20,al ; read Interrupt Request Register
;keyboardRead:
; ; Loop until the IRR bit 1 (IRQ 1) is high
; in al,0x20
; and al,2
; jz keyboardRead
; ; Read the keyboard byte and store it
; in al,0x60
;; mov bl,al
; ; Acknowledge the previous byte
; in al,0x61
; or al,0x80
; out 0x61,al
; and al,0x7f
; out 0x61,al

jmp screenLoop

2 changes: 2 additions & 0 deletions 8088/cga/artifact/build.bat
@@ -0,0 +1,2 @@
@echo off
yasm artifact.asm -o artifact.bin
179 changes: 2 additions & 177 deletions 8088/dos/kernel.asm
Expand Up @@ -124,32 +124,12 @@ interruptSetupLoop:
; Disable NMI
xor al,al
out 0xa0,al
; Find end of memory. Memory is always added in 16Kb units. We can't use
; the BIOS measurement since it won't have been initialized.
; mov ax,0x9c00
;findRAM:
; mov ds,ax
; mov [0],ax
; cmp [0],ax
; je foundRAM
; sub ax,0x400
; jmp findRAM
;foundRAM:
; sub ax,0xc00
mov ax,0x9000

; Move the stack right at the end of main RAM.
mov ax,0x9000
mov ss,ax
xor sp,sp

; Enable NMI
; in al,0x61
; or al,0x30
; out 0x61,al
; and al,0xcf
; out 0x61,al
; mov al,0x80
; out 0xa0,al

mov di,0x50 ;Target segment (TODO: make this 0060:0000 as FreeDOS does?)
mov bx,cs
call main
Expand Down Expand Up @@ -198,9 +178,6 @@ noRelocationNeeded:
; int 0x60 == output AX as a 4-digit hex number
; int 0x61 == output CX bytes from DS:SI
; int 0x62 == output AL as a character
; int 0x63 == print AX as a 4-digit hex number
; int 0x64 == print CX bytes from DS:SI
; int 0x65 == print AL as a character
; int 0x67 == finish
xor ax,ax
mov ds,ax
Expand All @@ -210,21 +187,9 @@ noRelocationNeeded:
mov [0x186], cs
mov word [0x188], writeCharacter
mov [0x18a], cs
; mov word [0x18c], printHex
; mov [0x18e], cs
; mov word [0x190], printString
; mov [0x192], cs
; mov word [0x194], printCharacter
; mov [0x196], cs
mov word [0x19c], complete
mov [0x19e], cs

; ; Reset video variables
; xor ax,ax
; mov [cs:column],al
; mov [cs:startAddress],ax


; Receive a byte over serial and put it in AL. DX == port base address + 5
%macro receiveByte 0
; Wait until a byte is available
Expand Down Expand Up @@ -316,13 +281,6 @@ noRelocationNeeded:
out dx,al


; ; Print the boot message
; mov ax,cs
; mov ds,ax
; mov si,bootMessage
; mov cx,bootMessageEnd - bootMessage
; int 0x64

; Push the cleanup address for the program to retf back to.
mov bx,cs
push bx
Expand Down Expand Up @@ -384,14 +342,8 @@ loadProgramDone:

cmp bh,bl
je checksumOk
; mov si,failMessage
; mov cx,failMessageEnd - failMessage
; int 0x64
jmp tryLoad
checksumOk:
; mov si,okMessage
; mov cx,okMessageEnd - okMessage
; int 0x64
retf

; Load CX bytes from keyboard to DS:DI (or a full 64Kb if CX == 0)
Expand Down Expand Up @@ -473,131 +425,4 @@ complete:
jmp 0 ; Restart the kernel



;printNybble:
; cmp al,10
; jge printAlphabetic
; add al,'0'
; jmp printGotCharacter
;printAlphabetic:
; add al,'A' - 10
;printGotCharacter:
; jmp printChar
;
;
;printHex:
; push bx
; push cx
; mov bx,ax
; mov al,bh
; mov cl,4
; shr al,cl
; call printNybble
; mov al,bh
; and al,0xf
; call printNybble
; mov al,bl
; shr al,cl
; call printNybble
; mov al,bl
; and al,0xf
; call printNybble
; pop cx
; pop bx
; iret
;
;
;printString:
; lodsb
; call printChar
; loop printString
; iret
;
;
;printCharacter:
; call printChar
; iret
;
;
;printChar:
; push bx
; push cx
; push dx
; push es
; push di
; mov dx,0xb800
; mov es,dx
; mov dx,0x3d4
; mov cx,[cs:startAddress]
; cmp al,10
; je printNewLine
; mov di,cx
; add di,cx
; mov bl,[cs:column]
; xor bh,bh
; mov [es:bx+di+24*40*2],al
; inc bx
; inc bx
; cmp bx,80
; jne donePrint
;printNewLine:
; add cx,40
; and cx,0x1fff
; mov [cs:startAddress],cx
;
; ; Scroll screen
; mov ah,ch
; mov al,0x0c
; out dx,ax
; mov ah,cl
; inc ax
; out dx,ax
; ; Clear the newly scrolled area
; mov di,cx
; add di,cx
; add di,24*40*2
; mov cx,40
; mov ax,0x0700
; rep stosw
; mov cx,[cs:startAddress]
;
; xor bx,bx
;donePrint:
; mov [cs:column],bl
;
; ; Move cursor
; shr bx,1
; add bx,cx
; add bx,24*40
; and bx,0x1fff
; mov ah,bh
; mov al,0x0e
; out dx,ax
; mov ah,bl
; inc ax
; out dx,ax
;
; pop di
; pop es
; pop dx
; pop cx
; pop bx
; ret
;
;
;column:
; db 0
;startAddress:
; dw 0
;bootMessage:
; db 'XT Serial Kernel',10
;bootMessageEnd:
;okMessage:
; db 'OK',10
;okMessageEnd:
;failMessage:
; db 'Checksum failure',10
;failMessageEnd:


kernelEnd:

0 comments on commit 8740169

Please sign in to comment.