You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.MODEL SMALL.STACK 100H.CODEMAIN PROCMOVAH,1INT21H ; Input a characterMOVBL,ALMOVAH,2MOVDL,BL ; Print the input characterINT21H EXIT:MOVAH,4CHINT21H MAIN ENDPEND MAIN
; scan a character, print a new line and then print the input char.MODEL SMALL.STACK 100H.CODEMAIN PROCMOVAH,1 ; Scan the charINT21HMOVBL,ALMOVAH,2 ; Print the new lineMOVDL,0AH ; 0AH ascii code for new lineINT21HMOVDL,0DH ; Remove the space (cret 0dh)INT21HMOVAH,2 ; Print the charMOVDL,BLINT21H EXIT:MOVAH,4CHINT21H MAIN ENDPEND MAIN
; input multidigit number and print.MODEL SMALL.STACK 100H.CODEMAIN PROC ; input a four digit numberMOVAH,1INT21HMOVBL,ALINT21HMOVBH,ALINT21HMOVCL,ALINT21HMOVCH,AL ;---------------------------------- ;print a new lineMOVAH,2MOVDL,0AHINT21HMOVDL,0DHINT21H ;---------------------------------- ;Print the 4 digit numberMOVAH,2MOVDL,BLINT21HMOVAH,2MOVDL,BHINT21HMOVAH,2MOVDL,CLINT21HMOVAH,2MOVDL,CHINT21H ;---------------------------------- EXIT:MOVAH,4CHINT21H MAIN ENDPEND MAIN
; Print a string.MODEL SMALL.STACK 100H.DATA STR1 DB 'We need to print a string.$' STR2 DB 'STR1, STR2 & STR3 are string variables...$' STR3 DB 'Doller sign in the null char for the string..$'.CODEMAIN PROCMOVAX, @DATA ;initializing the data segmentMOVDS,AX ; Print the stringsLEADX, STR1 ;Load Effective AddressMOVAH,9 ;Print the 1st stringINT21HMOVAH,2 ;New LineMOVDL,0AHINT21HMOVDL,0DHINT21HLEADX, STR2MOVAH,9 ;Print the 2nd stringINT21HMOVAH,2 ;New LineMOVDL,0AHINT21HMOVDL,0DHINT21HLEADX, STR3MOVAH,9 ;Print the 3rd stringINT21H EXIT:MOVAH,4CHINT21H MAIN ENDPEND MAIN
; add two digits.MODEL SMALL.STACK 100H.CODEMAIN PROC ; input two digit [a b format]MOVAH,1INT21HMOVBL,ALMOVAH,1 ; scan a spaceINT21HMOVCL,ALMOVAH,1INT21HMOVCH,ALMOVCL,BL ;Keep the value of a for print result ;----------------------------ADDBL,CH ; BL = BL + CHSUBBL,30H ; BL = BL - 48, make the result ;Print the result [a + b = c format]MOVAH,2 ; New LineMOVDL,0AHINT21HMOVDL,0DHINT21HMOVDL,CL ; print aINT21HMOVDL,20H ; print a spaceINT21HMOVDL,2BH ; print a +INT21HMOVDL,20H ; print a spaceINT21HMOVDL,CH ; print aINT21HMOVDL,20H ; print a spaceINT21HMOVDL,3DH ; print an =INT21HMOVDL,20H ; print a spaceINT21HMOVDL,BL ; print the result cINT21H ;---------------------------- EXIT:MOVAH,4CHINT21H MAIN ENDPEND MAIN
; variable declaration, initializing the; value and scan a variable.MODEL SMALL.STACK 100H.DATA A DB 3 ; A = 3 B DB ? ; value isn't initialized.CODEMAIN PROCMOVAX, @DATA ; initializing the data segmentMOVDS,AX ; scan the value of BMOVAH,1INT21HMOV B,AL ;--------------------MOVAH,2 ; new lineMOVDL,0AHINT21HMOVDL,0DHINT21H ; print the value of the two variable ; print the value of AMOVAH,2ADD A,48 ; to make the ascii value of 3MOVDL, A ;ADD DL, 48 ; to make the ascii value of 3INT21HMOVDL,20H ; print a spaceINT21H ; print the value of BMOVDL, BINT21H ;-------------------- EXIT:MOVAH,4CHINT21H MAIN ENDPEND MAIN
.model small.stack 100h.data a db ? b db ? c db ? d db ? e db ? f db ?.codemain procmovax, @datamovds,ax ; input a bmovah,1int21hmov a,alint21h ; spacemovbl,alint21hmov b,al ;--------------------- ; add c = a + bmovbl, amov c,blmovbl, badd c,blsub c,48 ;--------------------- ; sub d = a - bmovbl, amov d,blmovbl, badd d,blsub d,54 ;--------------------- ; print a + b = cmovah,2 ; new linemovdl,0ahint21hmovdl,0dhint21hmovdl, a ; print aint21hmovdl,20h ; spaceint21hmovdl,2bh ; +int21hmovdl,20h ; spaceint21hmovdl, b ; print bint21hmovdl,20h ; spaceint21hmovdl,3dh ; =int21hmovdl,20h ; spaceint21hmovdl, cint21h ;--------------------- ; print a - b = dmovah,2 ; new linemovdl,0ahint21hmovdl,0dhint21hmovdl, a ; print aint21hmovdl,20h ; spaceint21hmovdl,2dh ; -int21hmovdl,20h ; spaceint21hmovdl, b ; print bint21hmovdl,20h ; spaceint21hmovdl,3dh ; =int21hmovdl,20h ; spaceint21hmovdl, dint21h ;--------------------- exit:movah,4chint21h main endpend main
; loop.MODEL SMALL.STACK 100H.DATA TXT DB ' Mellllooooowwww!!! $'.CODEMAIN PROCMOVAX, @DATAMOVDS,AXMOVAH,1INT21HMOVBL,ALSUBBL,48LOOP:MOVCX,0 ; Loops run in CXMOVCL,BLMOVBL,'5' SEC:MOVAH,2MOVDL,0AHINT21HMOVDL,0DHINT21HMOVDL,BLINT21HLEADX, TXTMOVAH,9INT21HINCBLLOOP SEC EXIT:MOVAH,4CHINT21H MAIN ENDPEND MAIN
; nested loop.MODEL SMALL.STACK 100H.CODEMAIN PROCMOVAH,1INT21HMOVBL,ALMOVAH,2 ; NEW LINEMOVDL,0AHINT21HMOVDL,0DHINT21HMOVBH,'1' LOOP1:MOVCL,'1' LOOP2:MOVAH,2 ; PRINT THE *MOVDL,2AHINT21HINCCLCMPCL,BHJLE LOOP2MOVAH,2 ; NEW LINEMOVDL,0AHINT21HMOVDL,0DHINT21HINCBHCMPBH,BLJLE LOOP1 EXIT:MOVAH,4CHINT21H MAIN ENDPEND MAIN
; array.MODEL SMALL.STACK 100H.DATA A DB 10 DUP(0).CODEMAIN PROCMOVAX, @DATAMOVDS,AXXORBX,BX FOR:MOVAH,1INT21HMOVCL,ALCMPCL,0DHJE END_FOR ;SUB BL, 48MOV A[BX],CLINCBXJMP FOR END_FOR:MOVAH,2 ; NEWLINEMOVDL,0AHINT21HMOVDL,0DHINT21HMOVDX,BXINT21HMOVAH,4CHINT21H MAIN ENDPEND MAIN