flat assembler
Message board for the users of flat assembler.

Index > Main > Is anything wrong with this?

Author
Thread Post new topic Reply to topic
hckr83



Joined: 12 Nov 2006
Posts: 86
Location: usa
hckr83 25 Feb 2007, 22:44
I have made a super generic putpixel function..
it isn't working however...I am doing this on my emulator, hence my wierd small instruction set things..

is anything wrong with this?
Code:
PutPoint: ;ax=x bx=y cx=count dl=color
push ds
push bp

push di
mov di, 0xb800
mov ds,di
pop di


;nop
;this translates to C as bp=ax(x)+(bx(y)*320)
;mov bp,0
mov bp,ax ;bp=ax
mov ax,320
push dx
mul bx ;(bx*320)
pop dx ;ignore top word..
add bp,ax ;+

;cx is already setup
_drawing_loop:
mov [bp],dl
mov bx,0x500
cmp bp,bx
jg failure
mov ax,1

add bp,ax
loop _drawing_loop

pop bp
pop ds
ret
;;END;;
failure:
nop
nop
hlt


display_test:

mov ax,2
mov bx,0
mov cx,20
mov dl,0xF0
call PutPoint
nop

jmp infinite_loop

    

_________________
x86 CPU Emulation library: http://sourceforge.net/projects/x86lib
Post 25 Feb 2007, 22:44
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Chewy509



Joined: 19 Jun 2003
Posts: 297
Location: Bris-vegas, Australia
Chewy509 25 Feb 2007, 23:11
2 immediate problems. I assume your in 320x200x256colour graphics mode?

The screen buffer for this mode is located at a0000h not b8000h, (eg mov di, 0a000h).

Also try using a segment override when placing your pixel, eg. mov [ds:bp], dl. As a side note, I highly recommend using ES instead of DS.

Also 320 = 256 + 64... So instead of mul we can use 2 shifts and add the result.

eg.
Code:
mov di, [y] ; di = y
mov bx, di ; bx = y
shl di, 8; di = di * 256
shl bx, 6; bx = bx * 64
add di, bx ; di = di + bx
add di, [x] ; di = di + x
mov bx, 0a000h
mov es, bx
mov [es:di], dl
    
Post 25 Feb 2007, 23:11
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 25 Feb 2007, 23:12
Quote:
I have made a super generic putpixel function..

super-generic = slow
fast = totoally not generic
Post 25 Feb 2007, 23:12
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
hckr83



Joined: 12 Nov 2006
Posts: 86
Location: usa
hckr83 25 Feb 2007, 23:50
lol...it's only temporary, and I emulate the device wrong so it is at b8000..I did forget that BP uses SS though..(and it took me so long to implement that right!)
won't use ES...no support for segment overrides(yet)

lol..you'd be suprised how fun you can have coding on an imcomplete instruction set
Post 25 Feb 2007, 23:50
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 26 Feb 2007, 01:07
hckr83 wrote:

lol..you'd be suprised how fun you can have coding on an imcomplete instruction set


>++++++++[<+++++++++>-]<++++++.>+++++[<++++++>-]<+++.>++[<++>-]<+.>++
+++++++[<--------->-]<---.>+++++++++[<+++++++++>-]<+.>+++[<---->-]<-.
----.>+++[<+++>-]<++..>+++[<++++>-]<+.>+++++++++[<--------->-]<------
-.-..>+++++[<+++++>-]<+.>+++[<---->-]<-.----.>+++++[<------>-]<-.
Post 26 Feb 2007, 01:07
View user's profile Send private message Visit poster's website Reply with quote
hckr83



Joined: 12 Nov 2006
Posts: 86
Location: usa
hckr83 10 Mar 2007, 01:46
not even gonna try to get that joke...
Post 10 Mar 2007, 01:46
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 10 Mar 2007, 10:38
Smile it was BF* if I'm correct, but I don't know enough to translate it Smile
Post 10 Mar 2007, 10:38
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 10 Mar 2007, 13:47
You could uses DexOS's BF* interpreter Wink
http://jas2o.forthworks.com/dexforum/index.php?topic=55.msg1651#msg1651

PS: I would say it's " Not really!  Smile "
Post 10 Mar 2007, 13:47
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 13 Mar 2007, 08:26
Yes, I said "Not really", as in "No, I'm not surprised at all, many people enjoy weird things like that from time to time." (Just in case you misunderstood me.) Laughing

EDIT: Check here for TXT2BF.C (worked as expected w/ GCC 4.1.0, aka DJGPP 2.04 beta). Also, a good small! BF compiler (written in NASM) is bfd. Have fun! Smile
Post 13 Mar 2007, 08:26
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.