Illegal instructions 
Author Message
 Illegal instructions

Hi

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
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.
JNZ should be JMP
3 - Describe in a sentence or two the overall fuction of the program.
4 - Which instructions can a LOOPNZ instruction replace.

If some of these instructions are illegal - I don't know which - any help would
be greatly appreciated.  Thanks.

Will.



Sat, 23 Dec 2000 03:00:00 GMT  
 Illegal instructions

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



Sat, 23 Dec 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Illegal Instruction Workaround

2. clipper & nt illegal instruction

3. Windows NT 3.5 Illegal Instruction

4. Any illegal instruction processing interrupts?

5. Why does this give illegal instruction?

6. Illegal instruction (core dumped)

7. drand : illegal instruction ???

8. Illegal Instruction on Mac OS X Intel

9. Illegal Instruction in Tcl_Eval()

10. 'after' causes illegal instruction errors

11. VW Coredump -> oeMain()->startSupervisor()->Illegal Instruction

12. Help! Bizarre illegal instruction / screen effects from DOS GNAT linker

 

 
Powered by phpBB® Forum Software