Wolfgang Kern wrote:
> Frank Kotler wrote:
>
>
>>>>db "Hello There",$
>
>
>>>It's just a string definition, usually preceded by a label.
>>>If you find it within code right after a call without a label,
>>>then you found one of these well known weird HLL functions.
>
>
>>; nasm -f bin -o pfm.com pfm.asm
>>
>>org 100h
>>segment .text
>> call print_following_message
>> db 'Hello, World!', 0Dh, 0Ah, 0
>>; note: zero-terminated, not '$'!!!
>>
>>; mov ah, 4Ch ; or "exitprocess" of your choice
>>; int 21h
>> ret
>>
>>;----------------------
>>; trashes si
>>;----------------------
>>print_following_message
>> ;xchg si, [esp] ; if known 386+
>> pop si
>> push ax
>>pfm1:
>>; lodsb ; ok if ds == cs
>> mov al, [cs:si]
>> inc si
>> or al, al
>> jz pfm2
>> int 29h ; or "putchar" of your choice
>> jmp pfm1
>>pfm2:
>> pop ax
>> push si
>> ;xchg si,[esp] ; if known 386+
>> ret
>>;-------------------------
>>
>>Where's the HLL? "Weird"? Okay... "weird" I'll give ya! :)
>
>
> When I first saw this method used on an x86 it came from HLA ...
Wolfgang, you know a lot about a lot of things. HLA ain't one of 'em!
I'd be willing to bet you *can't* find this method in HLA. Any version.
(UCR stdlib, yes, IIRC)
(FWIW, I think I first saw it in GRDB code, but the method's been around
a *lot* longer than that!)
> it is an excellent example of how to useless detour things :)
How is it "detoured"? Given that we want our string in the middle of our
code (a *horrible* idea, IMO), what less detoured method would you use?
Jump over it? (like some packages which shall remain nameless...)
> I'd use si as the strptr instead.
Okay... (I use si, too...) What then?
Best,
Frank


|