Printing Failure for Municipality

31 Views Asked by At

This code is for input the name age and municipality. It can print out the age and more but the municipality cannot print out the value.

.MODEL SMALL
ORG 100h

.DATA

outmsg db 'Hello User $'  
inputmsg db 0Dh, 0Ah, 'Name: $'  
inputmsg2 db 0Dh, 0Ah, 'Age: $'
inputmsg3 db 0Dh, 0Ah, 'Municipality: $'

outputMsg db 0dh, 0Ah, 'Hello, my name is $'
outputMsg2 db ', i am $'
outputMsg3 db 0dh, 0Ah, 'Years Old. I live in $'
 
buffer db 10, ?, 10 dup(' ') ;Buffer to hold input string
buffer2 db 10, ?, 10 dup(' ') 
buff db 10, ?, 10 dup(' ')

.CODE
MAIN PROC
    MOV AX, @DATA
    MOV DS, AX

    ;display hello world
    mov ah, 09h
    lea dx, outmsg
    int 21h    
    
    mov ah, 09h
    lea dx, inputMsg
    int 21h 
    
    mov dx, offset buffer
    mov ah, 0ah 
    int 21h
    
    mov ah, 09h
    lea dx, inputMsg2
    int 21h 
    
    mov dx, offset buffer2
    mov ah, 0ah
    int 21h
    
    mov ah, 09h
    lea dx, inputMsg3
    int 21h 
    
    mov dx, offset buff
    mov ah, 0ah
    int 21h  
      
    
    mov ah, 09h
    lea dx, outputMsg
    int 21h
    mov bl,buffer[1]
    mov buffer[bx + 2], '$' 
    mov dx, offset buffer + 2
    mov ah, 9
    int 21h 
    
    
    mov ah, 09h
    lea dx, outputMsg2
    int 21h
    mov bl,buffer2[1]
    mov buffer2[bx + 2], '$' 
    mov dx, offset buffer2 + 2
    mov ah, 9
    int 21h
    ret
    
    mov ah, 09h
    lea dx, outputMsg3
    int 21h

    mov bl,buff[1]
    mov buffer3[bx + 2], '$' 
    mov dx, offset buff + 2
    mov ah, 9
    int 21h
    ret
    
    
    

MAIN ENDP
END MAIN

I want to print out three inputs.

1

There are 1 best solutions below

1
Sep Roland On
.MODEL SMALL
ORG 100h

In a program for which you define .MODEL SMALL, you should not be using the ORG 100h directive. That particular directive suits the TINY memory model.
To terminate your SMALL program (.EXE) always use the code: mov ax, 4C00h int 21h. Don't use a mere ret, that again only suits the TINY model (provided the stack wasn't messed-up).

You can't see the municipality displayed since you had a program termination before that code could run. The intervening ret instruction.

mov bl,buff[1]
mov buffer3[bx + 2], '$'

You should not rely on the BH register to hold a zero! Even if in emu8086 this maybe is the case at program start, this is in general not true!
And as @Nassau already told you, buffer3 is wrong. This should read buff and emu8086 should have complained about a non-defined label. So did it complain?