Re: comp.lang.asm.x86 Is Undergoing Testing




Herbert Kleebauer posted:

Frank Kotler wrote:

So how do you think this updated FAQ should be organized?

Isn't the purpose of a FAQ to reduce the amount of simple questions
which are repeated again and again? I don't think ala or clax
has any problem with such questions. As I see it, the problem
of ala and clax is the opposite: to less traffic and to less
questions. So, if a FAQ fulfills it's destiny, things will become
even worse. More important than to give solutions for a collection
of problems is, to show that it is very easy to make your first
assembly program. And with "make" I don't mean to generate
a sequence of OS calls which does the job, but writing a sequence
of CPU instruction which do all themselves.

How much CPU instructions and addressing modes must you know
to write a simple x86 "Hello World" program? I think three
instructions and three addressing modes are sufficient:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

move src,dest ; copy the data at "src" location to the "dest" location
sub src,dest ; subtract the data at "src" location from the data at
"dest" location
beq address ; jump to "address" if the result of the last sub was zero


"src" can be an immediate operand (#123), one of four register (r0-r3)
or a memory location.

"dest" can be one of four register (r0-r3) or a memory location.

"src" and "dest" must not be both memory locations.

A memory location is specified by a segment start address stored in
one of four segment registers (s0-s3) and an offset, which can be
given directly ( move #123,456{s0} ) or be stored in a data register
( move #123,(r2){s0} ).

memory address = [si]*16 + offset

If in the "move" instruction one operand is a data register (r0-r3), the
other can be a segment register (s0-s3). "move" and "sub" can be used for
bytes (8 bit), words (16 bit) or longs (32 bit) (move.b, move.w, move.l).

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Now, that's all you need to know to write your first "Hello World"
program:

@=$100
00000100: b8 b800 move.w #$b800,r0
00000103: 8e c0 move.w r0,s1
00000105: 66 b9 0000012f move.l #text,r2
0000010b: 66 bb 00000668 move.l #10*160+40,r3
00000111: b8 3600 move.w #$3600,r0
00000114: 67 8a 01 loop: move.b (r2){s0},r0
00000117: 2c 00 sub.b #0,r0
00000119: 0f 84 fee3 beq.w 0
0000011d: 81 e9 ffff sub.w #-1,r2
00000121: 67 26 89 03 move.w r0,(r3){s1}
00000125: 81 eb fffe sub.w #-2,r3
00000129: 28 c0 sub.b r0,r0
0000012b: 0f 84 ffe5 beq.w loop

0000012f: 68 65 6c 6c 6f 20
00000135: 77 6f 72 6c 64 00 text: dc.b "hello world",0


You will get a binary of 59 bytes where you know the purpose
of any of them.

Fine for newbies who search for a quick start Herbert!
but I can't see a reason for the 66' in the above text-mode version.
Perhaps just to create an overoll/exception for out of bound char/pixel ?
__
wolfgang

btw: I didn't forget the challenge (C vs.ASM) from the last year,
but the hex-dump you posted didn't survive the transportation-phase
(I had to reinstall all my PC's after a heavy delayed move to my new
and hopefully final residential location).
If you don't mind please repost or even find any other C-example
where I can satisfy my LL-ego on :) :)



.



Relevant Pages

  • Re: 0x8024D007, automatic update service starting, REGSVR32 wuauen
    ... Yes, when I try to register wuaueng.dll, I get the same error (Invalid ... access to memory location) as when I try to start the BITS service. ... When I try to register wuaueng.dll by using the command REGSVR32 ... That would hopefully expose the source of the failure. ...
    (microsoft.public.windowsupdate)
  • Re: Tornado Computer Unit - Any info around?
    ... Now the following commands work: ... ADD (subtracts or adds a memory location to ... CLRA (clear accumulator) ... LDI (load index register, the next instruction is ...
    (rec.aviation.military)
  • LPC2106 jtag debugging problems
    ... say that in this case the instruction loaded by default is the IDCODE ... SCAN_N instruction - the data shifted out while feeding the instruction ... register with the value 0010. ... data shifted out while feeding the four-bit data register in this case ...
    (comp.sys.arm)
  • Re: LPC2106 jtag debugging problems
    ... say that in this case the instruction loaded by default is the IDCODE ... SCAN_N instruction - the data shifted out while feeding the instruction ... register with the value 0010. ... data shifted out while feeding the four-bit data register in this case ...
    (comp.sys.arm)
  • Re: maybe a bit OT: EEPROMs and PCs
    ... We have a register set (let's use the names ... | content of memory location 4 into register 0. ... (not to mention that my keyboard got square brackets as prime keys). ... This seems to be reversed HLA/gcc syntax:) ...
    (alt.lang.asm)