1

This code should color the top pixels only red. the pixels keep repeatingly to be colored else where like a tile no matter how much ive changed the line size and the color (I specified only the top 2000 pixels get colored) I think its because of DUBBLE_BUFFER_START's location but I dont know where to put the double buffer other than after the space of the video memory 0xa000. any suggestions? any other better practices I could take

start.asm

[bits 16]
[org 0x7c00]
%include "kernel.asm"
;%include "std.asm"
%include "graphics.asm"
xor ax, ax
mov ss, ax
mov sp, STACK_STD_START
mov bp,sp
mov ds, ax
mov es, ax
mov si, 0
; cli
; lgdt [gdtinfo]   ; load gdt register
; mov  eax, cr0   ; switch to pmode by
; or al,1         ; set pmode bit
; mov  cr0, eax
; sti
; [bits 32]

call GRAPHICS_START
jmp _start

 _start:

    mov ax,0
    mov bl,4
.repeat:    

    call GRAPHICS_BLIT
    cmp ax,2000
    jge .done
    inc ax
    jmp .repeat
    .done:
    call GRAPHICS_UPDATE
hang:
jmp hang

OS_WELCOME db 'What is giong on',0
OS_USERNAME_DESCRIPT db 'Username:',0

times (510 - ($-$$)) db 0x00
dw 0xAA55

kernel.asm

__Kernel_asm:
jmp _KERNEL_ASM_END

;STD STORAGE SPACE
SEAM_STD_BUFFER equ 0x8000
SEAM_STD_LIMIT equ 0x80ff

;GRAPHICS STORAGE SPACE

GRAPHICS_DEFAULT_START equ 0xa000
GRAPHICS_DEFAULT_END equ 0x19A00
MAX_GRAPHICS_SIZE equ 0xFA00
DUBBLE_BUFFER_START equ 0x19B00
DUBBLE_BUFFER_END equ 0x29500

;ARGUMENT STORAGE

STACK_STD_START equ 0x8100
STACK_STD_LIMIT equ 0x81ff

;REGISTER STORAGE

AX_STORAGE_PRESERVATIVE equ 8200h
BX_STORAGE_PRESERVATIVE equ 8202h
CX_STORAGE_PRESERVATIVE equ 8204h
DX_STORAGE_PRESERVATIVE equ 8206h
SI_STORAGE_PRESERVATIVE equ 8208h
DI_STORAGE_PRESERVATIVE equ 8210h
BP_STORAGE_PRESERVATIVE equ 8212h
IP_STORAGE_PRESERVATIVE equ 8214h
CS_STORAGE_PRESERVATIVE equ 8216h
DS_STORAGE_PRESERVATIVE equ 8218h
SS_STORAGE_PRESERVATIVE equ 8220h
ES_STORAGE_PRESERVATIVE equ 8222h
STD_MODE:
    mov SI,STACK_STD_START
ret
dalloc_std: ; (ptr si)
    mov al,[si]
ret
alloc_std: ;(si place to allocate,al byte value)
    mov [si], al
ret
free_std: ;(si ptr at place start to free, ax at end )
    mov [si],byte 0
    cmp si,ax
    je .done
    inc si
    jmp free_std
    .done:
ret
alloc_stack_byte: ; (al byte to store)
mov [bp],al
ret
dealloc_stack_byte: ; (al byte to give)
mov al,[bp]
ret
alloc_stack_word: ; (ax word to store)
mov [bp],ax
ret
dealloc_stack_word: ; (ax word to give)
mov ax,[bp]
ret
STORE_AX:
mov [AX_STORAGE_PRESERVATIVE],AX
ret
STORE_BX:
mov [BX_STORAGE_PRESERVATIVE],BX
ret
RESTORE_AX:
mov AX,[AX_STORAGE_PRESERVATIVE]
ret
RESTORE_BX:
mov BX,[BX_STORAGE_PRESERVATIVE]
ret
STORE_CX:
mov [CX_STORAGE_PRESERVATIVE],CX
ret
RESTORE_CX:
mov CX,[CX_STORAGE_PRESERVATIVE]
ret
STORE_DX:
mov [DX_STORAGE_PRESERVATIVE],DX
ret
STORE_SI:
mov [SI_STORAGE_PRESERVATIVE],SI
ret
STORE_DI:
mov [DI_STORAGE_PRESERVATIVE],DI
ret
STORE_BP:
mov [BP_STORAGE_PRESERVATIVE],BP
ret
_KERNEL_ASM_END:

graphics.asm

**

GRAPHICS_MODE:
jmp GRAPHIC_MODE_END
_32_BITS_MODE:
    jmp contin
    ret
GRAPHICS_START:
    mov DI, GRAPHICS_DEFAULT_START
    mov ES,DI
    mov AX,DI
    mov ax,DUBBLE_BUFFER_START
    break:
    mov DS,ax
    xor ax,ax
    mov SI,AX
    mov DI,AX
    mov AH, 0
    mov AL, 13h
    int 10h
    ret
GRAPHICS_UPDATE:;()
    call STORE_CX
    mov cx,64000
    mov SI,0
    mov DI,0
    rep movsb
    call RESTORE_CX
    mov SI,0
    mov DI,0
    ret
GRAPHICS_BLIT:;(ah xposition, al y position, bl color)
    call STORE_AX
    call STORE_BX
    mov si,ax
    mov [si], bl
    call RESTORE_AX
    call RESTORE_BX
    ret
contin:
    ;[bits 32]
    ret
GRAPHIC_MODE_END:

**

11
  • 1
    dalloc gives me nightmares lol. mov ax,DUBBLE_BUFFER_START won't work for a value over 0xFFFF . since 0x19B00 is over that is a problem. One safe place (assuming you aren't using it for anything else) would be at 0x8000:0x0000 through 0x8000:0xFFFF . You would need to use a segment of 0x8000 and an offset to index into your double buffer. 0x8000:0x0000 is physical address (0x8000<<4)+0x0000=0x80000 Jul 31, 2018 at 1:30
  • im using 8000 in the standard input output library i made i tried using 9000h and 7000h they both work thanks but I have a question if using 7000h works why do they discourage using it
    – Dodo
    Jul 31, 2018 at 1:40
  • Have no idea why they would discourage 0x7000:0x0000, that is not used by the system at all. I can make a case for discouraging 0x9000:00000 up through 0x9000:0xFFFF since most system have an extended BIOS data area just below physical 0xA0000. Unless you account for that, you could run into issues. Jul 31, 2018 at 1:42
  • Unless someone meant 0x0000:0x7000 (which is not the same as 0x7000:0x0000). I can make a case that 0x0700:0x0000 (not the same as 0x7000:0x0000) is bad because it would include the bootloader code itself. Jul 31, 2018 at 1:44
  • no i meant 7000h:0000h, anyways thanks for the answer for graphics problem i was having. How do I let this question be answered so I can close this case
    – Dodo
    Jul 31, 2018 at 1:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.