Advertisement

MASM Assembly bug [SOLVED]

Started by February 07, 2015 11:15 PM
1 comment, last by NUCLEAR RABBIT 9 years, 11 months ago

Hello,

So I was working on a very lame application to practice using assembly and I got the application working and doing what I want it to, but at the application endpoint it prints out the welcome greeting string and I only have one section that calls that greet (in the beginning). Does anyone know why this could be happening? Any help is appreciated!

PS - I took a screenshot of the output for you guys to see what I mean.

age.asm:


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                              ;
;   Name: Brandon                              ;
;   Date: 2/6/2015                             ;
;   Desc: Simply asks the user for their age   ;
;         and then greets the user with the    ;
;         age value they entered in            ;
;                                              ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

.model small
.stack 100h

.data
age db ?
welcome_greet db 'Welcome to the GREATEST application EVER!!!', 10, 13, '$'
age_prompt db 'Please enter your age: ', '$'
result_prompt db 10, 13, 'The age you entered is: ', '$'
exit_prompt db 'Goodbye, hope you enjoyed this AMAZING application!', 10, 13, '$'

.code
main proc
mov AX, @DATA              ; must do everytime
mov DS, AX                 ; must also do everytime as well

lea DX, welcome_greet
mov AH, 9h                 ; DOS command to print a string
int 21h

lea DX, age_prompt         ; prompts the user for their age
mov AH, 9h
int 21h

mov AH, 1h                 ; 1h is a DOS command to read in a char
int 21h
mov AGE, AL              

lea DX, result_prompt      ; prints the result message
mov AH, 9h
int 21h

lea DX, AGE                ; prints resulting age
mov AH, 9h
int 21h

mov AH, 04ch               ; exits the DOS application
int 21h

main ENDp
end main

Not that hot on MASM coding but it looks like there need to a be and end of string character after the age. Looks like $ is used to mark the end of a string. With no end marker after age it will keep on printing the next thing in memory. What if you create a variable with a single $ after the age.


.data
age db ?
endofline db '$'

@spinningcubes | Blog: Spinningcubes.com | Gamedev notes: GameDev Pensieve | Spinningcubes on Youtube

Advertisement

Not that hot on MASM coding but it looks like there need to a be and end of string character after the age. Looks like $ is used to mark the end of a string. With no end marker after age it will keep on printing the next thing in memory. What if you create a variable with a single $ after the age.


.data
age db ?
endofline db '$'

you must be a wizard biggrin.png thank you!

This topic is closed to new replies.

Advertisement