hi all
currently i'm reading "X86 Assembly Language and C Fundamentals" by Joseph Cavanagh and i have some questions that i cant find its answer in the book
first the author focused on c inline assembly, he also showed how to write it in only assembly but he dosent tell how to compile or link these assembly programm, he doesnt even tell which assembler we should use
here is the syntax of the first programm
;swap_bytes.asm
;-----------------------------------------------------------
.STACK
;-----------------------------------------------------------
.DATA
TEMP
DB ?
;$ sign is a delimiter meaning end of string
RSLT
DB 0DH, 0AH, 'BL = , BH = $'
;-----------------------------------------------------------
.CODE
BEGIN
PROC FAR
;set up pgm ds
MOV
AX, @DATA
MOV
DS, AX
;place the .DATA addr in ax
;set up data seg addr for this pgm
;assign values to bl and bh
MOV
BL,'A'
MOV
BH, 'B'
;store bl in temp area before swapping
MOV
TEMP, BL
;swap registers
MOV
BL, BH
MOV
BH, TEMP
;move registers to result area for display
MOV
RSLT + 7, BL
MOV
RSLT + 15, BH
;print result
MOV
AH, 09H
;display string
MOV
DX, OFFSET RSLT ;rslt addr must be in dx
INT
21H
;a dos interrupt that uses
;a fctn code in ah
BEGIN ENDP
END
BEGIN
;start pgm at begin
and it equlivant C code
#include "stdafx.h"
char main (void)
{
char temp;
char rslt1, rslt2;
//switch to assembly
_asm
{
MOV
BL, 'A'
MOV
BH, 'B'
//swap bytes
MOV
temp, BL
MOV
rslt1, BH
MOV
BH, temp
MOV
rslt2, BH
}
//print result
printf ("BL = %c, BH = %c\n", rslt1, rslt2);
return 0;
}
which memory mode this asm program written for ? how do i compile and link with masm ?