I have been learning Assembly and I have a question. The textbook presents the following example:
Assume that the printer data port is memory-mapped to address 0FFE0h and the printer status port is bit zero of memory-mapped port 0FFE2h. The following code waits until the printer is ready to accept a byte of data and then it writes the byte in the L.O. byte of ax to the printer port:
0000: mov bx, [FFE2] 0003: and bx, 1 0006: cmp bx, 0 0009: je 0000 000C: mov [FFE0], ax . . . . . .
The first instruction fetches the data at the status input port. The second instruction logically ands this value with one to clear bits one through fifteen and set bit zero to the current status of the printer port. Note that this produces the value zero in bx if the printer is busy, it produces the value one in bx if the printer is ready to accept additional data. The third instruction checks bx to see if it contains zero (i.e., the printer is busy). If the printer is busy, this program jumps back to location zero and repeats this process over and over again until the printer status bit is one.
Why must we perform the second instruction, and bx, 1
? Can't we just go straight to cmp bx, 0
?
Also, can you please clarify or reword "The second instruction logically ands this value with one to clear bits one through fifteen and set bit zero to the current status of the printer port"? I don't understand what it means right now because English isn't my first language.
Thank you for