| Index | Manual | Download | Source | Macros | Embedded word Case ins.
Sitemap | Links | Forum | Tests | Projects

# Test t7924: Compile to MZ in COMPACT model

Description
  Executable MZ program with segments [CODE],[RODATA],[DATA],[BSS],[STACK]. In FARCODE memory models (COMPACT|LARGE|HUGE) instructions CALL and RET are by default FAR. In FARDATA memory models (MEDIUM|LARGE|HUGE) access to each data segment requires to update DS.
See also
  t7921 t7922 t7924 t7925 t7926
Tested procedures
  PfomfCompile PfmzCompile PfomfLoadPgm PgmLink

Source & expected listing t7924.htm.lst
  `| | EUROASM AUTOSEGMENT=ON,CPU=086,DUMPWIDTH=24 |7437393234 |%TEST %SET t7924 ; Name of EuroAssembler test program. |434F4D50414354 |%MODEL %SET COMPACT ; Memory model of the test program and its modules. |31 |%FARDATA %SETB "%MODEL"=="COMPACT" || "%MODEL"=="LARGE" || "%MODEL"=="HUGE" | |;; Boolean var %FARDATA is set when each of [RODATA],[DATA],[BSS] requires its own segment address. | |;; | |;; Create the first auxilliary OMF module with functions Write.D16 and Beep.D16. | |%TEST.WB PROGRAM FORMAT=OMF,MODEL=%MODEL |[CODE] ::::Section changed. |0000: |Write.D16:: PROC ; Display ASCIIZ string pointed to by DS:SI using DOS. |0000:B402 | MOV AH,02h ; DOS service Write character form DL to standard output. |0002:FC | CLD ; Direction forward. |0003:AC |.1:LODSB ; Load a character from string to AL, increment SI. |0004:3C00 | CMP AL,0 ; Test if zero-terminator reached. |0006:7406 | JE .9: ; Exit the procedure if AL=0. |0008:88C2 | MOV DL,AL |000A:CD21 | INT 21h ; Otherwise display the character AL and advance screen cursor. |000C:EBF5 | JMP .1: ; Repeat with following characters. |000E:C3 |.9:RET ; AX,DL,SI are clobbered. |000F: | ENDP Write.D16:: | |;; |000F: |Beep.D16:: PROC ; Display message "Beeping.." and play a sound using DOS. |000F:BE[0000] | MOV SI,=B"Beeping..." ; Define a literal string in [RODATA]. |TRUE | %IF %FARDATA |0012:B8{0000} | MOV AX,PARA# =B"Beeping..." |0015:8ED8 | MOV DS,AX ; Paragraph address of literal segment [RODATA]. | | %ENDIF |0017:E8E6FF | CALL Write.D16:: ; Display the notification "Beeping...". |001A:BE[0000] | MOV SI,=W(0x0007) ; Define ASCIIZ string with BEL character in [RODATA]. |001D:E8E0FF | CALL Write.D16:: ; Play the beep sound. |0020:C3 | RET ; AX,DL,SI are clobbered. |0021: | ENDP Beep.D16:: |[@LT2] ====ListLiterals in section [@LT2]. |0000:0700 =W(0x0007) |[@LT1] ====ListLiterals in section [@LT1]. |0000:42656570696E672E~=B"Beeping..." | | ENDPROGRAM %TEST.WB | **** ListMap "t7924.WB.obj",model=COMPACT,groups=1,segments=2,entry=,stack= | [CGROUP],FA=00000080h,RVA=00000000h,size=00000021h=33,group [CODE] | [CODE],FA=00000080h,RVA=00000000h,size=00000021h=33,width=16,align=0010h,purpose=CODE | [RODATA],FA=000000BAh,RVA=00000000h,size=0000000Dh=13,width=16,align=0010h,purpose=RODATA+LITERAL | **** ListGlobals "t7924.WB.obj",Global=0,Public=2,Extern=0,eXport=0,Import=0 | Beep.D16,[CGROUP]:0000000Fh,scope='P' | Write.D16,[CGROUP]:00000000h,scope='P' | |;; | |;; Create other auxilliary OMF module with function Exit.D16. | |%TEST.EX PROGRAM FORMAT=OMF,MODEL=%MODEL |[CODE] ::::Section changed. |0000: |Exit.D16:: PROC ; Display message "End", terminate the program and return to DOS. |0000:BE[0000] | MOV SI,.M: ; String "End" will be defined in segment [BSS] at DS:SI. |TRUE | %IF %FARDATA |0003:B8{0000} | MOV AX,PARA# .M: |0006:8ED8 | MOV DS,AX ; Paragraph address of segment [BSS]. | | %ENDIF |0008:C704456E | MOVW [SI+0],"En" ; Dynamically initialize the notification string. |000C:C744026420 | MOVW [SI+2],"d " ; Assume DS=PARA# [BSS]. |0011:C744040D0A | MOVW [SI+4],0x0A0D ; CR+LF. |0016:C6440600 | MOVB [SI+6],0 ; Zero-terminate the notiofication string. |001A:E8(0000) | CALL Write.D16:: ; Display the notification "End". |001D:B44C | MOV AH,4Ch ; DOS service Terminate program. |001F:CD21 | INT 21h |[BSS] ::::Section changed. |0000:.............. |.M:DB 7*BYTE ; Reserve space for ASCIIZ string "End" in [BSS] segment. |[CODE] ::::Section changed. |0021: | ENDP Exit.D16:: | | ENDPROGRAM %TEST.EX | **** ListMap "t7924.EX.obj",model=COMPACT,groups=1,segments=2,entry=,stack= | [CGROUP],FA=00000079h,RVA=00000000h,size=00000021h=33,group [CODE] | [CODE],FA=00000079h,RVA=00000000h,size=00000021h=33,width=16,align=0010h,purpose=CODE | [BSS],FA=00000000h,RVA=00000000h,size=00000007h=7,width=16,align=0010h,purpose=BSS | **** ListGlobals "t7924.EX.obj",Global=0,Public=1,Extern=1,eXport=0,Import=0 | Exit.D16,[CGROUP]:00000000h,scope='P' | Write.D16,[Write.D16]:00000000h,scope='E' | |;; | |;; Create the main program which links auxilliary OMF modules. | |%TEST PROGRAM FORMAT=MZ, MODEL=%MODEL, ENTRY=Start |[CODE] ::::Section changed. |0000:90 |Start:NOP |0001:BE[0000] | MOV SI,Msg |0004:B8{0000} | MOV AX,PARA# Msg ; MZ program requires paragraph address of [DATA] segment |0007:8ED8 | MOV DS,AX ; in all realmode models, including TINY. |0009:E8(0000) | CALL Write.D16:: |000C:E8(0000) | CALL Beep.D16:: |000F:E8(0000) | CALL Exit.D16:: | | LINK %TEST.WB.obj, %TEST.EX.obj |[DATA] ::::Section changed. |0000:313662697420434F~|Msg:DB '%^WIDTH[]bit %MODEL MZ program "%^OUTFILE" linked',13,10 |002D:207769746820434F~| DB ' with %MODEL OMF module "%TEST.WB.obj" and "%TEST.EX.obj".',13,10,0 | | ENDPROGRAM %TEST |# I0560 Linking OMF module "./t7924.WB.obj". |# I0560 Linking OMF module "./t7924.EX.obj". | **** ListMap "t7924.exe",model=COMPACT,groups=2,segments=5,entry=Start,stack=[SGROUP]:00002000h | [CGROUP],FA=00000060h,RVA=00000000h,size=00000071h=113,group [CODE] | [CODE],FA=00000060h,RVA=00000000h,size=00000071h=113,width=16,align=0010h,purpose=CODE | [RODATA],FA=000000E0h,RVA=00000080h,size=0000000Dh=13,width=16,align=0010h,purpose=RODATA | [DATA],FA=000000F0h,RVA=00000090h,size=0000006Bh=107,width=16,align=0010h,purpose=DATA | [BSS],FA=00000160h,RVA=00000100h,size=00000007h=7,width=16,align=0010h,purpose=BSS | [SGROUP],FA=00000160h,RVA=00000110h,size=00002000h=8192,group [STACK] | [STACK],FA=00000160h,RVA=00000110h,size=00002000h=8192,width=16,align=0010h,purpose=STACK | **** ListGlobals "t7924.exe",Global=0,Public=4,Extern=0,eXport=0,Import=0 | Beep.D16,[CGROUP]:0000002Fh,RVA=0000002Fh,scope='P' | Exit.D16,[CGROUP]:00000050h,RVA=00000050h,scope='P' | Start,[CGROUP]:00000000h,RVA=00000000h,scope='P' | Write.D16,[CGROUP]:00000020h,RVA=00000020h,scope='P'`

