Analysis of Checkpoint 9.2 in Assembly Language

“Assembly Language”, 3rd Edition by Wang ShuangChapter 9: Principles of Transfer Instructions, Checkpoint 9.2 (Page 184)

Complete the programming task using the jcxz instruction to find the first byte with a value of 0 in the memory segment starting at 2000H. Once found, store its offset address in dx.

assume cs:codecode segment  start: mov ax, 2000H         mov ds, ax         mov bx, 0      s: ______________         ______________         ______________         ______________          jmp short s     ok: mov dx, bx         mov ax, 4c00H         int 21Hcode endsend start         

————————Reference AnswerAnalysis: Since we need to find the first byte with a value of 0, we must search byte by byte, which means we need to operate on bytes to assign values. Therefore, when assigning a value to cx, we need to assign values to ch and cl separately.The four lines of code to be completed at label s are:mov ch, 0mov cl, [bx]jcxz okinc bxIt is important to note that for this problem, the read byte can be placed in either ch or cl, so it can also be written as:mov ch, [bx]mov cl, 0jcxz okinc bxBoth methods are valid.

Leave a Comment