Created
February 9, 2012 15:05
-
-
Save rolisz/1780513 to your computer and use it in GitHub Desktop.
Rezolvare problema 2 AC grupa 215
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assume cs:code, ds:data | |
data segment | |
original dd 12A63478h | |
dd 12345678h | |
dd 1A2B3C4dh | |
dd 0FEDC9876h | |
lungime db (lungime-original)/4 | |
ranks db 10 DUP(?) | |
suma dw 0 | |
contor db 0 | |
numar db 10 DUP(?) | |
nrCifre db 0 | |
data ends | |
code segment | |
convertString proc | |
mov nrCifre,0 | |
mov di,offset(numar) | |
cmp ax,0 | |
jge pozitiv | |
push ax | |
mov al,'-' | |
stosb | |
pop ax | |
neg ax | |
pozitiv: | |
imparte: | |
mov dx,0 | |
mov bx,10 | |
div bx | |
push dx | |
inc nrCifre | |
cmp al,0 | |
jne imparte | |
puneinstring: | |
pop ax | |
add ax,'0' | |
stosb | |
dec nrCifre | |
cmp nrCifre,0 | |
jne puneinstring | |
mov al,' ' | |
stosb | |
mov al,'$' | |
stosb | |
ret | |
convertString endp | |
start: | |
mov ax, data | |
mov ds, ax | |
mov es,ax | |
mov di,offset(ranks) | |
mov cl,lungime | |
mov ch, 0 | |
cld | |
mov si, offset(original) | |
add si, 2 | |
mov contor,1 | |
repeta: | |
lodsb | |
cmp al,0 | |
jge peste | |
cbw | |
add suma, ax | |
mov al,contor | |
mov ah,0 | |
call convertString | |
mov ah,09h | |
mov dx,offset(numar) | |
int 21h | |
peste: | |
inc contor | |
add si,3 | |
loop repeta | |
mov ax,suma | |
call convertString | |
mov ah,09h | |
mov dx,offset(numar) | |
int 21h | |
mov ax,4c00h | |
int 21h | |
code ends | |
end start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
... ai incercat fasm ? eu as fi adaugat la assume si es:dseg , ss:sseg .
in teorie se spune ca assume este direct legat de legatura intre segment si date.
nu este obligatoriu , dar te poate ajuta in anumite cazuri :)