Parameters may be passed to a procedure also in registers, memory (either local, or global variables), etc... in asm you have free hands.
Yet if you want to call ASM procedure from C, then every decent compiler does support stack calling convention (putting arguments into stack, as desribed above).
The Watcom compiler did support also register calling convention, which is faster and I like it much more, but
it doesn''t look it will be implemented in such cool way
in other compilers ... (watcom rules in this case)
Anonymous:
your code looks fine, and I don''t have x86 machine here to debug it, so it must be something weird (use some debugger, if you are interested, where''s the problem), yet the way you do this fill is ... ehm... WEIRD ... )
mov di,where
mov dx,SizeY
@LineLoop:
mov cx,SizeX
push di
rep stosb ; es:[di] = al, inc di, do it cx times
pop di
add di,320
dec dx
jnz @LineLoop
@end1:
this should work, and it should be faster, and it look cleaner...
---------------------------------------------------
Ped - Peter Helcmanovsky - 7 Gods demo group
http://7gods.rulez.sk
First Sight Entertainment - http://members.xoom.com/fseteam
---------------------------------------------------
Question about assembly...
---------------------------------------------------Ped - Peter Helcmanovsky - 7 Gods demo grouphttp://7gods.rulez.skFirst Sight Entertainment - http://members.xoom.com/fseteam---------------------------------------------------
I am anonymous! but not anymore
Thanx, I already had solved the problem though (read post ''Registered!'')
Here''s how my code goes:
mov al,4 ;Color
mov di,4 ;Start offset
mov bh,0 ;Y2 counter
@loop:
mov cx,10 ;Blit to screen 10 times
rep stosb ;Mov es:[di],al until CX e uppfyllt
cmp bh,10 ; Check so it only does the above 10times
je @Check ; If so, wait for mouse-click
add di,310 ; Carridge return + Line feed
inc bh ; Bh + 1
jmp @loop ; Repeat
I got some other questions though.
When I use the Macro for a routine, if I use:
Macro Draw_Pix Arg1, Arg2, Arg3
mov ax,arg1
mov bx,arg2
mov cx,arg3
Then the call must be with the exact same registers like
mov ax,10
mov bx,11
mov cx,12
Draw_Pix AX , BX, CX
else the compiler(Tasm 3.1) says ''operand types dont match''
That''s kind''o weird I think.
Second, when I want to draw to the screen, can I do like this:
.data
Pic_X equ 10
Pic_Y equ 10
@Offset db Pic_Y * 320 + Pic_X
or something, the point is that it''s very weird to write
mov di,340 when you could have written mov di,@Offset
And that hits me with another problem, when and why to use these ax,[var]??
Thanx in advance!
//Freddie
Thanx, I already had solved the problem though (read post ''Registered!'')
Here''s how my code goes:
mov al,4 ;Color
mov di,4 ;Start offset
mov bh,0 ;Y2 counter
@loop:
mov cx,10 ;Blit to screen 10 times
rep stosb ;Mov es:[di],al until CX e uppfyllt
cmp bh,10 ; Check so it only does the above 10times
je @Check ; If so, wait for mouse-click
add di,310 ; Carridge return + Line feed
inc bh ; Bh + 1
jmp @loop ; Repeat
I got some other questions though.
When I use the Macro for a routine, if I use:
Macro Draw_Pix Arg1, Arg2, Arg3
mov ax,arg1
mov bx,arg2
mov cx,arg3
Then the call must be with the exact same registers like
mov ax,10
mov bx,11
mov cx,12
Draw_Pix AX , BX, CX
else the compiler(Tasm 3.1) says ''operand types dont match''
That''s kind''o weird I think.
Second, when I want to draw to the screen, can I do like this:
.data
Pic_X equ 10
Pic_Y equ 10
@Offset db Pic_Y * 320 + Pic_X
or something, the point is that it''s very weird to write
mov di,340 when you could have written mov di,@Offset
And that hits me with another problem, when and why to use these ax,[var]??
Thanx in advance!
//Freddie
You say ''Hi'' and I say ''How?''You say ''I dont know''I am my own virusI dont need a host to live![Email]Doomer7@hotmail.com[/Email]
About JMP, isnt there some sort of limitation? like you cant jump more than a certain amount of bytes or something?
Edited by - JonatanHedborg on 3/23/00 6:54:20 AM
Edited by - JonatanHedborg on 3/23/00 6:54:20 AM
=======================Game project(s):www.fiend.cjb.net
Eh?
The jmp just jumps to an defined ''label''
Like:
@label:
mov a,b
mov c,d
jmp @label
Works like a goto instruction or something like that, I''ve never heard of any limitation and I''d be fairly suprised if there was any.
//Freddie From Sweden
You say ''Hi'' and I say ''How?''
You say ''I dont know''
I am my own virus
I dont need a host to live!
[Email]Doomer7@hotmail.com[/Email]
The jmp just jumps to an defined ''label''
Like:
@label:
mov a,b
mov c,d
jmp @label
Works like a goto instruction or something like that, I''ve never heard of any limitation and I''d be fairly suprised if there was any.
//Freddie From Sweden
You say ''Hi'' and I say ''How?''
You say ''I dont know''
I am my own virus
I dont need a host to live!
[Email]Doomer7@hotmail.com[/Email]
You say ''Hi'' and I say ''How?''You say ''I dont know''I am my own virusI dont need a host to live![Email]Doomer7@hotmail.com[/Email]
I have a big problem, im trying to write a program that draws a picture then moves(with clearing the screen and wait for retrace) it 1 step to the left, but the computer hangs up all the time when I run, and I cant figure the fucking problem,it hangs up when it has drawn the picture I dont know if it moves. Here''s the full source:
.model small ; should it be a bigger model?
.stack 100h
.data
Picture db 0,0,0,0,0,0,0,0,0,0
db 0,4,4,4,4,4,4,4,4,0
db 0,4,0,0,0,0,0,0,4,0
db 0,4,0,4,4,4,4,0,4,0
db 0,4,0,4,4,4,4,0,4,0
db 0,4,0,4,4,4,4,0,4,0
db 0,4,0,4,4,4,4,0,4,0
db 0,4,0,0,0,0,0,0,4,0
db 0,4,4,4,4,4,4,4,4,0
db 0,0,0,0,0,0,0,0,0,0
.code
start:
mov ax,@data
mov ds,ax
xor ax,ax
call @Init
mov ax,0a000h
mov es,ax
call @Clear
mov di,100 ;start X,Y
xor dx,dx ;picture height
mov si,offset Picture
xor ax,ax
@Animera:
cmp ax,2
je @Check
call @Draw
call @WaitRetrace
inc di
inc ax
call @Clear
jmp @Animera
@Draw:
push dx
mov cx,10 ;picture width
rep movsb
add di,320-10
inc dx
cmp dx,10
je @E1
jmp @Draw
@E1:
pop dx
ret
;======================
@WaitRetrace:
push dx
push ax
mov dx,3dah
@l1:
in al,dx
and al,08h
jnz @l1
@l2:
in al,dx
and al,08h
jz @l2
@quit: ; it doesnt seem to reach this part
pop dx
pop ax
ret
;=======================
@Init:
mov ax,0013h
int 10h
ret
@Clear:
push cx
push di
push ax
mov di,0
mov cx,64000
mov al,0
rep stosb
pop cx
pop di
pop ax
ret
;======================
@Check:
mov ax,5
mov bx,0
int 33h
cmp bx,1
je @Exit
jmp @Check
;======================
@Exit:
xor ax,ax
mov ax,0003h
int 10h
mov ah,4ch
int 21h
;======================
end start
Really thankfull if someone could please take the time to help me solve this..
You say ''Hi'' and I say ''How?''
You say ''I dont know''
I am my own virus
I dont need a host to live!
[Email]Doomer7@hotmail.com[/Email]
.model small ; should it be a bigger model?
.stack 100h
.data
Picture db 0,0,0,0,0,0,0,0,0,0
db 0,4,4,4,4,4,4,4,4,0
db 0,4,0,0,0,0,0,0,4,0
db 0,4,0,4,4,4,4,0,4,0
db 0,4,0,4,4,4,4,0,4,0
db 0,4,0,4,4,4,4,0,4,0
db 0,4,0,4,4,4,4,0,4,0
db 0,4,0,0,0,0,0,0,4,0
db 0,4,4,4,4,4,4,4,4,0
db 0,0,0,0,0,0,0,0,0,0
.code
start:
mov ax,@data
mov ds,ax
xor ax,ax
call @Init
mov ax,0a000h
mov es,ax
call @Clear
mov di,100 ;start X,Y
xor dx,dx ;picture height
mov si,offset Picture
xor ax,ax
@Animera:
cmp ax,2
je @Check
call @Draw
call @WaitRetrace
inc di
inc ax
call @Clear
jmp @Animera
@Draw:
push dx
mov cx,10 ;picture width
rep movsb
add di,320-10
inc dx
cmp dx,10
je @E1
jmp @Draw
@E1:
pop dx
ret
;======================
@WaitRetrace:
push dx
push ax
mov dx,3dah
@l1:
in al,dx
and al,08h
jnz @l1
@l2:
in al,dx
and al,08h
jz @l2
@quit: ; it doesnt seem to reach this part
pop dx
pop ax
ret
;=======================
@Init:
mov ax,0013h
int 10h
ret
@Clear:
push cx
push di
push ax
mov di,0
mov cx,64000
mov al,0
rep stosb
pop cx
pop di
pop ax
ret
;======================
@Check:
mov ax,5
mov bx,0
int 33h
cmp bx,1
je @Exit
jmp @Check
;======================
@Exit:
xor ax,ax
mov ax,0003h
int 10h
mov ah,4ch
int 21h
;======================
end start
Really thankfull if someone could please take the time to help me solve this..
You say ''Hi'' and I say ''How?''
You say ''I dont know''
I am my own virus
I dont need a host to live!
[Email]Doomer7@hotmail.com[/Email]
You say ''Hi'' and I say ''How?''You say ''I dont know''I am my own virusI dont need a host to live![Email]Doomer7@hotmail.com[/Email]
Hello everyone,
JonatanHedborg: As far as I''m aware (and I don''t do much ASM) JMP has no limitations, what your thinking of is instructions like JA, which use relative addressing, which means they can only jump a short distance (-128..127 bytes)from the current instruction.
Freddie: I''d love to try and help you, but your post is really long and I cannot be bothered to read it! Sorry, hope you suss it out.
George.
"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
JonatanHedborg: As far as I''m aware (and I don''t do much ASM) JMP has no limitations, what your thinking of is instructions like JA, which use relative addressing, which means they can only jump a short distance (-128..127 bytes)from the current instruction.
Freddie: I''d love to try and help you, but your post is really long and I cannot be bothered to read it! Sorry, hope you suss it out.
George.
"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
George. F"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
Assembler is very useful to speed up routines.. but why develop the ENTIRE program using ASM? I suggest to just use them in the critical places where you need the extra umph. Finding a flaw in ASM is also a very difficult task to do... but with a mixture of C and ASM your application should ROCK!
The nightmare travels across the cosmos with his burning mane. The trail of ash that is produced.
?Have a nice day!?
Assembler is very useful to speed up routines.. but why develop the ENTIRE program using ASM? I suggest to just use them in the critical places where you need the extra umph. Finding a flaw in ASM is also a very difficult task to do... but with a mixture of C and ASM your application should ROCK!
The nightmare travels across the cosmos with his burning mane. The trail of ash that is produced.
?Have a nice day!?
I agree with both of the above posts from GoofProg
George.
"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
George.
"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
George. F"Who says computer games affect kids, imagine if PacMan affected us as kids, we'd all sit around in a darkened room munching pills and listening to repetitive music....uh oh!"
I know but im've become kind of fond of assembly and really would like to make just an tetris game in ASM before i go of on C.
To make it easier to solve it for those who would like, the @clear, @Init, @draw, @exit, @check has worked so very fine in other small programs so it must be that they either crash with the newer routines @waitretrace and @animera or those routine's arent correct
Please help!
//Freddie
You say 'Hi' and I say 'How?'
You say 'I dont know'
I am my own virus
I dont need a host to live!
[Email]Doomer7@hotmail.com[/Email]
Edited by - Freddie on 3/23/00 10:20:46 AM
To make it easier to solve it for those who would like, the @clear, @Init, @draw, @exit, @check has worked so very fine in other small programs so it must be that they either crash with the newer routines @waitretrace and @animera or those routine's arent correct
Please help!
//Freddie
You say 'Hi' and I say 'How?'
You say 'I dont know'
I am my own virus
I dont need a host to live!
[Email]Doomer7@hotmail.com[/Email]
Edited by - Freddie on 3/23/00 10:20:46 AM
You say ''Hi'' and I say ''How?''You say ''I dont know''I am my own virusI dont need a host to live![Email]Doomer7@hotmail.com[/Email]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement