Author Topic: Variable output  (Read 1696 times)

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Variable output
« on: July 13, 2021, 10:42:32 PM »
Hello.
I need help - I don't know how to print a variable through normal print, without masmBasic and Irvine32. Who knows, tell me. :undecided:

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #1 on: July 13, 2021, 10:44:07 PM »
print str$(myvar), 13, 10

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #2 on: July 13, 2021, 10:44:56 PM »
lol

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #3 on: July 13, 2021, 10:47:50 PM »
print str$(myvar), 13, 10
My code with this is not working
  .686
  .model flat, stdcall
  option casemap :none
  include C:\masm32\include\masm32rt.inc
  .data
    s db "SS",0
  .code
  main:
    print str$(s)
  end main

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #4 on: July 13, 2021, 10:50:24 PM »
Code: [Select]
include \masm32\include\masm32rt.inc

.data
myvar dd 12345

.code
start:
  print str$(myvar), " is the value of myvar", 13, 10
  inkey "press any key"
  exit

end start

- use include \Masm32\include\..., not C:\Masm32; many members use other drives

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #5 on: July 13, 2021, 10:54:28 PM »
Code: [Select]
include \masm32\include\masm32rt.inc

.data
myvar dd 12345

.code
start:
  print str$(myvar), " is the value of myvar", 13, 10
  inkey "press any key"
  exit

end start

- use include \Masm32\include\..., not C:\Masm32; many members use other drives

no errors, but no output

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #6 on: July 13, 2021, 10:56:27 PM »
- did you use "console assembly"?
- was an exe file created?
- did you see any error messages?

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #7 on: July 13, 2021, 11:25:22 PM »
- did you use "console assembly"?
- was an exe file created?
- did you see any error messages?
1. Yes(Subsystem in Link).
2. Yes.
3. No.
I have now specially compiled and linked manually.

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #8 on: July 13, 2021, 11:28:00 PM »
How many bytes does your executable have?
What exactly do you see when you run the exe from a DOS prompt?

The only reason I could imagine that you don't see anything would be an AV that silently blocks the exe.

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #9 on: July 13, 2021, 11:29:35 PM »
How many bytes does your executable have?
What exactly do you see when you run the exe from a DOS prompt?

The only reason I could imagine that you don't see anything would be an AV that silently blocks the exe.
The size is 2.50 kilobytes. I run the file from the console, half a second passes, and the program closes.

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #10 on: July 13, 2021, 11:31:11 PM »
Size is ok. Mysterious - please zip the exe and attach it to a post here.

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #11 on: July 13, 2021, 11:36:55 PM »
Ok

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #12 on: July 13, 2021, 11:55:33 PM »
Thanks. You are victim of a very old MASM bug:
Code: [Select]
Address   Hex dump          Command                                  Comments
00401000  /$  68 03304000   push offset 00403003
00401005  |.  6A 00         push 0                                   ; /Arg2 = 0
00401007  |.  A0 00304000   mov al, [403000]                         ; |ASCII "SS"
0040100C  |.  66:0FB6C0     movzx ax, al                             ; |
00401010  |.  66:50         push ax                                  ; |Arg1<<<<<<<<<<<<<< BUG <<<
00401012  |.  E8 19000000   call 00401030                            ; \main.00401030

Use UAsm.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8497
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Variable output
« Reply #13 on: July 14, 2021, 12:06:03 AM »
You may need to add that you don't normally PUSH a 16 bit register in 32 bit as an argument. He probably needs UASM where MASM requires correct code.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #14 on: July 14, 2021, 02:01:31 AM »
Hutch,

This is the code that I proposed, and that he apparently used. No idea where the push ax comes from :cool:

Code: [Select]
include \masm32\include\masm32rt.inc

.data
myvar dd 12345

.code
start:
  print str$(myvar), " is the value of myvar", 13, 10
  inkey "press any key"
  exit

end start