|
Prev: using serial device on USB port
Next: Tasm IDE
From: naunetr on 4 Dec 2007 02:43 hi group! just dl'ed Dr. Paul Carter's tutorial (http://drpaulcarter.com/pcasm/) and also PGU from (http://savannah.nongnu.org/projects/pgubook/). i also borrowed "Assembly langauge step-by-step" by Jeff Dunteman from library. so which one does the group experts reccomend to start with? my os is linux and i dont have windows. is it necessary to start with dos as many books say? then i'll have to use DosEmu+FreeDOS. is that okay? or can i go with linux? will i miss something important if i dont start in dos? also which is reccomanded..nasm or gas? thanks a lot for all answers.
From: Herbert Kleebauer on 4 Dec 2007 03:45 naunetr wrote: > just dl'ed Dr. Paul Carter's tutorial (http://drpaulcarter.com/pcasm/) > and also PGU from (http://savannah.nongnu.org/projects/pgubook/). i also > borrowed "Assembly langauge step-by-step" by Jeff Dunteman from library. > so which one does the group experts reccomend to start with? my os is > linux and i dont have windows. is it necessary to start with dos as many > books say? then i'll have to use DosEmu+FreeDOS. is that okay? or can i > go with linux? will i miss something important if i dont start in dos? > also which is reccomanded..nasm or gas? If you do it the "simple" way, assembly programming in Linux is as nearly as simple as in DOS. Start with simple console applications (a simple getc and putc to read/write from stdin/stdout is sufficient for a start) and include the elf header as data block into the source (this way you need no linker, NASM directly generates the executable binary). Here a simple NASM example which converts DOS files (<CR><LF>) to Unix files (<LF> only): ; nasm -O99 -f bin -o d2u d2u.asm %include "mac.inc" ; ftp://137.193.64.130/pub/assembler/xlinux.zip ;=========================================================================== seg 32 orig equ $08048000 code_addr equ orig code_offset equ 0 section .text vstart=code_addr ;--------------------------- ELF header ----------------------------------- dc.l $464c457f,$00010101,0,0,$00030002,1,main,$34,0,0,$00200034,2,0 dc.l 1,code_offset,code_addr,code_addr,code_filez,code_memsz,5,4096 dc.l 1,data_offset,data_addr,data_addr,data_filez,data_memsz,6,4096 ;--------------------------- code ------------------------------------------ main: .10: bsr.l getc cmp.l -1,r0 beq.b .20 cmp.b 13,r0 beq.b .10 bsr.l putc br.b .10 .20: move.l 0,r3 ; return code move.l 1,r0 ; exit trap $80 getc: movem.l r0-r7,-[sp] move.l 0,r3 ; stdin move.l buf,r2 move.l 1,r1 ; 1 byte move.l 3,r0 ; read trap $80 tst.l r0,r0 bmi.b .10 movem.l [sp]+,r0-r7 beq.b .20 movu.bl [buf],r0 rts.l .20: orq.l -1,r0 rts.l .10: orq.l -1,r3 ; return code move.l 1,r0 ; exit trap $80 putc: movem.l r0-r7,-[sp] move.l 1,r3 ; stdout move.l buf,r2 move.b r0,[r2.l] move.l 1,r1 ; 1 byte move.l 4,r0 ; write trap $80 cmpq.l 1,r0 bne.b .10 movem.l [sp]+,r0-r7 rts.l .10: orq.l -1,r3 ; return code move.l 1,r0 ; exit trap $80 ;--------------------------- constant data --------------------------------- ; insert here any constant data you need in your program ;--------------------------------------------------------------------------- align 4, db 0 code_memsz equ $-$$ code_filez equ code_memsz data_addr equ (orig+code_memsz+4095)/4096*4096 + (code_filez % 4096) data_offset equ code_filez section .data vstart=data_addr ;--------------------------- initialized data ------------------------------ ; insert here any initialized data you need in your program ;--------------------------------------------------------------------------- idat_memsz equ $-$$ bss_addr equ data_addr+ ($-$$) section .bss vstart=bss_addr ;--------------------------- uninitialized data ---------------------------- ; insert here space for any uninitialized data you need in your program buf: blk.b 4 ;--------------------------------------------------------------------------- udat_memsz equ $-$$ data_memsz equ idat_memsz + udat_memsz data_filez equ idat_memsz ;===========================================================================
From: santosh on 4 Dec 2007 03:55 naunetr wrote: > hi group! > > just dl'ed Dr. Paul Carter's tutorial (http://drpaulcarter.com/pcasm/) > and also PGU from (http://savannah.nongnu.org/projects/pgubook/). i > also borrowed "Assembly langauge step-by-step" by Jeff Dunteman from > library. so which one does the group experts reccomend to start with? It depends on your objectives. > my os is linux and i dont have windows. Both Paul Carter's and Jonathan Bartlett's books are applicable to Linux, indeed the latter is specifically for Linux. > is it necessary to start with > dos as many books say? Again, depends. Start with DOS if any of the following is important for you: 1. Want to learn the DOS API. 2. Want to call BIOS routines. 3. Want to learn the peculiarities of 16 bit x86 architecture. 4. Want to program in a "unrestricted" environment that allows access to all the features of the CPU and hardware. As Herbert is wont to point out often, the above four are not assembler programming per se, but they are often the objective for many people to learn assembler. If you simply want to focus on x86 assembler programming and you are not interested in 16 bit legacy details, nor in using "privileged" instructions, or in "talking" to hardware directly, then Linux should be perfectly fine for you. As Betov says, 32 bit assembler is even simpler in some regards than the 16 bit variant. > then i'll have to use DosEmu+FreeDOS. Or FreeDOS or MS DOS or Windows under a Virtual Machine. IIRC VMWare is freely available for Linux. > is that okay? I suppose so. DOSEmu and FreeDOS should be sufficient for starting with. But certain things like changing to protected mode etc. cannot be done inside DOSEmu. You'll need "real" DOS for that. > or can i go with linux? Yes. This is what I'll recommend. In any case, when you are ready for advanced, system level programming, you can always learn DOS, BIOS and x86 system instructions, when needed. > will i miss something important if i > dont start in dos? Depends on what's important to you? > also which is reccomanded..nasm or gas? I use NASM and will recommend it. But GAS is the canonical assembler under UNIX and, sooner or later, you may want to learn it's syntax too. Also note that Jonathan Bartlett's book deals only with GAS, so if you go with that book, you'll have to learn GAS. In any case, once you learn the basics of assembler programming, it trivial to learn the syntax of another assembler. It like learning British English and then learning the differences with American English or Australian English etc. > thanks a lot for all answers. No problem. All considered, I recommend you to go with either Linux + NASM + Paul Carter's book or Linux + GAS + Jonathan Bartlett's book. Unless you _want_ to, it may not be the best choice to start with DOS. There are also other assembler out there, but since mention of some of them is quite controversial in this group, I'll let the braver souls do that. :-) Best of Luck.
From: santosh on 4 Dec 2007 04:20 Herbert Kleebauer wrote: > naunetr wrote: > >> just dl'ed Dr. Paul Carter's tutorial >> (http://drpaulcarter.com/pcasm/) and also PGU from >> (http://savannah.nongnu.org/projects/pgubook/). i also borrowed >> "Assembly langauge step-by-step" by Jeff Dunteman from library. so >> which one does the group experts reccomend to start with? my os is >> linux and i dont have windows. is it necessary to start with dos as >> many books say? then i'll have to use DosEmu+FreeDOS. is that okay? >> or can i go with linux? will i miss something important if i dont >> start in dos? also which is reccomanded..nasm or gas? > > If you do it the "simple" way, assembly programming in Linux is as > nearly as simple as in DOS. Start with simple console applications > (a simple getc and putc to read/write from stdin/stdout is sufficient > for a start) and include the elf header as data block into the source > (this way you need no linker, NASM directly generates the executable > binary). Here a simple NASM example which converts DOS files > (<CR><LF>) to Unix files (<LF> only): > > > ; nasm -O99 -f bin -o d2u d2u.asm > > %include "mac.inc" ; > ftp://137.193.64.130/pub/assembler/xlinux.zip <snip> Your Linux/X demos in the archive above don't seem to work here. All three of them (ANNIE, ERDE and HLA) simply exit when I invoke them. Any idea?
From: Herbert Kleebauer on 4 Dec 2007 05:08
santosh wrote:> > Herbert Kleebauer wrote: > > ftp://137.193.64.130/pub/assembler/xlinux.zip > > Your Linux/X demos in the archive above don't seem to work here. All > three of them (ANNIE, ERDE and HLA) simply exit when I invoke them. Any > idea? Execute an older debug version (source below) and post the output. The output I get here: return code get socket handle: 00000005 return code socket connect: 00000000 return code open .Xauthority: 00000007 return code read .Xauthority: 00000065 00000000 04000000 00000004 0100007f 00000008 00300100 0000000c 54494d12 00000010 47414d2d 00000014 432d4349 00000018 494b4f4f 0000001c 00312d45 00000020 40428b10 00000024 33790d95 00000028 bc603d5e 0000002c 2937b198 00000030 0000017c 00000034 6c655207 00000038 316b6f74 0000003c 00300100 00000040 54494d12 00000044 47414d2d 00000048 432d4349 0000004c 494b4f4f 00000050 00312d45 00000054 9458d510 00000058 55034fd0 0000005c 52869436 00000060 67ad71a3 00000064 000000dd return code close .Xauthority: 00000000 data found in .Xauthority 00000000 return code send connect: 0804a54f return code recv data: 000001f4 00000000 000b0001 00000004 007b0000 00000008 03a142a0 0000000c 02000000 00000010 001fffff 00000014 00000100 00000018 ffff0014 0000001c 00000701 00000020 ff082020 00000024 080e71de 00000028 20656854 0000002c 724f2e58 00000030 6f462067 00000034 61646e75 00000038 6e6f6974 0000003c b7200101 00000040 b7ee9620 00000044 b7200804 00000048 b7ee9620 0000004c b7200808 00000050 b7ee9620 00000054 b720100f 00000058 b7ee9620 0000005c b7201010 00000060 b7ee9620 00000064 b7202018 00000068 b7ee9620 0000006c b7202020 00000070 b7ee9620 00000074 00000047 00000078 00000020 0000007c 00ffffff 00000080 00000000 00000084 00fa4031 00000088 03000400 0000008c 00c30104 00000090 00010001 00000094 00000022 00000098 07180000 0000009c 000c9718 000000a0 b7ee9668 000000a4 00000022 000000a8 01000804 000000ac 00ff0000 000000b0 0000ff00 000000b4 000000ff 000000b8 b7ee9620 000000bc 00000023 000000c0 01000804 000000c4 00ff0000 000000c8 0000ff00 000000cc 000000ff 000000d0 b7ee9620 000000d4 00000024 000000d8 01000804 000000dc 00ff0000 000000e0 0000ff00 000000e4 000000ff 000000e8 b7ee9620 000000ec 00000025 000000f0 01000804 000000f4 00ff0000 000000f8 0000ff00 000000fc 000000ff 00000100 b7ee9620 00000104 00000026 00000108 01000804 0000010c 00ff0000 00000110 0000ff00 00000114 000000ff 00000118 b7ee9620 0000011c 00000027 00000120 01000804 00000124 00ff0000 00000128 0000ff00 0000012c 000000ff 00000130 b7ee9620 00000134 00000028 00000138 01000804 0000013c 00ff0000 00000140 0000ff00 00000144 000000ff 00000148 b7ee9620 0000014c 00000029 00000150 01000804 00000154 00ff0000 00000158 0000ff00 0000015c 000000ff 00000160 b7ee9620 00000164 0000002a 00000168 01000804 0000016c 00ff0000 00000170 0000ff00 00000174 000000ff 00000178 b7ee9620 0000017c 0000002b 00000180 01000804 00000184 00ff0000 00000188 0000ff00 0000018c 000000ff 00000190 b7ee9620 00000194 0000002c 00000198 01000804 0000019c 00ff0000 000001a0 0000ff00 000001a4 000000ff 000001a8 b7ee9620 000001ac 0000002d 000001b0 01000804 000001b4 00ff0000 000001b8 0000ff00 000001bc 000000ff 000001c0 b7ee9620 000001c4 00009701 000001c8 b7ee9668 000001cc 00009704 000001d0 b7ee9668 000001d4 00009708 000001d8 b7ee9668 000001dc 0000970f 000001e0 b7ee9668 000001e4 00009710 000001e8 b7ee9668 000001ec 00009720 000001f0 b7ee9668 000001f4 return code recv connect: 000001f4 Succes protocol-major-version: 000b protocol-minor-version: 0000 release-number: 03a142a0 resource_id-Base: 02000000 resource-id-mask: 001fffff motion-buffer-size: 00000100 maximum-request-length: ffff image-byte-order: 00 bitmap-format-bit-order: 00 bitmap-format-scanline-unit: 20 bitmap-format-scanline-pad: 20 min-keycode: 08 max-keykode: ff vendor: The X.Org Foundation Format 01/07 depth: 01 bits-per-pixel: 01 scanline-pad: 20 Format 02/07 depth: 04 bits-per-pixel: 08 scanline-pad: 20 Format 03/07 depth: 08 bits-per-pixel: 08 scanline-pad: 20 Format 04/07 depth: 0f bits-per-pixel: 10 scanline-pad: 20 Format 05/07 depth: 10 bits-per-pixel: 10 scanline-pad: 20 Format 06/07 depth: 18 bits-per-pixel: 20 scanline-pad: 20 Format 07/07 depth: 20 bits-per-pixel: 20 scanline-pad: 20 SCREEN 01/01 root: 00000047 default-colormap: 00000020 white-pixel: 00ffffff black-pixel: 00000000 current-input-mask: 00fa4031 width-in-pixel: 0400 hight-in-pixel: 0300 width-in-millimeters: 0104 hight-in-millimeters: 00c3 min-installed-maps: 0001 max-installed-maps: 0001 root-visual: 00000022 backing-stores: 00 save-unders: 00 root-depth 18 DEPTH 01/07 depth: 18 VISUALTYPE 0001/000c visual_id: 00000022 class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 0002/000c visual_id: 00000023 class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 0003/000c visual_id: 00000024 class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 0004/000c visual_id: 00000025 class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 0005/000c visual_id: 00000026 class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 0006/000c visual_id: 00000027 class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 0007/000c visual_id: 00000028 class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 0008/000c visual_id: 00000029 class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 0009/000c visual_id: 0000002a class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 000a/000c visual_id: 0000002b class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 000b/000c visual_id: 0000002c class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff VISUALTYPE 000c/000c visual_id: 0000002d class: 04 bits-per-rgb-value: 08 colormap-entries: 0100 red-mask: 00ff0000 green-mask: 0000ff00 blue-mask: 000000ff DEPTH 02/07 depth: 01 DEPTH 03/07 depth: 04 DEPTH 04/07 depth: 08 DEPTH 05/07 depth: 0f DEPTH 06/07 depth: 10 DEPTH 07/07 depth: 20 return code send CreateWindow: 0804a2fc return code send MapWindow: 0804a324 return code send createDC: 0804a34c return code recv data: 00000020 00000000 0002f60c 00000004 02000000 00000008 00000000 0000000c 01900190 00000010 088a0000 00000014 088516e0 00000018 00000000 0000001c ffffffff 00000020 00000000 0002f60c 00000004 02000000 00000008 00000000 0000000c 01900190 00000010 088a0000 00000014 088516e0 00000018 00000000 0000001c ffffffff return code recv data: 00000000 ---------------------------------------------------------------------------------------- The source code: debug=1 ;=========================================================================== seg32 @=$08048000 code_offset=@@ code_addr: ;--------------------------- ELF header ----------------------------------- dc.l $464c457f,$00010101,0,0,$00030002,1,main,$34,0,0,$00200034,2,0 dc.l 1,code_offset,code_addr,code_addr,code_filez,code_memsz,5,4096 dc.l 1,data_offset,data_addr,data_addr,data_filez,data_memsz,6,4096 ;--------------------------- code ------------------------------------------ main: move.l r7,stack_ptr ; save initial stack pointer ; ******************** get socket handle *************************** moveq.l #0,-(sp) ; no protocol specified moveq.l #1,-(sp) ; 1: SOCK_STREAM (/usr/include/linux/net.h) moveq.l #1,-(sp) ; 1: AF_UNIX, AF_LOCAL (/usr/include/linux/socket.h) move.l r7,r2 ; pointer to parameter for "socket" move.l #1,r3 ; "socket" (/usr/include/linux/net.h) move.l #102,r0 ; socketcall (/usr/include/asm/unistd.h) trap #$80 addq.l #3*4,r7 ; free space for parameters IF DEBUG move.l #text1,out_text bsr.l out_status ENDIF cmp.l #-4095,r0 ; ERROR bhs.l err move.l r0,x_handle ; ********** connect socket to /tmp/.X11-unix/X0" ****************** moveq.l #sockaddr_un_l,-(sp) move.l #sockaddr_un,-(sp) ; (/usr/include/linux/un.h) move.l x_handle,-(sp) ; socket handle move.l r7,r2 ; pointer to parameter for "connect" move.l #3,r3 ; "connect" (/usr/include/linux/net.h) move.l #102,r0 ; socketcall (/usr/include/asm/unistd.h) trap #$80 IF DEBUG move.l #text2,out_text bsr.l out_status ENDIF addq.l #3*4,r7 ; free space for parameters cmp.l #-4095,r0 ; ERROR bhs.l err ; ******************* send connect message ************************* move.l #send1,r0 ; pointer to connect message move.l #send1l,r1 bsr.l get_xauth ; try to read .Xauthority bcs.b _11 ; no success, let's try without auth. move.w r3,send1+6 ; insert name length move.w r5,send1+8 ; insert data length bsr.l x_send ; send header move.l r2,r0 ; pointer to name lea.l 3.b(r3),r1 ; pad to a multiple of 4 andq.l #$fffffffc,r1 bsr.l x_send ; send name move.l r4,r0 ; pointer to data lea.l 3.b(r5),r1 ; pad to a multiple of 4 andq.l #$fffffffc,r1 _11: bsr.l x_send ; send data IF DEBUG move.l #text5,out_text bsr.l out_status ENDIF eor.l r4,r4 ; number of total bytes read move.l #buf2,r5 ; pointer to buffer for next read move.l #buf2l,r6 ; max. bytes to read _10: move.l r5,r0 move.l r6,r1 bsr.l x_receive_raw beq.b _10 ; but we need a reply IF DEBUG move.l #text6,out_text bsr.l out_status ENDIF cmp.b #1,buf2 ; success bne.l err ; something went wrong add.l r0,r4 ; total read bytes add.l r0,r5 ; pointer to buffer for next read sub.l r0,r6 ; max. bytes to read cmpq.l #8,r4 ; at least 8 bytes read? blo.b _10 ; no, get more movu.wl buf2+6,r3 ; additional data in 4 bytes lea.l 8(r3*4),r3 ; total size in bytes cmp.l r3,r4 ; all read blo.b _10 ; no, get more IF DEBUG bsr.l dump_connect ENDIF ; ******************* calculate id's ******************************* move.l #buf2,r5 move.l $0c.b(r5),r0 ; resource_id_base move.l $10.b(r5),r1 ; resource_id_mask move.l r1,r2 neg.l r2 and.l r2,r1 ; resource_id_incr move.l r0,s2a ; wid for CreateWindow move.l r0,s3a ; wid for MapWindow move.l r0,s5a ; wid for CreateDC move.l r0,s8a ; wid for PolyArcFill move.l r0,s9a ; wid for ImageText8 add.l r1,r0 ; next id move.l r0,s5b ; cid for CreateDC move.l r0,s6b ; cid for ChangeDC move.l r0,s7b ; cid for ChangeDC move.l r0,s8b ; cid for PolyArcFill move.l r0,s9b ; cid for ImageText8 add.l r1,r0 ; next id move.l r0,s4c ; fid for OpenFont move.l r0,s5c ; fid for CreatDc add.l r1,r0 ; next id ; move.l r0,resource_id_next ; maybe we need more id's later ; move.l r1,resource_id_incr ; maybe we need more id's later ; ******************* get root window id *************************** movu.wl $18.b(r5),r0 ; length of vendor string addq.l #$28+3,r0 ; const header length + round vendor length and.b #$fc,r0 ; round to 4 bytes movu.bl $1d.b(r5),r1 ; number of FORMATs lsl.l #3,r1 ; 8 byte for each FORMAT entry add.l r0,r1 ; offset to root WINDOW id move.l (r5,r1),r0 ; root window move.l r0,s2b ; CreateWindow needs root window id ; ******************* send CreatWindow request ********************* move.l #send2,r0 move.l #send2l,r1 bsr.l x_send IF DEBUG move.l #text7,out_text bsr.l out_status ENDIF ; ******************* send MapWindow request *********************** move.l #send3,r0 move.l #send3l,r1 bsr.l x_send IF DEBUG move.l #text9,out_text bsr.l out_status ENDIF ; ******************* send OpenFont request ************************* move.l #send4,r0 move.l #send4l,r1 bsr.l x_send ; ******************* send CreatDC request ************************* move.l #send5,r0 move.l #send5l,r1 bsr.l x_send IF DEBUG move.l #text11,out_text bsr.l out_status ENDIF ; ******************** main loop *************************** loop: bsr.l display _20: bsr.l x_receive IF DEBUG bsr.l dump_buf2 ENDIF cmp.b #0,(r0) ; error message beq.l err cmp.b #2,(r0) ; key press bne.b _30 cmp.b #$1b,1.b(r0) ; r bne.b _31 move.l #0,brett move.l #0,brett+4 br.b loop _31: cmp.b #$09,1.b(r0) ; ESC bne.b _20 ; ignore anything else br.b ende _30: cmp.b #4,(r0) ; button press bne.b _10 move.l 24.b(r0),r0 eor.l r1,r1 move.l #50,r2 divu.w r2,r1|r0 not.b r0 move.l r0,r3 andq.l #7,r3 ; x: 0-7 lsr.l #16,r0 eor.l r1,r1 divu.w r2,r1|r0 andq.l #7,r0 ; y: 0-7 bchg.l r3,brett(r0) bchg.l r3,brett-1(r0) bchg.l r3,brett+1(r0) inc.l r3 tst.b #%1000,r3 bne.b _40 bchg.l r3,brett(r0) _40: subq.l #2,r3 bmi.l loop bchg.l r3,brett(r0) br.l loop _10: cmp.b #12,(r0) ; Expose beq.l loop br.l _20 ; ignore anything else err: ende: move.l #0,r3 ; return code move.l #1,r0 ; exit trap #$80 display: move.l #brett+8,r6 lea.l -8.b(r6),r5 move.w #0,s8y _10: move.w #0,s8x move.l #8,r2 move.b (r5),r3 inc.l r5 _11: lsl.b #1,r3 bcc.b _12 move.l #send8,r0 ; circle move.l #send8l,r1 bsr.l x_send _12: addq.w #50,s8x dbf.l r2,_11 addq.w #50,s8y cmp.l r6,r5 blo.l _10 move.l #send7,r0 ; color2 move.l #send7l,r1 bsr.l x_send move.l #'msa',s9t lea.l -8.b(r6),r5 move.w #0,s8y move.w #30,s9y _20: move.w #0,s8x move.w #5,s9x move.l #8,r2 move.b (r5),r3 inc.l r5 _21: lsl.b #1,r3 bcc.b _22 move.l #send9,r0 ; text move.l #send9l,r1 bsr.l x_send br.b _23 _22: move.l #send8,r0 ; circle move.l #send8l,r1 bsr.l x_send _23: addq.w #50,s8x addq.w #50,s9x dbf.l r2,_21 addq.w #50,s8y addq.w #50,s9y cmp.l r6,r5 blo.l _20 move.l #send6,r0 ; color1 move.l #send6l,r1 bsr.l x_send move.l #'ALH',s9t lea.l -8.b(r6),r5 move.w #30,s9y _30: move.w #5,s9x move.l #8,r2 move.b (r5),r3 inc.l r5 _31: lsl.b #1,r3 bcs.b _32 move.l #send9,r0 ; text move.l #send9l,r1 bsr.l x_send _32: addq.w #50,s9x dbf.l r2,_31 addq.w #50,s9y cmp.l r6,r5 blo.l _30 rts.l ;********************************************************** ;******** read cookie from $home/.Xauthority ************** ;********************************************************** ; * ; input: stack_ptr: original sp at program start * ; output: C=0: cookie found in $home/.Xauthority * ; r2: pointer to protocol name * ; r3: length of protocol name * ; r4: pointer to protocol data * ; r5: length of protocol data * ; C=1: nothing found * ; r2/r3/r4/r5 undefined * ; * ; typedef struct xauth { * ; unsigned short family; * ; unsigned short address_length; * ; char *address; * ; unsigned short number_length; * ; char *number; * ; unsigned short name_length; * ; char *name; * ; unsigned short data_length; * ; char *data; * ; } Xauth; * ;********************************************************** get_xauth: move.l r0,-(sp) move.l r1,-(sp) move.l r6,-(sp) move.l stack_ptr,r6 ; original stack pointer at program start move.l (r6),r0 ; number of arguments lea.l 8.b(r6,r0*4),r6 ; skip arguments + trailing null pointer _20: move.l (r6),r5 ; pointer to next env variable addq.l #4,r6 tst.l r5,r5 ; no more env variables beq.l _notfound cmp.l #'EMOH',(r5) ; HOME found? bne.b _20 ; no, try next cmp.b #'=',4.b(r5) ; HOME= found? bne.b _20 ; no, try next addq.l #5,r5 ; start of HOME path orq.l #-1,r2 _30: inc.l r2 ; count length of HOME path cmp.b #0,(r5,r2) bne.b _30 or.l r2,r2 ; at least one char long? beq.l _notfound ; no, HOME is empty cmp.l #256,r2 ; more than 256 charcters bhi.l _notfound ; somebody tries a buffer overflow move.l #fname,r6 ; buffer for filename rep_r2 move.b (r5)+-,(r6)+-{s1} ; copy HOME path move.l #'aX./',r0 ; add .Xauthority move.l r0,(r6)+-{s1} move.l #'ohtu',r0 move.l r0,(r6)+-{s1} move.l #'ytir',r0 move.l r0,(r6)+-{s1} move.b #0,(r6) ; and a trailing 0 move.l #fname,r3 eor.l r2,r2 ; readonly move.l #5,r0 ; open trap #$80 IF DEBUG move.l #text16,out_text bsr.l out_status ENDIF cmp.l #-4095,r0 ; file open error? bhs.b _notfound ; yes move.l r0,r3 ; file handle move.l #buf2,r2 move.l #buf2l,r1 ; read 1024 byte move.l #3,r0 ; read trap #$80 IF DEBUG move.l #text17,out_text bsr.l out_status bsr.l dump_buf ENDIF cmp.l #buf2l,r0 bhs.l err ; .Xauthority >= 1024 byte move.l r0,r4 ; bytes read move.l #6,r0 ; close trap #$80 IF DEBUG move.l #text18,out_text bsr.l out_status ENDIF tst.l r4,r4 ; file empty beq.b _notfound move.l #buf2,r5 add.l r5,r4 ; end of read data eor.l r0,r0 ; delete upper 16 bit of r0 _60: move.w (r5)+-,r0 ; family dec.w r0 beq.b _40 ; 1=FamilyLocal move.l #4,r2 ; skip entry _50: move.w (r5)+-,r0 ror.w #8,r0 ; big -> little endian add.l r0,r5 dbf.l r2,_50 cmp.l r4,r5 ; more data blo.b _60 ; try next entry _notfound: IF DEBUG move.l #text20,out_text bsr.l out_status ENDIF bset.w #0,sr ; set Carry br.b _70 _40: IF DEBUG move.l #text21,out_text bsr.l out_status ENDIF move.l #2,r2 move.l r2,r3 _41: move.w (r5)+-,r0 ; size of data ror.w #8,r0 ; big endian <-> little endian add.l r0,r5 ; skip address/number dbf.l r2,_41 _42: move.w (r5)+-,r0 ; size of protocol name ror.w #8,r0 ; big endian <-> little endian move.l r5,r2 ; pointer to protocol name move.l r0,r3 ; size of protocol name add.l r3,r5 ; skip name move.w (r5)+-,r0 ; size of protocol data ror.w #8,r0 ; big endian <-> little endian move.l r5,r4 ; pointer to protocol data move.l r0,r5 ; size of protocol data bclr.w #0,sr ; clear carry _70: move.l (sp)+,r6 move.l (sp)+,r1 move.l (sp)+,r0 rts.l ;********************************************************** ;******** send message to X server ************** ;********************************************************** ; input: r0: pointer to message * ; r1: length of message * ;********************************************************** x_send: movem.l r0-r7,-(sp) move.l r0,r4 ; pointer to next byte of message move.l r1,r5 ; remaining bytes to send _20: moveq.l #0,-(sp) ; flags move.l r5,-(sp) ; length move.l r4,-(sp) ; pointer to data move.l x_handle,-(sp) ; socket handle move.l r7,r2 ; pointer to parameter for "send" move.l #9,r3 ; "send" (/usr/include/linux/net.h) move.l #102,r0 ; socketcall (/usr/include/asm/unistd.h) trap #$80 addq.l #4*4,r7 ; free space for parameters IF DEBUG&0 move.l #text13,out_text bsr.l out_status ENDIF cmpq.l #-11,r0 ; EAGAIN: beq.b _20 ; message couldn't be sent, try again cmp.l #-4095,r0 ; ERROR bhs.l err sub.l r0,r5 ; remaining bytes to send beq.b _30 ; nothing, all sent add.l r0,r4 ; pointer to remaining message br.b _20 ; send rest of message _30: movem.l (sp)+,r0-r7 rts.l ;********************************************************** ;******** receive ONE message from X server ********** ;********************************************************** ; input: none * ; output: Z=1: no complete message available * ; r0/r1 undefined * ; Z=0: r0: pointer to message data * ; r1: size of data * ;********************************************************** x_receive: move.l r2,-(sp) move.l r5,-(sp) move.l r6,-(sp) _00: move.l buf2_rest,r0 ; still something in read buffer? cmpq.l #32,r0 ; a message has at least 32 bytes bhs.b _10 ; maybe it is a complete message _30: move.l buf2_ptr,r5 ; start of message move.l #buf2,r6 ; start of buffer move.l r6,buf2_ptr ; we copy message to top of buffer cmp.l r5,r6 ; already at top of buffer beq.b _50 ; then nothing to copy or.l r0,r0 ; nothing in buffer beq.b _50 ; then also nothing to copy move.l r0,r2 ; copy to top of buffer rep_r2 move.b (r5)+-,(r6)+-{s1} _50: move.l #buf2l,r1 ; let's try to get some more data sub.l r0,r1 ; not more bytes than space is left in the buf lea.l buf2(r0),r0 ; append it here bsr.l x_receive_raw bne.b _20 ; we could read something br.b _100 ; return with Z=1 _20: add.l r0,buf2_rest ; now we have a few more bytes in the buffer br.b _00 ; let's try again _10: move.l buf2_ptr,r5 ; let's test if it is a complete meesage ; cmp.b #34,(r5) ; the last known message is nr 34 ; bhi.l err ; don't know why but there is also a message ; with number 150 if StructureNotify is enabled move.l #32,r1 ; error/reply/event base length cmp.b #1,(r5) ; reply message bne.b _40 ; no, then event/error messages (always 32 byte) add.l 4.b(r5),r1 ; + additional data for reply add.l 4.b(r5),r1 ; + additional data for reply add.l 4.b(r5),r1 ; + additional data for reply add.l 4.b(r5),r1 ; + additional data for reply cmp.l r1,r0 ; complete reply in buffer blo.b _30 ; no, let's try to get more _40: move.l r5,r0 ; pointer to data sub.l r1,buf2_rest ; new rest add.l r1,buf2_ptr ; pointer to next data; clear Z flag _100: move.l (sp)+,r6 move.l (sp)+,r5 move.l (sp)+,r2 rts.l ;********************************************************** ;******** read data from X server ********** ;********************************************************** ; input: r0: pointer to read buffer * ; r1: size of buffer * ; output: Z=1: nothing to read * ; Z=0: r0 bytes read * ;********************************************************** x_receive_raw: move.l r2,-(sp) move.l r3,-(sp) moveq.l #0,-(sp) ; flags move.l r1,-(sp) ; number of bytes to read move.l r0,-(sp) ; pointer to buffer move.l x_handle,-(sp) ; socket handle move.l r7,r2 ; pointer to parameter for "recv" move.l #10,r3 ; "recv" (/usr/include/linux/net.h) move.l #102,r0 ; socketcall (/usr/include/asm/unistd.h) trap #$80 IF DEBUG move.l #text14,out_text bsr.l out_status ENDIF addq.l #4*4,r7 ; free space for parameters move.l (sp)+,r3 move.l (sp)+,r2 cmpq.l #-11,r0 ; EAGAIN: no message available -> Z=1 beq.b _10 cmp.l #-4095,r0 ; ERROR bhs.l err tst.l r0,r0 ; 0: NULL message -> Window close? beq.l ende IF DEBUG beq.b _10 bsr.l dump_buf bsr.l out_hex_l tst.l r0,r0 ; Z=0 ENDIF _10: rts.l ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF DEBUG out_status: move.l r0,-(sp) move.l out_text,r0 bsr.l puts move.l (sp)+,r0 bsr.l out_hex_l rts.l text1: dc.b 10,"return code get socket handle: ",0 text2: dc.b 10,"return code socket connect: ",0 text3: dc.b 10,"return code F_GETFL: ",0 text4: dc.b 10,"return code F_SETFL: ",0 text5: dc.b 10,"return code send connect: ",0 text6: dc.b 10,"return code recv connect: ",0 text7: dc.b 10,"return code send CreateWindow: ",0 text8: dc.b 10,"return code recv CreateWindow: ",0 text9: dc.b 10,"return code send MapWindow: ",0 text10: dc.b 10,"return code recv MapWindow: ",0 text11: dc.b 10,"return code send createDC: ",0 text12: dc.b 10,"return code recv createDC: ",0 text13: dc.b 10,"return code send data: ",0 text14: dc.b 10,"return code recv data: ",0 text15: dc.b 10," ",0 text16: dc.b 10,"return code open .Xauthority: ",0 text17: dc.b 10,"return code read .Xauthority: ",0 text18: dc.b 10,"return code close .Xauthority: ",0 text19: dc.b 10," ",0 text20: dc.b 10,"nothing found in .Xauthority ",0 text21: dc.b 10,"data found in .Xauthority ",0 dump_connect: tst.l r0,r0 bne.b _00 rts.l _00: movem.l r0-r7,-(sp) bsr.l out_lf move.l #buf2,r5 move.l r0,r2 move.b (r5),r1 cmp.b #0,r1 beq.b _10 cmp.b #1,r1 beq.l _20 cmp.b #2,r1 beq.b _30 movem.l (sp)+,r0-r7 br.l dump_buf _10: move.l #_t1,r0 bsr.l puts movu.bl 1.b(r5),r1 move.l #_t2,r0 bsr.l puts move.w 2.b(r5),r0 bsr.l out_hex_w move.l #_t3,r0 bsr.l puts move.w 4.b(r5),r0 bsr.l out_hex_w move.l #_t4,r0 bsr.l puts lea.l 8.b(r5),r0 bsr.l putt bsr.l out_lf br.l ende _30: move.l #_t5,r0 bsr.l puts move.l #_t4,r0 bsr.l puts movu.wl 6.b(r5),r1 lsl.l #2,r1 lea.l 8.b(r5),r0 bsr.l putt bsr.l out_lf br.l ende _20: move.l #_t6,r0 bsr.l puts move.l #_t2,r0 bsr.l puts move.w 2.b(r5),r0 bsr.l out_hex_w move.l #_t3,r0 bsr.l puts move.w 4.b(r5),r0 bsr.l out_hex_w move.l #_t7,r0 bsr.l puts move.l 8.b(r5),r0 bsr.l out_hex_l move.l #_t8,r0 bsr.l puts move.l 12.b(r5),r0 bsr.l out_hex_l move.l #_t9,r0 bsr.l puts move.l 16.b(r5),r0 bsr.l out_hex_l move.l #_t10,r0 bsr.l puts move.l 20.b(r5),r0 bsr.l out_hex_l move.l #_t11,r0 bsr.l puts move.w 26.b(r5),r0 bsr.l out_hex_w move.l #_t12,r0 bsr.l puts move.b 30.b(r5),r0 bsr.l out_hex_b move.l #_t13,r0 bsr.l puts move.b 31.b(r5),r0 bsr.l out_hex_b move.l #_t14,r0 bsr.l puts move.b 32.b(r5),r0 bsr.l out_hex_b move.l #_t15,r0 bsr.l puts move.b 33.b(r5),r0 bsr.l out_hex_b move.l #_t16,r0 bsr.l puts move.b 34.b(r5),r0 bsr.l out_hex_b move.l #_t17,r0 bsr.l puts move.b 35.b(r5),r0 bsr.l out_hex_b move.l #_t18,r0 bsr.l puts lea.l 40.b(r5),r0 movu.wl 24.b(r5),r1 bsr.l putt addq.l #3,r1 andq.l #$fffffffc,r1 lea.l (r0,r1),r6 move.b #1,r3 _50: cmp.b 29.b(r5),r3 bhi.b _40 move.l #_t19,r0 bsr.l puts move.b r3,r0 bsr.l out_hex_b move.b #'/',r0 bsr.l putc move.b 29.b(r5),r0 bsr.l out_hex_b move.l #_t20,r0 bsr.l puts move.b (r6),r0 bsr.l out_hex_b move.l #_t21,r0 bsr.l puts move.b 1.b(r6),r0 bsr.l out_hex_b move.l #_t22,r0 bsr.l puts move.b 2.b(r6),r0 bsr.l out_hex_b inc.b r3 addq.l #8,r6 br.b _50 _40: move.b #1,r3 _60: cmp.b 28.b(r5),r3 bhi.l _70 move.l #_t23,r0 bsr.l puts move.b r3,r0 bsr.l out_hex_b move.b #'/',r0 bsr.l putc move.b 28.b(r5),r0 bsr.l out_hex_b move.l #_t24,r0 bsr.l puts move.l (r6),r0 bsr.l out_hex_l move.l #_t25,r0 bsr.l puts move.l 4.b(r6),r0 bsr.l out_hex_l move.l #_t26,r0 bsr.l puts move.l 8.b(r6),r0 bsr.l out_hex_l move.l #_t27,r0 bsr.l puts move.l 12.b(r6),r0 bsr.l out_hex_l move.l #_t28,r0 bsr.l puts move.l 16.b(r6),r0 bsr.l out_hex_l move.l #_t29,r0 bsr.l puts move.w 20.b(r6),r0 bsr.l out_hex_w move.l #_t30,r0 bsr.l puts move.w 22.b(r6),r0 bsr.l out_hex_w move.l #_t31,r0 bsr.l puts move.w 24.b(r6),r0 bsr.l out_hex_w move.l #_t32,r0 bsr.l puts move.w 26.b(r6),r0 bsr.l out_hex_w move.l #_t33,r0 bsr.l puts move.w 28.b(r6),r0 bsr.l out_hex_w move.l #_t34,r0 bsr.l puts move.w 30.b(r6),r0 bsr.l out_hex_w move.l #_t35,r0 bsr.l puts move.l 32.b(r6),r0 bsr.l out_hex_l move.l #_t36,r0 bsr.l puts move.b 36.b(r6),r0 bsr.l out_hex_b move.l #_t37,r0 bsr.l puts move.b 37.b(r6),r0 bsr.l out_hex_b move.l #_t38,r0 bsr.l puts move.b 38.b(r6),r0 bsr.l out_hex_b move.b #1,r2 move.b 39.b(r6),m2 addq.l #40,r6 _90: cmp.b m2,r2 bhi.l _80 move.l #_t39,r0 bsr.l puts move.b r2,r0 bsr.l out_hex_b move.b #'/',r0 bsr.l putc move.b m2,r0 bsr.l out_hex_b move.l #_t40,r0 bsr.l puts move.b (r6),r0 bsr.l out_hex_b move.w #1,r1 move.w 2.b(r6),r4 addq.w #8,r6 _110: cmp.w r4,r1 bhi.l _100 move.l #_t41,r0 bsr.l puts move.w r1,r0 bsr.l out_hex_w move.b #'/',r0 bsr.l putc move.w r4,r0 bsr.l out_hex_w move.l #_t42,r0 bsr.l puts move.l (r6),r0 bsr.l out_hex_l move.l #_t43,r0 bsr.l puts move.b 4.b(r6),r0 bsr.l out_hex_b move.l #_t44,r0 bsr.l puts move.b 5.b(r6),r0 bsr.l out_hex_b move.l #_t45,r0 bsr.l puts move.w 6.b(r6),r0 bsr.l out_hex_w move.l #_t46,r0 bsr.l puts move.l 8.b(r6),r0 bsr.l out_hex_l move.l #_t47,r0 bsr.l puts move.l 12.b(r6),r0 bsr.l out_hex_l move.l #_t48,r0 bsr.l puts move.l 16.b(r6),r0 bsr.l out_hex_l addq.w #24,r6 inc.w r1 br.l _110 _100: inc.b r2 br.l _90 _80: inc.b r3 addq.l #8,r6 br.l _60 _70: movem.l (sp)+,r0-r7 rts.l _t1: dc.b 10,"Failed",0 _t2: dc.b 10,"protocol-major-version: ",0 _t3: dc.b 10,"protocol-minor-version: ",0 _t4: dc.b 10,"reason: ",0 _t5: dc.b 10,"Authenticate",0 _t6: dc.b 10,"Succes",0 _t7: dc.b 10,"release-number: ",0 _t8: dc.b 10,"resource_id-Base: ",0 _t9: dc.b 10,"resource-id-mask: ",0 _t10: dc.b 10,"motion-buffer-size: ",0 _t11: dc.b 10,"maximum-request-length: ",0 _t12: dc.b 10,"image-byte-order: ",0 _t13: dc.b 10,"bitmap-format-bit-order: ",0 _t14: dc.b 10,"bitmap-format-scanline-unit: ",0 _t15: dc.b 10,"bitmap-format-scanline-pad: ",0 _t16: dc.b 10,"min-keycode: ",0 _t17: dc.b 10,"max-keykode: ",0 _t18: dc.b 10,"vendor: ",0 _t19: dc.b 10,10,"Format ",0 _t20: dc.b 10," depth: ",0 _t21: dc.b 10," bits-per-pixel: ",0 _t22: dc.b 10," scanline-pad: ",0 _t23: dc.b 10,10,"SCREEN ",0 _t24: dc.b 10," root: ",0 _t25: dc.b 10," default-colormap: ",0 _t26: dc.b 10," white-pixel: ",0 _t27: dc.b 10," black-pixel: ",0 _t28: dc.b 10," current-input-mask: ",0 _t29: dc.b 10," width-in-pixel: ",0 _t30: dc.b 10," hight-in-pixel: ",0 _t31: dc.b 10," width-in-millimeters: ",0 _t32: dc.b 10," hight-in-millimeters: ",0 _t33: dc.b 10," min-installed-maps: ",0 _t34: dc.b 10," max-installed-maps: ",0 _t35: dc.b 10," root-visual: ",0 _t36: dc.b 10," backing-stores: ",0 _t37: dc.b 10," save-unders: ",0 _t38: dc.b 10," root-depth ",0 _t39: dc.b 10," DEPTH ",0 _t40: dc.b 10," depth: ",0 _t41: dc.b 10," VISUALTYPE ",0 _t42: dc.b 10," visual_id: ",0 _t43: dc.b 10," class: ",0 _t44: dc.b 10," bits-per-rgb-value: ",0 _t45: dc.b 10," colormap-entries: ",0 _t46: dc.b 10," red-mask: ",0 _t47: dc.b 10," green-mask: ",0 _t48: dc.b 10," blue-mask: ",0 dump_buf2: ; r0: pointer to buf r1: number of bytes movem.l r0-r7,-(sp) move.l r0,r5 move.l r1,r0 br.b .db1 dump_buf: ; dump buf2 r0: number of bytes movem.l r0-r7,-(sp) move.l #buf2,r5 ..db1: tst.l r0,r0 beq.b _20 bmi.b _20 bsr.l out_lf bsr.l out_lf move.l r0,r2 addq.l #3,r0 lsr.l #2,r0 move.l r0,r2 _10: lea.l -buf2(r5),r0 bsr.l out_hex_l move.b #' ',r0 bsr.l putc move.l (r5),r0 addq.l #4,r5 bsr.l out_hex_l bsr.l out_lf dbf.l r2,_10 bsr.l out_lf _20: movem.l (sp)+,r0-r7 rts.l ; r0 -> hex to stdout out_hex_l: ror.l #16,r0 bsr.l out_hex_w ror.l #16,r0 out_hex_w: ror.w #8,r0 bsr.l out_hex_b ror.w #8,r0 out_hex_b: ror.b #4,r0 bsr.l out_hex_n ror.b #4,r0 out_hex_n: move.l r0,-(sp) andq.l #$0f,r0 cmp.b #9,r0 bls.b _10 add.b #'a'-'0'-10,r0 _10: add.b #'0',r0 bsr.l putc move.l (sp)+,r0 rts.l out_lf: move.l r0,-(sp) move.b #10,r0 bsr.l putc move.l (sp)+,r0 rts.l ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; r0: pointer to NULL terminated string puts: movem.l r0-r7,-(sp) move.l r0,r1 br.b _20 _30: bsr.l putc _20: move.b (r1),r0 inc.l r1 tst.b r0,r0 bne.b _30 movem.l (sp)+,r0-r7 rts.l ; r0: pointer string r1: length of string putt: movem.l r0-r7,-(sp) move.l r0,r2 br.b _20 _30: bsr.l putc _20: move.b (r2),r0 inc.l r2 dec.l r1 bpl.b _30 movem.l (sp)+,r0-r7 rts.l ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; next char from stdin -> r0.l ; EOF: -1 -> r0.l ; error: exit getc: movem.l r0-r7,-(sp) move.l #0,r3 ; stdin move.l #buf,r2 move.l #1,r1 ; 1 byte move.l #3,r0 ; read trap #$80 tst.l r0,r0 bmi.b _10 movem.l (sp)+,r0-r7 beq.b _20 movu.bl buf,r0 rts.l _20: orq.l #-1,r0 rts.l _10: orq.l #-1,r3 ; return code move.l #1,r0 ; exit trap #$80 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; r0.b -> stdout ; error: exit putc: movem.l r0-r7,-(sp) move.l #1,r3 ; stdout move.l #buf,r2 move.b r0,(r2) move.l #1,r1 ; 1 byte move.l #4,r0 ; write trap #$80 cmpq.l #1,r0 bne.b _10 movem.l (sp)+,r0-r7 rts.l _10: orq.l #-1,r3 ; return code move.l #1,r0 ; exit trap #$80 ENDIF ;--------------------------- constant data --------------------------------- even 4,$90 sockaddr_un: dc.w 1 ; 1: AF_UNIX, AF_LOCAL (/usr/include/linux/socket.h) dc.b "/tmp/.X11-unix/X0" sockaddr_un_l= @-sockaddr_un even 4,$90 ;--------------------------------------------------------------------------- code_filez=@@-code_offset code_memsz= @-code_addr even 4 @=(@+4095)/4096*4096+(@@\4096) data_offset=@@ data_addr: ;--------------------------- initialized data ------------------------------ buf2_ptr: dc.l buf2 buf2_rest: dc.l 0 ; Connection Setup send1: dc.b $6c,0 ; LSB first dc.w 11,0 ; major/minor version dc.w 0,0 ; length of protocol name/data dc.w 0 ; unused send1l=@-send1 ; Create Window send2: dc.b 1 ; opcode for Create Window dc.b 0 ; depth from parent dc.w send2l/4; request length s2a: dc.l 0 ; wid (has to be calculated) s2b: dc.l 0 ; parent (has to be calculated) dc.w 0 ; x dc.w 0 ; y s2x: dc.w 400 ; with s2y: dc.w 400 ; higth dc.w 0 ; border-width dc.w 0 ; class: CopyFromParent dc.l 0 ; visual: CopyFromParent dc.l $802 ; value-mask: background-pixel 2 ; - override-redirect 200 ; + event-mask 800 dc.l $ff8080 ; background: black ; dc.b 1 ; override-redirect = true ; dc.b 0,0,0 ; pad dc.l $8005 ; event_mask: KeyPress 1 ; +ButtenPress 4 ; +PointerMotion $40 ; +Exposure $8000 ; +StructureNotify $20000 send2l=((@-send2)+3) & $fffffffc ; Map Window send3: dc.b 8 ; opcode for Map Window dc.b 0 ; unused dc.w send3l/4; request length s3a: dc.l 0 ; wid (has to be calculated) send3l=@-send3 ; Open Font send4: dc.b 45 ; opcode for OpenFont dc.b 0 ; unused dc.w send4l/4; request length s4c: dc.l 0 ; fid (has to be calculated) dc.w s4tl dc.w 0 ; unused s4t: dc.b "lucidasans-bold-12" ; font name s4tl=@-s4t even 4 send4l=@-send4 ; Create GC send5: dc.b 55 ; opcode for CreateGC dc.b 0 ; unused dc.w send5l/4; request length s5b: dc.l 0 ; cid (has to be calculated) s5a: dc.l 0 ; wid (has to be calculated) dc.l 1+4+8+$4000 ; function+foreground+background+font dc.l 3 ; function=copy dc.l $ffff00 ; foreground: white dc.l $0080ff ; background: light blue s5c: dc.l 0 ; fid (hast to be calculated) send5l=@-send5 ; Change GC send6: dc.b 56 ; opcode for ChangeGC dc.b 0 ; unused dc.w send6l/4; request length s6b: dc.l 0 ; cid (has to be calculated) dc.l 4+8 ; foreground+background dc.l $ffff00 ; foreground: white dc.l $0080ff ; background: light blue send6l=@-send6 ; Change GC send7: dc.b 56 ; opcode for ChangeGC dc.b 0 ; unused dc.w send7l/4; request length s7b: dc.l 0 ; cid (has to be calculated) dc.l 4+8 ; foreground+background dc.l $0080ff ; foreground: white dc.l $ffff00 ; background: light blue send7l=@-send7 send8: dc.b 71 ; opcode for PolyFillArc dc.b 0 ; unused dc.w send8l/4; request length s8a: dc.l 0 ; wid (has to be calculated) s8b: dc.l 0 ; cid (has to be calculated) s8x: dc.w 0 ; x s8y: dc.w 0 ; y dc.w 50 ; w dc.w 50 ; h dc.w 0*64 ; start angle *64 dc.w 360*64 ; end angle *64 send8l=@-send8 send9: dc.b 76 ; opcode for ImageText8 dc.b s9tl ; string length dc.w send9l/4; request length s9a: dc.l 0 ; wid (has to be calculated) s9b: dc.l 0 ; cid (has to be calculated) s9x: dc.w 0 ; x s9y: dc.w 30 ; y s9t: dc.b "HLA" ; string s9tl=@-s9t even 4 send9l=@-send9 dc.b 0 ; we need this byte brett: dc.b 0,0,0,0,0,0,0,0 dc.b 0 ; we need this byte ;--------------------------- uninitialized data ---------------------------- if debug buf: blk.b 4 out_text: blk.l 1 endif stack_ptr: blk.l 1 x_handle: blk.l 1 fname: blk.b 256+32 buf2: blk.b 1024 buf2l=@-buf2 ;--------------------------------------------------------------------------- data_filez=@@-data_offset data_memsz= @-data_addr ;=========================================================================== |