رووبيي
12-01-2007, 10:11 PM
السلام عليكم ورحمة الله وبركاته
مساء الخير لكل الموجودين :silly:
نبي هالموضوع لاهنتوا يعني لو مريتوا وكان عندكم برامج محلوله بلغة الأسمبلي تحطونها هنا
عشان الإستفاده للكل
بس قبل لا تحطون حل البرنامج حطو وش سالفته ( يعني وش يبي بالضبط :09: ) يعني وش يسوي بعدين حطوا الحل
لأنها تفيد الطلاب والطالبات اللي يدرسون هالماده
انا عن نفسي عندي كذا برنامج
متى ما خلصت منهم راح انزلهم
عشان يصير تبادل خبرات بين الأعضاء
وبعدين مهما كانت صعوبة البرنامج او مهما كانت سهولته سواء كان للمبتدئين او للمحترفين
ما يمنع هالشي من وضعه
لأن اللي راح يمر على هالموضوع شرائح كثيره مختلفه ثقافتهم
تحياتي لكم
رووبيي
13-01-2007, 11:27 PM
هذا اول برنامج يطلب من اليزور يدخل رقم هكس مكون من أربع أرقام أو أقل
ويطبعه باينري بالسطر اللي بعده لما يطبع غلط يطلب منه يدخل رقم هكس مره ثانيه
ويقبل الأبر كيس ولا يقبل اللور كيس
.CODE
main proc
mov ax,@data
mov ds,ax
;read a character
mov ah,1
int 21h
mov cl,4
;check for hex input,
while: CMP al,0DH
JE End_while
CMP al,"0" ;read value in al >=0?
JNGE NONHEX ;No, not a HEX
CMP al,"9" ;read value in al <=9 ?
JLE NUM
;No,CHECK IF HEX LETTER
CMP AL,"A"
JNGE NONHEX
CMP AL,"F"
JNLE NONHEX
jmp hexlett
;if value entered is within the range of (0..FFFF), start INSERTing to NUM
NUM: AND
Al,0F
JMP INSERT ;mask off code,keep decimal value,ex.(32h ? 02)
HEXLETT:SUB AL,37H
INSERT: MOV bl,al
SHL Bx,cl ;add only the actual value and not the code
nondigit:Int 21h
Jmp while
; display Sum stored in BX as binary output
End_while:
Mov ah,2 ;start binary output
Mov cx,16 ;repeat 16times to display 16bits stored in SUM
next: ROL bx,1 ;shift to get
one bit only from the byte
JC Print_1 ;check bit if 1 then print 1
Mov dl,'0' ;otherwise, print 0
jmp display
Print_1:Mov dl,'1'
display:int 21
loop next ;decrement cl and repeat if cl is not zero
mov ah,4Ch
int 21h
main endp
end main
وهذاا واحد ثاني رحه بالكومنت ووظيفته
;This program prompts to enter stream character ended with CR. Calculate cumulative sum Print Sum in Hex.
.MODEL SMALL
.STACK 100H
.DATA
MSG DB 0Dh,0Ah,'Enter a
hex # (0...FFFF): $'
MSG1 DB 0Dh,0Ah,'The Cumulative Sum in Hex is:$ '
SUM DW 0
.CODE
main proc
mov ax,@data
mov ds,ax
;display a message
mov cl,4 ;initialise # if shifts
top: mov ah,9
LEA dx,MSG
int 21h
XOR BX,BX ; initilalise number
XOR Dx,DX ; initialise sum of numbers
;read a character
mov ah,1
While_: int 21h
;check for end of string input, if not,add to
sum
CMP al,0DH
JE End_while
cmp al,'9'
JG alpha
sub al,30h
jmp insert
alpha: sub al,37h
insert: mov dl,al
add SUM, DX ; to add a read value to sum
shl bx,cl
OR bl,al
Jmp while_ ;loop back to read next character
; display Sum stored in BX as hex output
End_while:
getsum:
mov BX,SUM
mov AH,9
lea DX,MSG1
INT 21H
MOV AH,2
mov dl,Bh
noc: mov ch,4 ;repeat 4 times to display 4 hex digits in SUM
Mov
cl,4 ; number of shifts
next: Mov dl,bh ;start printing from the left,print digit in high byte
SHR dl,cl ;shift to get the first one digit only from the hi byte
CMP dl,09h ;check SUM stored as hex letter(A..F)/or hex#(0..9)
Jg letter
ADD
dl,30h ;convert to ascii character of decimal code
Jmp display
letter: Add dl,37h ;convert to ascii character of letter code
display: int 21h ;print it
ROL bx,cl ;get next stored digit from the left
dec ch ;decrement ch and repeat if ch is not zero
jnz next
mov
ah,4Ch
int 21h
main endp
end main
جميع حقوق برمجة vBulletin محفوظة ©2025 ,لدى مؤسسة Jelsoft المحدودة.
جميع المواضيع و المشاركات المطروحة من الاعضاء لا تعبر بالضرورة عن رأي أصحاب شبكة المنتدى .