flat assembler
Message board for the users of flat assembler.

Index > DOS > [newbie] Normaly using 65xx user needs some adivce ;)

Author
Thread Post new topic Reply to topic
BastetFurry



Joined: 28 Jul 2008
Posts: 4
Location: Essen, NRW, Germany
BastetFurry
Hi!

Coming from the land of the C64 and the 6510 i want to learn x86 assembler for some oldschool DOS hacking, maybe even build a cool demo in 2 or 3 years and win the Wild at Breakpoint Wink (No DOS in PC-Demo Compo Sad )

I want to build a loop, for learning purposes, that increases every pixel on a $13 screen, but nothing shows up.
Could anyone please look at my code and tell me my mind-mistake?
Code:
format MZ ; DOS executable format

stack $1000
heap $200

start:
    ;Make code and data segment the same
    push cs
    pop ds
    
    ;Get into graphic mode $13 (320x200x8bit)
    mov ax, 0x13
    int 0x10

mainloop:    
    push es
    mov ax,0xa000
    mov es,ax
    
    mov bx,0xFA00
    mov di,bx

    mov ax,0
myloop:
    inc byte [di]
    dec di
    jz loopend
    jmp myloop
    
loopend:
    
    pop es
    jmp mainloop

    
    ;DOS end of programm routine
    mov ax,0x4c00
    int 0x21
    ret    
Post 28 Jul 2008, 22:15
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
simple thing that does what you want:
This makes a '.com' not '.exe' like your code does.
com is easier to work with for smaller programs.

Code:
org 100h         ;Make it .com

push 0a000h      ;Where the screen area is
pop es           ;^^

mov ax,13h       ;Video mode
int 10h          ;^^

mov cx,64000     ;screen has 64,000 pixels
a_loop: 
inc byte [es:di] ;YOU HAVE TO USE [es:di], NOT [di]
inc di           ;Next pixel
loop a_loop      ;Loop 64k times

key:             ;Simple checking for escape
in al,60h        ;Don't use for anything you'll actually release..
dec al           ;People will complain...
jnz key          ;
ret              ;                         
    
Post 28 Jul 2008, 22:38
View user's profile Send private message Reply with quote
BastetFurry



Joined: 28 Jul 2008
Posts: 4
Location: Essen, NRW, Germany
BastetFurry
First, thanks Smile

Some question about your code, i dont see you decrementing register cx, does loop do that for you?
Post 28 Jul 2008, 23:00
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
loop basically does two things in one. It decrements cx and does jnz

BTW: Your code has a few flaws. It never stops looping because at loopend you have it jump back to the first loop. The next dec di would make di FFFF and cause the whole thing to start back up. Also, you zero out ax but don't actually use it.

_________________
----> * <---- My star, won HERE
Post 28 Jul 2008, 23:03
View user's profile Send private message Reply with quote
BastetFurry



Joined: 28 Jul 2008
Posts: 4
Location: Essen, NRW, Germany
BastetFurry
Um, i wanted it to go trough all colors, i assume that when some memory location contains $ff and i "inc" that, that it turns to $00.
Post 28 Jul 2008, 23:17
View user's profile Send private message Reply with quote
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Ohhhh, I thought you wanted it to go through once, sorry.

Edit: Is this like what you wanted?
Code:
org 100h         ;Make it .com

push 0a000h      ;Where the screen area is 
pop es           ;^^ 

mov ax,13h       ;Video mode 
int 10h          ;^^ 

start:

mov cx,64000     ;screen has 64,000 pixels
a_loop:  
inc byte [es:di] ;YOU HAVE TO USE [es:di], NOT [di] 
inc di           ;Next pixel 
loop a_loop      ;Loop 64k times 

key:             ;Simple checking for escape 
in al,60h        ;Don't use for anything you'll actually release.. 
dec al           ;People will complain... 
jnz start        ;
ret           
    


It doesn't look all that great because it doesn't wait for vertical retrace.

BastetFurry wrote:

Um, i wanted it to go trough all colors, i assume that when some memory location contains $ff and i "inc" that, that it turns to $00.


Ya, it would go to 0


Take a look at This Thread for some good links on DOS coding. Especially check out Ralph Browns Interrupt list.

_________________
----> * <---- My star, won HERE
Post 28 Jul 2008, 23:18
View user's profile Send private message Reply with quote
BastetFurry



Joined: 28 Jul 2008
Posts: 4
Location: Essen, NRW, Germany
BastetFurry
windwakr wrote:

It doesn't look all that great because it doesn't wait for vertical retrace.

Trying to get that done ATM Smile
I know that under QB45 its: WAIT &h3da,8
So i have this, but he never leaves the loop.
Code:
    mov dx,0x03da
vblankloop:
    in ax,dx
    cmp ax,8
    jne vblankloop    

windwakr wrote:

Take a look at This Thread for some good links on DOS coding. Especially check out Ralph Browns Interrupt list.

Thanks Smile

EDIT:
Exchanged cmp with test and now it works. Question
Post 28 Jul 2008, 23:40
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
try this Very Happy
Post 29 Jul 2008, 00:20
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.