如何让用户在变量A,B和C中添加一些数字(值)?我不知道要开始写作。
stk segment stack
db 256 dup ('?') ;segment steka
stk ends
;------------------------------------------------------
code segment para public 'code'
assume cs:code,ss:stk
A db ?
B db ?
C db
答案 0 :(得分:0)
这是完整代码,如果A + B + C大于9,则此程序打印错误(greska)
data segment
poruka1 db 'Unesi,write A: ', '$'
poruka2 db 'Unesi B: ', '$'
poruka3 db 'Unesi C: ', '$'
greska db 'Greska', '$'
A db 0
B db 0
C db 0
nr db 13, 10, '$'
data ends
stk segment stack
db 256 dup (?)
stk ends
code segment
assume cs: code, ds: data, ss: stk
main:
mov ax, data
mov ds, ax
mov ah, 09h
lea dx, poruka1
int 21h
mov ah, 01h ; u al ide cifra
int 21h
mov dl, al
sub dl, 30h
mov A, dl
mov ah, 09h
lea dx, nr
int 21h
mov ah, 09h
lea dx, poruka2
int 21h
mov ah, 01h ; u al ide cifra
int 21h
mov dl, al
sub dl, 30h
mov B, dl
mov ah, 09h
lea dx, nr
int 21h
mov ah, 09h
lea dx, poruka3
int 21h
mov ah, 01h ; u al ide cifra
int 21h
mov dl, al
sub dl, 30h
mov C, dl
xor bx, bx
mov bl, A
add bl, B
add bl, C
cmp bl, 9h
jg odje
mov ah, 09h
lea dx, nr
int 21h
mov ah, 02h
mov dl, bl
add dl, 30h
int 21h
jmp kraj
odje:
mov ah, 09h
lea dx, nr
int 21h
mov ah, 09h
lea dx, greska
int 21h
kraj:
mov ax, 4c00h
int 21h
code ends
end main