Saturday, 5 December 2009

Assembler 12

Second example

- a100
0C1B:0100 jmp 125 ; Jumps to direction 125H
0C1B:0102 [Enter]
- e 102 'Hello, How are you ?' 0d 0a '$'
- a125
0C1B:0125 MOV DX,0102 ; Copies string to DX register
0C1B:0128 MOV CX,000F ; Times the string will be displayed
0C1B:012B MOV AH,09 ; Copies 09 value to AH register
0C1B:012D INT 21 ; Displays string
0C1B:012F DEC CX ; Reduces in 1 CX
0C1B:0130 JCXZ 0134 ; If CX is equal to 0 jumps to 0134
0C1B:0132 JMP 012D ; Jumps to direction 012D
0C1B:0134 INT 20 ; Ends the program

This program displays on the screen 15 times a character string.

Third example

-a100
297D:0100 MOV AH,01 ;Function to change the cursor
297D:0102 MOV CX,0007 ;Forms the cursor
297D:0105 INT 10 ;Calls for BIOS
297D:0107 INT 20 ;Ends the program

This program is good for changing the form of the cursor.

Fourth example

-a100
297D:0100 MOV AH,01 ; Funtion 1 (reads keyboard)
297D:0102 INT 21 ; Calls for DOS
297D:0104 CMP AL,0D ; Compares if what is read is a carriage return
297D:0106 JNZ 0100 ; If it is not, reads another character
297D:0108 MOV AH,02 ; Funtion 2 (writes on the screen)
297D:010A MOV DL,AL ; Character to write on AL
297D:010C INT 21 ; Calls for DOS
297D:010E INT 20 ; Ends the program

This program uses DOS 21H interruption. It uses two functions of the same: the first one reads the keyboard (function 1) and the second one writes on the screen. It reads the keyboard characters until it finds a carriage
return.

No comments:

Post a Comment