Quote:
> I have a problem with the following assembly language program and the related
> questions. Could anyone please help? I am new to assembly language and have
> been told that some of the instructions are illegal.
> LABEL EQU 00400H ;Array start address
> TOTAL EQU 20H ;Number of items in the array
> MOV CX,TOTAL ;Set counter to register
> MOV SI,LABEL ;Set index register
> LOOP: MOV AH,00H ;1
> INT 16H ;2
> MOV [SI],AL ;3
> ADD SI,1 ;Increment array address
> SUB [CX],1 ;Decrement loop counter
> JNZ LOOP ;Jump for next item
> END ;Assembler directive
> The questions are
> 1 - Write down suitable text for the missing comments 1 to 3
1: AH=00h selects the "read keystroke" function of INT 16h.
2: call to BIOS keyboard service: returns the ASCII code of
a key in AL.
3: Stores the ASCII code (AL) in the data segment at offset pointed
to by SI.
Quote:
> 2 - There is one deliberate error in the program where the instruction does not
> match the comment. Explain the error and write down the correct instruction.
SUB [CX],1 should be SUB CX,1 (or why not just DEC CX?)...
Quote:
> JNZ should be JMP
No, except if you want to create an infinite loop...
Quote:
> 3 - Describe in a sentence or two the overall fuction of the program.
Reads 32 (TOTAL) characters from the keyboard buffer and stores them
in a buffer starting at DS:SI.
Quote:
> 4 - Which instructions can a LOOPNZ instruction replace.
LOOPNZ LOOP could replace SUB CX,1 and JNZ LOOP...
Quote:
> If some of these instructions are illegal - I don't know which - any help would
> be greatly appreciated. Thanks.
Did I just do your homework? :-)
Take care,
Bartosz Dietrich