Author Topic: Variable output  (Read 1697 times)

Vortex

  • Member
  • *****
  • Posts: 2583
Re: Variable output
« Reply #15 on: July 14, 2021, 02:13:45 AM »
Hi Timo,

Here is another example :

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

.data

var         dd  100
string      db 'var = %u',13,10,0

.code

start:

    invoke  crt_printf,ADDR string,var

    invoke  ExitProcess,0

END start

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #16 on: July 14, 2021, 04:13:39 AM »
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.
There are other options? I need only MASM

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #17 on: July 14, 2021, 04:15:31 AM »
Hi Timo,

Here is another example :

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

.data

var         dd  100
string      db 'var = %u',13,10,0

.code

start:

    invoke  crt_printf,ADDR string,var

    invoke  ExitProcess,0

END start
I need only MASM/WinAPI functions, no C

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #18 on: July 14, 2021, 04:21:03 AM »
Quote
Use UAsm.
There are other options? I need only MASM

Actually, the code that I posted above, and that you claim to have used, assembles fine with MASM. Save your source code, then assemble it, zip both the source and the exe and post it here.

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #19 on: July 14, 2021, 04:23:48 AM »
Use UAsm.
There are other options? I need only MASM

Actually, the code that I posted above, and that you claim to have used, assembles fine with MASM. Save your source code, then assemble it, zip both the source and the exe and post it here.
[/quote]

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #20 on: July 14, 2021, 04:25:45 AM »
Code: [Select]
  .data
    sd db "SS",0

So you did not use the code I posted. Please don't waste members' time with such games.

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #21 on: July 14, 2021, 04:29:53 AM »
Code: [Select]
  .data
    sd db "SS",0

So you did not use the code I posted. Please don't waste members' time with such games.
Sorry, I thought it wouldn't affect the code, thanks everyone for the answers

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #22 on: July 14, 2021, 04:32:46 AM »
Code: [Select]
  .data
    sd db "SS",0

So you did not use the code I posted. Please don't waste members' time with such games.
Sorry, but it only displays a numerical value

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #23 on: July 14, 2021, 04:33:36 AM »
Code: [Select]
  .data
    sd db "SS",0

So you did not use the code I posted. Please don't waste members' time with such games.
Sorry, I thought it wouldn't affect the code, thanks everyone for the answers

Every single character affects the code. There is a huge difference between
Code: [Select]
myvar dd 12345 ; my code: a numeric DWORD variable, ok for str$()
sd db "SS",0 ; a string variable, nonsense for str$()

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #24 on: July 14, 2021, 04:35:05 AM »
Code: [Select]
  .data
    sd db "SS",0

So you did not use the code I posted. Please don't waste members' time with such games.
Sorry, I thought it wouldn't affect the code, thanks everyone for the answers
Every single character affects the code. There is a huge difference between
Code: [Select]
myvar dd 12345 ; my code: a DWORD variable, ok for str$()
sd db "SS",0 ; a string variable, nonsense for str$()
I tried to make a variable with
myvar dd "Hi",0

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #25 on: July 14, 2021, 04:37:44 AM »
Code: [Select]
  .data
    sd db "SS",0

So you did not use the code I posted. Please don't waste members' time with such games.
Sorry, I thought it wouldn't affect the code, thanks everyone for the answers
Every single character affects the code. There is a huge difference between
Code: [Select]
myvar dd 12345 ; my code: a DWORD variable, ok for str$()
sd db "SS",0 ; a string variable, nonsense for str$()
I tried to make a variable with
myvar dd "Hi",0
If I don't use str$ is don't output anything

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #26 on: July 14, 2021, 04:39:38 AM »
I tried to make a variable with
myvar dd "Hi",0

Great. Trial and error is what you need as a programmer. Did you succeed? If yes, do you understand why it prints 18537? What about reading a book about numbers and all that stuff?

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #27 on: July 14, 2021, 04:43:05 AM »
I tried to make a variable with
myvar dd "Hi",0

Great. Trial and error is what you need as a programmer. Did you succeed? If yes, do you understand why it prints 18537? What about reading a book about numbers and all that stuff?
Sorry, I just work with assembler only to create a mini-OS for i386, but I'm not very familiar with newer processors, and I can ask stupid questions

jj2007

  • Member
  • *****
  • Posts: 11551
  • Assembler is fun ;-)
    • MasmBasic
Re: Variable output
« Reply #28 on: July 14, 2021, 04:45:23 AM »
I just work with assembler only to create a mini-OS for i386

You made my day :mrgreen:

Timofeyka

  • Regular Member
  • *
  • Posts: 29
Re: Variable output
« Reply #29 on: July 14, 2021, 04:46:38 AM »
I just work with assembler only to create a mini-OS for i386

You made my day :mrgreen:
str $ is only intended for converting to a string, but without it nothing is output - at the same time, Uasm / JWasm and C functions do not suit me, is there any other option?