Hello.
I need help - I don't know how to print a variable through normal print, without masmBasic and kip irvines library. Who knows, tell me. :undecided:
print str$(myvar), 13, 10
lol
Quote from: jj2007 on July 13, 2021, 10:44:07 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
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
Quote from: jj2007 on July 09, 2021, 06:47:06 PM
- use include \Masm32\include\..., not C:\Masm32; many members use other drives
Quote from: jj2007 on July 13, 2021, 10:50:24 PM
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
Quote from: jj2007 on July 09, 2021, 06:47:06 PM
- use include \Masm32\include\..., not C:\Masm32; many members use other drives
no errors, but no output
- did you use "console assembly"?
- was an exe file created?
- did you see any error messages?
Quote from: jj2007 on July 13, 2021, 10:56:27 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.
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.
Quote from: jj2007 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.
The size is 2.50 kilobytes. I run the file from the console, half a second passes, and the program closes.
Size is ok. Mysterious - please zip the exe and attach it to a post here.
Ok
Thanks. You are victim of a very old MASM bug:
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 (http://www.terraspace.co.uk/uasm.html#p2).
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,
This is the code that I proposed, and that he apparently used. No idea where the push ax comes from :cool:
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
Hi Timo,
Here is another example :
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
Quote from: jj2007 on July 13, 2021, 11:55:33 PM
Thanks. You are victim of a very old MASM bug:
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 (http://www.terraspace.co.uk/uasm.html#p2).
There are other options? I need only MASM
Quote from: Vortex on July 14, 2021, 02:13:45 AM
Hi Timo,
Here is another example :
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
Quote from: Timofeyka on July 14, 2021, 04:13:39 AMQuote
Use UAsm (http://www.terraspace.co.uk/uasm.html#p2).
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 from: jj2007 on July 14, 2021, 04:21:03 AM
Quote from: Timofeyka on July 14, 2021, 04:13:39 AMUse UAsm (http://www.terraspace.co.uk/uasm.html#p2).
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]
.data
sd db "SS",0
So you did not use the code I posted. Please don't waste members' time with such games.
Quote from: jj2007 on July 14, 2021, 04:25:45 AM
.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
Quote from: jj2007 on July 14, 2021, 04:25:45 AM
.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
Quote from: Timofeyka on July 14, 2021, 04:29:53 AM
Quote from: jj2007 on July 14, 2021, 04:25:45 AM
.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
myvar dd 12345 ; my code: a numeric DWORD variable, ok for str$()
sd db "SS",0 ; a string variable, nonsense for str$()
Quote from: jj2007 on July 14, 2021, 04:33:36 AM
Quote from: Timofeyka on July 14, 2021, 04:29:53 AM
Quote from: jj2007 on July 14, 2021, 04:25:45 AM
.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
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
Quote from: Timofeyka on July 14, 2021, 04:35:05 AM
Quote from: jj2007 on July 14, 2021, 04:33:36 AM
Quote from: Timofeyka on July 14, 2021, 04:29:53 AM
Quote from: jj2007 on July 14, 2021, 04:25:45 AM
.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
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
Quote from: Timofeyka on July 14, 2021, 04:35:05 AMI 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?
Quote from: jj2007 on July 14, 2021, 04:39:38 AM
Quote from: Timofeyka on July 14, 2021, 04:35:05 AMI 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
Quote from: Timofeyka on July 14, 2021, 04:43:05 AMI just work with assembler only to create a mini-OS for i386
You made my day :mrgreen:
Quote from: jj2007 on July 14, 2021, 04:45:23 AM
Quote from: Timofeyka on July 14, 2021, 04:43:05 AMI 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?
Quote from: Timofeyka on July 14, 2021, 04:46:38 AMQuote from: jj2007 on July 14, 2021, 04:45:23 AMQuote from: Timofeyka on July 14, 2021, 04:43:05 AMI 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?
I used kip irvines library before, but I need to have access to both print and WriteString, and they conflict
Quote from: jj2007 on July 14, 2021, 04:45:23 AM
Quote from: Timofeyka on July 14, 2021, 04:43:05 AMI just work with assembler only to create a mini-OS for i386
You made my day :mrgreen:
As strange as it may sound, thank you for not answering) They made me read the MASM32 documentation, and it said that you need to specify the string address! :greenclp:
RTFM is an essential rule for becoming a successful programmer :thumbsup: