'How do I store the incremented value and output it using 8086 DOS assembly language?
The goal is that whenever the user inputs the letter "s" it should increment and store but it increments one time only and it doesn't display the newer increment. Sorry for being dumb. Thanks in advance.
dosseg
.model small
.stack
.data
msg1 db "[S] Choose size $"
msg2 db "[S] Small Item $"
msg3 db "Small item has been stored: $"
msg4 db "Do you want to continue type x or y: $"
.code
base:
mov ax,@data
mov ds,ax
mov ah, 6
mov bh, 30H
mov cx, 0
mov dx, 184fH
int 10h
choose:
mov ah, 02
mov bh, 0
mov dh, 15
mov dl, 30
int 10h
mov dx,offset msg1 ;Choose a size:
mov ah,09
int 21h
mov dl, 's'
mov ah, 1 ;Condition
int 21h
cmp al, dl
je s
mov ah, 4ch
int 21h
s:
mov ah, 02
mov bh, 0
mov dh, 18 ; Position of the message db
mov dl, 30
int 10h
mov dx, offset msg3; Small item has been stored;
mov ah, 9 ;
int 21h
mov dl, dh
inc dl ; increment
add dl, 48
mov al, dl
mov ah, 2h; code for printing
int 21h
jmp continue
continue:
mov ah, 02
mov bh, 0
mov dh, 10 ;Position of the message db
mov dl, 30
int 10h
mov dx, offset msg4
mov ah, 9 ;
int 21h
mov dl, 'y'
mov ah, 1 ; condition
int 21h
cmp al, dl
je choose
mov ah, 4ch
int 21h
end base
Solution 1:[1]
Well, as far as I understood you want to store the amount of small items chosen by the user. Well the code right now does nothing in terms of storing the thing as far as I can see. So first you need to reserve some space for the amount of small item. So something like this (I do not know which assembler you are using, I could tell you the exact syntax if you give me that):
.data
smallItems dw 0h
Then inside the s:
label you need to increment this variable value.
inc [smallItems]
As I have mentioned before I have only used NASM as assembler so I do not know your assembler's syntax.
Edit: OK I found your assembler to be MASM, I have updated the code accordingly
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |