News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MSG help

Started by Bipolargod, July 09, 2007, 02:17:40 AM

Previous topic - Next topic

Bipolargod

FIXED: Problem found I forgot to add in the db and I reversed the bit numbers at the end.  Can you plz try my program to see how you like it?

Ok I written a program that when a certain button is pushed that a message will appear.  But when I declare the message types: msg1, msg2, msg3, msg4 all I get are mnemomic errors on the msg part.  Whats wrong with it?  Here is the program.  I am just a beginner if you must know so plz no flaming at me.




jmp start

msg1 db "Hello World!$"

msg2 db "Hello Galaxy!$"

msg3 db "Hello Universe!$"

msg4 db "Press either 1, 2, or 3." ,10, 13, "$"

start:
  mov ah,09      ; sub-function 9
  mov dx,offset msg4   ; dx holds msg4
  int 21h      ; execute msg4
  mov ah,08      ; sub-function 8
  int 21h      ; read character
  CMP al,49      ; compare al and 1(ascii 1=49 etc.)
  JZ num_1      ; jmp to num_1 if equal
  CMP al,50      ; compare al and 2
  JZ num_2      ; jmp to num_2 if equal
  CMP al,51      ; compare al and 3
  JZ num_3      ; jmp to num_3 if equal

num_1:
  mov ah,09
  mov dx,offset msg1
  int 21h
  jmp exit

num_2:
  mov ah,09
  mov dx,offset msg2
  int 21h
  jmp exit

num_3:
  mov ah,09
  mov dx,offset msg3
  int 21h
  jmp exit

exit:
  mov ah,4ch
  mov al,00
  int 21h
 

Rockphorr

Do you try to press 4 on your program choice ???
I think that will to outing msg1.

...
CMP al,51      ; compare al and 3
  JZ num_3      ; jmp to num_3 if equal
jmp exit
...





Strike while the iron is hot - Бей утюгом, пока он горячий

MichaelW

I'm guessing that the jump around the data means that this is supposed to be a .COM program instead of a .EXE. To ML and the 16-bit linker this would be a "tiny" memory model. So if I add the missing components:

.model tiny
.code
.startup

  jmp start

msg1 db "Hello World!$"

msg2 db "Hello Galaxy!$"

msg3 db "Hello Universe!$"

msg4 db "Press either 1, 2, or 3." ,10, 13, "$"

start:
  mov ah,09      ; sub-function 9
  mov dx,offset msg4   ; dx holds msg4
  int 21h      ; execute msg4
  mov ah,08      ; sub-function 8
  int 21h      ; read character
  CMP al,49      ; compare al and 1(ascii 1=49 etc.)
  JZ num_1      ; jmp to num_1 if equal
  CMP al,50      ; compare al and 2
  JZ num_2      ; jmp to num_2 if equal
  CMP al,51      ; compare al and 3
  JZ num_3      ; jmp to num_3 if equal

num_1:
  mov ah,09
  mov dx,offset msg1
  int 21h
  jmp exit

num_2:
  mov ah,09
  mov dx,offset msg2
  int 21h
  jmp exit

num_3:
  mov ah,09
  mov dx,offset msg3
  int 21h
  jmp exit

exit:

  mov ah,4ch
  mov al,00
  int 21h

end

Name the file bipolar.asm, assemble with ML /c bipolar.asm, and link with LINK16 /tiny bipolar.obj (and ignore the "name of output file is bipolar.com" warning, then the program runs OK.
eschew obfuscation

Rockphorr

Quote from: MichaelW on September 12, 2007, 01:24:00 AM
Name the file bipolar.asm, assemble with ML /c bipolar.asm, and link with LINK16 /tiny bipolar.obj (and ignore the "name of output file is bipolar.com" warning, then the program runs OK.
Program runs ok but work with the artefact. Any another key does as 1.
Strike while the iron is hot - Бей утюгом, пока он горячий

MichaelW

Yes, I noticed that but I didn't bother to correct it. I think jmp start might be a better choice.
eschew obfuscation