Operation of Assemblers

Authors Avatar

Assemblers                Tom Hall

Operation of Assemblers

A program written in assembly language is much more readable and understandable than its equivalent in machine code; an assembler is a program which translates assembly language into machine code.

The assembler accepts an assembly language program as data, converts mnemonic operation codes (op-codes) to their numeric equivalents, assigns symbolic addresses to memory locations and produces as output the required machine code program.

Assembly language is the source program and when translated into machine code it is know as object program.

The following programs are written for the BEP/16 programming environment to achieve the following arithmetic operations:

  1. a + b


SWI getInt        ; Operating         
        ; system call to                  ; get a 16 bit                  ; integer from                  ; the keyboard.                  ; Value returned                 ; in R0

Join now!

MOV R1, R0        ; Store the first                 ; value in R1

SWI getInt        ; Get second value

MOV R2, R0        ; Store in register         ; R2

MOV R3, R1        ; R3 = a

ADD R3, R2        ; R3 = a+b

MOV R4, R1        ; R4 = a

MOV R0, R3        ; Copy amswer to R0

SWI putInt        ; Operating system         ; call to display the         ; 16-bit integer in         ; R0

HLT        ; Terminate program.

  1. a – b

SWI getInt        ; Operating         
        ; system call to                  ; get a 16 bit                  ; integer from                  ; the keyboard.                  ; Value returned                 ; in R0

MOV R1, R0        ; ...

This is a preview of the whole essay