To move value in register
MOV AX,0001
MOV BX,0002
Then
CMP AX,BX
JL IF_THEN
- Here JL=JUMP IF LOW means if AX is less than BX.
- IF_THEN is a label used in conditional jump JL.
- We have to define the body of the label ,which will perform further comparisons.
IF_THEN: ;BODY OF IF_THEN LABEL
CMP BX,CX ;COMPARE IF BX IS LESS THAN CX
JL DISPLAY ;JUMP TO ANOTHER LABEL IF LESS
DISPLAY: ;BODY OF DISPLAY
MOV DL,01
MOV AH,4CH
INT 21
Q5:TITLE to determine user input then display it
We have to define a byte for message in DATA segment
.DATA
MSG DB 'YOU ENTERED $'
CHR DB 'A$'
.CODE
;For character input
MOV AH,2
INT 21H
Storing the input character in another register for later use
MOV BH,AL
For other input perform the above task ,but store the input value in BL otherwise it will override the previous value.
To check what is the input from the user,we have to be aware of ASCII table .In ASCII table ,uppercase letters start from 41 as A and so on.So to check whether it is A or B we perform CMP to check
CMP BH,41H
JE DISPLAY
This will subtract the source 41H from value stored in BH.If the input character is A then value stored in BH will be 41 so 41-41=0.So the jump JE (Jump if equal) will be taken to the display label
DISPLAY:
MOV AH,09 ;FOR STRING OUTPUT
LEA DX,MSG ;LOADING THE ADDRESS OF MSG DEFINED IN .DATA
INT 21H
MOV AH,09
LEA DX,CHR
INT 21H
The above code of DISPLAY will first load address of defined byte MSG in DX and will display the string on the screen then the character A afterwards.
Q6:TITLE to display * on all console
As our console has 25 rows and 80 columns.
To understand this,remember the concept of Matrix if 2 row and three column then total elements 2*3=6
This is the concept applied here
25*80=2000
as internally assembler is performing hexadecimal ,but 2000 is in decimal so 2000 in hexa is 256.
Simply use counter register
MOV CX,256
This will run a loop 256 times and apply appropriate display of * label as defined in the previous tasks.
This will print * on the whole console.
Q7:TITLE to display characters in ascending order
----------------------
If you have any question,you can ask me in the comments section.
For further updates ,you can subscribe my blog
0 comments:
Post a Comment