Merry Christmas to all!
Merry Christmas and a Happy New Year!
Nathan.
Sorry, there must be a bug. Your code crashes when I execute it.
Here a working version (maybe you should use an assembler
with a more logical syntax):
@=$100
dc.b "Merry Christmas and a Happy New Year!"
dc.b "$VZ500599"
trap #$21
rts.w
The hexdump of the binary:
4d65727279204368726973746d617320616e64206120486170
7079204e657720596561722124565a353030353939cd21c3
No, he just didn't include the macro definitions. :)
And neither will I:
¡Feliz Navidad!
С Рождеством!
Alex
> the traslation
> ------------------
> org 100h
> main:
> push si
> mov ah, 0Eh
> mov si, auguri
> .1: mov al, [si]
> cmp al, 0
> je .2
> inc si
> int 10h
> jmp short .1
> .2: mov ax, 0
> pop si
> ret
> auguri db "Auguri di Buon Natale, e di un felice "
> db "anno nuovo!" , 13, 10
> db "Merry Christmas and a Happy New Year!"
> db 13, 10, 0, 0
Displaying a text string on the screen is a beginners works.
The greetings are meant for the CPU and not for a lazy
human sitting before the screen. The CPU does all the
hard work all the day and deserves some greetings. In my
code "Merry Christmas and a Happy New Year!" is not some
data string written to the screen but executed as code by
the CPU byte by byte.
PS: And the CPU really deserves some greetings if it
accepts such a syntax without a word of protest:
I try to interprete it out from my head:
(assume a 16-bit .com)
0100 4d dec bp ;M
0101 65 72 72 gs: jc 0176 ;err ;if carry wasn't set
0104 79 20 jns 0126 ;y[] ;andif bp was >0 ...
0106 43 inc bx ;C
0107 68 72 69 push 6972 ;hri
010a 73 74 jnc 0180 ;st
010c 6d insw ;m
010d 61 popa ;a
010e 73 20 jnc 0130 ;s[]
0110 61 popa ;a
0111 6e outsb ;n
0112 64 20 61 20 and fs:[bx+di+20],ah ;d[]a[]
0116 48 dec ax ;H
0117 61 popa ;a
0118 70 70 jo 18a ;pp
011a 79 20 jns 13c ;y[]
011c 4e dec di ;N
011d 65 77 20 gs: ja 0140 ;ew[]
0120 59 pop cx ;Y
0121 65 61 gs: popa ;ea
0123 72 21 jc 0146 ;r!
0125 24 (56) and al,56 ;$(V)
:126 56 push di ;V ;...then it might come here
0127 5a pop dx ;Z ;DS=PSP+0100, dx= 0 now ?
0128 35 30 30 xor ax,3030 ;500
012b 35 39 39 xor ax,3939 ;599 ;ah= 09 yet ?
012e cd 21 int 21 ;
:130 c3 ret ;
ASCII-decoding is kinda fun, Happy New Year!
__
wolfgang
i like what is easy [for me], and loops
Right! Everybody knows an x86 CPU prefers Motorola syntax! Oh, wait...
Best,
Frank
It doesn't matter what "everybody" knows. It only matters what the
CPU thinks. Just ask your CPU yourself. But you have to do this in
an OS which allows the CPU to give an uncensored answer (real mode
DOS instead of protected mode Linux). I have converted the question
to NASM syntax, so go ahead and feed the question to the CPU and
read it's answer.
nasm askcpu.asm -o askcpu.com
org $100
db "Isn't the Motorola syntax much superior to the Intel syntax? ",13,10
db "I suppose, there is no doubt about your answer. ",13,10
db "VX4$, 0D',u,uPZ511599"
int $21
ret
Well, the wind blew and the power went out, so I had a chance to boot
dos and try this. Even trickier than it appears! In DEBUG, it waits for
a key and doesn't print anything! I'll have to study this... Thanks,
Herbert!
Best,
Frank
yes possibily i'm not much sure on "ah=0Eh|int 10h"
> Here a working version (maybe you should use an assembler
> with a more logical syntax):
this below here not segfault, and print the strings in a cmd window
where "bcc32" is the Borland C and C++ compiler 32bit
-------------------------------------------
; nasmw -fobj this.asm
; bcc32 -v this.obj
section _DATA use32 public class=DATA
global _main
extern _printf
fmt db "%c" , 0, 0
auguri db "Auguri di Buon Natale, e di un felice "
db "anno nuovo!" , 13, 10
db "Merry Christmas and a Happy New Year!"
db 13, 10, 0, 0
section _TEXT use32 public class=CODE
_main:
pushad
mov esi, auguri
xor ebx, ebx
.1: mov bl, [esi]
cmp ebx, 0
je .2
push ebx
push fmt
call _printf
add esp, 8
cmp eax, 1
jne .2
inc esi
jmp short .1
.2:
popad
mov eax, 0
ret
--------------------
; nasmw -fobj this.asm
; bcc32 -v this.obj
section _DATA use32 public class=DATA
global _main
extern _printf
fmt db "%c", 0, 0
auguri db "Auguri di Buon Natale, e di un felice "
db "anno nuovo!", 13, 10
db "Merry Christmas and a Happy New Year!"
db 13, 10, 0, 0
section _TEXT use32 public class=CODE
_main:
pushad
i=auguri|b^=b
.1: bl=*i|b==0#.2
_printf<(fmt, b)|a!=1#.2
++i|#.1
.2:
popad
a=0
ret
--------------------
> > io_x wrote:
> >>
> >> Buon Natale
> >>
> >> Merry Christmas to all!
> >
> > Sorry, there must be a bug. Your code crashes when I execute it.
>
> yes possibily i'm not much sure on "ah=0Eh|int 10h"
I didn't say your code but your greetings crashes when executed.
When I disassemble the text:
------------------------------------------
Buon Natale
Merry Christmas to all!
------------------------------------------
I get:
0100 inc.w r1 (42)
0101 bne.b $0172 (75 6f)
0103 out.b (r5.w)+-,r1 (6e)
0104 and.b r2,$61(r4.w){s7} (20 4e 61)
0107 beq.b $016a (74 61)
0109 in.b r1,(r6.w)+-{s1} (6c)
010a or.w #$0d0a,r0 (65 0d 0a 0d)
010e or.b $65(r6.w),r2 (0a 4d 65)
0111 bcs.b $0185 (72 72)
0113 bpl.b $0135 (79 20)
0115 inc.w r3 (43)
0116 move.w #$6972,-(sp) (68 72 69)
0119 bcc.b $018f (73 74)
011b in.w r1,(r6.w)+-{s1} (6d)
011c movem.w (sp)+,r0-r7 (61)
011d bcc.b $013f (73 20)
011f beq.b $0190 (74 6f)
0121 and.b m0,$6c(r3.w,r6.w) (20 61 6c)
0124 in.b r1,(r6.w)+-{s1} (6c)
0125 and.w r0,(r3.w,r5.w) (21 00)
And because your greetings doesn't specify any code at
address 0x0172, the processor executes what ever is
left there.
---------------------
Buon Natale e un felice anno nuovo!
Merry Christmas and one Happy New Year!
Thanks to CPU x86 and all you too
$CLARA_LUX_VZ._S�!S� !