简体   繁体   中英

Assembly 8086 - strange result after removing a line

I have an exam today and in preparation for it, I solved this question:

We are given a small program, we need to say what it does, and then what would happen if we remove the line denoted with *

data
A DB '1A2B3C4D'
B DB 10 DUP(?)
C DB 4
.CODE
MOV AX,@DATA
MOV DS,AX
XOR BX,BX
XOR SI,SI
XOR CX,CX
MOV CL,C
LOP1: MOV AL,A[BX]
AND AL,0FH ;*
MOV AH,A[BX+1]
LOP2: MOV B[SI],AH
INC SI
DEC AL
JNZ LOP2
ADD BX,2
LOOP LOP1
END: MOV AH,4CH

The program is quite simple, I understand what it does. It puts the array ABBCCCDDDD at address B (defined in the data segment).

Now, we are asked what happens if we remove the line with *. I think nothing would change, because AL is a byte, and 0Fh is a byte where its just 11111111 in binary, so AL AND 11111111 = AL, so nothing would change.

But according to the teacher, it would make a difference, because if we don't have the line "AND AL, 0Fh" then it will write 49 times the letter A, 50 times the letter B, 51 times the letter C, because thats the ascii value of those letters.

I don't see why that's true and would like an explanation

This one is not correct: "0Fh is a byte where its just 11111111 "

It should be FFh. 0Fh is just 00001111.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM