【正文】
r1:word, Var2:word, Proc1:near CSEG segment para public 39。data39。data39。hello39。$39。these are just the procs or macros, included in this file include _arrayproc proc near push bp mov bp,sp mov ax,[bp+4] call dec_out message newline mov ax,[bp+6] call dec_out message newline mov di,[bp+4] mov cx,[bp+6] looptop: add word ptr [di],10 inc di inc di loop looptop pop bp ret _arrayproc endp end Example with arrays in Borland C continued: the main include extern void arrayproc(int [],int)。i++)x[i]=i*5。i++)printf(%d\n,x[i])。 funct(a)。 ? void main(){ ? a=。 ? } function .model small .code public _funct _funct proc near push bp mov bp,sp fld qword ptr [bp+4] fld qword ptr [bp+4] fadd st,st(1) mov si,[bp+12] fstp qword ptr [si] fwait pop bp ret _funct endp end Run of copro2 W:\assembly\turboC\BINcopro2 answer W:\assembly\turboC\BIN An assembly main .model small .stack 100h dataseg val dw ? num dw ? prompt db 39。 p2 db 39。 crlf db 0ah,0dh,39。} run W:\assembly\turboC\BINasmtoc enter 123 enter 456 value is 579 W:\assembly\turboC\BIN Linking assembly and C ? You can use assembly inline ? You can link c functions to an assembly main ? Or visa versa ? Some versions of Borland C are available in the labs ? I used the text’s VC++ examples. ? As mentioned earlier, you need 32 bit TASM (Borland assembler) to properly configure assembly with borland c programs. main extern C void asm_main()。 clear the screen, display disk directory INVOKE system,ADDR str1 INVOKE system,ADDR str2 。 Close the file INVOKE fclose, pFile quit: ret 。 for(unsigned i = 0。,39。 LongRandom procedure module () .model large .386 Public _LongRandom .data seed dd 12345678h//seed should be odd, not even 。 copy upper 16 bits of EAX to DX ret _LongRandom endp end ? text examples e with (some) piled cpp and assembled asm examples. ? you would need to find a borland c piler to undertake this work. ? there is a free c piler (mandline only – no ide) available from inprise (borland) ? you would link the two obj files to create an exe Free piler from borland ? Link for piler: IDEs available for Borland piler IDE continuedamp。 long last = startSector + numSectors。 for(int i = 0。.39。 } } int main() { char * buffer。 system(CLS)。 cin startSector。 cout \n\nReading sectors startSector (startSector + numSectors) from Drive driveNum endl。 return 0。 It can read FAT12, FAT16, and FAT32 disks under 。 number of sectors bufferOfs DW ? 。 。 and number of sectors. 。 always this value mov dx,driveNumber 。 read disk sector popa leave ret _ReadSector ENDP END arraysum in C void MySub() { char A = 39。 name[0] = 39。 for(int i = 0。 } void main() { int Array[50]。 ? _TEXT ENDS ? _DATA SEGMENT DWORD USE32 PUBLIC 39。 ? CONST ENDS ? _BSS SEGMENT DWORD USE32 PUBLIC 39。 ? _TLS ENDS ? 。 COMDAT ?ArraySumYAHQAHHZ ? _TEXT SEGMENT PARA USE32 PUBLIC 39。CODE39。 MySub, COMDAT ? 。 ArraySum 。 Line 17 mov esi, DWORD PTR [ecx] add ecx, 4 add eax, esi dec edx jne SHORT $L277 pop esi $L279: 。 COMDAT 。 00000032H push eax call ?ArraySumYAHQAHHZ 。 ? struct Package { ? long originZip。 ? ? char myChar。 ? long myLong。 ? long double myLongDouble。 // 1 mov eax,LENGTH myLongArray。 // 2 mov eax,TYPE myInt。 // 8 mov eax,TYPE myPackage。 // 4 mov eax,SIZE myPackage。 int main() { int total = addem( 10, 15, 25 )。 This subroutine links to Visual C++ . .386P .model flat public _addem .code _addem proc near push ebp mov ebp,esp mov eax,[ebp+16] 。 // Assembly language version // CPP version } bool FindArray2( long n, long array[], long count )。 i ARRAY_SIZE。 long searchVal。 else std::cout Your number was not found.\n。 i++) if( searchVal == array[i] ) return true。 search value mov ecx, count 。 ZF = 1 if found returnFalse: mov al, false jmp short exit returnTrue: mov al, true exit: pop edi pop ebp ret _FindArray endp end Compile, assemble, link C:ML /nologo Zi c Fl Sg –coff This creates C: cl /c /EHsc This creates C:cl /Gy Links and sets up extern fn references I unedited cout values in FindArray program in text uses inline assembly code include iostream include fstream using namespace std。 // character count unsigned short encryptCode。 ifstream infile( ,ios::binary )。 count = ()。186。?161。241。║161。Φ171。┼┬┼┬??▓┼┬?172。? C:\Program Files\Microsoft Visual Studio 8\VCcl /EHsc Microsoft (R) 32bit C/C++ Optimizing Compiler Version for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. Swapping infile with outfile to decode Microsoft (R) Incremental Linker Version Copyright (C) Microsoft Corporation. All rights reserved. /out: C:\Program Files\Microsoft Visual Studio 8\VCEncode Encryption code [0255]? 200 Reading and creating ... C:\Program Files\Microsoft Visual Studio 8\VCtype 187。172。241。161。161。161。√