Expected messages t7924.out
  `I0180 Assembling source file "t7924.htm". I0270 Assembling source "t7924". I0310 Assembling source pass 1. I0330 Assembling source pass 2 - final. I0470 Assembling program "t7924.WB". "t7924.htm"{86} I0510 Assembling program pass 1. "t7924.htm"{86} I0510 Assembling program pass 2. "t7924.htm"{86} I0530 Assembling program pass 3 - final. "t7924.htm"{86} I0660 16bit COMPACT OMF file "t7924.WB.obj" created, size=211. "t7924.htm"{115} I0650 Program "t7924.WB" assembled in 3 passes with errorlevel 0. "t7924.htm"{115} I0470 Assembling program "t7924.EX". "t7924.htm"{125} I0510 Assembling program pass 1. "t7924.htm"{125} I0510 Assembling program pass 2. "t7924.htm"{125} I0530 Assembling program pass 3 - final. "t7924.htm"{125} I0660 16bit COMPACT OMF file "t7924.EX.obj" created, size=182. "t7924.htm"{144} I0650 Program "t7924.EX" assembled in 3 passes with errorlevel 0. "t7924.htm"{144} I0470 Assembling program "t7924". "t7924.htm"{154} I0510 Assembling program pass 1. "t7924.htm"{154} I0510 Assembling program pass 2. "t7924.htm"{154} I0530 Assembling program pass 3 - final. "t7924.htm"{154} I0560 Linking OMF module "./t7924.WB.obj". "t7924.htm"{167} I0560 Linking OMF module "./t7924.EX.obj". "t7924.htm"{167} I0660 16bit COMPACT MZ file "t7924.exe" created, size=347. "t7924.htm"{167} I0650 Program "t7924" assembled in 3 passes with errorlevel 0. "t7924.htm"{167} I0750 Source "t7924" (241 lines) assembled in 2 passes with errorlevel 0. I0860 Listing file "t7924.htm.lst" created, size=7478. I0990 EuroAssembler terminated with errorlevel 0.`

Expected output file t7924. exe

      0000: 4D 5A 5B 01 01 00 03 00 06 00 02 02 FF FF 11 00  MZ[··°·°·°··¤¤·°
      0010: 00 20 6F 81 00 00 00 00 40 00 00 00 00 00 00 00  °¯o¤°°°°@°°°°°°°
      0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
      0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
      0040: 05 00 00 00 33 00 00 00 54 00 00 00 00 00 00 00  ·°°°3°°°T°°°°°°°
      0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  °°°°°°°°°°°°°°°°
      0060: 90 BE 00 00 B8 09 00 8E D8 E8 14 00 E8 20 00 E8  ¤¤°°¤·°¤¤¤·°¤¯°¤
      0070: 3E 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90  >°¤¤¤¤¤¤¤¤¤¤¤¤¤¤
      0080: B4 02 FC AC 3C 00 74 06 88 C2 CD 21 EB F5 C3 BE  ¤·¤¤<°t·¤¤¤!¤¤¤¤
      0090: 02 00 B8 08 00 8E D8 E8 E6 FF BE 00 00 E8 E0 FF  ·°¤·°¤¤¤¤¤¤°°¤¤¤
      00A0: C3 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90  ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
      00B0: BE 00 00 B8 10 00 8E D8 C7 04 45 6E C7 44 02 64  ¤°°¤·°¤¤¤·En¤D·d
      00C0: 20 C7 44 04 0D 0A C6 44 06 00 E8 B3 FF B4 4C CD  ¯¤D··¬¤D·°¤¤¤¤L¤
      00D0: 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  !°°°°°°°°°°°°°°°
      00E0: 07 00 42 65 65 70 69 6E 67 2E 2E 2E 00 00 00 00  ·°Beeping...°°°°
      00F0: 31 36 62 69 74 20 43 4F 4D 50 41 43 54 20 4D 5A  16bit¯COMPACT¯MZ
      0100: 20 70 72 6F 67 72 61 6D 20 22 74 37 39 32 34 2E  ¯program¯"t7924.
      0110: 65 78 65 22 20 6C 69 6E 6B 65 64 0D 0A 20 77 69  exe"¯linked·¬¯wi
      0120: 74 68 20 43 4F 4D 50 41 43 54 20 4F 4D 46 20 6D  th¯COMPACT¯OMF¯m
      0130: 6F 64 75 6C 65 20 22 74 37 39 32 34 2E 57 42 2E  odule¯"t7924.WB.
      0140: 6F 62 6A 22 20 61 6E 64 20 22 74 37 39 32 34 2E  obj"¯and¯"t7924.
      0150: 45 58 2E 6F 62 6A 22 2E 0D 0A 00                 EX.obj".·¬°

▲Back to the top▲