3 Replies - 1838 Views - Last Post: 06 December 2012 - 07:48 PM

#1 aquilina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-December 11

Problem-Assembly Language programming

Posted 06 December 2012 - 01:21 PM

I having a problem in assembly code.. i need some one to fix it or get help on this language.. below is my code
a 100
mov ah, 09
mov dx, 200
int 21
mov ah, 3f
mov dx, 300
int 21
mov ah, 09
mov dx, 280
int 21
mov ah, 09
mov dx, 300
int 21
mov ah, 09
mov dx,221
int 21
mov ah, 3f
mov dx, 320
int 21
mov ah,09
mov dx,293
int 21
mov ah, 09
mov dx, 320
int 21
int 20

a 200
db "     Please enter your name   : $"
a 221
db "     Please enter your age    : $"

a 280
db "     Your name is $"
a 293
db "     You are $ years old"

a 320
db 0D, '$                  '
a 340
db 0D, '$'


rcx
399
rcx
499
n test.com
w
quit


and here is the ss of it.. there's something that missing from the output.. its should be "You are 12 years old"
Posted Image

Is This A Good Question/Topic? 0
  • +

Replies To: Problem-Assembly Language programming

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,302
  • Joined: 28-March 11

Re: Problem-Assembly Language programming

Posted 06 December 2012 - 05:58 PM

Might I offer you a few suggestions...

Comment your code!!!

Spaces between you functions...
This:
mov ah, 09
mov dx, 200
int 21
mov ah, 3f
mov dx, 300
int 21
mov ah, 09
mov dx, 280
int 21

becomes this:
mov ah, 09
mov dx, 200
int 21

mov ah, 3f
mov dx, 300
int 21

mov ah, 09
mov dx, 280
int 21


Use descriptive names for your variables!!!!!!!!! Seriously, an a? Variables are used to make code more readable and cut down on bugs... I am not even going to try to figure out what your code does.. Use them!
szPrompt1 db "     Please enter your name   : $"
szPrompt2 db db "     Please enter your age    : $"


and use them like this:
mov ah, 09
lea dx, szPrompt1
int 21

Someone can look at your code and know you are trying to print szPrompt1 to the terminal instead of all the number offsets.

Not even sure how it even works, as the interrupt to "WRITE STRING TO STANDARD OUTPUT" is INT 21H, not INT 21.

INT 20 to exit? Usually we use INT 21H/AX =4Ch

What is the string terminator in DOS? What character tells DOS the end of string is here? It is the "$" sign, "You are $ years old" - your telling DOS the end of the string is after "You Are" and you can print the name after that. Maybe double quote the $ in your string?
Was This Post Helpful? 0
  • +
  • -

#3 aquilina  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 05-December 11

Re: Problem-Assembly Language programming

Posted 06 December 2012 - 07:38 PM

once i tried the szPrompt1 and the lea dx, szPrompt, it give me a weird sysmbol came out...
Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,302
  • Joined: 28-March 11

Re: Problem-Assembly Language programming

Posted 06 December 2012 - 07:48 PM

No need to quote the whole post above your reply. FTFY.

You got weird characters? Without seeing your code, it is hard to say.

A DOS program is setup different than a 32bit app. You need to set ds to your data section, and define your variables there.

Without knowing what Assembler you are using, I cannot tell you how to do it. In most Assemblers, your strings would be in the .data section.
.data
szHello db "Hello there with INT 21H! $"


And the following produce the same result:
	lea     dx, szHello
	mov     ah, 09h
	int     21h

	mov     dx, offset szHello
	mov     ah, 09h
	int     21h

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1