ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
 
   ProfileProfile   Log in to check your private messagesLog in to check your private messages  |  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups Log inLog in   RegisterRegister 

برنامه مبدل مبنا از 10 به 4 و 8 و 16

 
Post new topic   Reply to topic    ParsX.com Forum Index -> ساختمان و زبان ماشين
View previous topic :: View next topic  
Author Message
vahid
بي تو هرگز


Joined: 26 Nov 2004
Posts: 2973
Location: Tehran

PostPosted: Wed Jan 26, 2005 11:47 am    Post subject: برنامه مبدل مبنا از 10 به 4 و 8 و 16 Reply with quote

برنامه زير به زبان اسمبلي نوشته شده است كه خانه اي از حافظه كه ادرس n را دارد به مبناي 4 و 8 و 16 تبديل ميكند و در خروجي نشان ميدهد .
;this program convert N to base in 4 and 8 and 16
; by computer.parsx.com
.model small
CR macro
mov ah,2
mov dl,10;cr
int 21h
mov dl,13;lf
int 21h
endm
.stack 64 ;byte
.data
n db 20
text4 db '4 base:$'
text8 db '8 base:$'
text16 db '16 base:$'
.code
start:
mov ax,@data
mov ds,ax
lea dx,text4
mov ah,9
int 21h
call proc4 ; decode to 4th base
cr
lea dx,text8
mov ah,9
int 21h
call proc8 ; decode to octal
cr
lea dx,text16
mov ah,9
int 21h
call proc16; decode to hex
mov ah,4ch
int 21h
proc4 proc near
mov cl,8
parsx4:
mov ah,n
sub cl,2
shr ah,cl
and ah,3
add ah,'0'
mov dl,ah
mov ah,2
int 21h
cmp cl,0
jne parsx4
ret
proc4 endp
proc8 proc
mov cl,9
parsx8:
mov ah,n
sub cl,3
shr ah,cl
and ah,7
add ah,'0'
mov dl,ah
mov ah,2
int 21h
cmp cl,0
jne parsx8
ret
proc8 endp
proc16 proc
mov cl,16
parsx16:
mov ah,n
sub cl,4
shr ah,cl
and ah,7
cmp ah,9
jb hexa
sub ah,10
hexa:
add ah,'0'
mov dl,ah
mov ah,2
int 21h
cmp cl,0
jne parsx16
 ret
proc16 endp
end start;
Back to top
arash
مدير بخش سي
مدير بخش سي


Joined: 27 Nov 2004
Posts: 1232
Location: www.parsx.com

PostPosted: Thu Jan 27, 2005 5:07 am    Post subject: Reply with quote

وحید جان کاش تکه تکه با استفاده از include macro.asm می نوشتی
Back to top
vahid
بي تو هرگز


Joined: 26 Nov 2004
Posts: 2973
Location: Tehran

PostPosted: Thu Jan 27, 2005 1:27 pm    Post subject: Reply with quote

خودت مينوشتي Razz
Back to top
Display posts from previous:   
Post new topic   Reply to topic    ParsX.com Forum Index -> ساختمان و زبان ماشين All times are GMT + 3.5 Hours
Page 1 of 1

 
Jump to:  
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