1
我對我的代碼打印,我沒能解決問題..打印輸出錯誤與assymble代碼
我的程序很簡單敏銳地這是對如何繪製簡單的線性方程實踐
x在-2和2之間爲常數
並且用戶必須在線性等式y = ax + b中輸入一個& b。
一個& b的簽約用戶還必須輸入符號
,程序必須給5對(Y,X),但它不是爲我工作
這裏是代碼:
{
; multi-segment executable file template.
data segment
; add your data here!
x db -2,-1,0,1,2
r1 dw 0,0,0,0,0
r2 dw 0,0,0,0,0
z1 dw 0,0,0,0,0
z2 dw 0,0,0,0,0
a1 db 0
a2 db 0
b1 db 0
b2 db 0
m1 db "This program will give u 5 pairs of result for the following eqn 'y=ax+b' where x is between -2 & 2.",0ah,0dh,"$",0ah,0dh
m2 db 0ah,0dh,"Enter the sign of 'a',(+,-)",0ah,0dh,"$",0ah,0dh
m3 db 0ah,0dh,"Enter 'a'",0ah,0dh,"$",0ah,0dh
m4 db 0ah,0dh,"Enter the sign of 'b',(+,-)",0ah,0dh,"$",0ah,0dh
m5 db 0ah,0dh,"Enter 'b'",0ah,0dh,"$",0ah,0dh
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
lea dx, m1
mov ah, 9
int 21h
lea dx, m2
mov ah, 9
int 21h
xor ax,ax
mov ah, 1 ;entering the sign of "a"
int 21h
CMP al,'-'
jnz next
lea dx, m3
mov ah, 9
int 21h
mov ah, 1 ;entering "a"
int 21h
sub al,30h
neg al
mov a1,al
xor ah,ah
xor si,si
mov cx,5
mul1:
mov al,a1
imul x[si]
mov r1[si],ax ;saving the result from multiplying "-ax"
inc si
loop mul1
jmp b
next: ;if "a" was pasitive
lea dx, m3
mov ah, 9
int 21h
mov ah, 1 ;entering "a"
int 21h
sub al,30h
mov a2,al
xor ah,ah
xor si,si
mov cx,5
mul2:
mov al,a2
imul x[si]
mov r2[si],ax ;saving the result from multiplying "ax"
inc si
loop mul2
b: lea dx, m4
mov ah, 9
int 21h
mov ah, 1 ;entering the sign of "b"
int 21h
CMP al,'-'
jnz next1
lea dx, m5
mov ah, 9
int 21h
mov ah, 1 ;entering "b"
int 21h
sub al,30h
mov b1,al
xor ah,ah
xor si,si
mov cx,5
sub1:
mov al,b1
sub ax,r1[si]
mov z1[si],ax ;saving the result from the op "ax-b"
inc si
loop sub1
jmp print1
next1:
lea dx, m5
mov ah, 9
int 21h
mov ah, 1 ;entering "b"
int 21h
sub al,30h
mov b2,al
xor ah,ah
xor si,si
mov cx,5
add1:
mov al,b2
add ax,r2[si]
mov z2[si],ax ;saving the result from the op "ax+b"
inc si
loop add1
jmp print2
;printing the 5 pairs (x,y) when ax-b
print1:
xor si,si
mov cx,5
print:
mov dl,0ah
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
mov dl,'('
mov ah,2
int 21h
lea dx,x[si]
mov ah,9
int 21h
mov dl,","
mov ah,2
int 21h
lea dx,z1[si]
mov ah,9
int 21h
mov dl,")"
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
inc si
loop print
jmp end1
print2: ;printing the 5 pairs (x,y) when ax+b
xor si,si
mov cx,5
print11:
mov dl,0ah
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
mov dl,"("
mov ah,2
int 21h
lea dx,x[si]
mov ah,9
int 21h
mov dl,","
mov ah,2
int 21h
lea dx,z2[si]
mov ah,9
int 21h
mov dl,")"
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h
inc si
loop print11
end1 :
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
}
和感謝提前的幫助:)
沒有消息能夠被正確打印.. – 2015-04-05 18:25:53
實際的問題是在最後結果時,我想打印Ÿ – 2015-04-05 18:26:50
見編輯答案。同樣的問題4次。 – 2015-04-05 18:29:52