2017-03-01 1 views
0

두 자릿수를 더하고 VDU에 결과를 인쇄하려고하면 반환되는 최대 값은 3 자리를 초과하지 않습니다.두 자릿수를 추가하여 VDU에 인쇄하려고 시도합니다 (총 100 자 이하)

지금까지 VDU에 두 자리 숫자를 추가 할 수 있었지만이 방법을 다시 복제하고 숫자를 함께 추가하는 방법은 확실하지 않습니다. 내가 지금까지 함께 넣었습니다

코드는 다음과 같습니다

In 00 
sub al, 30 
mul al, 0a 
push al 

in 00 
sub al, 30 
pop bl 
add al, bl 

push al 
mod al, 0a 
add al, 30 
mov [c1], al 

pop al 
div al, 0a 
add al, 30 
mov [c0], al 
end 
+2

이, 8086 8 비트'al'를 밀어 수 없습니다 8086입니다. 지금까지 작성한 코드는 실제로는 어떤 코드입니다. 컴퓨터에 더 많은 코드를 추가하면 더 많은 코드가 실행됩니다. 어쩌면 재미있는 일을 할 수도 있습니다. 각 부분에서 특별한 관심을 보이기를 원한다면 어쩌면 어디에서 일어날 지 코멘트를 추가하면 다른 사람들이 자신이 옳았는지 아닌지를 알 수 있습니다. 어쩌면 예상대로 작동하는지 여부를 인식 할 수도 있습니다. – Ped7g

답변

0

당신은 단순히 8086 또는 x86 코드 유효하지 않은 명령을 많이 사용하는 것 같다!

in 00   Use a DOS function to get a character 
mul al, 0a  Move the number 10 to an extra register 
push al  Push a complete word to to stack 
pop bl   Pop a complete word off the stack 
mod al, 0a  Use the remainder you get from a division 
div al, 0a  Move the number 10 to an extra register 

이것은 (적용되지 않은 최적화)처럼 보일 수있는 것입니다 :

mov ah, 01h Input a character for the tens 
int 21h 
sub al, 30h Turn into number 
mov bl, 10 
mul al, bl  Multiplies AL by BL : So times 10 
push ax 

mov ah, 01h Input a character for the units 
int 21h 
sub al, 30h Turn into number 
mov ah, 0  Clear AH so addition works correctly 
pop bx 
add ax, bx  Add tens and units 


Here anything else! 

mov bl, 10 
div bl   Divides AX by BL : Gives remainder in AH, quotient in AL 

add ah, 30h Turn into character 
mov [c1], ah 

add al, 30h Turn into character 
mov [c0], al 
관련 문제