News:

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

Re: some questions about szText Macro

Started by bomz, April 07, 2012, 06:06:58 AM

Previous topic - Next topic

bomz

This Macros only makes code more readable, but represent wrong assembler philosophy .

hutch--

Everybody has a theory, yours happens to be wrong.  :tdown
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

bomz

code must be convenient to processor not for programmer

qWord

Quote from: bomz on April 07, 2012, 01:52:18 PM
code must be convenient to processor not for programmer
You have obviously never worked ...
Also, you knwo that you are using the Macro Assembler MASM?
FPU in a trice: SmplMath
It's that simple!

bomz

asm lose sense. use C you just have a lot of macros

jj2007

Quote from: bomz on April 07, 2012, 06:06:58 AM
This Macros only makes code more readable, but represent wrong assembler philosophy

Right assembler = unreadable code? You are a great philosopher, bomz :toothy

bomz

He is beginer, he write simlest example. and it's important to him not spoil assembler style. leave macros to the very end

bomz

I was happy to studied in school in which enthusiast makes computer experimental class in that time when in USSR absolutely wasn't computers. abacus - communist computers. and we devided to two direction basic and pascal - begining forever change programming style. we was as from different planet

macros useful helpful auxiliary secondary instrument

hutch--

15 years ago, what passed as assembler programmers used to say the same thing, just as assembler was dying for being unreadable and unmaintainable. The reason why it survives today is not some mindless notion of purity but flexibility and readability. MASM is a macro assembler and it made it possible to write clean clear code that did not look like a dis-assembly.

All of the old timers know how to write code the old way but it cannot be taught that way as the past has shown.

The other factor is to know the difference between code that must be fast and code that must work. Genuinely fast code is written in pure mnemonics and usually without a stack frame where code that needs to be read with no great need for speed picks up advantages by using high level macros and similar capacity in MASM. Experienced programmers know the difference, amateurs confuse the two.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave


daydreamer

there are alot of useful macros I love to use when meddling with directx code, which give me ability to easy port things from C++ dx examples
for example equates that makes me able to use "float" instead of need to translate everything in datasection to "real4's"
IF ELSE ENDIF etc macros is great for write readable code, instead of bigger cmp/jxx combination that also require you write the name of the label twice that you jump to
and do not forget about big an INVOKE becomes, especially makes code hardreadable to expand those macros in modern 32bit code which requires lots of Invokes to make a working application

Farabi

Sometimes by using macro for a beginer making it comprehends less. By telling them both side with macro and without macro, it will gave them more deep understand how things worked. But macros is very helpfull and convenient for me as a hobyist programmers. Save lots of time typing.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

donkey

Quote from: bomz on April 07, 2012, 06:06:58 AM
This Macros only makes code more readable, but represent wrong assembler philosophy .

There are thousands of macros written for MASM, you are not obliged to use any of them.

For myself I generally only use 1 external macro (CoInvoke) in my programs but then I use GoAsm which has a much less powerful macro engine and am not terribly interested in turning it into C with MOV. That said, the szText macro (well its equivalent) is intrinsic in GoAsm as are many of the more useful ones written for MASM. Readable code is extremely important if you plan on maintaining or expanding your code in the future, for example failure to use INVOKE in GoAsm makes porting your code to X64 quite a task when compared to PUSH/PUSH/CALL.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

zemtex

If we put it this way, understanding macros can't hurt. Whether you use them or not is a different case. But if you DO understand them, you will probably not consider it a weakness.
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

jj2007

I like these philosophic threads. What could be more exciting than translating...
include \masm32\include\masm32rt.inc
.code
start: print "Hello World", 13, 10
exit
end start

... into real, pure assembly?

Below I have tried my luck, almost from scratch. I call it, strictly internally of course, "Little Masochist's Hello World Program":
.386
.model flat, stdcall
option casemap :none   ; case sensitive

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

.data
szHello db "Hello World", 13, 10, 0

.data?
bWritten dd ?

.code
start:
push esi
push STD_OUTPUT_HANDLE
call GetStdHandle
push eax
mov esi, offset szHello
xor ecx, ecx
@@: mov dl, [esi+ecx]
inc ecx
cmp dl, 0
jne @B
push NULL
push offset bWritten
push ecx
push esi
push eax
call WriteFile
call CloseHandle
pop esi
push 0
call ExitProcess
end start


Sorry that I didn't find the time to duely comment my code. And a word of warning: Under the hood of "WriteFile" (a library function) there is an awful lot of code that a Real Pure Assembler ProgrammerTM should have included, too. When I was young, I used to do that. In fact I once published a book in a well-known academic publishing house that I had written myself, using my own wordprocessor. I confess that most of the word processor was written in BASIC :red but those routines that translated font data into the pixels to be sent to the screen and, later, to the printer were written in pure assembler. At least for that final step I didn't use "impure" stuff such as WriteFile :boohoo: