More Assembler programs examples( using TASM program)
;name of the program:one.asm
;
.model small
.stack
.code
mov AH,1h ;Selects the 1 D.O.S. function
Int 21h ;reads character and return ASCII code to register AL
mov DL,AL ;moves the ASCII code to register DL
sub DL,30h ;makes the operation minus 30h to convert 0-9 digit number
cmp DL,9h ;compares if digit number it was between 0-9
jle digit1 ;If it true gets the first number digit (4 bits long)
sub DL,7h ;If it false, makes operation minus 7h to convert letter A-F
digit1:
mov CL,4h ;prepares to multiply by 16
shl DL,CL ; multiplies to convert into four bits upper
int 21h ;gets the next character
sub AL,30h ;repeats the conversion operation
cmp AL,9h ;compares the value 9h with the content of register AL
jle digit2 ;If true, gets the second digit number
sub AL,7h ;If no, makes the minus operation 7h
digit2:
add DL,AL ;adds the second number digit
mov AH,4CH
Int 21h ;21h interruption
End ; finishs the program code
This program reads two characters from the keyboard and prints them on the screen.
;name the program:two.asm
.model small
.stack
.code
PRINT_A_J PROC
MOV DL,'A' ;moves the A character to register DL
MOV CX,10 ;moves the decimal value 10 to register cx
;This number value its the time to print out after the A ;character
PRINT_LOOP:
CALL WRITE_CHAR ;Prints A character out
INC DL ;Increases the value of register DL
LOOP PRINT_LOOP ;Loop to print out ten characters
MOV AH,4Ch ;4Ch function of the 21h interruption
INT 21h ;21h interruption
PRINT_A_J ENDP ;Finishes the procedure
WRITE_CHAR PROC
MOV AH,2h ;2h function of the 21 interruption
INT 21h ;Prints character out from the register DL
RET ;Returns the control to procedure called
WRITE_CHAR ENDP ;Finishes the procedure
END PRINT_A_J ;Finishes the program code
This program prints the a character through j character on the screen
Quantum Computing: Revolutionizing the Future with Cutting-Edge
Advancements Introduction to Quantum Computing
-
Quantum Computing: Revolutionizing the Future with Cutting-Edge
Advancements
Introduction to Quantum Computing
Quantum computing is tran...
No comments:
Post a Comment