News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

"Binary" assembly?

Started by NoCforMe, August 10, 2022, 04:39:47 AM

Previous topic - Next topic

NoCforMe

@Hutch: In a post in the Campus, you said
Quote from: hutch-- on August 09, 2022, 01:20:09 PM
There is a response to the "no comments" brigade, real men[tm] write in binary. In the right context, binary is a ton of fun to write but its application is reasonably limited.
I'm curious to know what you mean by "binary" here. I'm imagining something like this:

01010111 ; PUSH EDI
1000110101111101 10110100 ; LEA EDI,[LOCAL.19]
10110001 01001100 000000 00000 ... 00000 ; MOV ECX,4C
0011001111000000 ; XOR EAX,EAX
11110011:10101010 ; REP STOSB
01011111 ; POP EDI

but that can't possibly be right. Who would ever code like that? and why?

So what is "binary" assembler?
Assembly language programming should be fun. That's why I do it.

quarantined

I'm thinking he meant Byte Coding e.g.,



... header here
start:

db 90h. ; nop
db 90h. ; nop
db 0C3h. ; ret

end start



Using the hexadecimal op codes...

Otherwise getting the op codes then translating to binary would be rather tedious and could get very cumbersome and of course error prone.

I'm on my iPad right now otherwise I'd give a better example...

Darn auto correct doesn't like the mnemonics


Direct binary coding would be an exercise in futility, lol

quarantined

Of course you could make a very large set of macros to help you accomplish that feat. But would still be too time consuming and too much effort.

quarantined


Quote
but that can't possibly be right. Who would ever code like that? and why?

Back in the day from what I understand the only way to code was 1's and 0's. No whiz bang gui's
And I assume was quite complicated. Some of the older old timers may remember this...

NoCforMe

Welll, I remember doing things like that back in the bad ol' days of DOS 16-bit programming. Was looking through some old include files when I came across these:

@CS MACRO
DB 2EH
ENDM

@DS MACRO
DB 3EH
ENDM

@ES MACRO
DB 26H
ENDM

@SS MACRO
DB 36H
ENDM

(Heh; remember segment overrides?* Good times ...)

But why would you need to do that nowadays?

* I can't remember the last time I even thought about using a segment register. So nice not having to deal with them in a flat address space!
Assembly language programming should be fun. That's why I do it.

NoCforMe

Quote from: quarantined on August 10, 2022, 05:09:20 AM

Quote
but that can't possibly be right. Who would ever code like that? and why?

Back in the day from what I understand the only way to code was 1's and 0's. No whiz bang gui's
And I assume was quite complicated. Some of the older old timers may remember this...

Well, there was "front-panel" programming, where you entered your program (byte-by-byte, or maybe word-by-word) by flipping switches where each switch was a bit in the byte/word. (Waaaaay before my programming time.)

https://hackaday.com/2020/10/30/altair-front-panel-tutorials/
Assembly language programming should be fun. That's why I do it.

quarantined

Quote
But why would you need to do that...

I'd imagine for fun or out of boredom. I never did any 16 bit programming, thankfully.

hutch--

Where you have a reason to write binary, hex notation does the job OK. x86 x64 have the base unit of a BYTE and bit values are done via masking so BYTE is the base unit for writing binary code in x86 x64. There are occasions where you have to produce binary output and its no big deal to do this in a sequence of hex notation. Its simply the reverse of reading hex data in a hex editor, something that is an amazingly useful tool.

NoCforMe

Can you post an example of that type of coding? I'm curious.
Assembly language programming should be fun. That's why I do it.

NoCforMe

Quote from: quarantined on August 10, 2022, 05:13:23 AM
Quote
But why would you need to do that...

I'd imagine for fun or out of boredom. I never did any 16 bit programming, thankfully.

I did a lot of 16-bit stuff. DOS programs where all the OS functions were accessed through INT 21H. Actually a very good way to learn assembler.
Assembly language programming should be fun. That's why I do it.

NoCforMe

I love reading about these old primitive computer systems.

This is what computing will look like once again in the post-zombie apocalypse era. People with old 8080s and Z80s and perfboards and soldering irons and diode matrices ... Mad Max computing. "Macro assembler"? Hah!
Assembly language programming should be fun. That's why I do it.

Vortex

Hi NoCforMe,

One possible case for binary code could be writing self modifying code.

NoCforMe

Yes, I forgot about that.

Is that allowed in Win32 programs? Does the .code section allow writes?

I hope I never have to do that in one of my programs ...
Assembly language programming should be fun. That's why I do it.

daydreamer

Quote from: NoCforMe on August 10, 2022, 05:19:19 AM
Can you post an example of that type of coding? I'm curious.
here is old example of use hexadecimal prefixes in macros so older ML 6.14 can use newer mnemonics/opcodes it originally didnt supported
http://www.masmforum.com/board/index.php?topic=973.0
this is just examine opcodes and find differences in prefix that is the difference between
MULPS (SSE) and MULPD (later SSE2 instruction set)
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

NoCforMe

Well, so those are pretty much equivalent to the segment-override macros I posted here.
Assembly language programming should be fun. That's why I do it.