PDA

View Full Version : پیاده سازی گوی سرگردان در محیط مستطیل بسته (در خواست برنامه به زبان اسمبلی)



R4z!Ye
دوشنبه 28 خرداد 1386, 14:11 عصر
برنامه ای بنویسید که n رشته کاراکتری را از ورودی گرفته،این رشته را که کاراکترهای آن به رنگ مختلف نمایش داده می شوند بر روی صفحه نمایش از یک نقطه دلخواه به صورت قطری شروع به حرکت داده و پس از برخورد به گوشه های تصویر با زاویه ی مناسب برگردد.(اسمبلی)

Alay102
سه شنبه 29 خرداد 1386, 01:32 صبح
حالا ما باید این برنامه رو برای شما بنویسیم یا اینکه شما تو نوشتنش به مشکل برخوردی ، احتیاج به کمک داری ؟!؟!

دوست عزیز توقع نداشته باش که کسی وقتش رو صرف نوشتن برنامه شما بکنه ...
پیشنهاد می کنم شما خودت شروع کن به نوشتن برنامه اگه به مشکلی بر خوردی که نتونستی حلش بکنی اون وقت در این مکان مطرح کن !

موفق باشی ...

R4z!Ye
چهارشنبه 30 خرداد 1386, 16:32 عصر
سلام....
اول از شما تشکر کنم....بعدش این که خوب من چون دیدم بقیه سوالشونو این جوری البته بعضیا مطرح کردن..این کارو کردم....باشه مشکلمو میام میگم......ممنون ازتون

Smart User
پنج شنبه 31 خرداد 1386, 10:50 صبح
این میتونه برنامه جالبی باشه .. بنویسش و اگه کمک خواستی بگو..

computer_eng
دوشنبه 13 خرداد 1387, 23:12 عصر
ooooooo گوی سرگردان؟ با اسمبلی؟
می بینم که بچه های مهرآستان کارشون به اینجا هم کشیده!
ایول پورسیاه!
منم دقیقا همین برنامه رو میخوام!!!!!!!!!
اینجوری که نمیشه نمره گرفت شاید اونجوری بشه... نه؟

saghi_87
پنج شنبه 20 تیر 1387, 20:07 عصر
R4Z!YE لطفا اگه تونستی برنامه گوی سرگردانو بنویسی در اختیار ما هم قرار بده، ممنون.

Felony
جمعه 21 تیر 1387, 13:19 عصر
من قبلا نوشتم همچین چیزی ولی الان هرچی میگردم سورسش رو پیدا نمیکنم ...
برای کی میخواین شاید تا 2 یا 3 روز دیگه بتونم براتون دوباره بنویسمش و بزارم

saghi_87
یک شنبه 23 تیر 1387, 22:00 عصر
اگه بتونی تا 7 الی 8 روز دیگه بنویسی ممنونت میشم

computer_eng
دوشنبه 24 تیر 1387, 00:00 صبح
من پردازنده اینتل دارم و نمی تونم رو سیستمم برنامه اسمبلی اجرا کنم. اگر می تونید راهنمایی کنید... منتظرم

Felony
دوشنبه 24 تیر 1387, 05:44 صبح
من پردازنده اینتل دارم و نمی تونم رو سیستمم برنامه اسمبلی اجرا کنم. اگر می تونید راهنمایی کنید... منتظرم

دوست عزیز چه ربطی داره به اینتل یا AMD بودن پردازنده ی شما برای منم Intel هستش و به راحتی همه کار میکنه ...

Felony
دوشنبه 24 تیر 1387, 08:38 صبح
سورس :


title Bouncing Ball (bounce.asm)
; Dani Horowitz
; CSC111 x86 Assembly Programming
; This program displays a bouncing ball on the screen
INCLUDE Irvine32.inc
;--------------------------------------------------
.stack ; begin stack segment
;--------------------------------------------------
.data ; begin data segment
ball byte 'O' ; ball character
row byte 10 ; starting vertical location of ball
column byte 30 ; starting horizontal location of ball
xvector byte 1 ; direction of X vector (1=right, 0=left)
yvector byte 1 ; direction of Y vector (1=down, 0=up)
;--------------------------------------------------
.code ; begin code segment
;--------------------------------------------------
;--------------------------------------------------
flipx PROC
;
; Flips X vector if necessary
;--------------------------------------------------
cmp column, 70 ; did we reach right boundary?
jge FlipLeft ; if yes then goto FlipLeft
cmp column, 0 ; did we reach left boundary?
jle FlipRight ; if yes then goto FlipRight
jmp Done
FlipLeft: ; set X vector left
mov xvector,-1
jmp Done

FlipRight: ; set X vector right
mov xvector,1

Done:
ret
;--------------------------------------------------
flipx ENDP
;--------------------------------------------------

;--------------------------------------------------
;--------------------------------------------------
flipy PROC
;
; Flips Y vector if necessary
;--------------------------------------------------
cmp row, 30 ; did we reach bottom boundary?
jge FlipUp ; if yes then goto FlipUp
cmp row, 0 ; did we reach top boundary?
jle FlipDown ; if yes then goto FlipDown
jmp Done
FlipUp: ; set Y vector up
mov yvector,-1
jmp Done

FlipDown: ; set Y vector down
mov yvector,1

Done:
ret
;--------------------------------------------------
flipy ENDP
;--------------------------------------------------

;--------------------------------------------------
eraseball PROC
;
; Positions the cursor at the correct screen coordinates
; and then draws an empty string
;--------------------------------------------------
mov dh, row
mov dl, column
call Gotoxy ; goto row,column coordinates
mov al, ' '
call WriteChar ; print empty string
ret
;--------------------------------------------------
eraseball ENDP
;--------------------------------------------------

;--------------------------------------------------
drawball PROC
;
; Positions the cursor at the correct screen coordinates
; and then draws a ball
;--------------------------------------------------
mov dh, row
mov dl, column
call Gotoxy ; goto row,column coordinates
mov al, ball
call WriteChar ; print ball to screen
ret
;--------------------------------------------------
drawball ENDP
;--------------------------------------------------

;--------------------------------------------------
moveball PROC
;
; Determines new coordinates for ball
; Updates row and column values
;--------------------------------------------------
TestHorizontal:
call flipx ; flip xvector if necessary
cmp xvector,1 ; is xvector set to right?
je GoRight ; if yes goto GoRight
jmp GoLeft ; goto GoLeft

TestVertical:
call flipy ; flip y vector if necessary
cmp yvector,1 ; is yvector set to down?
je GoDown ; if yes goto GoDown
jmp GoUp ; goto GoUp

GoRight:
inc column ; move right
jmp TestVertical ; prepare to move up or down
GoLeft:
dec column ; move left
jmp TestVertical ; prepare to move up or down
GoDown:
inc row ; move down
jmp Done
GoUp:
dec row ; move up
Done:

ret
;--------------------------------------------------
moveball ENDP
;--------------------------------------------------

;--------------------------------------------------
take5 PROC
;
; Take a break! Pauses screen
;--------------------------------------------------
mov eax,100
call Delay
ret
;--------------------------------------------------
take5 ENDP
;--------------------------------------------------

;--------------------------------------------------
main proc
;--------------------------------------------------
call Clrscr ; clear screen
BounceBall:
call drawball ; draw ball to the screen
call take5 ; pause
call eraseball ; erase ball from current location
call moveball ; determine new coordinates for ball
jmp BounceBall ; loop

EndBounce:
exit

main endp
end main
;------------------------

saghi_87
دوشنبه 24 تیر 1387, 12:05 عصر
سورس :


title Bouncing Ball (bounce.asm)
; Dani Horowitz
; CSC111 x86 Assembly Programming
; This program displays a bouncing ball on the screen
INCLUDE Irvine32.inc
;--------------------------------------------------
.stack ; begin stack segment
;--------------------------------------------------
.data ; begin data segment
ball byte 'O' ; ball character
row byte 10 ; starting vertical location of ball
column byte 30 ; starting horizontal location of ball
xvector byte 1 ; direction of X vector (1=right, 0=left)
yvector byte 1 ; direction of Y vector (1=down, 0=up)
;--------------------------------------------------
.code ; begin code segment
;--------------------------------------------------
;--------------------------------------------------
flipx PROC
;
; Flips X vector if necessary
;--------------------------------------------------
cmp column, 70 ; did we reach right boundary?
jge FlipLeft ; if yes then goto FlipLeft
cmp column, 0 ; did we reach left boundary?
jle FlipRight ; if yes then goto FlipRight
jmp Done
FlipLeft: ; set X vector left
mov xvector,-1
jmp Done

FlipRight: ; set X vector right
mov xvector,1

Done:
ret
;--------------------------------------------------
flipx ENDP
;--------------------------------------------------

;--------------------------------------------------
;--------------------------------------------------
flipy PROC
;
; Flips Y vector if necessary
;--------------------------------------------------
cmp row, 30 ; did we reach bottom boundary?
jge FlipUp ; if yes then goto FlipUp
cmp row, 0 ; did we reach top boundary?
jle FlipDown ; if yes then goto FlipDown
jmp Done
FlipUp: ; set Y vector up
mov yvector,-1
jmp Done

FlipDown: ; set Y vector down
mov yvector,1

Done:
ret
;--------------------------------------------------
flipy ENDP
;--------------------------------------------------

;--------------------------------------------------
eraseball PROC
;
; Positions the cursor at the correct screen coordinates
; and then draws an empty string
;--------------------------------------------------
mov dh, row
mov dl, column
call Gotoxy ; goto row,column coordinates
mov al, ' '
call WriteChar ; print empty string
ret
;--------------------------------------------------
eraseball ENDP
;--------------------------------------------------

;--------------------------------------------------
drawball PROC
;
; Positions the cursor at the correct screen coordinates
; and then draws a ball
;--------------------------------------------------
mov dh, row
mov dl, column
call Gotoxy ; goto row,column coordinates
mov al, ball
call WriteChar ; print ball to screen
ret
;--------------------------------------------------
drawball ENDP
;--------------------------------------------------

;--------------------------------------------------
moveball PROC
;
; Determines new coordinates for ball
; Updates row and column values
;--------------------------------------------------
TestHorizontal:
call flipx ; flip xvector if necessary
cmp xvector,1 ; is xvector set to right?
je GoRight ; if yes goto GoRight
jmp GoLeft ; goto GoLeft

TestVertical:
call flipy ; flip y vector if necessary
cmp yvector,1 ; is yvector set to down?
je GoDown ; if yes goto GoDown
jmp GoUp ; goto GoUp

GoRight:
inc column ; move right
jmp TestVertical ; prepare to move up or down
GoLeft:
dec column ; move left
jmp TestVertical ; prepare to move up or down
GoDown:
inc row ; move down
jmp Done
GoUp:
dec row ; move up
Done:

ret
;--------------------------------------------------
moveball ENDP
;--------------------------------------------------

;--------------------------------------------------
take5 PROC
;
; Take a break! Pauses screen
;--------------------------------------------------
mov eax,100
call Delay
ret
;--------------------------------------------------
take5 ENDP
;--------------------------------------------------

;--------------------------------------------------
main proc
;--------------------------------------------------
call Clrscr ; clear screen
BounceBall:
call drawball ; draw ball to the screen
call take5 ; pause
call eraseball ; erase ball from current location
call moveball ; determine new coordinates for ball
jmp BounceBall ; loop

EndBounce:
exit

main endp
end main
;------------------------
:بوس: ممنون

ناز باران
شنبه 12 بهمن 1387, 12:25 عصر
با سلام من تازه عضو این سایت شدم این سورس برنامه اسمبلی شما رو گرفتم بعد از خطا یابی وارد محیط اجرا نمی شود و این پیغام رو میده که cpu با یک دستور غیر مجاز برخورد کرده لطفا اگه میشه برای رفع این خطا کمکم کنید