Does anyone know assembly? newbie here!

Programming, for all ages and all languages.
Post Reply
yosuke

Does anyone know assembly? newbie here!

Post by yosuke »

Hello All!
I am learning C++ about year now, but I want to start learning assembly! I'm using Linux and I have nasm compiler! Does anyone know any newbie friendly tutorial on assembler? Thank you!
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Does anyone know assembly? newbie here!

Post by Solar »

Every good solution is obvious once you've found it.
Yosuke

Thank you!

Post by Yosuke »

Thank you very much!
But I have try to compile some asm example source code with nasm, but nasm shows me errors:

h.asm:3: error: label or instruction expected at start of line


code:
#MAKE_COM# ; instruct compiler to make COM file.
ORG 100h ; directive required for a COM program.
MOV AX, 0B800h ; set AX to hexadecimal value of B800h.
MOV DS, AX ; copy value of AX to DS.
MOV CL, 'A' ; set CL to ASCII code of 'A', it is 41h.
MOV CH, 01011111b ; set CH to binary value.
MOV BX, 15Eh ; set BX to 15Eh.
MOV [BX], CX ; copy contents of CX to memory at B800:015E
RET ; returns to operating system.


Doesn't diferent assamlers have a litle different syntax? thank you!
beyondsociety

Re:Does anyone know assembly? newbie here!

Post by beyondsociety »

You need to add a label to the beginining of your code for nasm to compile your assembly language source.

Code: Select all

ORG 100h              ; directive required for a COM program.
begin:                   
  MOV AX, 0B800h    ; set AX to hexadecimal value of B800h.
  MOV DS, AX        ; copy value of AX to DS.
  MOV CL, 'A'         ; set CL to ASCII code of 'A', it is 41h.
  MOV CH, 01011111b ; set CH to binary value.
  MOV BX, 15Eh      ; set BX to 15Eh.
  MOV [BX], CX      ; copy contents of CX to memory at B800:015E
  RET                    ; returns to operating system.
Doesn't diferent assamlers have a litle different syntax? thank you!
Yes, they do.
Post Reply