Professional Documents
Culture Documents
#make_COM#
start:
; welcome message
lea SI, msgInput
call print_string
; read num
call scan_num
; calculate sub
call Razlika
; new line
lea si, msgCR
call print_string
; result message
lea si, msgResult1
call print_string
mov ax, cx
call print_num
; print num
1
mov ax, dx
call print_num
Razlika proc
MOV DX, CX
MOV BX, 10
SUB DX, BX
; convert to BCD,
; AL = 6
; (and 1 is borrowed from AH,
; like calculating 15 - 9):
AAS
Razlika endp
RET
DEFINE_PRINT_STRING
DEFINE_SCAN_NUM
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS
END
Задача 2. Внесување на три броја x, y и z, ако x>y print x+y, ако x>z print x+z, ако y
+ z print y + z.
#make_COM#
jmp start
include 'emu8086.inc'
x dw ?
2
y dw ?
z dw ?
start:
;z=
lea SI, msgInputx
call print_string
call scan_num
;y=
lea SI, msgInputy
call print_string
mov y, cx ;cx->y
;z=
lea SI, msgInputz
call print_string
call scan_num
mov z, cx ;cx->z
mov ax, x
cmp ax, y
jb u1
add ax, y ;ako x>y
call print_num ;print x+y
ret
3
add ax, z ;x>z
call print_num ;print x+z
ret
DEFINE_PRINT_NUM
DEFINE_SCAN_NUM
DEFINE_PRINT_STRING
DEFINE_PRINT_NUM_UNS
mov dl,"a"
call display
mov dl,"b"
call display
mov dl,"c"
call display
ret
display proc
mov ah,2
int 21h
ret
display endp
end
mov cx,94
4
mov DL,21h
next: call display
inc DL
loop next
ret
display proc
mov ah,2
int 21h
ret
display endp
end
#make_COM#
#programa za preobrazuvane na ASCII kodiran simbol#
; COM file is loaded at CS:0100h
ORG 100h
MOV AL, 40H
CMP AL, 39H
JBE U1
CMP AL, 46H
JBE U2
ERR: MOV AL, 0FFH
JMP KR
U1: CMP AL, 30H
JB ERR
SUB AL, 30H
JMP KR
U2: SUB AL,40H
JE ERR
MOV BL,9H
U3: INC BL
DEC AL
JNZ U3
MOV AL,BL
JMP KR
KR: RET
END