الگوریتم مجموع ارقام یک عدد
کد برنامه به زبان Assemblyinclude io.hcr EQU 0dh ;carriage return characterlf EQU 0ah ;linefeed characterstack SEGMENT stack DW 100h DUP(?)stack ENDSdata SEGMENTprompt DB cr,lf,'sum of number''s digits.' DB cr,lf,'Please enter number: ',0number DB 40 DUP(?) answer DB cr,lf,'The result is: 'sum DB 6 DUP(?) DB cr,lf,0data ENDScode SEGMENT ASSUME cs:code,ds:datastart: mov ax,SEG data ;load data segment mov ds,axprint: output prompt inputs number,40 atoi number mov cx,10 mov bx,0 ;sumwhile_loop: div cx add bx,ah add al,0 jnz while_loop mov ax,bx itoa sum,ax output answer quit: mov al, 0 ;return code 0mov ah, 4ch ;DOS function to returnint 21h ;interupt for DOS...
تاریخ 09 اسفند 1399