0dh is for the ENTER KEY and the 0ah is for the NEW LINE
Chat with our AI personalities
10 = 0AH
start: jmp main option1 db 0ah, 0dh, "1. OPTION 1 $" option2 db 0ah, 0dh, "2. OPTION 2 $" exit db 0ah, 0dh, "3. EXIT $" str1 db 0ah, 0dh, "Press Key: $" x db 0ah, 0dh, "You Pressed option 1 $" y db 0ah, 0dh, "You Pressed option 2 $" z db 0ah, 0dh, "End $" nvl db 0ah, 0dh, "Invalid Option $" one db "1" two db "2" tre db "3" main proc mov ah,09h lea dx,option1 int 21h lea dx,option2 int 21h lea dx,exit int 21h again: mov ah,09h lea dx,str1 int 21h mov ah,01 int 21h mov bl,al cmp bl,"1" je disp1 cmp bl,"2" je disp2 cmp bl,"3" je dispexit cmp al,one jne n cmp al,two jne n cmp al,tre jne n n: mov ah,09h lea dx,nvl int 21h jmp again disp1: mov ah,09h lea dx,x int 21h jmp again disp2: mov ah,09h lea dx,y int 21h jmp again dispexit: mov ah,09h lea dx,z int 21h int 20h main endp end start
name "str2bin" ; convert string number to binary! ; this program written in 8086 assembly language to ; convert string value to binary form. ; this example is copied with major modifications ; from macro "scan_num" taken from c:\emu8086\inc\emu8086.inc ; ; the original "scan_num" not only converts the string number ; but also reads the string from the keyboard and supports ; backspace key, this example is a shorten version ; of original "scan_num" macro. ; here we assume that the string number is already given, ; and the string number does not contain non-digit chars ; and it cannot cause buffer overflow (number is in word range ; and/or has only 4 digits). ; negative values are allowed in this example. ; the original "scan_num" does not allow to enter non-digits ; and it also checks for buffer overflow. ; you can the original file with other macro definitions ; in c:\emu8086\inc\emu8086.inc org 100h jmp start ; text data: msg1 db 0Dh,0Ah, " enter any number from -32768 to 65535 inclusive, or zero to stop: $" msg2 db 0Dh,0Ah, " binary form: $" ; buffer for int 21h/0ah ; fist byte is buffer size, ; second byte is number of chars actually read (set by int 21h/0ah). buffer db 7,?, 5 dup (0), 0, 0 ; for result: binary dw ? start: ; print welcome message: mov dx, offset msg1
Org 1000 mov si,1100 mov di,1400 cld mov bl,20h next: lodsb cmp al, bl je exit sub al,30h cmp al,0ah jc store sub al,07h store: stosb jmp next exit: hlt
Source program :MVI D, COUNT : Initialize counterMVI B, 00 : Initialize variable to store previous numberMVI C, 01 : Initialize variable to store current numberMOV A, B :[Add two numbers]BACK: ADD C :[Add two numbers]MOV B, C : Current number is now previous numberMOV C, A : Save result as a new current numberDCR D : Decrement countJNZ BACK : if count 0 go to BACKHLT : Stop.